diff --git a/cg/cg2100.cpp b/cg/cg2100.cpp index 5fac7f388..8c8cf3fa4 100755 --- a/cg/cg2100.cpp +++ b/cg/cg2100.cpp @@ -117,6 +117,7 @@ TMask* TPrimanota_application::load_mask(int n) TSheet_field& ps = (TSheet_field&)m->field(FS_RATESHEET); ps.set_notify(pag_notify); m->set_handler(FS_RATESHEET, pag_sheet_handler); + m->set_handler(F_ANNORIF, annorif_handler); m->set_handler(F_NUMRIF, numrif_handler); m->set_handler(FS_RESET, reset_handler); m->set_handler(FS_NRATE, nrate_handler); diff --git a/cg/cg2100c.uml b/cg/cg2100c.uml index d20b14c12..006833a28 100755 --- a/cg/cg2100c.uml +++ b/cg/cg2100c.uml @@ -421,7 +421,6 @@ BEGIN DISPLAY "Valuta" CODTAB[1,3] DISPLAY "Data@10" D0 DISPLAY "Cambio@18" R10 - OUTPUT SK_VALUTA CODTAB[1,3] OUTPUT SK_DATACAMBIO D0 OUTPUT SK_CAMBIO R10 GROUP 3 @@ -445,7 +444,7 @@ BEGIN PICTURE "." END -NUMBER SK_TOTDOCVAL 15 2 +NUMBER SK_TOTDOCVAL 15 3 BEGIN PROMPT 35 13 "Tot. in valuta " FIELD TOTDOCVAL @@ -545,7 +544,7 @@ BEGIN GROUP 4 END -NUMBER F_CORRVALUTA 15 2 +NUMBER F_CORRVALUTA 15 3 BEGIN PROMPT 37 18 "Corrispettivo valuta " FIELD CORRVALUTA diff --git a/cg/cg2102.cpp b/cg/cg2102.cpp index aa5c3e882..f65539a6f 100755 --- a/cg/cg2102.cpp +++ b/cg/cg2102.cpp @@ -539,9 +539,9 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k) return f.error_box("Il conto della riga %d non e' completo", i+1); const TBill co(r, 10, 0x0); if (!co.empty() && !co.ok()) - return f.error_box("La contropartita della riga %d non e' completa", i+1); - empty = FALSE; + f.error_box("La contropartita della riga %d non e' completa", i+1); + empty = FALSE; if (paga || nota) { const char tipo = row_type(r); @@ -1594,7 +1594,7 @@ bool TPrimanota_application::doc_handler(TMask_field& f, KEY key) { if (f.dlg() == F_DATADOC) { - if (app().is_fattura()) + if (app().is_fattura() && m.get(F_ANNORIF).empty()) { const TDate dd(val); m.set(F_ANNORIF, dd.year()); // copia anno documento @@ -1749,7 +1749,11 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key) { const TString& valuta = clifo.get(CLI_CODVAL); if (valuta.not_empty()) + { m.set(SK_VALUTA, valuta, TRUE); + if (m.get(SK_DATACAMBIO).empty()) + m.set(SK_DATACAMBIO, m.get(F_DATADOC), TRUE); + } } if (clifo.get(CLI_CODCAB).not_empty()) @@ -1853,16 +1857,46 @@ bool TPrimanota_application::main_codiva_handler(TMask_field& f, KEY key) return TRUE; } +// Riempie i campi valuta a zero in base agli altri +void TPrimanota_application::gioca_cambi(int force) +{ + TMask& m = curr_mask(); + real totale = m.get(F_TOTALE); + real totval = m.get(SK_TOTDOCVAL); + real cambio = m.get(SK_CAMBIO); + + if ( (force == 0x1 || totale.is_zero()) && !(totval.is_zero() || cambio.is_zero()) ) + { + totale = totval * cambio; + m.set(F_TOTALE, totale, TRUE); + return; + } + + if ( (force == 0x2 || totval.is_zero()) && !(totale.is_zero() || cambio.is_zero())) + { + totval = totale / cambio; + m.set(SK_TOTDOCVAL, totval); + return; + } + + if ( (force == 0x4 || cambio.is_zero()) && !(totale.is_zero() || totval.is_zero())) + { + cambio = totale / totval; + m.set(SK_CAMBIO, cambio); + return; + } +} + + // Handler of the F_TOTALE // Certified 99% bool TPrimanota_application::totdoc_handler(TMask_field& f, KEY key) { bool ok = TRUE; + TMask& m = f.mask(); if (key == K_TAB && f.focusdirty()) { - TMask& m = f.mask(); - if (app().iva() != nessuna_iva) { app().add_cgs_tot(m); @@ -1875,50 +1909,39 @@ bool TPrimanota_application::totdoc_handler(TMask_field& f, KEY key) app().calcola_saldo(); } - TMask_field& totval = m.field(SK_TOTDOCVAL); - if (totval.active() && totval.get().empty()) - { - const real cambio(m.get(SK_CAMBIO)); - if (!cambio.is_zero()) - { - real tot(f.get()); - tot /= cambio; - totval.set(tot.string()); - } - } + app().gioca_cambi(); } - if (key == K_ENTER && f.get().empty()) - ok = f.yesno_box("Totale documento nullo: continuare ugualmente?"); + if (key == K_ENTER) + { + const real totale(f.get()); + if (totale.is_zero()) + ok = yesno_box("Totale documento nullo: continuare ugualmente?"); + + const real cambio(m.get(SK_CAMBIO)); + if (!cambio.is_zero()) + { + const real totval(m.get(SK_TOTDOCVAL)); + real totlit = totval * cambio; totlit.round(0); + if (totale != totlit) + ok = yesno_box("Il totale documento dovrebbe essere %s: continuare ugualmente?", + totlit.string(".")); + } + } return ok; } bool TPrimanota_application::totdocval_handler(TMask_field& f, KEY key) { - if (key == K_TAB && f.focusdirty() && f.get().not_empty()) + if (key == K_TAB && f.focusdirty()) { - TMask& m = f.mask(); - real totval(f.get()); - real cambio(m.get(SK_CAMBIO)); - real totale(m.get(F_TOTALE)); - if (totale.is_zero()) - { - totval *= cambio; - m.set(F_TOTALE, totval, TRUE); - } - else - { - if (cambio.is_zero()) - { - totale /= totval; - m.set(SK_CAMBIO, totale, TRUE); - } - } + app().gioca_cambi(0x1); if (app().is_fattura()) // Se e' una vera fattura { TPagamento& pag = app().pagamento(); + const real totval(f.get()); pag.set_total(totval, ZERO, ZERO); pag.set_rate_auto(); pag.set_sheet(app().pags()); diff --git a/cg/cg2102.h b/cg/cg2102.h index e6ac6ff30..93b3ba263 100755 --- a/cg/cg2102.h +++ b/cg/cg2102.h @@ -81,6 +81,7 @@ class TPrimanota_application : public TRelation_application static bool datacomp_handler(TMask_field& f, KEY key); static bool data74ter_handler(TMask_field& f, KEY key); static bool doc_handler(TMask_field& f, KEY key); + static bool annorif_handler(TMask_field& f, KEY key); static bool numrif_handler(TMask_field& f, KEY key); static bool protiva_handler(TMask_field& f, KEY key); static bool clifo_handler(TMask_field& f, KEY key); @@ -147,7 +148,8 @@ protected: // TRelation_application protected: void check_saldi(); void genera_incasso(const char* causimm); - + void gioca_cambi(int force = 0x00); + TMask* load_mask(int n); TMask& occas_mask() { return *load_mask(3); } void open_files(int logicnum, ...); diff --git a/cg/cg2103.cpp b/cg/cg2103.cpp index 3034131f2..7cf5af283 100755 --- a/cg/cg2103.cpp +++ b/cg/cg2103.cpp @@ -469,7 +469,8 @@ bool TCausale::similar(const TCausale& c) const if (intra() != c.intra()) err = "la gestione dei movimenti intra"; if (valuta() != c.valuta()) err = "la gestione valuta"; if (corrispettivi() != c.corrispettivi()) err = "la gestione dei corrispettivi"; - if (iva() != c.iva()) err = "il tipo di IVA"; + if (iva() != c.iva()) err = "il tipo di IVA"; + if (tipomov() != c.tipomov()) err = "il tipo di movimento"; if (*err) error_box("La causale e' diversa per %s", err); diff --git a/cg/cg2104.cpp b/cg/cg2104.cpp index 94e5cb818..1b6b69df8 100755 --- a/cg/cg2104.cpp +++ b/cg/cg2104.cpp @@ -175,6 +175,22 @@ bool TPrimanota_application::codpag_handler(TMask_field& f, KEY key) return TRUE; } +bool TPrimanota_application::annorif_handler(TMask_field& f, KEY key) +{ + bool ok = TRUE; + const TMask& m = f.mask(); + + if (f.to_check(key) && f.get().empty() && m.insert_mode()) + { + const TString& anno = m.get(F_DATADOC).right(4); + f.set(anno); + ok = error_box("Il numero di riferimento partita e' obbligatorio!\n" + "Se possibile esso verra' proposto, ma potra'\n" + "essere modificato prima di registrare il movimento."); + } + return ok; +} + bool TPrimanota_application::numrif_handler(TMask_field& f, KEY key) { bool ok = TRUE; @@ -185,11 +201,6 @@ bool TPrimanota_application::numrif_handler(TMask_field& f, KEY key) if (empty && m.insert_mode()) { f.set(m.get(app()._npart_is_prot ? F_PROTIVA : F_NUMDOC)); - if (m.get(F_ANNORIF).empty()) - { - const TString& anno = m.get(F_DATADOC).right(4); - m.set(F_ANNORIF, anno); - } if (m.get(F_CODPAG).empty()) { TMask_field& clifo = m.field(app().iva() == iva_vendite ? F_CLIENTE : F_FORNITORE); @@ -234,15 +245,19 @@ bool TPrimanota_application::cambio_handler(TMask_field& f, KEY key) pag.set_cambio(ex); TMask& m = f.mask(); - if (m.insert_mode()) + if (m.insert_mode()) { pag.set_rate_auto(); TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET); pag.set_sheet(ps); app().pag_rows() = ps.rows_array(); } + + // Copio la valuta a pagina 3 const TValuta val(m, SK_VALUTA, SK_DATACAMBIO, SK_CAMBIO); val.set(m, FS_VALUTA, FS_DATACAMBIO, FS_CAMBIO); + + app().gioca_cambi(0x1); // Forza il ricalcolo del totale in lire } } return TRUE; @@ -623,7 +638,8 @@ void TPrimanota_application::write_scadenze(const TMask& m) { sposta = (oldgame->conto().sottoconto() == newgame->conto().sottoconto()); if (sposta) - sposta = yesno_box("Spostare le righe nella nuova partita?"); + sposta = yesno_box("Si desidera spostare la fattura ed i " + "pagamenti relativi nella nuova partita?"); } if (sposta) oldgame->sposta_riga(rigafatt, *newgame); diff --git a/cg/cg2105.cpp b/cg/cg2105.cpp index cde4f2eb6..b5e16ec7f 100755 --- a/cg/cg2105.cpp +++ b/cg/cg2105.cpp @@ -283,8 +283,7 @@ TGame_mask::TGame_mask(const TBill& bill, long numreg, int riga) case 'F': descr = "Fornitore"; break; default: descr = "Conto"; break; } - descr << ' ' << _conto.gruppo() << ' ' << _conto.conto() - << ' ' << _conto.sottoconto() << ' ' << ((TBill&)_conto).descrizione(); + descr << ' ' << _conto.sottoconto() << ' ' << ((TBill&)_conto).descrizione(); set(P_DESCR, descr); TValuta val; @@ -542,9 +541,9 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k) riga_fattura.add(""); riga_fattura.add(riga.get(PART_DATADOC)); gm.add_descrizione(riga_fattura, riga); - gm.add_importo(riga_fattura, TImporto(riga.sezione(), riga.get_real(SCAD_IMPORTO))); + gm.add_importo(riga_fattura, riga.importo(FALSE, 0x1)); if (in_valuta) - gm.add_importo(riga_fattura, TImporto(riga.sezione(), riga.get_real(SCAD_IMPORTOVAL)), TRUE); + gm.add_importo(riga_fattura, riga.importo(TRUE, 0x1), TRUE); else riga_fattura.add(""); riga_fattura.add(riga.get(PART_NREG)); @@ -560,9 +559,9 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k) TToken_string& row = scadenze.row(scadenze.add(riga_fattura)); row.add(ra, 1); row.add(scad.get(SCAD_DATASCAD), 2); - gm.add_importo(row, TImporto(riga.sezione(), scad.get_real(SCAD_IMPORTO)), FALSE, 5); + gm.add_importo(row, scad.importo(FALSE), FALSE, 5); if (in_valuta) - gm.add_importo(row, TImporto(riga.sezione(), scad.get_real(SCAD_IMPORTOVAL)), TRUE, 6); + gm.add_importo(row, scad.importo(TRUE), TRUE, 6); const int lastp = scad.last(); for (int pa = scad.first(); pa <= lastp; pa = scad.succ(pa)) @@ -620,7 +619,7 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k) { TToken_string& rdiff = scadenze.row(scadenze.add("")); rdiff.add("Differ. cambio rata ", 4); rdiff << ra; - gm.add_importo(rdiff, diff.normalize()); + gm.add_importo(rdiff, diff); } } @@ -683,8 +682,8 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k) { TToken_string& sp = scadenze.row(scadenze.add("")); sp.add("Saldo ", 4); sp << anno << ' ' << num; - gm.add_importo(sp, tot_lit.normalize()); - gm.add_importo(sp, tot_val.normalize(), TRUE); + gm.add_importo(sp, tot_lit); + gm.add_importo(sp, tot_val, TRUE); } if (should_delete_game) @@ -1045,7 +1044,8 @@ void TGame_mask::add_importo(TToken_string& s, const TImporto& i, bool valuta, i else { TString80 v; - v << i.valore().string(0, valuta ? 2 : 0) << ' ' << i.sezione(); + TImporto n(i); n.normalize(); + v << n.valore().string(0, valuta ? 3 : 0) << ' ' << n.sezione(); s.add(v, pos); } } @@ -1151,10 +1151,10 @@ void TGame_mask::update_saldo_clifo() r.add(""); r.add(TDate(TODAY).string()); r.add(""); - add_importo(r, sal.normalize()); - add_importo(r, doc.normalize()); - add_importo(r, pag.normalize()); - add_importo(r, imp.normalize()); + add_importo(r, sal); + add_importo(r, doc); + add_importo(r, pag); + add_importo(r, imp); r.add("Saldo "); if (conto().tipo() == 'C') @@ -1167,7 +1167,7 @@ void TGame_mask::update_saldo_clifo() bool TGame_mask::same_number(const char* s1, const char* s2) const { TString16 t1(s1); t1.upper(); t1.trim(); - TString16 t2(s2); t2.upper(); t2.trim(); + TString16 t2(s2); t2.upper(); t2.trim(); t2.cut(t1.len()); return t1 == t2; } diff --git a/cg/pagament.cpp b/cg/pagament.cpp index 50fb18da5..0846bce52 100755 --- a/cg/pagament.cpp +++ b/cg/pagament.cpp @@ -551,7 +551,10 @@ void TPagamento::strerr(word err, TString& s) if (err & P_SCAD) s << "Le scadenze non sono consecutive\n"; if (err & P_INIZIO) - s << "La prima rata e' antecedente alla data documento\n"; + { + s << "La prima rata (" << data_rata(0) << ") e' antecedente"; + s << " alla data del documento (" << _inizio << ")\n"; + } if (err & P_NEG) s << "L'importo dato e' inferiore al minimo possibile\n"; if (err & P_TROP)