From 054348d8963f6469b7cea022f7b9159aba2252b2 Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 19 Feb 1996 14:04:36 +0000 Subject: [PATCH] Corretta gestione saldaconto in prima nota git-svn-id: svn://10.65.10.50/trunk@2611 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg2100.cpp | 3 +- cg/cg2100c.uml | 2 +- cg/cg2104.cpp | 10 ++--- cg/cg2105.cpp | 112 ++++++++++++++++++++++++++++-------------------- cg/saldacon.cpp | 12 ++---- 5 files changed, 77 insertions(+), 62 deletions(-) diff --git a/cg/cg2100.cpp b/cg/cg2100.cpp index 86d8db2de..ed67f1a08 100755 --- a/cg/cg2100.cpp +++ b/cg/cg2100.cpp @@ -622,7 +622,8 @@ bool TPrimanota_application::test_swap(bool ritsoc) int TPrimanota_application::read(TMask& m) -{ +{ + m.reset(); // Azzera campi e relativi dirty = 3 m.autoload(_rel); // Carica testata const long numreg = _rel->curr().get_long(MOV_NUMREG); diff --git a/cg/cg2100c.uml b/cg/cg2100c.uml index d95938100..6004ce6d9 100755 --- a/cg/cg2100c.uml +++ b/cg/cg2100c.uml @@ -371,7 +371,7 @@ STRING F_CODPAG 4 BEGIN PROMPT 1 12 "Codice Pagamento " FIELD CODPAG - FLAGS "UZ" + FLAGS "U#" USE %CPG INPUT CODTAB F_CODPAG DISPLAY "Codice" CODTAB diff --git a/cg/cg2104.cpp b/cg/cg2104.cpp index 7bbcdcee0..7f209bddb 100755 --- a/cg/cg2104.cpp +++ b/cg/cg2104.cpp @@ -180,7 +180,6 @@ bool TPrimanota_application::pag_notify(TSheet_field& ps, int r, KEY k) ps.row(r).add(p.string(), 3); } ps.force_update(r); - } if (m_impv) { @@ -278,7 +277,7 @@ bool TPrimanota_application::pag_sheet_handler(TMask_field& f, KEY key) ok = yesno_box("Il totale in lire delle rate e' %s mentre\n" "il totale del documento e' %s.\n" "Si desidera registrare ugualmente?", - (const char *)is, (const char *)ts); + (const char*)is, (const char*)ts); } } } @@ -858,7 +857,7 @@ void TPrimanota_application::write_scadenze(const TMask& m) int nuova_riga = 0; - if (m.page_enabled(2)) + if (anno > 0 && !numpart.blank() && m.page_enabled(2)) { const int tmov = causale().tipomov(); const TString desc(m.get(F_DESCR)); @@ -989,9 +988,10 @@ bool TPrimanota_application::showpartite_handler(TMask_field& f, KEY k) bool ok = TRUE; TMask& m = f.mask(); TPrimanota_application& a = app(); + TMask& cm = a.curr_mask(); const char tipo = m.get(CG_ROWTYPE)[0]; - const bool is_nota = tipo == 'T' && a.causale().tipomov() == 2 && m.field(F_NUMRIF).active(); + const bool is_nota = tipo == 'T' && a.causale().tipomov() == 2 && cm.field(F_NUMRIF).active(); if (tipo == 'K' || is_nota) { TSheet_field& s = *m.get_sheet(); @@ -1006,7 +1006,7 @@ bool TPrimanota_application::showpartite_handler(TMask_field& f, KEY k) if (k == K_ENTER) { - const long curreg = a.curr_mask().get_long(F_NUMREG); + const long curreg = cm.get_long(F_NUMREG); const TImporto importo(a.get_cgs_imp(riga)); const TImporto speso(a.partite().importo_speso(curreg, riga+1)); diff --git a/cg/cg2105.cpp b/cg/cg2105.cpp index a7179ef1a..b0c0ada6d 100755 --- a/cg/cg2105.cpp +++ b/cg/cg2105.cpp @@ -784,7 +784,7 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k) const int lastrow = game->last(); - if (lastrow > 0 && prima_valuta.in_lire()) + if (lastrow > 0) prima_valuta.get(game->riga(lastrow)); const bool in_valuta = prima_valuta.in_valuta(); @@ -843,7 +843,7 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k) row.add(sum.get(PART_DATADOC)); row.add(sum.get(PART_DATAPAG)); gm.add_descrizione(row, sum); - TImporto imp(sez, pag.get_real(PAGSCA_IMPORTO)); + const TImporto imp(sez, pag.get_real(PAGSCA_IMPORTO)); if (in_valuta) { gm.add_importo(row, imp); @@ -860,46 +860,57 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k) row.add(""); row.add(sum.get(PART_TIPOMOV)); row.add(pa); - } - - const TImporto rit(scad.importo_pagato(FALSE, 0x8)); - if (!rit.is_zero()) - { - TToken_string& rrit = scadenze.row(scadenze.add("")); - rrit.add("Ritenute professionali", 4); - gm.add_importo(rrit, rit, FALSE); - } - TImporto abb(scad.importo_pagato(TRUE, 0x2)); - if (!abb.is_zero()) - { - TToken_string& rabb = scadenze.row(scadenze.add("")); - rabb.add("Abbuoni ", 4); - abb.normalize(); - rabb << (abb.sezione() == 'D' ? "attivi" : "passivi"); - - if (in_valuta) + // Le ritenute non possono esistere in valuta + if (!in_valuta) { - gm.add_importo(rabb, scad.importo_pagato(FALSE, 0x2), FALSE); - gm.add_importo(rabb, abb, TRUE); + const TImporto rit(sez, pag.get_real(PAGSCA_RITENUTE)); + if (!rit.is_zero()) + { + TToken_string& rrit = scadenze.row(scadenze.add("")); + rrit.add("Ritenute professionali", 4); + gm.add_importo(rrit, rit, FALSE); + } } - else + + // Gli abbuoni e le differenze cambio esistono solo se e' a saldo + if (pag.get_char(PAGSCA_ACCSAL) == 'S') { - gm.add_importo(rabb, abb, FALSE); - rabb.add(""); - } - } + const TImporto abb(sez, pag.get_real(PAGSCA_ABBUONI)); + if (!abb.is_zero()) + { + TToken_string& rabb = scadenze.row(scadenze.add("")); + const char tipo_abb = pag.get_char(PAGSCA_PASSATT); + rabb.add("Abbuoni ", 4); + rabb << (tipo_abb == 'A' ? "attivi" : "passivi"); + if (in_valuta) + { + TImporto abb_lit = abb; + prima_valuta.val2lit(abb_lit); + gm.add_importo(rabb, abb_lit, FALSE); + gm.add_importo(rabb, abb, TRUE); + } + else + { + gm.add_importo(rabb, abb, FALSE); + rabb.add(""); + } + } + + // Le differenze cambio possono esistere solo in valuta + if (in_valuta) + { + const TImporto diff(sez, pag.get_real(PAGSCA_DIFFCAM)); + if (!diff.is_zero()) + { + TToken_string& rdiff = scadenze.row(scadenze.add("")); + rdiff.add("Differenza cambio", 4); + gm.add_importo(rdiff, diff); + } + } - if (in_valuta) - { - TImporto diff(scad.importo_pagato(FALSE, 0x4)); - if (!diff.is_zero()) - { - TToken_string& rdiff = scadenze.row(scadenze.add("")); - rdiff.add("Differenza cambio", 4); - gm.add_importo(rdiff, diff); - } - } + } // Il pagamento era a saldo + } // Fine ciclo sui pagamenti della rata TToken_string& rsal = scadenze.row(scadenze.add("")); rsal.add("Saldo rata ", 4); rsal << ra; @@ -925,7 +936,7 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k) { const TRectype& pag = unas.row(pa); const TRiga_partite& sum = game->riga(pa); - TImporto imp(sum.sezione(), ZERO); + const char sez = sum.sezione(); TToken_string& row = scadenze.row(scadenze.add("")); row.add(pag.get(PAGSCA_NRIGA)); @@ -933,19 +944,18 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k) row.add(sum.get(PART_DATADOC)); row.add(sum.get(PART_DATAPAG)); gm.add_descrizione(row, sum); - TImporto i(sum.sezione(), pag.get_real(PAGSCA_IMPORTO)); - i.valore() += pag.get_real(PAGSCA_RITENUTE); - i.normalize(); - gm.add_importo(row, i); - tot_lit += i; + + TImporto imp(sez, pag.get_real(PAGSCA_IMPORTO)); + gm.add_importo(row, imp); + tot_lit += imp; const real& impval = pag.get_real(PAGSCA_IMPORTOVAL); if (!impval.is_zero()) { - i.set(sum.sezione(), impval); - i.normalize(); - gm.add_importo(row, i, TRUE); - tot_val += i; + imp.set(sum.sezione(), impval); + imp.normalize(); + gm.add_importo(row, imp, TRUE); + tot_val += imp; } else row.add(""); @@ -955,6 +965,14 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k) row.add(""); row.add(sum.get(PART_TIPOMOV)); row.add(pa); + + const TImporto rit(sez, pag.get_real(PAGSCA_RITENUTE)); + if (!rit.is_zero()) + { + TToken_string& row = scadenze.row(scadenze.add("")); + row.add("Ritenute professionali", 4); + tot_lit += rit; + } } if (lastrow > 0) diff --git a/cg/saldacon.cpp b/cg/saldacon.cpp index 668d45ad3..8d67d74d7 100755 --- a/cg/saldacon.cpp +++ b/cg/saldacon.cpp @@ -1500,15 +1500,11 @@ bool TPartita::chiusa(bool update) if (update) { const TImporto saldo = calcola_saldo(TRUE); // Saldo in valuta - const bool ora_chiusa = saldo.is_zero(); - if (chiusa != ora_chiusa) + chiusa = saldo.is_zero(); + for (int p = last(); p > 0; p = pred(p)) { - chiusa = ora_chiusa; - for (int p = last(); p > 0; p = pred(p)) - { - TRiga_partite& part = riga(p); - part.put(PART_CHIUSA, chiusa); - } + TRiga_partite& part = riga(p); + part.put(PART_CHIUSA, chiusa); } }