Gestione saldconto in valuta

git-svn-id: svn://10.65.10.50/trunk@1798 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-09-08 10:57:44 +00:00
parent ddad33ee19
commit dc6ee6cd72
13 changed files with 758 additions and 426 deletions

View File

@ -28,9 +28,9 @@ TMask* TPrimanota_application::load_mask(int n)
if (_msk[n] != NULL) if (_msk[n] != NULL)
return _msk[n]; 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) if (_msk[d] != NULL)
{ {
delete _msk[d]; 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_PROTIVA, protiva_handler);
m->set_handler(F_CLIENTE, clifo_handler); m->set_handler(F_CLIENTE, clifo_handler);
m->set_handler(F_FORNITORE, 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_RITFIS, ritfis_handler);
m->set_handler(F_RITSOC, ritsoc_handler); m->set_handler(F_RITSOC, ritsoc_handler);
m->set_handler(F_CORRLIRE, corrlire_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_DATACOMP, datacomp_handler);
m->set_handler(F_DESCR, descr_handler); m->set_handler(F_DESCR, descr_handler);
m->set_handler(F_CODCAUS, caus_modify_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); m->set_handler(F_SHEETCG, cg_handler);
TSheet_field& cg = (TSheet_field&)m->field(F_SHEETCG); TSheet_field& cg = (TSheet_field&)m->field(F_SHEETCG);
cg.set_notify(cg_notify); cg.set_notify(cg_notify);
TMask& cgm = cg.sheet_mask(); 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(101, dareavere_handler);
cgm.set_handler(102, dareavere_handler); cgm.set_handler(102, dareavere_handler);
cgm.set_handler(105, cg_conto_handler); cgm.set_handler(105, cg_conto_handler);
@ -311,12 +307,12 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
{ {
char tipr = ' '; char tipr = ' ';
if (_is_saldaconto) if (_is_saldaconto)
{ {
if (nriga < 13 && nriga != 10) continue; // Si considerano solo le spese if (nriga < 13 && nriga != 10 && nriga != 2) continue; // Si considerano solo le spese
tipr = 'G'; tipr = (nriga == 2) ? 'L' : 'G';
} }
const int pos = set_cgs_row(-1, zero, tc, desc, tipr); const int pos = set_cgs_row(-1, zero, tc, desc, tipr);
if (sezione > ' ' && tipr != ' ') if (sezione > ' ')
cgs().disable_cell(pos, sezione == 'A' ? 0 : 1); cgs().disable_cell(pos, sezione == 'A' ? 0 : 1);
} }
else else
@ -564,7 +560,6 @@ void TPrimanota_application::init_modify_mode(TMask& m)
{ {
const long numreg = m.get_long(F_NUMREG); const long numreg = m.get_long(F_NUMREG);
partite().add_numreg(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 // o quello delle ritenute sociali (ritsoc=TRUE) e' invertito rispetto al normale
bool TPrimanota_application::test_swap(bool ritsoc) bool TPrimanota_application::test_swap(bool ritsoc)
{ {
bool s = FALSE;
const char sez = ritsoc ? causale().sezione_ritsoc() : causale().sezione_clifo(); 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; return s;
} }
@ -600,11 +593,6 @@ int TPrimanota_application::read(TMask& m)
error_box("Registrazione di vendita attribuita ad un fornitore"); 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.reset(); // Azzera saldi
_saldi.set_movprovv(_rel->lfile().get_char("PROVVIS") > ' '); _saldi.set_movprovv(_rel->lfile().get_char("PROVVIS") > ' ');
_saldi.set_movap(causale().apertura()); _saldi.set_movap(causale().apertura());

View File

@ -102,12 +102,11 @@
#define I_SOTTOCONTO4 234 #define I_SOTTOCONTO4 234
// Saldaconto // Saldaconto
#define S_TOTDOC 301 #define S_TOTDOCVAL 301
#define S_TOTDOCVAL 302 #define S_VALUTA 302
#define S_VALUTA 303 #define S_DATACAMBIO 303
#define S_DATACAMBIO 304 #define S_CAMBIO 304
#define S_CAMBIO 305 #define S_TIPORIGA 305
#define S_TIPORIGA 306
// copie 2a pag. // copie 2a pag.
#define K_CODDITTA 401 #define K_CODDITTA 401

View File

@ -120,7 +120,7 @@ END
NUMBER F_TIPOMOV 1 NUMBER F_TIPOMOV 1
BEGIN BEGIN
PROMPT 32 6 "Tipo movimento " PROMPT 32 6 "Tipo movimento "
FIELD LF_MOV->TIPOMOV FIELD TIPOMOV
FLAGS "H" FLAGS "H"
END END
@ -174,51 +174,34 @@ BEGIN
COPY OUTPUT F_DESCAGG COPY OUTPUT F_DESCAGG
END END
GROUPBOX DLG_NULL 78 8 GROUPBOX DLG_NULL 78 5
BEGIN BEGIN
PROMPT 1 10 "Voci per saldaconto" PROMPT 1 10 "Voci per saldaconto"
END 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 STRING S_VALUTA 3
BEGIN BEGIN
PROMPT 2 13 "Valuta " PROMPT 2 11 "Valuta "
HELP "Codice della valuta per movimento" HELP "Codice della valuta per movimento"
FIELD LF_MOV->CODVAL FIELD CODVAL
FLAGS "U" FLAGS "UZ"
GROUP 3 GROUP 3
USE %VAL USE %VAL
INPUT CODTAB S_VALUTA INPUT CODTAB S_VALUTA
DISPLAY "Codice" CODTAB DISPLAY "Codice" CODTAB
DISPLAY "Nome@50" S0 DISPLAY "Nome@50" S0
DISPLAY "Ultimo cambio@15" R10
DISPLAY "Ultimo aggiornamento" D0
OUTPUT S_VALUTA CODTAB OUTPUT S_VALUTA CODTAB
OUTPUT S_CAMBIO R10
CHECKTYPE NORMAL CHECKTYPE NORMAL
MESSAGE EMPTY CLEAR,S_CAMBIO
MESSAGE ENABLE,S_CAMBIO
END END
DATE S_DATACAMBIO DATE S_DATACAMBIO
BEGIN BEGIN
PROMPT 22 13 "Data cambio " PROMPT 22 11 "Data cambio "
FIELD DATACAM
FLAGS "R" FLAGS "R"
USE CAM USE CAM SELECT CODTAB[1,3]==#S_VALUTA
INPUT CODTAB[1,3] S_VALUTA INPUT CODTAB[1,3] S_VALUTA
INPUT CODTAB[4,11] S_DATACAMBIO INPUT CODTAB[4,11] S_DATACAMBIO
DISPLAY "Valuta" CODTAB[1,3] DISPLAY "Valuta" CODTAB[1,3]
@ -228,16 +211,37 @@ BEGIN
OUTPUT S_DATACAMBIO D0 OUTPUT S_DATACAMBIO D0
OUTPUT S_CAMBIO R10 OUTPUT S_CAMBIO R10
GROUP 3 GROUP 3
CHECKTYPE NORMAL
END END
NUMBER S_CAMBIO 15 5 NUMBER S_CAMBIO 15 5
BEGIN BEGIN
PROMPT 54 13 "Cambio " PROMPT 54 11 "Cambio "
HELP "Cambio della valuta" HELP "Cambio della valuta"
FIELD LF_MOV->CAMBIO FIELD CAMBIO
FLAGS "RU" FLAGS "RU"
GROUP 3 GROUP 3
PICTURE ".5" 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 END
ENDPAGE ENDPAGE

View File

@ -53,7 +53,7 @@ DATE F_DATAREG
BEGIN BEGIN
PROMPT 1 3 "Data operazione " PROMPT 1 3 "Data operazione "
HELP "Data in cui viene registrata l'operazione" HELP "Data in cui viene registrata l'operazione"
FIELD LF_MOV->DATAREG FIELD DATAREG
MESSAGE COPY,H_DATAREG|COPY,F_ANNOIVA,7,10 MESSAGE COPY,H_DATAREG|COPY,F_ANNOIVA,7,10
CHECKTYPE REQUIRED CHECKTYPE REQUIRED
END END
@ -61,7 +61,7 @@ END
NUMBER F_ANNOIVA 4 NUMBER F_ANNOIVA 4
BEGIN BEGIN
PROMPT 32 3 "Anno IVA " PROMPT 32 3 "Anno IVA "
FIELD LF_MOV->ANNOIVA FIELD ANNOIVA
FLAGS "D" FLAGS "D"
END END
@ -69,14 +69,14 @@ DATE F_DATACOMP
BEGIN BEGIN
PROMPT 1 4 "Data competenza " PROMPT 1 4 "Data competenza "
HELP "Data di competenza dell'operazione" HELP "Data di competenza dell'operazione"
FIELD LF_MOV->DATACOMP FIELD DATACOMP
CHECKTYPE REQUIRED CHECKTYPE REQUIRED
END END
NUMBER F_ANNOES 4 NUMBER F_ANNOES 4
BEGIN BEGIN
PROMPT 32 4 "Anno esercizio " PROMPT 32 4 "Anno esercizio "
FIELD LF_MOV->ANNOES FIELD ANNOES
FLAGS "DGZ" FLAGS "DGZ"
MESSAGE COPY,H_ANNOES MESSAGE COPY,H_ANNOES
END END
@ -85,7 +85,7 @@ STRING F_CODREG 3
BEGIN BEGIN
PROMPT 57 4 "Registro IVA " PROMPT 57 4 "Registro IVA "
FLAGS "DGUZ" FLAGS "DGUZ"
FIELD LF_MOV->REG FIELD REG
END END
STRING F_CODCAUS 3 STRING F_CODCAUS 3
@ -93,7 +93,7 @@ BEGIN
PROMPT 1 5 "Causale " PROMPT 1 5 "Causale "
HELP "Codice della causale generante l'operazione" HELP "Codice della causale generante l'operazione"
FLAGS "UZ" FLAGS "UZ"
FIELD LF_MOV->CODCAUS FIELD CODCAUS
USE LF_CAUSALI SELECT REG!="" USE LF_CAUSALI SELECT REG!=""
INPUT CODCAUS F_CODCAUS INPUT CODCAUS F_CODCAUS
DISPLAY "Codice" CODCAUS DISPLAY "Codice" CODCAUS
@ -129,7 +129,7 @@ END
DATE F_DATADOC DATE F_DATADOC
BEGIN BEGIN
PROMPT 1 6 "Data documento " PROMPT 1 6 "Data documento "
FIELD LF_MOV->DATADOC FIELD DATADOC
HELP "Data del documento che ha generato il movimento" HELP "Data del documento che ha generato il movimento"
WARNING "Inserire una data documento non superiore alla data dell'operazione" WARNING "Inserire una data documento non superiore alla data dell'operazione"
VALIDATE DATE_CMP_FUNC <= F_DATAREG VALIDATE DATE_CMP_FUNC <= F_DATAREG
@ -138,14 +138,14 @@ END
STRING F_TIPODOC 2 STRING F_TIPODOC 2
BEGIN BEGIN
PROMPT 32 6 "Tipo documento " PROMPT 32 6 "Tipo documento "
FIELD LF_MOV->TIPODOC FIELD TIPODOC
FLAGS "D" FLAGS "D"
END END
NUMBER F_TIPOMOV 1 NUMBER F_TIPOMOV 1
BEGIN BEGIN
PROMPT 32 6 "Tipo movimento " PROMPT 32 6 "Tipo movimento "
FIELD LF_MOV->TIPOMOV FIELD TIPOMOV
FLAGS "H" FLAGS "H"
END END
@ -153,7 +153,7 @@ STRING F_NUMDOC 7
BEGIN BEGIN
PROMPT 57 6 "Documento n. " PROMPT 57 6 "Documento n. "
HELP "Numero del documento che ha generato il movimento" 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" WARNING "La causale o il saldaconto richiedono il numero documento"
END END
@ -193,7 +193,7 @@ STRING F_DESCR 50
BEGIN BEGIN
PROMPT 25 8 "" PROMPT 25 8 ""
HELP "Descrizione del movimento" HELP "Descrizione del movimento"
FIELD LF_MOV->DESCR FIELD DESCR
USE %DPN KEY 2 USE %DPN KEY 2
INPUT S0 F_DESCR INPUT S0 F_DESCR
DISPLAY "Descrizione@50" S0 DISPLAY "Descrizione@50" S0
@ -205,14 +205,14 @@ NUMBER F_PROTIVA 5
BEGIN BEGIN
PROMPT 1 9 "Protocollo IVA " PROMPT 1 9 "Protocollo IVA "
HELP "Numero progressivo di protocollo IVA" HELP "Numero progressivo di protocollo IVA"
FIELD LF_MOV->PROTIVA FIELD PROTIVA
END END
NUMBER F_RIEPILOGO 5 NUMBER F_RIEPILOGO 5
BEGIN BEGIN
PROMPT 25 9 "Riepilogo fino al n. " PROMPT 25 9 "Riepilogo fino al n. "
HELP "Numero finale del documento ripilogativo di protocollo IVA" HELP "Numero finale del documento ripilogativo di protocollo IVA"
FIELD LF_MOV->UPROTIVA FIELD UPROTIVA
NUM_EXPR {(#F_RIEPILOGO==0)||(#F_RIEPILOGO>=#F_PROTIVA)} 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)" WARNING "Inserire un riepilogo non inferiore al protocollo IVA (Obbigatorio se il cliete/fornitore ha codice inserimento in allegati uguale a 3)"
END END
@ -245,7 +245,7 @@ BEGIN
PROMPT 1 10 "Cliente " PROMPT 1 10 "Cliente "
HELP "Codice del cliente" HELP "Codice del cliente"
FLAGS "R" FLAGS "R"
FIELD LF_MOV->CODCF FIELD CODCF
GROUP 1 GROUP 1
USE LF_CLIFO KEY 1 USE LF_CLIFO KEY 1
INPUT TIPOCF "C" INPUT TIPOCF "C"
@ -271,7 +271,7 @@ BEGIN
PROMPT 1 10 "Fornitore " PROMPT 1 10 "Fornitore "
FLAGS "R" FLAGS "R"
HELP "Codice del fornitore" HELP "Codice del fornitore"
FIELD LF_MOV->CODCF FIELD CODCF
GROUP 2 GROUP 2
USE LF_CLIFO KEY 1 USE LF_CLIFO KEY 1
INPUT TIPOCF "F" INPUT TIPOCF "F"
@ -417,43 +417,70 @@ STRING S_VALUTA 3
BEGIN BEGIN
PROMPT 1 12 "Valuta " PROMPT 1 12 "Valuta "
HELP "Codice della valuta per operazione con l'estero" HELP "Codice della valuta per operazione con l'estero"
FIELD LF_MOV->CODVAL FIELD CODVAL
FLAGS "UZ" FLAGS "UZ"
GROUP 3 GROUP 3
USE %VAL USE %VAL
INPUT CODTAB S_VALUTA INPUT CODTAB S_VALUTA
DISPLAY "Codice" CODTAB DISPLAY "Codice" CODTAB
DISPLAY "Nome@50" S0 DISPLAY "Nome@50" S0
DISPLAY "Cambio@15" R10
DISPLAY "Ultimo aggiornamento" D0
OUTPUT S_VALUTA CODTAB OUTPUT S_VALUTA CODTAB
OUTPUT S_CAMBIO R10
CHECKTYPE NORMAL CHECKTYPE NORMAL
WARNING "Codice valuta assente" 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 END
NUMBER S_CAMBIO 12 5 NUMBER S_CAMBIO 12 5
BEGIN BEGIN
PROMPT 20 12 "Cambio " PROMPT 58 12 "Cambio "
HELP "Cambio della valuta per operazione con l'estero" HELP "Cambio della valuta per operazione con l'estero"
FIELD LF_MOV->CAMBIO FIELD CAMBIO
FLAGS "RU" FLAGS "RU"
GROUP 3 GROUP 3
PICTURE ".5" PICTURE ".5"
CHECKTYPE REQUIRED
END END
NUMBER F_TOTALE 15 NUMBER F_TOTALE 15
BEGIN BEGIN
PROMPT 1 13 "Totale documento " PROMPT 1 13 "Totale documento "
HELP "Totale del documento generante il movimento" HELP "Totale del documento generante il movimento"
FIELD TOTDOC FIELD TOTDOC
FLAGS "RV"
PICTURE "." PICTURE "."
END 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 STRING F_CODIVA 4
BEGIN BEGIN
PROMPT 60 13 "Codice IVA " PROMPT 67 13 "IVA "
HELP "Codice IVA del documento generante il movimento" HELP "Codice IVA del documento generante il movimento"
FLAGS "U" FLAGS "U"
USE %IVA USE %IVA
@ -470,7 +497,7 @@ END
NUMBER F_RITFIS 15 NUMBER F_RITFIS 15
BEGIN BEGIN
PROMPT 1 14 "Ritenute fiscali " PROMPT 1 14 "Ritenute fiscali "
HELP "Ritenute fiscali del documento generante il movimento" HELP "Ritenute fiscali del documento generante il movimento"
FIELD RITFIS FIELD RITFIS
FLAGS "RV" FLAGS "RV"
@ -479,9 +506,9 @@ END
NUMBER F_RITSOC 15 NUMBER F_RITSOC 15
BEGIN BEGIN
PROMPT 1 15 "Ritenute sociali " PROMPT 1 15 "Ritenute sociali "
HELP "Ritenute fiscali del documento generante il movimento" HELP "Ritenute fiscali del documento generante il movimento"
FIELD LF_MOV->RITSOC FIELD RITSOC
FLAGS "RV" FLAGS "RV"
PICTURE "." PICTURE "."
END END
@ -512,7 +539,7 @@ END
STRING F_VALUTAINTRA 3 STRING F_VALUTAINTRA 3
BEGIN BEGIN
PROMPT 1 17 "Valuta intracom. " PROMPT 1 17 "Valuta intracom. "
HELP "Codice della valuta per operazione intracomunitaria" HELP "Codice della valuta per operazione intracomunitaria"
FIELD CODVALI FIELD CODVALI
FLAGS "UZ" FLAGS "UZ"
@ -542,9 +569,9 @@ END
NUMBER F_CORRLIRE 15 NUMBER F_CORRLIRE 15
BEGIN 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" 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" FLAGS "R"
PICTURE "." PICTURE "."
GROUP 4 GROUP 4
@ -554,7 +581,7 @@ NUMBER F_CORRVALUTA 15 2
BEGIN BEGIN
PROMPT 37 18 "Corrispettivo valuta " PROMPT 37 18 "Corrispettivo valuta "
HELP "Corrispettivo in valuta per operazioni intracomunitarie" HELP "Corrispettivo in valuta per operazioni intracomunitarie"
FIELD LF_MOV->CORRVALUTA FIELD CORRVALUTA
FLAGS "R" FLAGS "R"
PICTURE ".2" PICTURE ".2"
GROUP 4 GROUP 4

View File

@ -6,6 +6,9 @@
#define P_RESIDUO 106 #define P_RESIDUO 106
#define P_ANNO 107 #define P_ANNO 107
#define P_NUMERO 108 #define P_NUMERO 108
#define P_VALUTA 109
#define P_DATACAMBIO 110
#define P_CAMBIO 111
#define P_SHOWALL 180 #define P_SHOWALL 180
#define P_SCAMBIO 181 #define P_SCAMBIO 181
#define P_NUOVO 182 #define P_NUOVO 182
@ -31,7 +34,7 @@
#define S_RITENUTE 114 #define S_RITENUTE 114
#define S_IMPORTOVAL 115 #define S_IMPORTOVAL 115
#define S_SALDOACC 116 #define S_SALDOACC 116
#define S_RESIDUO 117 #define S_RESIDUORATA 117
#define S_DATAPAG 118 #define S_DATAPAG 118
#define S_CODPAG 119 #define S_CODPAG 119
#define S_TIPOPAG 120 #define S_TIPOPAG 120
@ -51,3 +54,4 @@
#define S_DESCNSABI 134 #define S_DESCNSABI 134
#define S_DESPAG 135 #define S_DESPAG 135
#define S_CODDESC 136 #define S_CODDESC 136
#define S_RESIDUOPAG 137

View File

@ -20,7 +20,7 @@ PAGE "PARTITE" -1 -1 77 20
LIST P_TIPOC 1 12 LIST P_TIPOC 1 12
BEGIN BEGIN
PROMPT 1 1 "Tipo conto " PROMPT 1 0 "Tipo conto "
ITEM " |Conto" ITEM " |Conto"
ITEM "C|Cliente" ITEM "C|Cliente"
ITEM "F|Fornitore" ITEM "F|Fornitore"
@ -29,49 +29,82 @@ END
NUMBER P_GRUPPO 3 NUMBER P_GRUPPO 3
BEGIN BEGIN
PROMPT 26 1 "Gruppo " PROMPT 26 0 "Gruppo "
FLAGS "D" FLAGS "D"
END END
NUMBER P_CONTO 3 NUMBER P_CONTO 3
BEGIN BEGIN
PROMPT 40 1 "Conto " PROMPT 40 0 "Conto "
FLAGS "D" FLAGS "D"
END END
NUMBER P_SOTTOCONTO 6 NUMBER P_SOTTOCONTO 6
BEGIN BEGIN
PROMPT 54 1 "Sottoconto " PROMPT 54 0 "Sottoconto "
FLAGS "D" FLAGS "D"
END END
STRING P_DESCR 50 STRING P_DESCR 50 58
BEGIN BEGIN
PROMPT 1 2 "Descrizione " PROMPT 1 1 "Descrizione "
FLAGS "D" FLAGS "D"
END END
NUMBER P_RESIDUO 15 STRING P_VALUTA 3
BEGIN BEGIN
PROMPT 1 3 "Residuo " PROMPT 1 2 "Valuta "
FLAGS "D" HELP "Codice della valuta per movimento"
PICTURE "." 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 END
NUMBER P_ANNO 4 NUMBER P_ANNO 4
BEGIN BEGIN
PROMPT 1 4 "Anno " PROMPT 1 3 "Anno "
FLAGS "A" FLAGS "A"
END END
STRING P_NUMERO 7 STRING P_NUMERO 7
BEGIN BEGIN
PROMPT 26 4 "Numero " PROMPT 21 3 "Numero "
END END
SPREADSHEET P_PARTITE 0 6 NUMBER P_RESIDUO 15
BEGIN BEGIN
PROMPT 0 5 "" PROMPT 48 3 "Residuo "
FLAGS "D"
PICTURE "."
END
SPREADSHEET P_PARTITE 0 7
BEGIN
PROMPT 0 4 ""
ITEM "Anno" ITEM "Anno"
ITEM "Partita@7" ITEM "Partita@7"
ITEM "Data doc.@10" ITEM "Data doc.@10"
@ -231,15 +264,16 @@ BEGIN
PROMPT 1 6 "Descrizione " PROMPT 1 6 "Descrizione "
END END
NUMBER 107 12 STRING 107 14
BEGIN BEGIN
PROMPT 1 7 "Importo Lire " PROMPT 1 7 "Importo Lire "
FLAGS "R"
END END
NUMBER 108 12 2 STRING 108 14
BEGIN BEGIN
PROMPT 30 7 "Importo Valuta " PROMPT 30 7 "Importo Valuta "
PICTURE ".2" FLAGS "R"
END END
BUTTON DLG_CANCEL 12 2 BUTTON DLG_CANCEL 12 2

View File

@ -25,7 +25,7 @@ PAGE "Pagamento" -1 -1 77 20
GROUPBOX DLG_NULL 78 7 GROUPBOX DLG_NULL 78 7
BEGIN BEGIN
PROMPT 1 0 "@BPartita" PROMPT 1 0 "@BScadenza"
END END
NUMBER S_ANNO 4 NUMBER S_ANNO 4
@ -37,24 +37,30 @@ END
STRING S_NUM 7 STRING S_NUM 7
BEGIN BEGIN
PROMPT 19 1 "Numero " PROMPT 15 1 "Numero "
FLAGS "DR" FLAGS "DR"
FIELD NUMPART FIELD NUMPART
END END
NUMBER S_RIGA 4 NUMBER S_RIGA 4
BEGIN BEGIN
PROMPT 40 1 "Riga " PROMPT 32 1 "Riga "
FLAGS "D" FLAGS "D"
FIELD NRIGA FIELD NRIGA
END END
NUMBER S_RATA 4 NUMBER S_RATA 4
BEGIN BEGIN
PROMPT 60 1 "Rata " PROMPT 44 1 "Rata "
FLAGS "D" FLAGS "D"
FIELD NRATA FIELD NRATA
END END
DATE S_DATASCAD
BEGIN
PROMPT 57 1 "Scadenza "
FLAGS "D"
END
STRING S_NUMDOC 7 STRING S_NUMDOC 7
BEGIN BEGIN
@ -80,41 +86,43 @@ BEGIN
FLAGS "D" FLAGS "D"
END 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 LIST S_SEZIONE_SCAD 6
BEGIN BEGIN
PROMPT 68 5 "" PROMPT 2 4 "Sez. "
ITEM "A|Avere" ITEM "A|Avere"
ITEM "D|Dare" ITEM "D|Dare"
FLAGS "D" FLAGS "D"
END 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 GROUPBOX DLG_NULL 78 12
BEGIN BEGIN
PROMPT 1 7 "@BPagamento" PROMPT 1 7 "@BPagamento"
@ -124,23 +132,23 @@ NUMBER S_IMPORTO 15
BEGIN BEGIN
PROMPT 2 8 "Importo pagamento " PROMPT 2 8 "Importo pagamento "
PICTURE "." PICTURE "."
FLAGS "U"
FIELD IMPORTO FIELD IMPORTO
VALIDATE REQIF_FUNC 1 S_IMPORTOVAL
END END
NUMBER S_IMPORTOVAL 15 2 NUMBER S_IMPORTOVAL 15 2
BEGIN BEGIN
PROMPT 2 9 "Importo in valuta " PROMPT 2 9 "Importo in valuta "
PICTURE ".2" PICTURE ".2"
FLAGS "U"
FIELD IMPORTOVAL FIELD IMPORTOVAL
GROUP 3
VALIDATE REQIF_FUNC 1 S_IMPORTO
END END
NUMBER S_RITENUTE 15 NUMBER S_RITENUTE 15
BEGIN BEGIN
PROMPT 38 8 "Ritenute professionali " PROMPT 38 8 "Ritenute professionali "
PICTURE "." PICTURE "."
FLAGS "U"
FIELD RITENUTE FIELD RITENUTE
END END

View File

@ -289,8 +289,8 @@ bool TPrimanota_application::add_cgs_imp(int n, const TImporto& imp)
TImporto tot; TImporto tot;
tot = cgs().row(n); tot = cgs().row(n);
tot += imp; tot += imp;
set_cgs_imp(n, tot); set_cgs_imp(n, tot.normalize());
return tot.is_zero();; return tot.is_zero();
} }
// Certified 90% // Certified 90%
@ -299,7 +299,7 @@ bool TPrimanota_application::sub_cgs_imp(int n, const TImporto& imp)
TImporto tot; TImporto tot;
tot = cgs().row(n); tot = cgs().row(n);
tot -= imp; tot -= imp;
set_cgs_imp(n, tot); set_cgs_imp(n, tot.normalize());
return tot.is_zero(); return tot.is_zero();
} }
@ -331,6 +331,7 @@ void TPrimanota_application::disable_cgs_cells(int n, char tipo)
case 'C': // Differenza cambio case 'C': // Differenza cambio
case 'D': // IVA Detraibile case 'D': // IVA Detraibile
case 'F': // Ritenute Fiscali case 'F': // Ritenute Fiscali
case 'L': // Contropartita delle spese
case 'N': // IVA Non detraibile case 'N': // IVA Non detraibile
case 'P': // Abbuoni passsivi case 'P': // Abbuoni passsivi
case 'R': // Ritenute professionali case 'R': // Ritenute professionali
@ -339,6 +340,8 @@ void TPrimanota_application::disable_cgs_cells(int n, char tipo)
last = 3; last = 3;
break; break;
case 'K': // Riga cliente/fornitore per saldaconto case 'K': // Riga cliente/fornitore per saldaconto
if (get_cgs_imp(n).is_zero())
break;
first = 2; first = 2;
case 'I': case 'I':
last = 7; // Imponibile 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) bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k)
{ {
int i; // Contatore nello switch static TImporto old_spesa;
const char tipo = row_type(cg.row(r)); // Tipo della riga in esame
TToken_string& row = cg.row(r);
const char tipo = row_type(row); // Tipo della riga in esame
switch(k) switch(k)
{ {
case K_SPACE:
if (tipo == 'G')
old_spesa = row;
break;
case K_TAB: case K_TAB:
cg.sheet_mask().enable(DLG_DELREC, tipo <= ' ' || tipo == 'K' || tipo == 'G'); cg.sheet_mask().enable(DLG_DELREC, tipo <= ' ' || tipo == 'K' || tipo == 'G');
cg.sheet_mask().enable(100, tipo == 'K'); cg.sheet_mask().enable(100, tipo == 'K');
break; break;
case K_ENTER:
if (app().iva() == nessuna_iva)
app().generazione_righe_cg(r);
app().calcola_saldo();
break;
case K_DEL: case K_DEL:
if (tipo == 'K') if (tipo == 'G')
app().notify_cgline_deletion(r+1); {
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; break;
case K_INS: case K_INS:
if (app().iva() == nessuna_iva && app().is_saldaconto()) if (app().iva() == nessuna_iva && app().is_saldaconto())
{ {
const char tipo = app().curr_mask().get(S_TIPORIGA)[0]; const char tipo = app().curr_mask().get(S_TIPORIGA)[0];
switch (tipo) if (tipo == 'K' || tipo == 'G')
{ {
case 'K': const int k = tipo == 'K' ? 1 : 10;
cg.row(r).add("K", 15); TBill conto; app().causale().bill(k, conto);
for (i = 0; i < r; i++) 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); for (int i = 0; i < r; i++)
if (row_type(row) != 'K')
{ {
cg.swap_rows(r, i); const TToken_string& row = cg.row(i);
break; if (row_type(row) != 'K')
{
cg.swap_rows(r, i);
break;
}
} }
} }
break; }
case 'G':
cg.row(r).add("G", 15);
break;
default:
break;
}
} }
break; break;
default: default:
@ -1651,10 +1686,7 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key)
TTable val("%val"); TTable val("%val");
val.put("CODTAB", valuta); val.put("CODTAB", valuta);
if (val.read() == NOERR) if (val.read() == NOERR)
{
m.set(S_VALUTA, valuta); m.set(S_VALUTA, valuta);
m.set(S_CAMBIO, val.get("R10"), TRUE);
}
} }
} }
if (occas && app().occas_mask().get(O_CODICE).empty()) 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 // Handler of the F_TOTALE
// Certified 99% // 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; bool ok = TRUE;
TMask& m = f.mask();
if (key == K_TAB && f.focusdirty()) if (key == K_TAB && f.focusdirty())
{ {
app().add_cgs_tot(m); TMask& m = f.mask();
m.field(F_CODIVA).on_hit();
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()) if (key == K_ENTER && f.get().empty())
ok = f.yesno_box("Totale documento nullo: continuare ugualmente?"); ok = f.yesno_box("Totale documento nullo: continuare ugualmente?");
return ok; 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_TAB && f.focusdirty() && f.get().not_empty())
if (key == K_ENTER && f.get().empty()) {
ok = f.yesno_box("Totale documento nullo: continuare ugualmente?"); TMask& m = f.mask();
return ok; 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) void TPrimanota_application::add_cgs_rit(bool fiscali)
{ {
const real imp(curr_mask().get(fiscali ? F_RITFIS : F_RITSOC)); const real imp(curr_mask().get(fiscali ? F_RITFIS : F_RITSOC));

View File

@ -91,8 +91,8 @@ class TPrimanota_application : public TRelation_application
static bool numrif_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 protiva_handler(TMask_field& f, KEY key);
static bool clifo_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 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 ritfis_handler(TMask_field& f, KEY key);
static bool ritsoc_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); 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(TPartita& partita, long nreg, int numrig);
bool notify_cgline_deletion(int numrig); bool notify_cgline_deletion(int numrig);
bool notify_edit_pagamento(TPartita& partita, TRectype& new_pag, int deleting = -1); 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); long calcola_m770(int tipo_coll, real& spese, real& compenso, real& iva, real& ritfis);
bool link_m770(); bool link_m770();

