From dc6ee6cd729ced1b860c88a0c12838c235a728b1 Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 8 Sep 1995 10:57:44 +0000 Subject: [PATCH] Gestione saldconto in valuta git-svn-id: svn://10.65.10.50/trunk@1798 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg2100.cpp | 30 ++--- cg/cg2100.h | 11 +- cg/cg2100b.uml | 62 ++++----- cg/cg2100c.uml | 89 ++++++++----- cg/cg2100p.h | 6 +- cg/cg2100p.uml | 68 +++++++--- cg/cg2100s.uml | 78 ++++++----- cg/cg2102.cpp | 150 +++++++++++++++------ cg/cg2102.h | 4 +- cg/cg2105.cpp | 339 +++++++++++++++++++++++++++++------------------- cg/cg21cg.uml | 4 +- cg/saldacon.cpp | 287 +++++++++++++++++++++++++--------------- cg/saldacon.h | 56 +++++++- 13 files changed, 758 insertions(+), 426 deletions(-) diff --git a/cg/cg2100.cpp b/cg/cg2100.cpp index 269c3fed9..41a888646 100755 --- a/cg/cg2100.cpp +++ b/cg/cg2100.cpp @@ -28,9 +28,9 @@ TMask* TPrimanota_application::load_mask(int n) if (_msk[n] != NULL) return _msk[n]; - if (n == 1 || n == 2) + if (n == 1 || n == 2) // Se voglio una maschera principale (cg o iva) { - const int d = 3-n; + const int d = 3-n; // Indice maschera complementare if (_msk[d] != NULL) { delete _msk[d]; @@ -71,7 +71,6 @@ TMask* TPrimanota_application::load_mask(int n) m->set_handler(F_PROTIVA, protiva_handler); m->set_handler(F_CLIENTE, clifo_handler); m->set_handler(F_FORNITORE, clifo_handler); - m->set_handler(F_TOTALE, totale_handler); m->set_handler(F_RITFIS, ritfis_handler); m->set_handler(F_RITSOC, ritsoc_handler); m->set_handler(F_CORRLIRE, corrlire_handler); @@ -107,17 +106,14 @@ TMask* TPrimanota_application::load_mask(int n) m->set_handler(F_DATACOMP, datacomp_handler); m->set_handler(F_DESCR, descr_handler); m->set_handler(F_CODCAUS, caus_modify_handler); + m->set_handler(F_TOTALE, totdoc_handler); + m->set_handler(S_TOTDOCVAL, totdocval_handler); m->set_handler(F_SHEETCG, cg_handler); TSheet_field& cg = (TSheet_field&)m->field(F_SHEETCG); cg.set_notify(cg_notify); TMask& cgm = cg.sheet_mask(); - if (n == 1) // movimento non IVA - { - m->set_handler(S_TOTDOC, totdoc_handler); - } - cgm.set_handler(101, dareavere_handler); cgm.set_handler(102, dareavere_handler); cgm.set_handler(105, cg_conto_handler); @@ -311,12 +307,12 @@ bool TPrimanota_application::read_caus(const char* cod, int year) { char tipr = ' '; if (_is_saldaconto) - { - if (nriga < 13 && nriga != 10) continue; // Si considerano solo le spese - tipr = 'G'; + { + if (nriga < 13 && nriga != 10 && nriga != 2) continue; // Si considerano solo le spese + tipr = (nriga == 2) ? 'L' : 'G'; } const int pos = set_cgs_row(-1, zero, tc, desc, tipr); - if (sezione > ' ' && tipr != ' ') + if (sezione > ' ') cgs().disable_cell(pos, sezione == 'A' ? 0 : 1); } else @@ -564,7 +560,6 @@ void TPrimanota_application::init_modify_mode(TMask& m) { const long numreg = m.get_long(F_NUMREG); partite().add_numreg(numreg); - remove_unassigned(); } } @@ -572,10 +567,8 @@ void TPrimanota_application::init_modify_mode(TMask& m) // o quello delle ritenute sociali (ritsoc=TRUE) e' invertito rispetto al normale bool TPrimanota_application::test_swap(bool ritsoc) { - bool s = FALSE; - const char sez = ritsoc ? causale().sezione_ritsoc() : causale().sezione_clifo(); - s = (iva() == iva_vendite) ^ sez == 'D'; + const bool s = (iva() == iva_vendite) ^ sez == 'D'; return s; } @@ -600,11 +593,6 @@ int TPrimanota_application::read(TMask& m) error_box("Registrazione di vendita attribuita ad un fornitore"); } - // Inizializza cambio - real cambio(_rel->lfile().get("CAMBIO")); - if (cambio < 1.0) cambio = 1.0; - m.set_exchange(FALSE, cambio); - _saldi.reset(); // Azzera saldi _saldi.set_movprovv(_rel->lfile().get_char("PROVVIS") > ' '); _saldi.set_movap(causale().apertura()); diff --git a/cg/cg2100.h b/cg/cg2100.h index 853e67d94..71ccafdd3 100755 --- a/cg/cg2100.h +++ b/cg/cg2100.h @@ -102,12 +102,11 @@ #define I_SOTTOCONTO4 234 // Saldaconto -#define S_TOTDOC 301 -#define S_TOTDOCVAL 302 -#define S_VALUTA 303 -#define S_DATACAMBIO 304 -#define S_CAMBIO 305 -#define S_TIPORIGA 306 +#define S_TOTDOCVAL 301 +#define S_VALUTA 302 +#define S_DATACAMBIO 303 +#define S_CAMBIO 304 +#define S_TIPORIGA 305 // copie 2a pag. #define K_CODDITTA 401 diff --git a/cg/cg2100b.uml b/cg/cg2100b.uml index 5831892a2..9733e428e 100755 --- a/cg/cg2100b.uml +++ b/cg/cg2100b.uml @@ -120,7 +120,7 @@ END NUMBER F_TIPOMOV 1 BEGIN PROMPT 32 6 "Tipo movimento " - FIELD LF_MOV->TIPOMOV + FIELD TIPOMOV FLAGS "H" END @@ -174,51 +174,34 @@ BEGIN COPY OUTPUT F_DESCAGG END -GROUPBOX DLG_NULL 78 8 +GROUPBOX DLG_NULL 78 5 BEGIN PROMPT 1 10 "Voci per saldaconto" END -NUMBER S_TOTDOC 15 -BEGIN - PROMPT 2 11 "Totale documento " - PICTURE "." - GROUP 5 - FIELD TOTDOC -END - -NUMBER S_TOTDOCVAL 15 2 -BEGIN - PROMPT 44 11 "Totale in valuta " - HELP "" - PICTURE ".2" - GROUP 3 -END - - STRING S_VALUTA 3 BEGIN - PROMPT 2 13 "Valuta " + PROMPT 2 11 "Valuta " HELP "Codice della valuta per movimento" - FIELD LF_MOV->CODVAL - FLAGS "U" + FIELD CODVAL + FLAGS "UZ" GROUP 3 USE %VAL INPUT CODTAB S_VALUTA DISPLAY "Codice" CODTAB DISPLAY "Nome@50" S0 - DISPLAY "Ultimo cambio@15" R10 - DISPLAY "Ultimo aggiornamento" D0 OUTPUT S_VALUTA CODTAB - OUTPUT S_CAMBIO R10 CHECKTYPE NORMAL + MESSAGE EMPTY CLEAR,S_CAMBIO + MESSAGE ENABLE,S_CAMBIO END DATE S_DATACAMBIO BEGIN - PROMPT 22 13 "Data cambio " + PROMPT 22 11 "Data cambio " + FIELD DATACAM FLAGS "R" - USE CAM + USE CAM SELECT CODTAB[1,3]==#S_VALUTA INPUT CODTAB[1,3] S_VALUTA INPUT CODTAB[4,11] S_DATACAMBIO DISPLAY "Valuta" CODTAB[1,3] @@ -228,16 +211,37 @@ BEGIN OUTPUT S_DATACAMBIO D0 OUTPUT S_CAMBIO R10 GROUP 3 + CHECKTYPE NORMAL END NUMBER S_CAMBIO 15 5 BEGIN - PROMPT 54 13 "Cambio " + PROMPT 54 11 "Cambio " HELP "Cambio della valuta" - FIELD LF_MOV->CAMBIO + FIELD CAMBIO FLAGS "RU" GROUP 3 PICTURE ".5" + CHECKTYPE REQUIRED +END + +NUMBER F_TOTALE 15 +BEGIN + PROMPT 2 12 "Totale documento " + PICTURE "." + GROUP 5 + FIELD TOTDOC + VALIDATE REQIF_FUNC 1 F_TOTDOCVAL +END + +NUMBER S_TOTDOCVAL 15 2 +BEGIN + PROMPT 44 12 "Totale in valuta " + HELP "" + PICTURE ".2" + GROUP 3 + VALIDATE REQIF_FUNC 1 F_TOTALE + FIELD TOTDOCVAL END ENDPAGE diff --git a/cg/cg2100c.uml b/cg/cg2100c.uml index 3d071d0fa..44feeb378 100755 --- a/cg/cg2100c.uml +++ b/cg/cg2100c.uml @@ -53,7 +53,7 @@ DATE F_DATAREG BEGIN PROMPT 1 3 "Data operazione " HELP "Data in cui viene registrata l'operazione" - FIELD LF_MOV->DATAREG + FIELD DATAREG MESSAGE COPY,H_DATAREG|COPY,F_ANNOIVA,7,10 CHECKTYPE REQUIRED END @@ -61,7 +61,7 @@ END NUMBER F_ANNOIVA 4 BEGIN PROMPT 32 3 "Anno IVA " - FIELD LF_MOV->ANNOIVA + FIELD ANNOIVA FLAGS "D" END @@ -69,14 +69,14 @@ DATE F_DATACOMP BEGIN PROMPT 1 4 "Data competenza " HELP "Data di competenza dell'operazione" - FIELD LF_MOV->DATACOMP + FIELD DATACOMP CHECKTYPE REQUIRED END NUMBER F_ANNOES 4 BEGIN PROMPT 32 4 "Anno esercizio " - FIELD LF_MOV->ANNOES + FIELD ANNOES FLAGS "DGZ" MESSAGE COPY,H_ANNOES END @@ -85,7 +85,7 @@ STRING F_CODREG 3 BEGIN PROMPT 57 4 "Registro IVA " FLAGS "DGUZ" - FIELD LF_MOV->REG + FIELD REG END STRING F_CODCAUS 3 @@ -93,7 +93,7 @@ BEGIN PROMPT 1 5 "Causale " HELP "Codice della causale generante l'operazione" FLAGS "UZ" - FIELD LF_MOV->CODCAUS + FIELD CODCAUS USE LF_CAUSALI SELECT REG!="" INPUT CODCAUS F_CODCAUS DISPLAY "Codice" CODCAUS @@ -129,7 +129,7 @@ END DATE F_DATADOC BEGIN PROMPT 1 6 "Data documento " - FIELD LF_MOV->DATADOC + FIELD DATADOC HELP "Data del documento che ha generato il movimento" WARNING "Inserire una data documento non superiore alla data dell'operazione" VALIDATE DATE_CMP_FUNC <= F_DATAREG @@ -138,14 +138,14 @@ END STRING F_TIPODOC 2 BEGIN PROMPT 32 6 "Tipo documento " - FIELD LF_MOV->TIPODOC + FIELD TIPODOC FLAGS "D" END NUMBER F_TIPOMOV 1 BEGIN PROMPT 32 6 "Tipo movimento " - FIELD LF_MOV->TIPOMOV + FIELD TIPOMOV FLAGS "H" END @@ -153,7 +153,7 @@ STRING F_NUMDOC 7 BEGIN PROMPT 57 6 "Documento n. " HELP "Numero del documento che ha generato il movimento" - FIELD LF_MOV->NUMDOC + FIELD NUMDOC WARNING "La causale o il saldaconto richiedono il numero documento" END @@ -193,7 +193,7 @@ STRING F_DESCR 50 BEGIN PROMPT 25 8 "" HELP "Descrizione del movimento" - FIELD LF_MOV->DESCR + FIELD DESCR USE %DPN KEY 2 INPUT S0 F_DESCR DISPLAY "Descrizione@50" S0 @@ -205,14 +205,14 @@ NUMBER F_PROTIVA 5 BEGIN PROMPT 1 9 "Protocollo IVA " HELP "Numero progressivo di protocollo IVA" - FIELD LF_MOV->PROTIVA + FIELD PROTIVA END NUMBER F_RIEPILOGO 5 BEGIN PROMPT 25 9 "Riepilogo fino al n. " HELP "Numero finale del documento ripilogativo di protocollo IVA" - FIELD LF_MOV->UPROTIVA + FIELD UPROTIVA NUM_EXPR {(#F_RIEPILOGO==0)||(#F_RIEPILOGO>=#F_PROTIVA)} WARNING "Inserire un riepilogo non inferiore al protocollo IVA (Obbigatorio se il cliete/fornitore ha codice inserimento in allegati uguale a 3)" END @@ -245,7 +245,7 @@ BEGIN PROMPT 1 10 "Cliente " HELP "Codice del cliente" FLAGS "R" - FIELD LF_MOV->CODCF + FIELD CODCF GROUP 1 USE LF_CLIFO KEY 1 INPUT TIPOCF "C" @@ -271,7 +271,7 @@ BEGIN PROMPT 1 10 "Fornitore " FLAGS "R" HELP "Codice del fornitore" - FIELD LF_MOV->CODCF + FIELD CODCF GROUP 2 USE LF_CLIFO KEY 1 INPUT TIPOCF "F" @@ -417,43 +417,70 @@ STRING S_VALUTA 3 BEGIN PROMPT 1 12 "Valuta " HELP "Codice della valuta per operazione con l'estero" - FIELD LF_MOV->CODVAL + FIELD CODVAL FLAGS "UZ" GROUP 3 USE %VAL INPUT CODTAB S_VALUTA DISPLAY "Codice" CODTAB DISPLAY "Nome@50" S0 - DISPLAY "Cambio@15" R10 - DISPLAY "Ultimo aggiornamento" D0 OUTPUT S_VALUTA CODTAB - OUTPUT S_CAMBIO R10 CHECKTYPE NORMAL WARNING "Codice valuta assente" + MESSAGE EMPTY CLEAR,S_CAMBIO + MESSAGE ENABLE,S_CAMBIO +END + +DATE S_DATACAMBIO +BEGIN + PROMPT 28 12 "Data cambio " + FIELD DATACAM + FLAGS "R" + USE CAM SELECT CODTAB[1,3]==#S_VALUTA + INPUT CODTAB[1,3] S_VALUTA + INPUT CODTAB[4,11] S_DATACAMBIO + DISPLAY "Valuta" CODTAB[1,3] + DISPLAY "Data@10" D0 + DISPLAY "Cambio@18" R10 + OUTPUT S_VALUTA CODTAB[1,3] + OUTPUT S_DATACAMBIO D0 + OUTPUT S_CAMBIO R10 + GROUP 3 + CHECKTYPE NORMAL END NUMBER S_CAMBIO 12 5 BEGIN - PROMPT 20 12 "Cambio " + PROMPT 58 12 "Cambio " HELP "Cambio della valuta per operazione con l'estero" - FIELD LF_MOV->CAMBIO + FIELD CAMBIO FLAGS "RU" GROUP 3 PICTURE ".5" + CHECKTYPE REQUIRED END NUMBER F_TOTALE 15 BEGIN - PROMPT 1 13 "Totale documento " + PROMPT 1 13 "Totale documento " HELP "Totale del documento generante il movimento" FIELD TOTDOC - FLAGS "RV" PICTURE "." END +NUMBER S_TOTDOCVAL 15 2 +BEGIN + PROMPT 35 13 "Tot. in valuta " + HELP "Totale del documento in valuta" + FIELD TOTDOCVAL + GROUP 3 + PICTURE ".2" + VALIDATE REQIF_FUNC 1 F_TOTALE +END + STRING F_CODIVA 4 BEGIN - PROMPT 60 13 "Codice IVA " + PROMPT 67 13 "IVA " HELP "Codice IVA del documento generante il movimento" FLAGS "U" USE %IVA @@ -470,7 +497,7 @@ END NUMBER F_RITFIS 15 BEGIN - PROMPT 1 14 "Ritenute fiscali " + PROMPT 1 14 "Ritenute fiscali " HELP "Ritenute fiscali del documento generante il movimento" FIELD RITFIS FLAGS "RV" @@ -479,9 +506,9 @@ END NUMBER F_RITSOC 15 BEGIN - PROMPT 1 15 "Ritenute sociali " + PROMPT 1 15 "Ritenute sociali " HELP "Ritenute fiscali del documento generante il movimento" - FIELD LF_MOV->RITSOC + FIELD RITSOC FLAGS "RV" PICTURE "." END @@ -512,7 +539,7 @@ END STRING F_VALUTAINTRA 3 BEGIN - PROMPT 1 17 "Valuta intracom. " + PROMPT 1 17 "Valuta intracom. " HELP "Codice della valuta per operazione intracomunitaria" FIELD CODVALI FLAGS "UZ" @@ -542,9 +569,9 @@ END NUMBER F_CORRLIRE 15 BEGIN - PROMPT 1 18 "Corrispettivo Lire " + PROMPT 1 18 "Corrispett. Lire " HELP "Corrispettivo in Lit. per operazioni intracomunitarie. Il tasto F8 lo pone uguale alla somma degli imponibili" - FIELD LF_MOV->CORRLIRE + FIELD CORRLIRE FLAGS "R" PICTURE "." GROUP 4 @@ -554,7 +581,7 @@ NUMBER F_CORRVALUTA 15 2 BEGIN PROMPT 37 18 "Corrispettivo valuta " HELP "Corrispettivo in valuta per operazioni intracomunitarie" - FIELD LF_MOV->CORRVALUTA + FIELD CORRVALUTA FLAGS "R" PICTURE ".2" GROUP 4 diff --git a/cg/cg2100p.h b/cg/cg2100p.h index 4963deb8a..ead2fcbea 100755 --- a/cg/cg2100p.h +++ b/cg/cg2100p.h @@ -6,6 +6,9 @@ #define P_RESIDUO 106 #define P_ANNO 107 #define P_NUMERO 108 +#define P_VALUTA 109 +#define P_DATACAMBIO 110 +#define P_CAMBIO 111 #define P_SHOWALL 180 #define P_SCAMBIO 181 #define P_NUOVO 182 @@ -31,7 +34,7 @@ #define S_RITENUTE 114 #define S_IMPORTOVAL 115 #define S_SALDOACC 116 -#define S_RESIDUO 117 +#define S_RESIDUORATA 117 #define S_DATAPAG 118 #define S_CODPAG 119 #define S_TIPOPAG 120 @@ -51,3 +54,4 @@ #define S_DESCNSABI 134 #define S_DESPAG 135 #define S_CODDESC 136 +#define S_RESIDUOPAG 137 diff --git a/cg/cg2100p.uml b/cg/cg2100p.uml index 193503aa2..63cef8c4a 100755 --- a/cg/cg2100p.uml +++ b/cg/cg2100p.uml @@ -20,7 +20,7 @@ PAGE "PARTITE" -1 -1 77 20 LIST P_TIPOC 1 12 BEGIN - PROMPT 1 1 "Tipo conto " + PROMPT 1 0 "Tipo conto " ITEM " |Conto" ITEM "C|Cliente" ITEM "F|Fornitore" @@ -29,49 +29,82 @@ END NUMBER P_GRUPPO 3 BEGIN - PROMPT 26 1 "Gruppo " + PROMPT 26 0 "Gruppo " FLAGS "D" END NUMBER P_CONTO 3 BEGIN - PROMPT 40 1 "Conto " + PROMPT 40 0 "Conto " FLAGS "D" END NUMBER P_SOTTOCONTO 6 BEGIN - PROMPT 54 1 "Sottoconto " + PROMPT 54 0 "Sottoconto " FLAGS "D" END -STRING P_DESCR 50 +STRING P_DESCR 50 58 BEGIN - PROMPT 1 2 "Descrizione " + PROMPT 1 1 "Descrizione " FLAGS "D" END -NUMBER P_RESIDUO 15 +STRING P_VALUTA 3 BEGIN - PROMPT 1 3 "Residuo " - FLAGS "D" - PICTURE "." + PROMPT 1 2 "Valuta " + HELP "Codice della valuta per movimento" + FLAGS "DUZ" +END + +DATE P_DATACAMBIO +BEGIN + PROMPT 21 2 "Data cambio " + FLAGS "DR" + USE CAM SELECT CODTAB[1,3]=#P_VALUTA + INPUT CODTAB[1,3] P_VALUTA + INPUT CODTAB[4,11] P_DATACAMBIO + DISPLAY "Valuta" CODTAB[1,3] + DISPLAY "Data@10" D0 + DISPLAY "Cambio@18" R10 + OUTPUT P_DATACAMBIO D0 + OUTPUT P_CAMBIO R10 + GROUP 3 + CHECKTYPE NORMAL +END + +NUMBER P_CAMBIO 15 5 +BEGIN + PROMPT 48 2 "Cambio " + HELP "Cambio della valuta" + FLAGS "DRU" + GROUP 3 + PICTURE ".5" + CHECKTYPE REQUIRED END NUMBER P_ANNO 4 BEGIN - PROMPT 1 4 "Anno " + PROMPT 1 3 "Anno " FLAGS "A" END STRING P_NUMERO 7 BEGIN - PROMPT 26 4 "Numero " + PROMPT 21 3 "Numero " END -SPREADSHEET P_PARTITE 0 6 +NUMBER P_RESIDUO 15 BEGIN - PROMPT 0 5 "" + PROMPT 48 3 "Residuo " + FLAGS "D" + PICTURE "." +END + +SPREADSHEET P_PARTITE 0 7 +BEGIN + PROMPT 0 4 "" ITEM "Anno" ITEM "Partita@7" ITEM "Data doc.@10" @@ -231,15 +264,16 @@ BEGIN PROMPT 1 6 "Descrizione " END -NUMBER 107 12 +STRING 107 14 BEGIN PROMPT 1 7 "Importo Lire " + FLAGS "R" END -NUMBER 108 12 2 +STRING 108 14 BEGIN PROMPT 30 7 "Importo Valuta " - PICTURE ".2" + FLAGS "R" END BUTTON DLG_CANCEL 12 2 diff --git a/cg/cg2100s.uml b/cg/cg2100s.uml index d0a4417c1..40bcadf0c 100755 --- a/cg/cg2100s.uml +++ b/cg/cg2100s.uml @@ -25,7 +25,7 @@ PAGE "Pagamento" -1 -1 77 20 GROUPBOX DLG_NULL 78 7 BEGIN - PROMPT 1 0 "@BPartita" + PROMPT 1 0 "@BScadenza" END NUMBER S_ANNO 4 @@ -37,24 +37,30 @@ END STRING S_NUM 7 BEGIN - PROMPT 19 1 "Numero " + PROMPT 15 1 "Numero " FLAGS "DR" FIELD NUMPART END NUMBER S_RIGA 4 BEGIN - PROMPT 40 1 "Riga " + PROMPT 32 1 "Riga " FLAGS "D" FIELD NRIGA END NUMBER S_RATA 4 BEGIN - PROMPT 60 1 "Rata " + PROMPT 44 1 "Rata " FLAGS "D" FIELD NRATA END + +DATE S_DATASCAD +BEGIN + PROMPT 57 1 "Scadenza " + FLAGS "D" +END STRING S_NUMDOC 7 BEGIN @@ -80,41 +86,43 @@ BEGIN FLAGS "D" END -DATE S_DATASCAD -BEGIN - PROMPT 20 4 "Data " - FLAGS "D" -END - -NUMBER S_RESIDUO 15 -BEGIN - PROMPT 44 4 "Residuo " - PICTURE "." - FLAGS "DR" -END - -NUMBER S_IMPORTOVAL_SCAD 15 2 -BEGIN - PROMPT 2 5 "Importo in valuta " - PICTURE ".2" - FLAGS "DR" -END - -NUMBER S_IMPORTO_SCAD 15 -BEGIN - PROMPT 38 5 "Importo " - PICTURE "." - FLAGS "DR" -END - LIST S_SEZIONE_SCAD 6 BEGIN - PROMPT 68 5 "" + PROMPT 2 4 "Sez. " ITEM "A|Avere" ITEM "D|Dare" FLAGS "D" END +NUMBER S_IMPORTO_SCAD 15 +BEGIN + PROMPT 18 4 "Importo " + PICTURE "." + FLAGS "DR" +END + +NUMBER S_IMPORTOVAL_SCAD 15 2 +BEGIN + PROMPT 43 4 "Importo in valuta " + PICTURE ".2" + FLAGS "DRV" + GROUP 3 +END + +NUMBER S_RESIDUOPAG 15 +BEGIN + PROMPT 2 5 "Residuo pagamento " + PICTURE "." + FLAGS "DR" +END + +NUMBER S_RESIDUORATA 15 +BEGIN + PROMPT 43 5 "Residuo rata " + PICTURE "." + FLAGS "DRV" +END + GROUPBOX DLG_NULL 78 12 BEGIN PROMPT 1 7 "@BPagamento" @@ -124,23 +132,23 @@ NUMBER S_IMPORTO 15 BEGIN PROMPT 2 8 "Importo pagamento " PICTURE "." - FLAGS "U" FIELD IMPORTO + VALIDATE REQIF_FUNC 1 S_IMPORTOVAL END NUMBER S_IMPORTOVAL 15 2 BEGIN PROMPT 2 9 "Importo in valuta " PICTURE ".2" - FLAGS "U" FIELD IMPORTOVAL + GROUP 3 + VALIDATE REQIF_FUNC 1 S_IMPORTO END NUMBER S_RITENUTE 15 BEGIN PROMPT 38 8 "Ritenute professionali " PICTURE "." - FLAGS "U" FIELD RITENUTE END diff --git a/cg/cg2102.cpp b/cg/cg2102.cpp index 26578ce66..cb8ed48cd 100755 --- a/cg/cg2102.cpp +++ b/cg/cg2102.cpp @@ -289,8 +289,8 @@ bool TPrimanota_application::add_cgs_imp(int n, const TImporto& imp) TImporto tot; tot = cgs().row(n); tot += imp; - set_cgs_imp(n, tot); - return tot.is_zero();; + set_cgs_imp(n, tot.normalize()); + return tot.is_zero(); } // Certified 90% @@ -299,7 +299,7 @@ bool TPrimanota_application::sub_cgs_imp(int n, const TImporto& imp) TImporto tot; tot = cgs().row(n); tot -= imp; - set_cgs_imp(n, tot); + set_cgs_imp(n, tot.normalize()); return tot.is_zero(); } @@ -331,6 +331,7 @@ void TPrimanota_application::disable_cgs_cells(int n, char tipo) case 'C': // Differenza cambio case 'D': // IVA Detraibile case 'F': // Ritenute Fiscali + case 'L': // Contropartita delle spese case 'N': // IVA Non detraibile case 'P': // Abbuoni passsivi case 'R': // Ritenute professionali @@ -339,6 +340,8 @@ void TPrimanota_application::disable_cgs_cells(int n, char tipo) last = 3; break; case 'K': // Riga cliente/fornitore per saldaconto + if (get_cgs_imp(n).is_zero()) + break; first = 2; case 'I': last = 7; // Imponibile @@ -670,49 +673,81 @@ void TPrimanota_application::generazione_righe_cg(int r) bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k) -{ - int i; // Contatore nello switch - const char tipo = row_type(cg.row(r)); // Tipo della riga in esame +{ + static TImporto old_spesa; + + TToken_string& row = cg.row(r); + const char tipo = row_type(row); // Tipo della riga in esame switch(k) { + case K_SPACE: + if (tipo == 'G') + old_spesa = row; + break; case K_TAB: cg.sheet_mask().enable(DLG_DELREC, tipo <= ' ' || tipo == 'K' || tipo == 'G'); cg.sheet_mask().enable(100, tipo == 'K'); break; - case K_ENTER: - if (app().iva() == nessuna_iva) - app().generazione_righe_cg(r); - app().calcola_saldo(); - break; case K_DEL: - if (tipo == 'K') - app().notify_cgline_deletion(r+1); + if (tipo == 'G') + { + row.add("", 0); + row.add("", 1); + } + else + { + if (tipo == 'K') + app().notify_cgline_deletion(r+1); + break; + } + case K_ENTER: + if (tipo == 'G') + { + TImporto growth; growth = row; growth -= old_spesa; + if (!growth.is_zero()) + { + const int s = type2pos('L'); + if (s < 0) + { + TConto cassa; app().causale().bill(2, cassa); + growth.swap_section(); growth.normalize(); + app().set_cgs_row(s, growth, cassa, app().causale().desc_agg(2), 'L'); + } + else + app().sub_cgs_imp(s, growth); + } + } + else + { + if (app().iva() == nessuna_iva && !app().is_saldaconto()) + app().generazione_righe_cg(r); + } + app().calcola_saldo(); break; case K_INS: if (app().iva() == nessuna_iva && app().is_saldaconto()) { const char tipo = app().curr_mask().get(S_TIPORIGA)[0]; - switch (tipo) - { - case 'K': - cg.row(r).add("K", 15); - for (i = 0; i < r; i++) + if (tipo == 'K' || tipo == 'G') + { + const int k = tipo == 'K' ? 1 : 10; + TBill conto; app().causale().bill(k, conto); + const TString80 desc(app().causale().desc_agg(k)); + app().set_cgs_row(r, TImporto('D', ZERO), conto, desc, tipo); + if (tipo == 'K') { - const TToken_string& row = cg.row(i); - if (row_type(row) != 'K') + for (int i = 0; i < r; i++) { - cg.swap_rows(r, i); - break; + const TToken_string& row = cg.row(i); + if (row_type(row) != 'K') + { + cg.swap_rows(r, i); + break; + } } } - break; - case 'G': - cg.row(r).add("G", 15); - break; - default: - break; - } + } } break; default: @@ -1651,10 +1686,7 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key) TTable val("%val"); val.put("CODTAB", valuta); if (val.read() == NOERR) - { m.set(S_VALUTA, valuta); - m.set(S_CAMBIO, val.get("R10"), TRUE); - } } } if (occas && app().occas_mask().get(O_CODICE).empty()) @@ -1734,31 +1766,65 @@ bool TPrimanota_application::main_codiva_handler(TMask_field& f, KEY key) // Handler of the F_TOTALE // Certified 99% -bool TPrimanota_application::totale_handler(TMask_field& f, KEY key) +bool TPrimanota_application::totdoc_handler(TMask_field& f, KEY key) { bool ok = TRUE; - TMask& m = f.mask(); if (key == K_TAB && f.focusdirty()) { - app().add_cgs_tot(m); - m.field(F_CODIVA).on_hit(); + TMask& m = f.mask(); + + if (app().iva() != nessuna_iva) + { + app().add_cgs_tot(m); + m.field(F_CODIVA).on_hit(); + } + + TMask_field& totval = m.field(S_TOTDOCVAL); + if (totval.active() && totval.get().empty()) + { + const real cambio(m.get(S_CAMBIO)); + if (!cambio.is_zero()) + { + real tot(f.get()); + tot /= cambio; + totval.set(tot.string()); + } + } } if (key == K_ENTER && f.get().empty()) ok = f.yesno_box("Totale documento nullo: continuare ugualmente?"); + return ok; } -bool TPrimanota_application::totdoc_handler(TMask_field& f, KEY key) +bool TPrimanota_application::totdocval_handler(TMask_field& f, KEY key) { - bool ok = TRUE; - if (key == K_ENTER && f.get().empty()) - ok = f.yesno_box("Totale documento nullo: continuare ugualmente?"); - return ok; + if (key == K_TAB && f.focusdirty() && f.get().not_empty()) + { + TMask& m = f.mask(); + real totval(f.get()); + real cambio(m.get(S_CAMBIO)); + real totale(m.get(F_TOTALE)); + if (totale.is_zero()) + { + totval *= cambio; + m.set(F_TOTALE, totval.string()); + } + else + { + if (cambio.is_zero()) + { + totale /= totval; + m.set(S_CAMBIO, totale.string()); + } + } + } + + return TRUE; } - void TPrimanota_application::add_cgs_rit(bool fiscali) { const real imp(curr_mask().get(fiscali ? F_RITFIS : F_RITSOC)); diff --git a/cg/cg2102.h b/cg/cg2102.h index 5042f803e..a67371b0c 100755 --- a/cg/cg2102.h +++ b/cg/cg2102.h @@ -91,8 +91,8 @@ class TPrimanota_application : public TRelation_application 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); - static bool totale_handler(TMask_field& f, KEY key); static bool totdoc_handler(TMask_field& f, KEY key); + static bool totdocval_handler(TMask_field& f, KEY key); static bool ritfis_handler(TMask_field& f, KEY key); static bool ritsoc_handler(TMask_field& f, KEY key); static bool main_codiva_handler(TMask_field& f, KEY key); @@ -222,9 +222,7 @@ protected: bool notify_cgline_deletion(TPartita& partita, long nreg, int numrig); bool notify_cgline_deletion(int numrig); - bool notify_edit_pagamento(TPartita& partita, TRectype& new_pag, int deleting = -1); - bool remove_unassigned(); long calcola_m770(int tipo_coll, real& spese, real& compenso, real& iva, real& ritfis); bool link_m770(); diff --git a/cg/cg2105.cpp b/cg/cg2105.cpp index 174fb39ec..d5842441f 100755 --- a/cg/cg2105.cpp +++ b/cg/cg2105.cpp @@ -18,6 +18,8 @@ class TGame_mask : public TMask { const TBill _conto; // Conto fisso del cliente/fornitore + long _numreg; // Numero movimento contabile + int _numrig; // Riga contabile corrente (prima = 1!) int _riga_partite; // Riga corrente delle partite protected: @@ -29,7 +31,7 @@ protected: static bool edit_scadenza_handler(TMask_field& f, KEY k); static bool nuovo_handler(TMask_field& f, KEY k); - void add_importo(TToken_string& s, const TImporto& i) const; + static void add_importo(TToken_string& s, const TImporto& i, int dec = 0); TImporto get_importo(TToken_string& s, int pos) const; void fill_partite(bool all) const; @@ -38,16 +40,19 @@ protected: void update_partita(const TPartita& game, int prow) const; void update_saldo_clifo() const; + bool cerca_valuta(TValuta& val) const; + public: TSheet_field& partite() const { return (TSheet_field&)field(P_PARTITE); } TSheet_field& scadenze() const { return (TSheet_field&)field(P_SCADENZE); } const TBill& conto() const { return _conto; } - TGame_mask(const TBill& bill); + TGame_mask(const TBill& bill, long numreg, int riga); virtual ~TGame_mask() {} }; -TGame_mask::TGame_mask(const TBill& bill) : TMask("cg2100p"), _conto(bill) +TGame_mask::TGame_mask(const TBill& bill, long numreg, int riga) +: TMask("cg2100p"), _conto(bill), _numreg(numreg), _numrig(riga+1) { const char tipocf[2] = { _conto.tipo(), '\0' }; set(P_TIPOC, tipocf); @@ -56,6 +61,19 @@ TGame_mask::TGame_mask(const TBill& bill) : TMask("cg2100p"), _conto(bill) set(P_SOTTOCONTO, _conto.sottoconto()); set(P_DESCR, ((TBill&)_conto).descrizione()); + TMask& cm = app().curr_mask(); + const TString& val = cm.get(S_VALUTA); + if (val.not_empty()) + { + TValuta val; + val.get(cm, S_VALUTA, S_DATACAMBIO, S_CAMBIO); + cerca_valuta(val); + val.set(*this, P_VALUTA, P_DATACAMBIO, P_CAMBIO); + enable(-3); + } + else + disable(-3); + set_handler(P_ANNO, annopart_handler); set_handler(P_NUMERO, numpart_handler); set_handler(P_SHOWALL, show_all_handler); @@ -137,18 +155,30 @@ bool TGame_mask::scambio_handler(TMask_field& f, KEY k) real TGame_mask::aggiorna_residuo() { - const TMask& cm = app().curr_mask(); - const long cur_reg = cm.get_long(F_NUMREG); - const int rmov = app().cgs().selected(); - - TImporto residuo(app().get_cgs_imp(rmov)); - residuo -= app().partite().importo_speso(cur_reg, rmov+1, TRUE); - + TImporto residuo(app().get_cgs_imp(_numrig-1)); + residuo -= app().partite().importo_speso(_numreg, _numrig, TRUE); set(P_RESIDUO, residuo.valore().string()); - return residuo.valore(); } +bool TGame_mask::cerca_valuta(TValuta& val) const +{ + bool found = FALSE; + TPartite_array& pa = app().partite(); + for (const TPartita* game = pa.first(); game; game = pa.next()) + { + const int r = game->mov2rig(_numreg, _numrig); + if (r > 0) + { + const TRiga_partite& row = game->riga(r); + val.get(row); + found = TRUE; + break; + } + } + return found; +} + bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k) { if (k == K_TAB) @@ -170,12 +200,15 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k) const bool should_delete_game = (game == NULL); // Ricorda di fare delete if (should_delete_game) // Se non c'era ... game = new TPartita(zio, anno, num); // ... creane una temporanea + + TImporto tot_lit, tot_val; const int lastrow = game->last(); for (int ri = game->first(); ri <= lastrow; ri = game->succ(ri)) { const TRiga_partite& riga = game->riga(ri); const bool in_valuta = riga.in_valuta(); + for (int ra = 1; ra <= riga.rate(); ra++) { const TRiga_scadenze& scad = riga.rata(ra); @@ -187,47 +220,89 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k) row.add(riga.get(PART_NREG)); row.add(riga.get(PART_DATAREG)); row.add(scad.get(SCAD_DATASCAD)); - row.add(scad.get(SCAD_IMPORTO)); - row.add(in_valuta ? scad.get_real(SCAD_IMPORTOVAL).string(0, 2) : ""); + add_importo(row, TImporto(riga.sezione(), scad.get_real(SCAD_IMPORTO))); + if (in_valuta) + add_importo(row, TImporto(riga.sezione(), scad.get_real(SCAD_IMPORTOVAL)), 2); + else + row.add(""); row.add(riga.get(PART_DESCR)); row.add(riga.get(PART_NUMDOC)); row.add(riga.get(PART_PROTIVA)); - + const int lastp = scad.last(); for (int pa = scad.first(); pa <= lastp; pa = scad.succ(pa)) { - const TRiga_partite& rigp = game->riga(pa); const TRectype& pag = scad.row(pa); + const TRiga_partite& sum = game->riga(pa); + const char sez = sum.sezione(); TToken_string& row = scadenze.row(scadenze.add("")); row.add(ri); row.add(ra); - row.add(rigp.get(PART_DATADOC)); - row.add(rigp.get(PART_NREG)); - row.add(rigp.get(PART_DATAREG)); + row.add(sum.get(PART_DATADOC)); + row.add(sum.get(PART_NREG)); + row.add(sum.get(PART_DATAREG)); row.add(scad.get(SCAD_DATASCAD)); - row.add(pag.get_real(PAGSCA_IMPORTO).string()); - row.add(in_valuta ? pag.get_real(PAGSCA_IMPORTOVAL).string(0, 2) : ""); - row.add(rigp.get(PART_DESCR)); - row.add(rigp.get(PART_NUMDOC)); + + add_importo(row, TImporto(sez, pag.get_real(PAGSCA_IMPORTO))); + if (in_valuta) + add_importo(row, TImporto(sez, pag.get_real(PAGSCA_IMPORTOVAL)), 2); + else + row.add(""); + + row.add(sum.get(PART_DESCR)); + row.add(sum.get(PART_NUMDOC)); row.add(""); row.add(pa); } - - TToken_string& sal = scadenze.row(scadenze.add("")); - sal.add(ri); - sal.add(ra); - if (scad.pagata()) + + TImporto abb(scad.importo_pagato(TRUE, 0x2)); + if (!abb.is_zero()) { - sal.add("", 6); - sal.add(""); + TToken_string& rabb = scadenze.row(scadenze.add("")); + rabb.add("", 5); + if (in_valuta) + { + add_importo(rabb, scad.importo_pagato(FALSE, 0x2)); + add_importo(rabb, abb.normalize()); + } + else + { + add_importo(rabb, abb, 2); + rabb.add(""); + } + rabb.add("Abbuoni rata ", 8); rabb << ra; } - else + + if (in_valuta) { - sal.add(scad.residuo(FALSE).string(), 6); - sal.add(in_valuta ? scad.residuo(TRUE).string(0, 2) : ""); + TImporto diff(scad.importo_pagato(FALSE, 0x4)); + if (!diff.is_zero()) + { + TToken_string& rdiff = scadenze.row(scadenze.add("")); + rdiff.add("", 5); + add_importo(rdiff, diff.normalize()); + rdiff.add("Differenza cambio rata ", 8); rdiff << ra; + } + } + + TToken_string& rsal = scadenze.row(scadenze.add("")); + if (!scad.chiusa()) + { + rsal.add("", 5); + + TImporto sl(scad.residuo(FALSE, 0x7)); + add_importo(rsal, sl); + tot_lit += sl.normalize(); + + if (in_valuta) + { + sl = scad.residuo(TRUE, 0x3); + tot_val += sl.normalize(); + add_importo(rsal, sl, 2); + } } - sal.add("Saldo della rata "); sal << ra; + rsal.add("Saldo rata ", 8); rsal << ra; } TRecord_array& unas = game->unassigned(); @@ -235,24 +310,41 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k) for (int pa = unas.first_row(); pa <= lastp; pa = unas.succ_row(pa)) { const TRectype& pag = unas.row(pa); - const TRiga_partite& rigp = game->riga(pa); + const TRiga_partite& sum = game->riga(pa); + TImporto imp(sum.sezione(), ZERO); TToken_string& row = scadenze.row(scadenze.add("")); row.add(pag.get(PAGSCA_NRIGA)); row.add(pag.get(PAGSCA_NRATA)); - row.add(rigp.get(PART_DATADOC)); - row.add(rigp.get(PART_NREG)); - row.add(rigp.get(PART_DATAREG)); - row.add(""); - row.add(pag.get_real(PAGSCA_IMPORTO).string()); - row.add(in_valuta ? pag.get_real(PAGSCA_IMPORTOVAL).string(0, 2) : ""); - row.add(rigp.get(PART_DESCR)); - row.add(rigp.get(PART_NUMDOC)); + row.add(sum.get(PART_DATADOC)); + row.add(sum.get(PART_NREG)); + row.add(sum.get(PART_DATAREG)); + row.add(""); + + TImporto i(sum.sezione(), pag.get_real(PAGSCA_IMPORTO)); + tot_lit += i; + add_importo(row, i); + if (in_valuta) + { + i = TImporto(sum.sezione(), pag.get_real(PAGSCA_IMPORTOVAL)); + tot_val += i; + add_importo(row, i, 2); + } + else + row.add(""); + row.add(sum.get(PART_DESCR)); + row.add(sum.get(PART_NUMDOC)); row.add(""); row.add(pa); } } + TToken_string& sp = scadenze.row(scadenze.add("")); + sp.add("", 5); + add_importo(sp, tot_lit.normalize()); + add_importo(sp, tot_val.normalize(), 2); + sp.add("Saldo partita", 8); + gm.scadenze().force_update(); if (should_delete_game) delete game; @@ -266,24 +358,26 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k) if (k == K_SPACE) { TMask& m = f.mask(); + const int nriga = m.get_int(101); + const int nrata = m.get_int(102); + if (nriga == 0 || nrata == 0) + return FALSE; // Ho cliccato su di un saldo (per sbaglio!) + TGame_mask& gm = (TGame_mask&)(m.get_sheet()->mask()); + TMask_field& cambio = gm.field(P_CAMBIO); + if (cambio.active() && cambio.get().empty()) + return f.error_box("E' necessario specificare un cambio"); const TBill& bill = gm.conto(); const int anno = gm.get_int(P_ANNO); const TString16 numero = gm.get(P_NUMERO); - const int nriga = m.get_int(101); - const int nrata = m.get_int(102); - const int rmov = app().cgs().selected()+1; - CHECK(nriga && nrata, "La riga della scadenza sembra vuota, ma tutti sanno che e' una balla!"); - TPartita& game = app().partite().partita(bill, anno, numero); int nrigp = m.get_int(112); if (nrigp == 0) - { - if (game.rata_pagata(nriga, nrata)) - return f.error_box("La rata %d e' gia' stata pagata", nrata); + { + const int rmov = app().cgs().selected()+1; nrigp = app().nuovo_pagamento(game, nriga, nrata, rmov); } else @@ -292,11 +386,7 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k) const long cur_reg = cm.get_long(F_NUMREG); const long nreg = m.get_long(104); if (cur_reg != nreg) - return f.error_box("Il movimento corrente e' il %ld", cur_reg); - - const int paga = game.rata_pagata(nriga, nrata); - if (paga != 0 && paga != nrigp) - return f.error_box("Pagamento non modificabile"); + return f.error_box("Modificare il movimento %ld", nreg); } const bool dirty = app().edit_pagamento(game, nriga, nrata, nrigp); @@ -317,10 +407,11 @@ bool TGame_mask::nuovo_handler(TMask_field& f, KEY k) if (k == K_SPACE) { TMask new_game("Nuova partita", 1, 24, 5); - new_game.add_number(P_ANNO, 0, "Anno ", 1, 1, 4, "A"); - new_game.add_string(P_NUMERO, 0, "Partita ", 1, 2, 7); - new_game.add_button(DLG_OK, 0, "", -12, 3, 8, 2); - new_game.add_button(DLG_CANCEL, 0, "", -22, 3, 8, 2); + new_game.add_number(P_ANNO, 0, "Anno ", 1, 1, 4, "A"); + new_game.add_string(P_NUMERO, 0, "Partita ", 1, 2, 7); + new_game.add_button(DLG_OK, 0, "" , -12, 3, 8, 2); + new_game.add_button(DLG_CANCEL, 0, "" , -22, 3, 8, 2); + new_game.first_focus(P_NUMERO); if (new_game.run() == K_ENTER) { @@ -330,10 +421,10 @@ bool TGame_mask::nuovo_handler(TMask_field& f, KEY k) TPartita& game = app().partite().partita(gm.conto(), anno, numero); if (game.ok()) return error_box("La partita %d %s esiste gia'.", anno, (const char*)numero); + const int nriga = TPartita::UNASSIGNED; const int nrata = TPartita::UNASSIGNED; - const int nrigp = app().nuovo_pagamento(game, nriga, nrata, app().cgs().selected()+1); - + const int nrigp = app().nuovo_pagamento(game, nriga, nrata, gm._numrig); app().edit_pagamento(game, nriga, nrata, nrigp); if (game.ok()) { @@ -354,13 +445,13 @@ bool TGame_mask::nuovo_handler(TMask_field& f, KEY k) // Metodi della maschera delle partite /////////////////////////////////////////////////////////// -void TGame_mask::add_importo(TToken_string& s, const TImporto& i) const +void TGame_mask::add_importo(TToken_string& s, const TImporto& i, int dec) { if (i.is_zero()) s.add(""); else { - s.add(i.valore().string()); + s.add(i.valore().string(dec)); s << ' ' << i.sezione(); } } @@ -537,11 +628,11 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad) set(S_SEZIONE_SCAD, scad.riga().sezione()); // Sezione della rata set(S_IMPORTO_SCAD, scad.get(SCAD_IMPORTO)); // Importo della rata set(S_IMPORTOVAL_SCAD, scad.get(SCAD_IMPORTOVAL)); // Importo in valuta - - _in_valuta = scad.in_valuta(); - _da_pagare = scad.residuo(_in_valuta); // Calcola residuo in valuta - TReal_field& res = (TReal_field&)field(S_RESIDUO); + _in_valuta = scad.in_valuta(); + _da_pagare = scad.residuo(_in_valuta).valore(); // Calcola residuo in valuta + + TReal_field& res = (TReal_field&)field(S_RESIDUORATA); res.set_decimals(_in_valuta ? 2 : 0); res.set(_da_pagare.string()); if (!_da_pagare.is_zero()) @@ -550,9 +641,21 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad) // Ricorda l'importo da pagare _da_pagare += oldpag.get_real(_in_valuta ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO); - show(S_IMPORTOVAL_SCAD, _in_valuta); - show(S_IMPORTOVAL, _in_valuta); + // Attiva campi relativi alla valuta + show(-3, _in_valuta); + // Il flag di saldo/acconto e' attivo solo se non ci sono acconti + bool sa = oldpag.get_int(PAGSCA_NRIGA) != TPartita::UNASSIGNED; + if (sa) + { + const TPartita& p = scad.partita(); + const int nrigp = oldpag.get_int(PAGSCA_NRIGP); + const TRiga_partite& sum = p.riga(nrigp); + const TDate datasca(parbas.get(PART_DATADOC)); + const TDate datapag(sum.get(PART_DATADOC)); + sa = datapag >= datasca; + } + enable(S_SALDOACC, sa); } void TPay_mask::get_pag(TRectype& newpag) const @@ -576,11 +679,11 @@ bool TPay_mask::importo_handler(TMask_field& f, KEY k) if (k == K_TAB && f.focusdirty()) { const real i(f.get()); - if (i >= m._da_pagare) + if (i >= m._da_pagare && m.field(S_SALDOACC).active()) m.set(S_SALDOACC, "S"); const real residuo(m._da_pagare - i); - m.set(S_RESIDUO, residuo.string()); + m.set(S_RESIDUORATA, residuo.string()); } return TRUE; @@ -629,17 +732,25 @@ bool TPrimanota_application::showpartite_handler(TMask_field& f, KEY k) bool TPrimanota_application::edit_partite(int riga) -{ +{ TToken_string& cgr = cgs().row(riga); + if (row_type(cgr) != 'K') + return FALSE; // Esci se non c'e' nessun importo + + TImporto imp; imp = cgr; + if (imp.is_zero()) // Esci se 'importo e' nullo + return FALSE; + const TBill b(cgr, 2, 0x3); // Legge il conto della riga selezionata - if (row_type(cgr) != 'K' || !b.ok()) + if (!b.ok()) return FALSE; // Esci se il conto della riga cliente non e' valido curr_mask().autosave(get_relation()); // Aggiorna i dati della testata sulle partite const TRectype& mov = get_relation()->curr(); partite().update_reg(mov); - TGame_mask mask(b); // Esecuzione maschera di selezione partite + // Esecuzione maschera di selezione partite + TGame_mask mask(b, mov.get_long(MOV_NUMREG), riga); mask.run(); cgs().force_update(); // Aggiornamento righe contabili @@ -649,8 +760,6 @@ bool TPrimanota_application::edit_partite(int riga) int TPrimanota_application::nuovo_pagamento(TPartita& partita, int nriga, int rata, int rmov) { - CHECKD(!partita.rata_pagata(nriga, rata), "Rata pagata ", rata); - TBill conto; partita.conto(conto); // Legge conto principale const long numreg = curr_mask().get_long(F_NUMREG); @@ -710,7 +819,8 @@ int TPrimanota_application::nuovo_pagamento(TPartita& partita, int nriga, int ra if (rata != TPartita::UNASSIGNED) { const TRiga_scadenze& scad = partita.rata(nriga, rata); - switch (scad.get_int(SCAD_TIPOPAG)) + const int tp = scad.get_int(SCAD_TIPOPAG); + switch (tp) { case 2: // Tratta case 7: // Tratta accettata @@ -729,6 +839,7 @@ int TPrimanota_application::nuovo_pagamento(TPartita& partita, int nriga, int ra default: caus = 2; break; } + pagamento.put(PAGSCA_TIPOPAG, tp); pagamento.put(PAGSCA_CODABIPR, scad.get(SCAD_CODABIPR)); pagamento.put(PAGSCA_CODCABPR, scad.get(SCAD_CODCABPR)); pagamento.put(PAGSCA_CODABI, scad.get(SCAD_CODABI)); @@ -813,7 +924,7 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa if (riga < 0) { TBill conto_rit; causale().bill(11, conto_rit); - set_cgs_row(riga, grow_ritenute, conto_rit, "", 'F'); + set_cgs_row(riga, grow_ritenute, conto_rit, causale().desc_agg(11), 'F'); } else { @@ -854,9 +965,10 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa { const riga_abb = type2pos(new_ap); if (riga_abb < 0) - { - TBill conto_abb; causale().bill(new_ap == 'A' ? 9 : 8, conto_abb); - app().set_cgs_row(riga_abb, new_abbuono, conto_abb, "", new_ap); + { + const int rc = new_ap == 'A' ? 9 : 8; + TBill conto_abb; causale().bill(rc, conto_abb); + app().set_cgs_row(riga_abb, new_abbuono, conto_abb, causale().desc_agg(rc), new_ap); } else add_cgs_imp(riga_abb, new_abbuono); @@ -878,7 +990,7 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa if (riga_diffcam < 0) { TBill conto_diffcam; causale().bill(12, conto_diffcam); - set_cgs_row(riga_diffcam, grow_diffcam, conto_diffcam, "", 'C'); + set_cgs_row(riga_diffcam, grow_diffcam, conto_diffcam, causale().desc_agg(12), 'C'); } else { @@ -926,21 +1038,22 @@ bool TPrimanota_application::edit_pagamento(TPartita& p, int nriga, int nrata, i { if (key == K_DEL) { - m.reset(S_IMPORTO); - m.reset(S_IMPORTOVAL); - m.reset(S_RITENUTE); + m.reset(S_SALDOACC); // Non puo' essere un saldo + m.reset(S_IMPORTO); // Azzera importo ... + m.reset(S_IMPORTOVAL); // .. anche in valuta + m.reset(S_RITENUTE); // Azzera ritenute } - else - { - somma.put(PART_DESCR, m.get(S_DESCAGG)); // Aggiorna descrizione (comune ai pagamenti) - } - - TRectype new_pag(oldpag); - m.get_pag(new_pag); - notify_edit_pagamento(p, new_pag); - } - - return key != K_ESC; +else +{ + somma.put(PART_DESCR, m.get(S_DESCAGG)); // Aggiorna descrizione (comune ai pagamenti) +} + +TRectype new_pag(oldpag); +m.get_pag(new_pag); +notify_edit_pagamento(p, new_pag); +} + +return key != K_ESC; } @@ -996,37 +1109,3 @@ bool TPrimanota_application::notify_cgline_deletion(int numrig) return found; } -bool TPrimanota_application::remove_unassigned() -{ - bool found = FALSE; - - const long nreg = curr_mask().get_long(F_NUMREG); - for (TPartita* game = partite().first(); game; game = partite().next()) - { - if (game->prima_fattura() > 0) - { - TRecord_array& unas = game->unassigned(); - for (int u = unas.last_row(); u > 0; u = unas.pred_row(u)) - { - const TRectype& pag = unas.row(u); - const int nrigp = pag.get_int(PAGSCA_NRIGP); - TRiga_partite& sum = game->riga(nrigp); - if (sum.get_long(PART_NREG) == nreg) - { - const int rmov = sum.get_int(PART_NUMRIG)-1; - const TImporto imp(sum.sezione(), pag.get_real(PAGSCA_IMPORTO)); - add_cgs_imp(rmov, imp); - - TRectype zero(pag); zero.zero(); - sum.update(pag, zero, PART_IMPORTO); - sum.update(pag, zero, PART_IMPORTOVAL); - sum.update(pag, zero, PART_RITENUTE); - unas.destroy_row(u); - found = TRUE; - } - } - } - } - - return found; -} diff --git a/cg/cg21cg.uml b/cg/cg21cg.uml index f49140884..7283b4a63 100755 --- a/cg/cg21cg.uml +++ b/cg/cg21cg.uml @@ -14,7 +14,7 @@ BEGIN INPUT CODTAB 108 DISPLAY "Codice" CODTAB DISPLAY "Descrizione@50" S0 - INPUT CODTAB 108 + INPUT CODTAB 108 OUTPUT 108 CODTAB OUTPUT 109 S0 CHECKTYPE NORMAL @@ -350,7 +350,9 @@ BEGIN ITEM "C|Gestione saldaconto" ITEM "D|IVA detraibile" ITEM "F|Ritenute fiscali" + ITEM "G|Spese" ITEM "I|Riga di IVA" + ITEM "L|Cassa" ITEM "K|Riga Cliente/Fornitore" ITEM "N|IVA non detraibile" ITEM "S|Ritenute sociali" diff --git a/cg/saldacon.cpp b/cg/saldacon.cpp index 5bfa1cbbf..41390ad79 100755 --- a/cg/saldacon.cpp +++ b/cg/saldacon.cpp @@ -1,7 +1,8 @@ +#include + #include "saldacon.h" #include -#include #include #include @@ -101,6 +102,82 @@ int TTree_rectype::remove(TBaseisamfile& f) return err; } +/////////////////////////////////////////////////////////// +// Valuta +/////////////////////////////////////////////////////////// + +TValuta::TValuta(const char* cod, const TDate& dat, const real& cam) +: _cod(cod), _dat(dat), _cam(cam) +{ + adjust(); +} + +TValuta::TValuta() : _cod(""), _dat(TODAY), _cam(1.0) +{} + +void TValuta::adjust() +{ + _cod.upper(); + if (_cod.empty() || _cod == "LIT") + _cam = 1.0; +} + +void TValuta::get(const TRectype& rec) +{ + _cod = rec.get("CODVAL"); + _dat = rec.get("DATACAM"); + _cam = rec.get_real("CAMBIO"); + adjust(); +} + +void TValuta::put(TRectype& rec) const +{ + rec.put("CODVAL", _cod); + rec.put("DATACAM", _dat); + rec.put("CAMBIO", _cam); +} + +void TValuta::set(TMask& m, short v, short d, short c) const +{ + m.set(v, _cod); + m.set(d, _dat.string()); + m.set(c, _cam.string(2)); +} + +void TValuta::get(const TMask& m, short v, short d, short c) +{ + _cod = m.get(v); + _dat = m.get(d); + _cam = real(m.get(c)); + adjust(); +} + +real TValuta::lit2val(const real& lit) const +{ + real val(lit); + val /= _cam; + val.round(2); + return val; +} + +real TValuta::val2lit(const real& val) const +{ + real lit(val); + lit *= _cam; + lit.round(); + return lit; +} + +void TValuta::val2lit(real& val) const +{ + val *= _cam; + val.round(); +} + +void TValuta::val2lit(TImporto& imp) const +{ + val2lit(imp.valore()); +} /////////////////////////////////////////////////////////// // TRiga_scadenze @@ -127,33 +204,51 @@ TPartita& TRiga_scadenze::partita() const // Controlla se la fattura della rata e' in valuta bool TRiga_scadenze::in_valuta() const { - return riga().get(PART_CODVAL).not_empty(); + return riga().in_valuta(); } // Controlla se la rata e' stata completamente pagata -int TRiga_scadenze::pagata() const +bool TRiga_scadenze::chiusa() const { - for (int p = last(); p > 0; p = pred(p)) - { - const TRectype& pag = row(p); - if (pag.get_char("ACCSAL") == 'S') - break; - } - return p; + TImporto imp(importo_da_pagare(TRUE)); + imp += importo_pagato(TRUE, 0x3); + return imp.is_zero(); } // Calcola il totale dei pagamenti (eventualmente in valuta) -TImporto TRiga_scadenze::importo_pagato(bool val) const -{ - const char* imp_field = val && in_valuta() ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO; +TImporto TRiga_scadenze::importo_pagato(bool val, int mode) const +{ + CHECKD(mode > 0 && mode < 8, "Bad importo_pagato mode ", mode); const TPartita& game = partita(); + const bool in_val = in_valuta(); + const char* imp_field = (val && in_val) ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO; + TImporto totale; for (int p = last(); p > 0; p = pred(p)) { const TRectype& pag = row(p); // Riga pagamento const TRiga_partite& sum = game.riga(p); // Riga partite - const TImporto imp(sum.sezione(), pag.get_real(imp_field)); - totale += imp; + const char sez = sum.sezione(); + + if (mode & 0x1) + totale += TImporto(sez, pag.get_real(imp_field)); + + if (mode & 0x2) // Voglio anche gli abbuoni + { + real abb(pag.get_real(PAGSCA_ABBUONI)); + if (!val && in_val) + { + abb *= sum.get_real(PART_CAMBIO); + abb.round(); + } + totale += TImporto(sez, abb); + } + + if (!val && (mode & 0x4)) // Voglio anche le differenze cambi + { + const TImporto diffcam(sez, pag.get_real(PAGSCA_DIFFCAM)); + totale += diffcam; + } } return totale; @@ -162,22 +257,31 @@ TImporto TRiga_scadenze::importo_pagato(bool val) const // Calcola l'importo da pagare (eventualmente in valuta) TImporto TRiga_scadenze::importo_da_pagare(bool val) const { - const char* imp_field = val && in_valuta() ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO; + const char* imp_field = (val && in_valuta()) ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO; const TRiga_partite& r = riga(); // Riga fattura const TImporto totale(r.sezione(), get_real(imp_field)); return totale; } -// Calcola l'abbuono della rata e ritorna il suo tipo: +// Calcola l'abbuono in valuta della rata e ritorna il suo tipo: // 'A' abbuono attivo; 'P' abbuono passivo // La sezione dell'abbuono calcolato e' quella della riga contabile in cui finira' -char TRiga_scadenze::calcola_abbuono(TImporto& abbuono, bool val) const +char TRiga_scadenze::calcola_abbuono(int p, TImporto& abbuono) const { bool ap = ' '; - if (pagata()) + + const TRectype& pag = row(p); + if (pag.get_char(PAGSCA_ACCSAL) == 'S') { abbuono = importo_da_pagare(TRUE); abbuono += importo_pagato(TRUE); + + for (int r = last(); r > 0; r = pred(r)) if (r != p) + { + const TRiga_partite& sum = partita().riga(r); // Riga partite + const TImporto imp(sum.sezione(), row(r).get_real(PAGSCA_ABBUONI)); + abbuono += imp; + } const int sign = abbuono.valore().sign(); if (sign != 0) @@ -187,12 +291,6 @@ char TRiga_scadenze::calcola_abbuono(TImporto& abbuono, bool val) const else ap = abbuono.sezione() == 'D' ? 'A' : 'P'; } - - if (val && in_valuta()) - { - abbuono.valore() *= riga().get_real(PART_CAMBIO); - abbuono.valore().round(); - } } else abbuono.valore() = ZERO; @@ -201,60 +299,40 @@ char TRiga_scadenze::calcola_abbuono(TImporto& abbuono, bool val) const } // Calcola la differenza cambi con la sezione da mettere nella riga contabile corrispondente -TImporto TRiga_scadenze::calcola_differenza_cambio(bool update) +TImporto TRiga_scadenze::calcola_differenza_cambio(int p, bool update) { TImporto diffcam; if (in_valuta()) { - const int riga_saldo = pagata(); - if (riga_saldo > 0) + TRectype& pag = row(p); + const char sez = partita().riga(p).sezione(); + + if (update) { - TRectype& pag = row(riga_saldo); - const TRiga_partite& sum = partita().riga(riga_saldo); - const char sez = sum.sezione(); - - if (update) - { - diffcam = importo_da_pagare(FALSE); - diffcam += importo_pagato(FALSE); - - real a = pag.get_real(PAGSCA_ABBUONI); - if (in_valuta()) - { - a *= riga().get_real(PART_CAMBIO); - a.round(); - } - - const TImporto abb_lit(sez, a); - diffcam += abb_lit; - diffcam.normalize(sez); - pag.put(PAGSCA_DIFFCAM, diffcam.valore()); - } - else - { - diffcam.set(sez, pag.get_real(PAGSCA_DIFFCAM)); - } - } + diffcam = importo_da_pagare(FALSE); + diffcam += importo_pagato(FALSE, 0x3); // Conta anche gli abbuoni + diffcam.normalize(sez); + pag.put(PAGSCA_DIFFCAM, diffcam.valore()); + } else - if (update) - { - for (int p = last(); p > 0; p = pred(p)) - { - TRectype& pag = row(p); - pag.zero(PAGSCA_DIFFCAM); - } - } - } - + { + diffcam.set(sez, pag.get_real(PAGSCA_DIFFCAM)); + } + } + else + { + if (update) + row(p).zero(PAGSCA_DIFFCAM); + } return diffcam; } -real TRiga_scadenze::residuo(bool val) const +TImporto TRiga_scadenze::residuo(bool val, int mode) const { TImporto residuo(importo_da_pagare(val)); - residuo += importo_pagato(val); // Somma con sezione opposta - return residuo.valore(); + residuo += importo_pagato(val, mode); // Somma con sezione opposta + return residuo; } @@ -267,31 +345,27 @@ bool TRiga_scadenze::modifica_pagamento(const TRectype& new_pag, TRiga_partite& sum = partita().riga(nrigp); TImporto old_abbuono; - old_ap = calcola_abbuono(old_abbuono, TRUE); // Vecchio abbuono in valuta + old_ap = calcola_abbuono(nrigp, old_abbuono); // Vecchio abbuono in valuta old_abb = old_abbuono; // Vecchio abbuono in lire if (in_valuta()) { - old_abb.valore() *= riga().get_real(PART_CAMBIO); + old_abb.valore() *= sum.get_real(PART_CAMBIO); old_abb.valore().round(); } - old_diffcam = calcola_differenza_cambio(FALSE); - - const char* imp_field = in_valuta() ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO; - const real importo(new_pag.get(imp_field)); - const bool empty = importo.is_zero(); - if (empty) - rows_array().destroy_row(nrigp); - else - row(nrigp) = new_pag; + old_diffcam = calcola_differenza_cambio(nrigp, FALSE); + + row(nrigp) = new_pag; + row(nrigp).zero(PAGSCA_ABBUONI); // Azzera abbuoni per ricalcolo + row(nrigp).zero(PAGSCA_DIFFCAM); // Azzera differenza cambio per ricalcolo TImporto new_abbuono; - new_ap = calcola_abbuono(new_abbuono, TRUE); // Calcolo abbuono in valuta + new_ap = calcola_abbuono(nrigp, new_abbuono); // Calcolo abbuono in valuta - new_abb = new_abbuono; // Calcola nuovo abbuono in lire + new_abb = new_abbuono; // Calcola nuovo abbuono in lire if (in_valuta()) { - new_abb.valore() *= riga().get_real(PART_CAMBIO); + new_abb.valore() *= sum.get_real(PART_CAMBIO); new_abb.valore().round(); } @@ -300,14 +374,13 @@ bool TRiga_scadenze::modifica_pagamento(const TRectype& new_pag, new_abbuono.swap_section(); new_abbuono.normalize(sum.sezione()); if (new_ap != ' ') - { - CHECK(nrigp == pagata(), "Aggiornamento abbuoni inconsistente"); - TRectype& pag = row(nrigp); - pag.put(PAGSCA_ABBUONI, new_abbuono.valore()); - } + row(nrigp).put(PAGSCA_ABBUONI, new_abbuono.valore()); + else + row(nrigp).zero(PAGSCA_ABBUONI); + sum.update(old_abbuono, new_abbuono, PART_SEZABB, PART_ABBUONI); - new_diffcam = calcola_differenza_cambio(TRUE); + new_diffcam = calcola_differenza_cambio(nrigp, TRUE); // Memorizza differenza cambi invertita, mettendo new_diffcam prima di old_diffcam! sum.update(new_diffcam, old_diffcam, PART_SEZDIFCAM, PART_DIFFCAM); @@ -317,6 +390,12 @@ bool TRiga_scadenze::modifica_pagamento(const TRectype& new_pag, partita().chiusa(TRUE); // Aggiorna flag di chiusura + const bool empty = new_pag.get(PAGSCA_IMPORTO).empty() || + new_pag.get(PAGSCA_ABBUONI).empty() || + new_pag.get(PAGSCA_DIFFCAM).empty(); + if (empty) + rows_array().destroy_row(nrigp); + return empty; } @@ -497,13 +576,13 @@ TRiga_scadenze& TPartita::rata(int nriga, int nrata) const return r.rata(nrata); } -int TPartita::rata_pagata(int nriga, int nrata) const +bool TPartita::rata_chiusa(int nriga, int nrata) const { - int pag = 0; + bool pag = FALSE; if (nriga != UNASSIGNED) { const TRiga_scadenze& r = rata(nriga, nrata); - pag = r.pagata(); + pag = r.chiusa(); } return pag; } @@ -534,6 +613,7 @@ bool TPartita::esiste(int nriga, int nrata, int nrigp) const return r.rows_array().exist(nrigp); } +// Ritorna l'importo in lire speso su di una riga contabile TImporto TPartita::importo_speso(long nreg, int numrig, bool extra) const { TImporto imp; @@ -547,13 +627,12 @@ TImporto TPartita::importo_speso(long nreg, int numrig, bool extra) const const int num = part.get_int(PART_NUMRIG); if (num == numrig) { - const char sez = part.get_char(PART_SEZ); // Deve essere valida per forza! - imp += TImporto(sez, part.get_real(PART_IMPORTO)); + imp += TImporto(part.sezione(), part.get_real(PART_IMPORTO)); if (extra) { TImporto abbuoni(part.get_char(PART_SEZABB), part.get_real(PART_ABBUONI)); - if (part.in_valuta()) // Se e' in valuta + if (part.in_valuta()) { abbuoni.valore() *= part.get_real(PART_CAMBIO); abbuoni.valore().round(); @@ -584,9 +663,6 @@ void TPartita::update_reg(long nreg, const TRectype& mov) pag.put(PART_REG, mov.get(MOV_REG)); pag.put(PART_PROTIVA, mov.get(MOV_PROTIVA)); pag.put(PART_CODCAUS, mov.get(MOV_CODCAUS)); - pag.put(PART_CODVAL, mov.get(MOV_CODVAL)); - pag.put(PART_CAMBIO, mov.get(MOV_CAMBIO)); - pag.put(PART_DATACAM, mov.get(MOV_DATACAM)); } } } @@ -744,25 +820,19 @@ bool TPartita::modifica_pagamento(const TRectype& new_pag, bool TPartita::chiusa(bool update) { bool chiusa = FALSE; - const int ultima = last(); - if (ultima > 0) - { - const TRiga_partite& row = riga(ultima); - chiusa = row.get_bool(PART_CHIUSA); - } if (update) { bool forse_chiusa = TRUE; for (int p = last(); p > 0 && forse_chiusa; p = pred(p)) { - const TRiga_partite& part = riga(first()); + const TRiga_partite& part = riga(p); if (part.get_int(PART_TIPOMOV) == 1) { for (int r = part.last(); r > 0; r--) { const TRiga_scadenze& scad = part.rata(r); - if (!scad.pagata()) + if (!scad.chiusa()) { forse_chiusa = FALSE; break; @@ -781,6 +851,15 @@ bool TPartita::chiusa(bool update) } } } + else + { + const int ultima = last(); + if (ultima > 0) + { + const TRiga_partite& row = riga(ultima); + chiusa = row.get_bool(PART_CHIUSA); + } + } return chiusa; } diff --git a/cg/saldacon.h b/cg/saldacon.h index 4445f0aeb..f98071aa0 100755 --- a/cg/saldacon.h +++ b/cg/saldacon.h @@ -9,6 +9,10 @@ #include #endif +#ifndef __MASK_H +class TMask; +#endif + #ifndef __CONTO_H #include "conto.h" #endif @@ -55,6 +59,46 @@ public: }; +/////////////////////////////////////////////////////////// +// Valuta +/////////////////////////////////////////////////////////// + +class TValuta : public TObject +{ + TString16 _cod; + TDate _dat; + real _cam; + +protected: + void adjust(); // Controlla il cambio per le lire + +public: + const TString& codice() const { return _cod; } + const TDate& data() const { return _dat; } + const real& cambio() const { return _cam; } + + real lit2val(const real& lit) const; + real val2lit(const real& val) const; + void val2lit(real& val) const; + void val2lit(TImporto& imp) const; + + void get(const TRectype& rec); + void put(TRectype& rec) const; + + void set(TMask& m, short v, short d, short c) const; + void get(const TMask& m, short v, short d, short c); + + TValuta(); + TValuta(const char* cod, const TDate& dat, const real& cam); + virtual ~TValuta() {} +}; + + + +/////////////////////////////////////////////////////////// +// Riga scadenza +/////////////////////////////////////////////////////////// + class TRiga_scadenze : public TTree_rectype { friend class TPartita; @@ -63,8 +107,8 @@ class TRiga_scadenze : public TTree_rectype TRiga_partite* _riga; protected: - char calcola_abbuono(TImporto& abbuono, bool val) const; - TImporto calcola_differenza_cambio(bool update); + char calcola_abbuono(int p, TImporto& abbuono) const; + TImporto calcola_differenza_cambio(int p, bool update); bool modifica_pagamento(const TRectype& new_pag, char& old_ap, TImporto& old_abb, TImporto& old_diffcam, @@ -74,16 +118,16 @@ protected: // TRecord_tree virtual TObject* dup() const { return new TRiga_scadenze(*this); } public: - int pagata() const; // Riga che chiude la rata o 0 se non pagata completamente + bool chiusa() const; bool in_valuta() const; TPartita& partita() const; TRiga_partite& riga() const { return *_riga; } // Riga partite - TImporto importo_pagato(bool val) const; + TImporto importo_pagato(bool val, int mode = 0x1) const; TImporto importo_da_pagare(bool val) const; - real residuo(bool val) const; // Differenza delle due funzioni precedenti + TImporto residuo(bool val, int mode = 0x1) const; // Differenza delle due funzioni precedenti TRiga_scadenze(TRiga_partite* riga); TRiga_scadenze(const TRiga_scadenze& s); @@ -136,7 +180,7 @@ public: void rimuovi_riga(int r) { _part.destroy_row(r); } TRiga_scadenze& rata(int nriga, int nrata) const; TRectype& pagamento(int nriga, int nrata, int nrigp); - int rata_pagata(int nriga, int nrata) const; + bool rata_chiusa(int nriga, int nrata) const; bool esiste(int nriga, int nrata = 0, int nrigp = 0) const; int succ(int r) const { return _part.succ_row(r); }