View File

@ -18,6 +18,8 @@
class TGame_mask : public TMask class TGame_mask : public TMask
{ {
const TBill _conto; // Conto fisso del cliente/fornitore 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 int _riga_partite; // Riga corrente delle partite
protected: protected:
@ -29,7 +31,7 @@ protected:
static bool edit_scadenza_handler(TMask_field& f, KEY k); static bool edit_scadenza_handler(TMask_field& f, KEY k);
static bool nuovo_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; TImporto get_importo(TToken_string& s, int pos) const;
void fill_partite(bool all) const; void fill_partite(bool all) const;
@ -38,16 +40,19 @@ protected:
void update_partita(const TPartita& game, int prow) const; void update_partita(const TPartita& game, int prow) const;
void update_saldo_clifo() const; void update_saldo_clifo() const;
bool cerca_valuta(TValuta& val) const;
public: public:
TSheet_field& partite() const { return (TSheet_field&)field(P_PARTITE); } TSheet_field& partite() const { return (TSheet_field&)field(P_PARTITE); }
TSheet_field& scadenze() const { return (TSheet_field&)field(P_SCADENZE); } TSheet_field& scadenze() const { return (TSheet_field&)field(P_SCADENZE); }
const TBill& conto() const { return _conto; } const TBill& conto() const { return _conto; }
TGame_mask(const TBill& bill); TGame_mask(const TBill& bill, long numreg, int riga);
virtual ~TGame_mask() {} 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' }; const char tipocf[2] = { _conto.tipo(), '\0' };
set(P_TIPOC, tipocf); 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_SOTTOCONTO, _conto.sottoconto());
set(P_DESCR, ((TBill&)_conto).descrizione()); 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_ANNO, annopart_handler);
set_handler(P_NUMERO, numpart_handler); set_handler(P_NUMERO, numpart_handler);
set_handler(P_SHOWALL, show_all_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() real TGame_mask::aggiorna_residuo()
{ {
const TMask& cm = app().curr_mask(); TImporto residuo(app().get_cgs_imp(_numrig-1));
const long cur_reg = cm.get_long(F_NUMREG); residuo -= app().partite().importo_speso(_numreg, _numrig, TRUE);
const int rmov = app().cgs().selected();
TImporto residuo(app().get_cgs_imp(rmov));
residuo -= app().partite().importo_speso(cur_reg, rmov+1, TRUE);
set(P_RESIDUO, residuo.valore().string()); set(P_RESIDUO, residuo.valore().string());
return residuo.valore(); 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) bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
{ {
if (k == K_TAB) 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 const bool should_delete_game = (game == NULL); // Ricorda di fare delete
if (should_delete_game) // Se non c'era ... if (should_delete_game) // Se non c'era ...
game = new TPartita(zio, anno, num); // ... creane una temporanea game = new TPartita(zio, anno, num); // ... creane una temporanea
TImporto tot_lit, tot_val;
const int lastrow = game->last(); const int lastrow = game->last();
for (int ri = game->first(); ri <= lastrow; ri = game->succ(ri)) for (int ri = game->first(); ri <= lastrow; ri = game->succ(ri))
{ {
const TRiga_partite& riga = game->riga(ri); const TRiga_partite& riga = game->riga(ri);
const bool in_valuta = riga.in_valuta(); const bool in_valuta = riga.in_valuta();
for (int ra = 1; ra <= riga.rate(); ra++) for (int ra = 1; ra <= riga.rate(); ra++)
{ {
const TRiga_scadenze& scad = riga.rata(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_NREG));
row.add(riga.get(PART_DATAREG)); row.add(riga.get(PART_DATAREG));
row.add(scad.get(SCAD_DATASCAD)); row.add(scad.get(SCAD_DATASCAD));
row.add(scad.get(SCAD_IMPORTO)); add_importo(row, TImporto(riga.sezione(), scad.get_real(SCAD_IMPORTO)));
row.add(in_valuta ? scad.get_real(SCAD_IMPORTOVAL).string(0, 2) : ""); 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_DESCR));
row.add(riga.get(PART_NUMDOC)); row.add(riga.get(PART_NUMDOC));
row.add(riga.get(PART_PROTIVA)); row.add(riga.get(PART_PROTIVA));
const int lastp = scad.last(); const int lastp = scad.last();
for (int pa = scad.first(); pa <= lastp; pa = scad.succ(pa)) 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 TRectype& pag = scad.row(pa);
const TRiga_partite& sum = game->riga(pa);
const char sez = sum.sezione();
TToken_string& row = scadenze.row(scadenze.add("")); TToken_string& row = scadenze.row(scadenze.add(""));
row.add(ri); row.add(ri);
row.add(ra); row.add(ra);
row.add(rigp.get(PART_DATADOC)); row.add(sum.get(PART_DATADOC));
row.add(rigp.get(PART_NREG)); row.add(sum.get(PART_NREG));
row.add(rigp.get(PART_DATAREG)); row.add(sum.get(PART_DATAREG));
row.add(scad.get(SCAD_DATASCAD)); 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) : ""); add_importo(row, TImporto(sez, pag.get_real(PAGSCA_IMPORTO)));
row.add(rigp.get(PART_DESCR)); if (in_valuta)
row.add(rigp.get(PART_NUMDOC)); 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("");
row.add(pa); row.add(pa);
} }
TToken_string& sal = scadenze.row(scadenze.add("")); TImporto abb(scad.importo_pagato(TRUE, 0x2));
sal.add(ri); if (!abb.is_zero())
sal.add(ra);
if (scad.pagata())
{ {
sal.add("", 6); TToken_string& rabb = scadenze.row(scadenze.add(""));
sal.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); TImporto diff(scad.importo_pagato(FALSE, 0x4));
sal.add(in_valuta ? scad.residuo(TRUE).string(0, 2) : ""); 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(); 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)) for (int pa = unas.first_row(); pa <= lastp; pa = unas.succ_row(pa))
{ {
const TRectype& pag = unas.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("")); TToken_string& row = scadenze.row(scadenze.add(""));
row.add(pag.get(PAGSCA_NRIGA)); row.add(pag.get(PAGSCA_NRIGA));
row.add(pag.get(PAGSCA_NRATA)); row.add(pag.get(PAGSCA_NRATA));
row.add(rigp.get(PART_DATADOC)); row.add(sum.get(PART_DATADOC));
row.add(rigp.get(PART_NREG)); row.add(sum.get(PART_NREG));
row.add(rigp.get(PART_DATAREG)); row.add(sum.get(PART_DATAREG));
row.add(""); row.add("");
row.add(pag.get_real(PAGSCA_IMPORTO).string());
row.add(in_valuta ? pag.get_real(PAGSCA_IMPORTOVAL).string(0, 2) : ""); TImporto i(sum.sezione(), pag.get_real(PAGSCA_IMPORTO));
row.add(rigp.get(PART_DESCR)); tot_lit += i;
row.add(rigp.get(PART_NUMDOC)); 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("");
row.add(pa); 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(); gm.scadenze().force_update();
if (should_delete_game) if (should_delete_game)
delete game; delete game;
@ -266,24 +358,26 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
if (k == K_SPACE) if (k == K_SPACE)
{ {
TMask& m = f.mask(); 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()); 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 TBill& bill = gm.conto();
const int anno = gm.get_int(P_ANNO); const int anno = gm.get_int(P_ANNO);
const TString16 numero = gm.get(P_NUMERO); 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); TPartita& game = app().partite().partita(bill, anno, numero);
int nrigp = m.get_int(112); int nrigp = m.get_int(112);
if (nrigp == 0) if (nrigp == 0)
{ {
if (game.rata_pagata(nriga, nrata)) const int rmov = app().cgs().selected()+1;
return f.error_box("La rata %d e' gia' stata pagata", nrata);
nrigp = app().nuovo_pagamento(game, nriga, nrata, rmov); nrigp = app().nuovo_pagamento(game, nriga, nrata, rmov);
} }
else 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 cur_reg = cm.get_long(F_NUMREG);
const long nreg = m.get_long(104); const long nreg = m.get_long(104);
if (cur_reg != nreg) if (cur_reg != nreg)
return f.error_box("Il movimento corrente e' il %ld", cur_reg); return f.error_box("Modificare il movimento %ld", nreg);
const int paga = game.rata_pagata(nriga, nrata);
if (paga != 0 && paga != nrigp)
return f.error_box("Pagamento non modificabile");
} }
const bool dirty = app().edit_pagamento(game, nriga, nrata, nrigp); 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) if (k == K_SPACE)
{ {
TMask new_game("Nuova partita", 1, 24, 5); TMask new_game("Nuova partita", 1, 24, 5);
new_game.add_number(P_ANNO, 0, "Anno ", 1, 1, 4, "A"); 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_string(P_NUMERO, 0, "Partita ", 1, 2, 7);
new_game.add_button(DLG_OK, 0, "", -12, 3, 8, 2); 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_button(DLG_CANCEL, 0, "" , -22, 3, 8, 2);
new_game.first_focus(P_NUMERO);
if (new_game.run() == K_ENTER) 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); TPartita& game = app().partite().partita(gm.conto(), anno, numero);
if (game.ok()) if (game.ok())
return error_box("La partita %d %s esiste gia'.", anno, (const char*)numero); return error_box("La partita %d %s esiste gia'.", anno, (const char*)numero);
const int nriga = TPartita::UNASSIGNED; const int nriga = TPartita::UNASSIGNED;
const int nrata = 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); app().edit_pagamento(game, nriga, nrata, nrigp);
if (game.ok()) if (game.ok())
{ {
@ -354,13 +445,13 @@ bool TGame_mask::nuovo_handler(TMask_field& f, KEY k)
// Metodi della maschera delle partite // 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()) if (i.is_zero())
s.add(""); s.add("");
else else
{ {
s.add(i.valore().string()); s.add(i.valore().string(dec));
s << ' ' << i.sezione(); 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_SEZIONE_SCAD, scad.riga().sezione()); // Sezione della rata
set(S_IMPORTO_SCAD, scad.get(SCAD_IMPORTO)); // Importo della rata set(S_IMPORTO_SCAD, scad.get(SCAD_IMPORTO)); // Importo della rata
set(S_IMPORTOVAL_SCAD, scad.get(SCAD_IMPORTOVAL)); // Importo in valuta 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_decimals(_in_valuta ? 2 : 0);
res.set(_da_pagare.string()); res.set(_da_pagare.string());
if (!_da_pagare.is_zero()) 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 // Ricorda l'importo da pagare
_da_pagare += oldpag.get_real(_in_valuta ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO); _da_pagare += oldpag.get_real(_in_valuta ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO);
show(S_IMPORTOVAL_SCAD, _in_valuta); // Attiva campi relativi alla valuta
show(S_IMPORTOVAL, _in_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 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()) if (k == K_TAB && f.focusdirty())
{ {
const real i(f.get()); 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"); m.set(S_SALDOACC, "S");
const real residuo(m._da_pagare - i); const real residuo(m._da_pagare - i);
m.set(S_RESIDUO, residuo.string()); m.set(S_RESIDUORATA, residuo.string());
} }
return TRUE; return TRUE;
@ -629,17 +732,25 @@ bool TPrimanota_application::showpartite_handler(TMask_field& f, KEY k)
bool TPrimanota_application::edit_partite(int riga) bool TPrimanota_application::edit_partite(int riga)
{ {
TToken_string& cgr = cgs().row(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 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 return FALSE; // Esci se il conto della riga cliente non e' valido
curr_mask().autosave(get_relation()); // Aggiorna i dati della testata sulle partite curr_mask().autosave(get_relation()); // Aggiorna i dati della testata sulle partite
const TRectype& mov = get_relation()->curr(); const TRectype& mov = get_relation()->curr();
partite().update_reg(mov); 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(); mask.run();
cgs().force_update(); // Aggiornamento righe contabili 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) 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 TBill conto; partita.conto(conto); // Legge conto principale
const long numreg = curr_mask().get_long(F_NUMREG); 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) if (rata != TPartita::UNASSIGNED)
{ {
const TRiga_scadenze& scad = partita.rata(nriga, rata); 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 2: // Tratta
case 7: // Tratta accettata case 7: // Tratta accettata
@ -729,6 +839,7 @@ int TPrimanota_application::nuovo_pagamento(TPartita& partita, int nriga, int ra
default: default:
caus = 2; break; caus = 2; break;
} }
pagamento.put(PAGSCA_TIPOPAG, tp);
pagamento.put(PAGSCA_CODABIPR, scad.get(SCAD_CODABIPR)); pagamento.put(PAGSCA_CODABIPR, scad.get(SCAD_CODABIPR));
pagamento.put(PAGSCA_CODCABPR, scad.get(SCAD_CODCABPR)); pagamento.put(PAGSCA_CODCABPR, scad.get(SCAD_CODCABPR));
pagamento.put(PAGSCA_CODABI, scad.get(SCAD_CODABI)); 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) if (riga < 0)
{ {
TBill conto_rit; causale().bill(11, conto_rit); 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 else
{ {
@ -854,9 +965,10 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa
{ {
const riga_abb = type2pos(new_ap); const riga_abb = type2pos(new_ap);
if (riga_abb < 0) if (riga_abb < 0)
{ {
TBill conto_abb; causale().bill(new_ap == 'A' ? 9 : 8, conto_abb); const int rc = new_ap == 'A' ? 9 : 8;
app().set_cgs_row(riga_abb, new_abbuono, conto_abb, "", new_ap); 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 else
add_cgs_imp(riga_abb, new_abbuono); 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) if (riga_diffcam < 0)
{ {
TBill conto_diffcam; causale().bill(12, conto_diffcam); 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 else
{ {
@ -926,21 +1038,22 @@ bool TPrimanota_application::edit_pagamento(TPartita& p, int nriga, int nrata, i
{ {
if (key == K_DEL) if (key == K_DEL)
{ {
m.reset(S_IMPORTO); m.reset(S_SALDOACC); // Non puo' essere un saldo
m.reset(S_IMPORTOVAL); m.reset(S_IMPORTO); // Azzera importo ...
m.reset(S_RITENUTE); m.reset(S_IMPORTOVAL); // .. anche in valuta
m.reset(S_RITENUTE); // Azzera ritenute
} }
else else
{ {
somma.put(PART_DESCR, m.get(S_DESCAGG)); // Aggiorna descrizione (comune ai pagamenti) somma.put(PART_DESCR, m.get(S_DESCAGG)); // Aggiorna descrizione (comune ai pagamenti)
} }
TRectype new_pag(oldpag); TRectype new_pag(oldpag);
m.get_pag(new_pag); m.get_pag(new_pag);
notify_edit_pagamento(p, new_pag); notify_edit_pagamento(p, new_pag);
} }
return key != K_ESC; return key != K_ESC;
} }
@ -996,37 +1109,3 @@ bool TPrimanota_application::notify_cgline_deletion(int numrig)
return found; 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;
}

View File

@ -14,7 +14,7 @@ BEGIN
INPUT CODTAB 108 INPUT CODTAB 108
DISPLAY "Codice" CODTAB DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@50" S0 DISPLAY "Descrizione@50" S0
INPUT CODTAB 108 INPUT CODTAB 108
OUTPUT 108 CODTAB OUTPUT 108 CODTAB
OUTPUT 109 S0 OUTPUT 109 S0
CHECKTYPE NORMAL CHECKTYPE NORMAL
@ -350,7 +350,9 @@ BEGIN
ITEM "C|Gestione saldaconto" ITEM "C|Gestione saldaconto"
ITEM "D|IVA detraibile" ITEM "D|IVA detraibile"
ITEM "F|Ritenute fiscali" ITEM "F|Ritenute fiscali"
ITEM "G|Spese"
ITEM "I|Riga di IVA" ITEM "I|Riga di IVA"
ITEM "L|Cassa"
ITEM "K|Riga Cliente/Fornitore" ITEM "K|Riga Cliente/Fornitore"
ITEM "N|IVA non detraibile" ITEM "N|IVA non detraibile"
ITEM "S|Ritenute sociali" ITEM "S|Ritenute sociali"

View File

@ -1,7 +1,8 @@
#include <mask.h>
#include "saldacon.h" #include "saldacon.h"
#include <mov.h> #include <mov.h>
#include <partite.h>
#include <scadenze.h> #include <scadenze.h>
#include <pagsca.h> #include <pagsca.h>
@ -101,6 +102,82 @@ int TTree_rectype::remove(TBaseisamfile& f)
return err; 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 // TRiga_scadenze
@ -127,33 +204,51 @@ TPartita& TRiga_scadenze::partita() const
// Controlla se la fattura della rata e' in valuta // Controlla se la fattura della rata e' in valuta
bool TRiga_scadenze::in_valuta() const 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 // 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)) TImporto imp(importo_da_pagare(TRUE));
{ imp += importo_pagato(TRUE, 0x3);
const TRectype& pag = row(p); return imp.is_zero();
if (pag.get_char("ACCSAL") == 'S')
break;
}
return p;
} }
// Calcola il totale dei pagamenti (eventualmente in valuta) // Calcola il totale dei pagamenti (eventualmente in valuta)
TImporto TRiga_scadenze::importo_pagato(bool val) const TImporto TRiga_scadenze::importo_pagato(bool val, int mode) const
{ {
const char* imp_field = val && in_valuta() ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO; CHECKD(mode > 0 && mode < 8, "Bad importo_pagato mode ", mode);
const TPartita& game = partita(); const TPartita& game = partita();
const bool in_val = in_valuta();
const char* imp_field = (val && in_val) ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO;
TImporto totale; TImporto totale;
for (int p = last(); p > 0; p = pred(p)) for (int p = last(); p > 0; p = pred(p))
{ {
const TRectype& pag = row(p); // Riga pagamento const TRectype& pag = row(p); // Riga pagamento
const TRiga_partite& sum = game.riga(p); // Riga partite const TRiga_partite& sum = game.riga(p); // Riga partite
const TImporto imp(sum.sezione(), pag.get_real(imp_field)); const char sez = sum.sezione();
totale += imp;
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; return totale;
@ -162,22 +257,31 @@ TImporto TRiga_scadenze::importo_pagato(bool val) const
// Calcola l'importo da pagare (eventualmente in valuta) // Calcola l'importo da pagare (eventualmente in valuta)
TImporto TRiga_scadenze::importo_da_pagare(bool val) const 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 TRiga_partite& r = riga(); // Riga fattura
const TImporto totale(r.sezione(), get_real(imp_field)); const TImporto totale(r.sezione(), get_real(imp_field));
return totale; 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 // 'A' abbuono attivo; 'P' abbuono passivo
// La sezione dell'abbuono calcolato e' quella della riga contabile in cui finira' // 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 = ' '; bool ap = ' ';
if (pagata())
const TRectype& pag = row(p);
if (pag.get_char(PAGSCA_ACCSAL) == 'S')
{ {
abbuono = importo_da_pagare(TRUE); abbuono = importo_da_pagare(TRUE);
abbuono += importo_pagato(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(); const int sign = abbuono.valore().sign();
if (sign != 0) if (sign != 0)
@ -187,12 +291,6 @@ char TRiga_scadenze::calcola_abbuono(TImporto& abbuono, bool val) const
else else
ap = abbuono.sezione() == 'D' ? 'A' : 'P'; ap = abbuono.sezione() == 'D' ? 'A' : 'P';
} }
if (val && in_valuta())
{
abbuono.valore() *= riga().get_real(PART_CAMBIO);
abbuono.valore().round();
}
} }
else else
abbuono.valore() = ZERO; 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 // 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; TImporto diffcam;
if (in_valuta()) if (in_valuta())
{ {
const int riga_saldo = pagata(); TRectype& pag = row(p);
if (riga_saldo > 0) const char sez = partita().riga(p).sezione();
if (update)
{ {
TRectype& pag = row(riga_saldo); diffcam = importo_da_pagare(FALSE);
const TRiga_partite& sum = partita().riga(riga_saldo); diffcam += importo_pagato(FALSE, 0x3); // Conta anche gli abbuoni
const char sez = sum.sezione(); diffcam.normalize(sez);
pag.put(PAGSCA_DIFFCAM, diffcam.valore());
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));
}
}
else else
if (update) {
{ diffcam.set(sez, pag.get_real(PAGSCA_DIFFCAM));
for (int p = last(); p > 0; p = pred(p)) }
{ }
TRectype& pag = row(p); else
pag.zero(PAGSCA_DIFFCAM); {
} if (update)
} row(p).zero(PAGSCA_DIFFCAM);
} }
return 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)); TImporto residuo(importo_da_pagare(val));
residuo += importo_pagato(val); // Somma con sezione opposta residuo += importo_pagato(val, mode); // Somma con sezione opposta
return residuo.valore(); return residuo;
} }
@ -267,31 +345,27 @@ bool TRiga_scadenze::modifica_pagamento(const TRectype& new_pag,
TRiga_partite& sum = partita().riga(nrigp); TRiga_partite& sum = partita().riga(nrigp);
TImporto old_abbuono; 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 old_abb = old_abbuono; // Vecchio abbuono in lire
if (in_valuta()) if (in_valuta())
{ {
old_abb.valore() *= riga().get_real(PART_CAMBIO); old_abb.valore() *= sum.get_real(PART_CAMBIO);
old_abb.valore().round(); old_abb.valore().round();
} }
old_diffcam = calcola_differenza_cambio(FALSE); old_diffcam = calcola_differenza_cambio(nrigp, FALSE);
const char* imp_field = in_valuta() ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO; row(nrigp) = new_pag;
const real importo(new_pag.get(imp_field)); row(nrigp).zero(PAGSCA_ABBUONI); // Azzera abbuoni per ricalcolo
const bool empty = importo.is_zero(); row(nrigp).zero(PAGSCA_DIFFCAM); // Azzera differenza cambio per ricalcolo
if (empty)
rows_array().destroy_row(nrigp);
else
row(nrigp) = new_pag;
TImporto new_abbuono; 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()) if (in_valuta())
{ {
new_abb.valore() *= riga().get_real(PART_CAMBIO); new_abb.valore() *= sum.get_real(PART_CAMBIO);
new_abb.valore().round(); new_abb.valore().round();
} }
@ -300,14 +374,13 @@ bool TRiga_scadenze::modifica_pagamento(const TRectype& new_pag,
new_abbuono.swap_section(); new_abbuono.swap_section();
new_abbuono.normalize(sum.sezione()); new_abbuono.normalize(sum.sezione());
if (new_ap != ' ') if (new_ap != ' ')
{ row(nrigp).put(PAGSCA_ABBUONI, new_abbuono.valore());
CHECK(nrigp == pagata(), "Aggiornamento abbuoni inconsistente"); else
TRectype& pag = row(nrigp); row(nrigp).zero(PAGSCA_ABBUONI);
pag.put(PAGSCA_ABBUONI, new_abbuono.valore());
}
sum.update(old_abbuono, new_abbuono, PART_SEZABB, PART_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! // Memorizza differenza cambi invertita, mettendo new_diffcam prima di old_diffcam!
sum.update(new_diffcam, old_diffcam, PART_SEZDIFCAM, PART_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 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; return empty;
} }
@ -497,13 +576,13 @@ TRiga_scadenze& TPartita::rata(int nriga, int nrata) const
return r.rata(nrata); 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) if (nriga != UNASSIGNED)
{ {
const TRiga_scadenze& r = rata(nriga, nrata); const TRiga_scadenze& r = rata(nriga, nrata);
pag = r.pagata(); pag = r.chiusa();
} }
return pag; return pag;
} }
@ -534,6 +613,7 @@ bool TPartita::esiste(int nriga, int nrata, int nrigp) const
return r.rows_array().exist(nrigp); 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 TPartita::importo_speso(long nreg, int numrig, bool extra) const
{ {
TImporto imp; 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); const int num = part.get_int(PART_NUMRIG);
if (num == numrig) if (num == numrig)
{ {
const char sez = part.get_char(PART_SEZ); // Deve essere valida per forza! imp += TImporto(part.sezione(), part.get_real(PART_IMPORTO));
imp += TImporto(sez, part.get_real(PART_IMPORTO));
if (extra) if (extra)
{ {
TImporto abbuoni(part.get_char(PART_SEZABB), part.get_real(PART_ABBUONI)); 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() *= part.get_real(PART_CAMBIO);
abbuoni.valore().round(); 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_REG, mov.get(MOV_REG));
pag.put(PART_PROTIVA, mov.get(MOV_PROTIVA)); pag.put(PART_PROTIVA, mov.get(MOV_PROTIVA));
pag.put(PART_CODCAUS, mov.get(MOV_CODCAUS)); 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 TPartita::chiusa(bool update)
{ {
bool chiusa = FALSE; bool chiusa = FALSE;
const int ultima = last();
if (ultima > 0)
{
const TRiga_partite& row = riga(ultima);
chiusa = row.get_bool(PART_CHIUSA);
}
if (update) if (update)
{ {
bool forse_chiusa = TRUE; bool forse_chiusa = TRUE;
for (int p = last(); p > 0 && forse_chiusa; p = pred(p)) 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) if (part.get_int(PART_TIPOMOV) == 1)
{ {
for (int r = part.last(); r > 0; r--) for (int r = part.last(); r > 0; r--)
{ {
const TRiga_scadenze& scad = part.rata(r); const TRiga_scadenze& scad = part.rata(r);
if (!scad.pagata()) if (!scad.chiusa())
{ {
forse_chiusa = FALSE; forse_chiusa = FALSE;
break; 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; return chiusa;
} }

View File

@ -9,6 +9,10 @@
#include <relation.h> #include <relation.h>
#endif #endif
#ifndef __MASK_H
class TMask;
#endif
#ifndef __CONTO_H #ifndef __CONTO_H
#include "conto.h" #include "conto.h"
#endif #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 class TRiga_scadenze : public TTree_rectype
{ {
friend class TPartita; friend class TPartita;
@ -63,8 +107,8 @@ class TRiga_scadenze : public TTree_rectype
TRiga_partite* _riga; TRiga_partite* _riga;
protected: protected:
char calcola_abbuono(TImporto& abbuono, bool val) const; char calcola_abbuono(int p, TImporto& abbuono) const;
TImporto calcola_differenza_cambio(bool update); TImporto calcola_differenza_cambio(int p, bool update);
bool modifica_pagamento(const TRectype& new_pag, bool modifica_pagamento(const TRectype& new_pag,
char& old_ap, TImporto& old_abb, TImporto& old_diffcam, 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); } virtual TObject* dup() const { return new TRiga_scadenze(*this); }
public: public:
int pagata() const; // Riga che chiude la rata o 0 se non pagata completamente bool chiusa() const;
bool in_valuta() const; bool in_valuta() const;
TPartita& partita() const; TPartita& partita() const;
TRiga_partite& riga() const { return *_riga; } // Riga partite 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; 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(TRiga_partite* riga);
TRiga_scadenze(const TRiga_scadenze& s); TRiga_scadenze(const TRiga_scadenze& s);
@ -136,7 +180,7 @@ public:
void rimuovi_riga(int r) { _part.destroy_row(r); } void rimuovi_riga(int r) { _part.destroy_row(r); }
TRiga_scadenze& rata(int nriga, int nrata) const; TRiga_scadenze& rata(int nriga, int nrata) const;
TRectype& pagamento(int nriga, int nrata, int nrigp); 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; bool esiste(int nriga, int nrata = 0, int nrigp = 0) const;
int succ(int r) const { return _part.succ_row(r); } int succ(int r) const { return _part.succ_row(r); }