Gestione saldaconto

git-svn-id: svn://10.65.10.50/trunk@2165 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-11-17 10:27:24 +00:00
parent 0245a5243a
commit f770af567e
9 changed files with 278 additions and 118 deletions

View File

@ -52,7 +52,6 @@ END
DATE F_DATAREG DATE F_DATAREG
BEGIN BEGIN
PROMPT 1 3 "Data operazione " PROMPT 1 3 "Data operazione "
HELP "Data in cui viene registrata l'operazione"
FIELD 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
@ -68,7 +67,6 @@ END
DATE F_DATACOMP DATE F_DATACOMP
BEGIN BEGIN
PROMPT 1 4 "Data competenza " PROMPT 1 4 "Data competenza "
HELP "Data di competenza dell'operazione"
FIELD DATACOMP FIELD DATACOMP
CHECKTYPE REQUIRED CHECKTYPE REQUIRED
END END
@ -91,7 +89,6 @@ END
STRING F_CODCAUS 3 STRING F_CODCAUS 3
BEGIN BEGIN
PROMPT 1 5 "Causale " PROMPT 1 5 "Causale "
HELP "Codice della causale generante l'operazione"
FLAGS "UZ" FLAGS "UZ"
FIELD CODCAUS FIELD CODCAUS
USE LF_CAUSALI SELECT REG!="" USE LF_CAUSALI SELECT REG!=""
@ -113,7 +110,6 @@ END
STRING F_DESCRCAUS 50 STRING F_DESCRCAUS 50
BEGIN BEGIN
PROMPT 25 5 "" PROMPT 25 5 ""
HELP "Descrizione della causale generante l'operazione"
USE LF_CAUSALI KEY 2 SELECT REG!="" USE LF_CAUSALI KEY 2 SELECT REG!=""
INPUT DESCR F_DESCRCAUS INPUT DESCR F_DESCRCAUS
DISPLAY "Descrizione@50" DESCR DISPLAY "Descrizione@50" DESCR
@ -130,7 +126,6 @@ DATE F_DATADOC
BEGIN BEGIN
PROMPT 1 6 "Data documento " PROMPT 1 6 "Data documento "
FIELD DATADOC FIELD DATADOC
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
END END
@ -152,7 +147,6 @@ END
STRING F_NUMDOC 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"
FIELD 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
@ -160,13 +154,11 @@ END
BOOLEAN F_SOLAIVA BOOLEAN F_SOLAIVA
BEGIN BEGIN
PROMPT 1 7 "Movimento di sola IVA" PROMPT 1 7 "Movimento di sola IVA"
HELP "Indicare se non vi sono righe di contabilita'"
END END
LIST F_PROVVISORIO 1 25 LIST F_PROVVISORIO 1 25
BEGIN BEGIN
PROMPT 31 7 "Movimento provvisorio " PROMPT 31 7 "Movimento provvisorio "
HELP "Indicare se si tratta di movimento provvisorio"
FIELD PROVVIS FIELD PROVVIS
ITEM " |No (movimento normale)" ITEM " |No (movimento normale)"
ITEM "P|Si (cancellabile)" ITEM "P|Si (cancellabile)"
@ -177,7 +169,6 @@ END
STRING F_DESCAGG 5 STRING F_DESCAGG 5
BEGIN BEGIN
PROMPT 1 8 "Descrizione " PROMPT 1 8 "Descrizione "
HELP "Codice della descrizione del movimento"
FLAGS "UZ" FLAGS "UZ"
USE %DPN USE %DPN
INPUT CODTAB F_DESCAGG INPUT CODTAB F_DESCAGG
@ -192,7 +183,6 @@ END
STRING F_DESCR 50 STRING F_DESCR 50
BEGIN BEGIN
PROMPT 25 8 "" PROMPT 25 8 ""
HELP "Descrizione del movimento"
FIELD DESCR FIELD DESCR
USE %DPN KEY 2 USE %DPN KEY 2
INPUT S0 F_DESCR INPUT S0 F_DESCR
@ -204,14 +194,12 @@ END
NUMBER F_PROTIVA 5 NUMBER F_PROTIVA 5
BEGIN BEGIN
PROMPT 1 9 "Protocollo IVA " PROMPT 1 9 "Protocollo IVA "
HELP "Numero progressivo di protocollo IVA"
FIELD 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"
FIELD 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)"
@ -243,7 +231,6 @@ END
NUMBER F_CLIENTE 6 NUMBER F_CLIENTE 6
BEGIN BEGIN
PROMPT 1 10 "Cliente " PROMPT 1 10 "Cliente "
HELP "Codice del cliente"
FLAGS "R" FLAGS "R"
FIELD CODCF FIELD CODCF
GROUP 1 GROUP 1
@ -270,7 +257,6 @@ NUMBER F_FORNITORE 6
BEGIN BEGIN
PROMPT 1 10 "Fornitore " PROMPT 1 10 "Fornitore "
FLAGS "R" FLAGS "R"
HELP "Codice del fornitore"
FIELD CODCF FIELD CODCF
GROUP 2 GROUP 2
USE LF_CLIFO KEY 1 USE LF_CLIFO KEY 1
@ -295,7 +281,6 @@ END
STRING F_RAGSOCFORNITORE 50 STRING F_RAGSOCFORNITORE 50
BEGIN BEGIN
PROMPT 25 10 "" PROMPT 25 10 ""
HELP "Ragione sociale del fornitore"
GROUP 2 GROUP 2
USE LF_CLIFO KEY 2 USE LF_CLIFO KEY 2
INPUT TIPOCF "F" INPUT TIPOCF "F"
@ -312,7 +297,6 @@ END
STRING F_RAGSOCCLIENTE 50 STRING F_RAGSOCCLIENTE 50
BEGIN BEGIN
PROMPT 25 10 "" PROMPT 25 10 ""
HELP "Ragione sociale del cliente del documento"
GROUP 1 GROUP 1
USE LF_CLIFO KEY 2 USE LF_CLIFO KEY 2
INPUT TIPOCF "C" INPUT TIPOCF "C"
@ -328,7 +312,6 @@ END
STRING F_COFICLIENTE 16 STRING F_COFICLIENTE 16
BEGIN BEGIN
PROMPT 1 11 "C.F. " PROMPT 1 11 "C.F. "
HELP "Codice fiscale del cliente del documento"
GROUP 1 GROUP 1
USE LF_CLIFO KEY 4 USE LF_CLIFO KEY 4
INPUT TIPOCF "C" INPUT TIPOCF "C"
@ -344,7 +327,6 @@ END
STRING F_COFIFORNITORE 16 STRING F_COFIFORNITORE 16
BEGIN BEGIN
PROMPT 1 11 "C.F. " PROMPT 1 11 "C.F. "
HELP "Codice fiscale del fornitore del documento"
GROUP 2 GROUP 2
USE LF_CLIFO KEY 4 USE LF_CLIFO KEY 4
INPUT TIPOCF "F" INPUT TIPOCF "F"
@ -358,7 +340,6 @@ END
STRING F_PIVACLIENTE 12 STRING F_PIVACLIENTE 12
BEGIN BEGIN
PROMPT 28 11 "Partita IVA " PROMPT 28 11 "Partita IVA "
HELP "Partita IVA del cliente del documento"
GROUP 1 GROUP 1
USE LF_CLIFO KEY 5 USE LF_CLIFO KEY 5
INPUT TIPOCF "C" INPUT TIPOCF "C"
@ -375,7 +356,6 @@ END
STRING F_PIVAFORNITORE 12 STRING F_PIVAFORNITORE 12
BEGIN BEGIN
PROMPT 28 11 "Partita IVA " PROMPT 28 11 "Partita IVA "
HELP "Partita IVA del fornitore del documento"
GROUP 2 GROUP 2
USE LF_CLIFO KEY 5 USE LF_CLIFO KEY 5
INPUT TIPOCF "F" INPUT TIPOCF "F"
@ -390,7 +370,6 @@ END
LIST F_STATOPAIV 18 LIST F_STATOPAIV 18
BEGIN BEGIN
PROMPT 57 11 "" PROMPT 57 11 ""
HELP "Codice ISO dello stato per la partita IVA"
ITEM " |Italia o extra CEE" ITEM " |Italia o extra CEE"
ITEM "BE|Belgio" ITEM "BE|Belgio"
ITEM "DE|Germania" ITEM "DE|Germania"
@ -416,7 +395,6 @@ END
STRING S_VALUTA 3 STRING S_VALUTA 3
BEGIN BEGIN
PROMPT 1 12 "Valuta " PROMPT 1 12 "Valuta "
HELP "Codice della valuta per operazione con l'estero"
FIELD CODVAL FIELD CODVAL
FLAGS "UZ" FLAGS "UZ"
GROUP 3 GROUP 3
@ -452,7 +430,6 @@ END
NUMBER S_CAMBIO 15 5 NUMBER S_CAMBIO 15 5
BEGIN BEGIN
PROMPT 55 12 "Cambio " PROMPT 55 12 "Cambio "
HELP "Cambio della valuta per operazione con l'estero"
FIELD CAMBIO FIELD CAMBIO
FLAGS "RU" FLAGS "RU"
GROUP 3 GROUP 3
@ -463,7 +440,6 @@ 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"
FIELD TOTDOC FIELD TOTDOC
PICTURE "." PICTURE "."
END END
@ -471,7 +447,6 @@ END
NUMBER S_TOTDOCVAL 15 2 NUMBER S_TOTDOCVAL 15 2
BEGIN BEGIN
PROMPT 35 13 "Tot. in valuta " PROMPT 35 13 "Tot. in valuta "
HELP "Totale del documento in valuta"
FIELD TOTDOCVAL FIELD TOTDOCVAL
GROUP 3 GROUP 3
PICTURE ".2" PICTURE ".2"
@ -481,7 +456,6 @@ END
STRING F_CODIVA 4 STRING F_CODIVA 4
BEGIN BEGIN
PROMPT 67 13 "IVA " PROMPT 67 13 "IVA "
HELP "Codice IVA del documento generante il movimento"
FLAGS "U" FLAGS "U"
USE %IVA USE %IVA
INPUT CODTAB F_CODIVA INPUT CODTAB F_CODIVA
@ -498,7 +472,6 @@ 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"
FIELD RITFIS FIELD RITFIS
FLAGS "RV" FLAGS "RV"
PICTURE "." PICTURE "."
@ -507,7 +480,6 @@ 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"
FIELD RITSOC FIELD RITSOC
FLAGS "RV" FLAGS "RV"
PICTURE "." PICTURE "."
@ -516,7 +488,6 @@ END
DATE F_DATA74TER DATE F_DATA74TER
BEGIN BEGIN
PROMPT 54 14 "Data 74/ter " PROMPT 54 14 "Data 74/ter "
HELP "Data per aliquota IVA ex art.74 ter"
WARNING "E' richiesta la data del 74/ter" WARNING "E' richiesta la data del 74/ter"
CHECKTYPE REQUIRED CHECKTYPE REQUIRED
FIELD DATA74TER FIELD DATA74TER
@ -535,13 +506,11 @@ BEGIN
PROMPT 68 15 "/ " PROMPT 68 15 "/ "
FIELD LF_PARTITE->NUMPART FIELD LF_PARTITE->NUMPART
FLAGS "U" FLAGS "U"
HELP "Numero di riferimento partita (documento o protocollo)"
END 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"
FIELD CODVALI FIELD CODVALI
FLAGS "UZ" FLAGS "UZ"
GROUP 4 GROUP 4
@ -552,7 +521,6 @@ BEGIN
DISPLAY "Cambio@15" R10 DISPLAY "Cambio@15" R10
DISPLAY "Ultimo aggiornamento" D0 DISPLAY "Ultimo aggiornamento" D0
OUTPUT F_VALUTAINTRA CODTAB OUTPUT F_VALUTAINTRA CODTAB
// OUTPUT F_CAMBIOINTRA R10
CHECKTYPE NORMAL CHECKTYPE NORMAL
WARNING "Codice valuta assente" WARNING "Codice valuta assente"
VALIDATE REQIF_FUNC 1 F_CORRVALUTA VALIDATE REQIF_FUNC 1 F_CORRVALUTA
@ -561,7 +529,6 @@ END
NUMBER F_CAMBIOINTRA 12 5 NUMBER F_CAMBIOINTRA 12 5
BEGIN BEGIN
PROMPT 37 17 "Cambio intracom. " PROMPT 37 17 "Cambio intracom. "
HELP "Cambio della valuta per operazione intracomunitaria"
FIELD CAMBIOI FIELD CAMBIOI
FLAGS "RU" FLAGS "RU"
GROUP 4 GROUP 4
@ -571,7 +538,6 @@ END
NUMBER F_CORRLIRE 15 NUMBER F_CORRLIRE 15
BEGIN BEGIN
PROMPT 1 18 "Corrispett. Lire " PROMPT 1 18 "Corrispett. Lire "
HELP "Corrispettivo in Lit. per operazioni intracomunitarie. Il tasto F8 lo pone uguale alla somma degli imponibili"
FIELD CORRLIRE FIELD CORRLIRE
FLAGS "R" FLAGS "R"
PICTURE "." PICTURE "."
@ -581,7 +547,6 @@ END
NUMBER F_CORRVALUTA 15 2 NUMBER F_CORRVALUTA 15 2
BEGIN BEGIN
PROMPT 37 18 "Corrispettivo valuta " PROMPT 37 18 "Corrispettivo valuta "
HELP "Corrispettivo in valuta per operazioni intracomunitarie"
FIELD CORRVALUTA FIELD CORRVALUTA
FLAGS "R" FLAGS "R"
PICTURE ".2" PICTURE ".2"

View File

@ -1514,7 +1514,8 @@ bool TPrimanota_application::datacomp_handler(TMask_field& f, KEY key)
f.set(datacomp); f.set(datacomp);
} }
const TDate dc(datacomp); // Data di competenza const TDate dc(datacomp); // Data di competenza
const int ae = date2esc(dc); // Esercizio corrispondente TEsercizi_contabili esc;
const int ae = esc.date2esc(dc); // Esercizio corrispondente
const char* data = "del 74/ter"; const char* data = "del 74/ter";
if (f.dlg() == F_DATACOMP) if (f.dlg() == F_DATACOMP)
@ -1525,8 +1526,8 @@ bool TPrimanota_application::datacomp_handler(TMask_field& f, KEY key)
if (ae) if (ae)
{ {
int pr; // Esercizio precedente const int ar = esc.date2esc(dr); // Esercizio in corso
const int ar = date2esc(dr, &pr); // Esercizio in corso const int pr = esc.pred(ar); // Esercizio precedente
if (ae != ar && ae != pr) if (ae != ar && ae != pr)
{ {
TString80 e; TString80 e;
@ -1566,23 +1567,24 @@ bool TPrimanota_application::data74ter_handler(TMask_field& f, KEY key)
bool TPrimanota_application::doc_handler(TMask_field& f, KEY key) bool TPrimanota_application::doc_handler(TMask_field& f, KEY key)
{ {
if (key == K_TAB && f.mask().is_running()) TMask& m = f.mask();
if (key == K_TAB && m.is_running())
{ {
TMask& m = f.mask();
const TString16 val(f.get()); const TString16 val(f.get());
if (!val.empty() && m.field(F_ANNORIF).active()) if (val.not_empty() && m.insert_mode() && m.field(F_ANNORIF).active())
{ // Se c'e' gestione saldaconto { // Se c'e' gestione saldaconto
if (f.dlg() == F_DATADOC) if (f.dlg() == F_DATADOC)
{ {
const TDate dd(val); const TDate dd(val);
m.set(F_ANNORIF, dd.year()); // copia data documento m.set(F_ANNORIF, dd.year()); // copia anno documento
if (app().pagamento() != NULL && m.insert_mode()) if (app().pagamento() != NULL)
app().recalc_scadenze(dd); app().recalc_scadenze(dd);
} }
else else
if (m.insert_mode() && !app().npart_is_prot()) if (!app().npart_is_prot())
{ {
if (m.get(F_NUMRIF).empty()) if (m.get(F_NUMRIF).empty())
m.set(F_NUMRIF, val); // copia numero documento m.set(F_NUMRIF, val); // copia numero documento
@ -1684,13 +1686,20 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key)
{ {
if (key == K_TAB && f.active()) if (key == K_TAB && f.active())
{ {
TMask& m = f.mask();
const char cf = app().clifo();
const long codice = atol(f.get()); const long codice = atol(f.get());
if (codice == 0) if (codice == 0)
{
m.hide(F_OCCASEDIT); // Spegni bottone occasionali
m.show(F_STATOPAIV); // Stato partita IVA
m.show(cf == 'C' ? F_PIVACLIENTE : F_PIVAFORNITORE); // Partita IVA
m.show(cf == 'C' ? F_COFICLIENTE : F_COFIFORNITORE); // Codice Fiscale
return TRUE; return TRUE;
}
TMask& m = f.mask();
const char cf = app().clifo();
TRelation cliforel(LF_CLIFO); cliforel.add(LF_CFVEN, "TIPOCF=TIPOCF|CODCF=CODCF"); TRelation cliforel(LF_CLIFO); cliforel.add(LF_CFVEN, "TIPOCF=TIPOCF|CODCF=CODCF");
TRectype& clifo = cliforel.curr(); TRectype& clifo = cliforel.curr();
clifo.put(CLI_TIPOCF, cf); clifo.put(CLI_TIPOCF, cf);

View File

@ -11,13 +11,13 @@
enum TipoIVA enum TipoIVA
{ {
iva_errata = -1, iva_errata = -1,
nessuna_iva = 0, nessuna_iva = 0,
iva_vendite = 1, iva_vendite = 1,
iva_acquisti = 2, iva_acquisti = 2,
libro_giornale = 5, libro_giornale = 5,
iva_generica = 9 iva_generica = 9
}; };
enum TipoConto enum TipoConto
{ {

View File

@ -204,7 +204,7 @@ protected:
#ifdef __EXTRA__ #ifdef __EXTRA__
bool edit_fattura(TPartita& p, int nriga); bool edit_fattura(TPartita& p, int nriga);
void prima_nota(const long nreg); bool prima_nota(const long nreg);
#endif #endif
bool cerca_valuta(TValuta& val) const; bool cerca_valuta(TValuta& val) const;
@ -712,11 +712,14 @@ int TGame_mask::nuova_riga(TPartita& partita) const
int TGame_mask::nuovo_pagamento(TPartita& partita, int nriga, int rata) const int TGame_mask::nuovo_pagamento(TPartita& partita, int nriga, int rata) const
{ {
const TBill& conto = partita.conto(); // Legge conto principale const TBill& conto = partita.conto(); // Legge conto principale
#ifdef __EXTRA__
const int nrigp = nuova_riga(partita);
#else
int nrigp = partita.mov2rig(_numreg, _numrig); // Cerca riga partita relativa alla riga rmov int nrigp = partita.mov2rig(_numreg, _numrig); // Cerca riga partita relativa alla riga rmov
if (nrigp <= 0) // Devo creare una nuova riga di partita if (nrigp <= 0) // Devo creare una nuova riga di partita
nrigp = nuova_riga(partita); nrigp = nuova_riga(partita);
#endif
TRectype& pagamento = partita.pagamento(nriga, rata, nrigp); // Crea nuovo pagamento TRectype& pagamento = partita.pagamento(nriga, rata, nrigp); // Crea nuovo pagamento
int caus = 2; // Calcola riga causale per la contropartita in base al tipo pagamento int caus = 2; // Calcola riga causale per la contropartita in base al tipo pagamento
@ -802,17 +805,15 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
nreg = gm._numreg; nreg = gm._numreg;
} }
bool cambiato = FALSE;
if (nrigp > 0) // Si vuole editare un pagamento if (nrigp > 0) // Si vuole editare un pagamento
{ {
if (nreg == gm._numreg) if (nreg == gm._numreg)
{ {
const bool dirty = gm.edit_pagamento(game, nriga, nrata, nrigp); cambiato = gm.edit_pagamento(game, nriga, nrata, nrigp);
if (dirty) if (cambiato)
{ {
gm.update_partita(game, gm._riga_partite);
partite_notify(gm.partite(), gm._riga_partite, K_TAB);
gm._changed = TRUE;
if (!game.esiste(nriga, nrata, nrigp)) if (!game.esiste(nriga, nrata, nrigp))
m.stop_run(K_ESC); m.stop_run(K_ESC);
} }
@ -832,7 +833,7 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
if (nreg > 0) if (nreg > 0)
gm.prima_nota(nreg); gm.prima_nota(nreg);
else else
gm.edit_fattura(game, nriga); cambiato = gm.edit_fattura(game, nriga);
#else #else
if (nreg != gm._numreg || nrata == 0) if (nreg != gm._numreg || nrata == 0)
{ {
@ -844,6 +845,12 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
} }
#endif #endif
} }
if (cambiato)
{
gm.update_partita(game, gm._riga_partite);
partite_notify(gm.partite(), gm._riga_partite, K_TAB);
gm._changed = TRUE;
}
} }
return TRUE; return TRUE;
} }
@ -898,7 +905,7 @@ 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*)game.numero());
if (gm._tipomov > 1) if (gm._tipomov > 1)
{ {
@ -1038,7 +1045,7 @@ void TGame_mask::update_saldo_clifo()
r << "cliente"; r << "cliente";
else else
r << "fornitore"; r << "fornitore";
r << conto().sottoconto(); r << ' ' << conto().sottoconto();
} }
bool TGame_mask::same_number(const char* s1, const char* s2) const bool TGame_mask::same_number(const char* s1, const char* s2) const
@ -1058,7 +1065,7 @@ void TGame_mask::fill_partite(int annorif, const char* numrif)
app().begin_wait(); app().begin_wait();
for (TPartita* gioco = app().partite().first(); gioco != NULL; gioco = app().partite().next()) for (TPartita* gioco = app().partite().first(); gioco != NULL; gioco = app().partite().next())
update_partita(*gioco, -1); // Memorizza posizione di inserimento update_partita(*gioco, -1);
TLocalisamfile partita(LF_PARTITE); TLocalisamfile partita(LF_PARTITE);
partita.zero(); partita.zero();
@ -1102,7 +1109,7 @@ void TGame_mask::fill_partite(int annorif, const char* numrif)
if (a.items() > 1) if (a.items() > 1)
{ {
partite_notify(partite(), 0, K_TAB); partite_notify(partite(), r, K_TAB);
} }
else else
{ {
@ -1134,7 +1141,14 @@ bool TGame_mask::edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) co
} }
m.set(S_DESCAGG, somma.get(PART_DESCR)); m.set(S_DESCAGG, somma.get(PART_DESCR));
const KEY key = m.run(); const bool nuovo = oldpag.get(PAGSCA_ACCSAL) != "S" &&
oldpag.get_real(PAGSCA_IMPORTO).is_zero();
KEY key = m.run();
if (key == K_ESC && nuovo)
key = K_DEL;
if (key == K_ENTER || key == K_DEL) if (key == K_ENTER || key == K_DEL)
{ {
if (key == K_DEL) if (key == K_DEL)
@ -1171,7 +1185,7 @@ bool TGame_mask::edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) co
bool TPrimanota_application::edit_partite(const TMask& m, int riga) bool TPrimanota_application::edit_partite(const TMask& m, int riga)
{ {
const TImporto imp = get_cgs_imp(riga); const TImporto imp = get_cgs_imp(riga);
if (imp.is_zero()) // Esci se 'importo e' nullo if (imp.is_zero()) // Esci se importo e' nullo
return FALSE; return FALSE;
const char tipo = m.get(103)[0]; const char tipo = m.get(103)[0];

View File

@ -50,6 +50,9 @@ protected: // TApplication
virtual bool create(); virtual bool create();
virtual bool destroy(); virtual bool destroy();
virtual bool menu(MENU_TAG m); virtual bool menu(MENU_TAG m);
protected:
static bool date_handler(TMask_field& f, KEY k);
public: public:
void inizia_saldi(const TRectype& mov); void inizia_saldi(const TRectype& mov);
@ -226,33 +229,44 @@ bool TProvvisori_app::delete_provv(TCursor& cur, TProgind& pi)
bool TProvvisori_app::filter(const TRelation* rel) bool TProvvisori_app::filter(const TRelation* rel)
{ {
TLocalisamfile& mov = rel->lfile(); bool ok = FALSE;
if (mov.get_char(MOV_PROVVIS) <= ' ')
return FALSE;
const char* caus = mov.get(MOV_CODCAUS); const TRectype& mov = rel->curr();
if (app()._from_caus.not_empty() && app()._from_caus < caus) if (mov.get_char(MOV_PROVVIS) > ' ')
return FALSE; {
const char* caus = mov.get(MOV_CODCAUS);
ok = app()._from_caus <= caus && app()._to_caus >= caus;
}
if (app()._to_caus.not_empty() && app()._to_caus > caus) return ok;
return FALSE; }
return TRUE; // Deve essere specificata almeno una data (inizio o fine)
bool TProvvisori_app::date_handler(TMask_field& f, KEY k)
{
bool ok = TRUE;
if (k == K_ENTER && f.get().empty())
{
const TMask& m = f.mask();
if (m.get(F_TODATE).empty())
ok = error_box("E' necessario specificare almeno una data");
}
return ok;
} }
bool TProvvisori_app::menu(MENU_TAG) bool TProvvisori_app::menu(MENU_TAG)
{ {
TMask m("cg2200a"); TMask m("cg2200a");
m.set_handler(F_FROMDATE, date_handler);
TCursor& cur = *m.efield(F_FROMDATE).browse()->cursor(); TCursor& cur = *m.efield(F_FROMDATE).browse()->cursor();
TLocalisamfile& mov = cur.file(LF_MOV);
KEY key; KEY key;
while ((key = m.run()) != K_QUIT) while ((key = m.run()) != K_QUIT)
{ {
mov.zero(); TRectype from(LF_MOV);
TRectype from(mov.curr()); TRectype to(LF_MOV);
TRectype to(mov.curr());
const char* s = m.get(F_FROMDATE); const char* s = m.get(F_FROMDATE);
@ -306,7 +320,7 @@ bool TProvvisori_app::menu(MENU_TAG)
action[0] = toupper(action[0]); action[0] = toupper(action[0]);
TProgind pi(total, action, FALSE, TRUE, 24); TProgind pi(total, action, FALSE, TRUE, 24);
cur.freeze(); cur.freeze(TRUE);
if (key == K_ENTER) if (key == K_ENTER)
confirm_provv(cur, pi); confirm_provv(cur, pi);
@ -317,6 +331,7 @@ bool TProvvisori_app::menu(MENU_TAG)
from.zero(); to.zero(); from.zero(); to.zero();
cur.setregion(from, to); cur.setregion(from, to);
cur.set_filterfunction(NULL); cur.set_filterfunction(NULL);
m.reset();
} }
return FALSE; return FALSE;

View File

@ -1,14 +1,21 @@
#ifndef __CGLIB_H #ifndef __CGLIB_H
#define __CGLIB_H #define __CGLIB_H
#ifndef __ISAM_H #ifndef __ASSOC_H
#include <isam.h> #include <assoc.h>
#endif #endif
#include <assoc.h> #ifndef __TABUTIL_H
#include "conto.h" #include <tabutil.h>
#include "cg2103.h" // per TCausale #endif
#ifndef __CONTO_H
#include "conto.h"
#endif
#ifndef __CG2103_H
#include "cg2103.h" // per TCausale
#endif
class TCaus : public TCausale class TCaus : public TCausale
{ {
@ -148,5 +155,52 @@ public:
int items() const { return _tab_conti.items();} int items() const { return _tab_conti.items();}
}; };
class TEsercizio : public TSortable
{
int _codice;
TDate _inizio, _fine, _scarico;
protected: // TSortable
int compare(const TSortable& s) const;
public:
int codice() const { return _codice; }
const TDate& inizio() const { return _inizio; }
const TDate& fine() const { return _fine; }
const TDate& scarico() const { return _scarico; }
TEsercizio(const TRectype& rec);
virtual ~TEsercizio() {}
};
class TEsercizi_contabili : private TArray
{
long _firm;
protected:
void check();
const TEsercizio& esc(int i) const
{ return (const TEsercizio&)operator[](i); }
int date2index(const TDate& d);
int esc2index(int codice);
public:
void update();
const TEsercizio& esercizio(int codice);
int date2esc(const TDate& date);
int pred(int codice);
int next(int codice);
int first();
int last();
bool exist(int codice);
TEsercizi_contabili();
virtual ~TEsercizi_contabili() {}
};
#endif #endif

View File

@ -7,14 +7,13 @@
#include <stdlib.h> #include <stdlib.h>
#include <isam.h> #include <applicat.h>
#include <utility.h> #include <utility.h>
#include <saldi.h>
#include "conto.h"
#include "cglib.h" #include "cglib.h"
#include <saldi.h>
TConto* TTab_conti::add(const TBill& c, int anno) TConto* TTab_conti::add(const TBill& c, int anno)
{ {
TString80 key; TString80 key;
@ -257,3 +256,118 @@ void TSaldo_agg::registra()
} }
///////////////////////////////////////////////////////////
// Gestione Tabella esercizi
///////////////////////////////////////////////////////////
TEsercizio::TEsercizio(const TRectype& rec)
{
_codice = rec.get_int("CODTAB");
_inizio = rec.get("D0");
_fine = rec.get("D1");
_scarico = rec.get("D2");
}
int TEsercizio::compare(const TSortable& s) const
{
const TEsercizio& e = (const TEsercizio&)s;
return _inizio > e._inizio ? +1 : -1;
}
TEsercizi_contabili::TEsercizi_contabili() : _firm(0)
{ }
void TEsercizi_contabili::update()
{
_firm = main_app().get_firm();
destroy();
TTable esc("ESC");
for (int err = esc.first(); err == NOERR; err = esc.next())
{
TEsercizio* e = new TEsercizio(esc.curr());
add(e);
}
sort();
}
void TEsercizi_contabili::check()
{
if (_firm != main_app().get_firm())
{
#ifdef DBG
if (_firm != 0)
error_box("Questo programma usa gli esercizi, ma non tiene conto del cambio ditta!");
#endif
update();
}
}
int TEsercizi_contabili::date2index(const TDate& d)
{
check();
for (int i = items()-1; i >= 0; i--)
{
const TEsercizio& e = esc(i);
if (d >= e.inizio() && d <= e.fine())
break;
}
return i;
}
int TEsercizi_contabili::esc2index(int codice)
{
check();
for (int i = items()-1; i >= 0; i--)
{
const TEsercizio& e = esc(i);
if (codice == e.codice())
break;
}
return i;
}
int TEsercizi_contabili::date2esc(const TDate& d)
{
const int i = date2index(d);
return i >= 0 ? esc(i).codice() : 0;
}
int TEsercizi_contabili::first()
{
check();
return items() ? esc(0).codice() : 0;
}
int TEsercizi_contabili::last()
{
check();
return items() ? esc(items()-1).codice() : 0;
}
int TEsercizi_contabili::pred(int codice)
{
const int i = esc2index(codice);
return i > 0 ? esc(i-1).codice() : 0;
}
int TEsercizi_contabili::next(int anno)
{
const int i = esc2index(anno);
return i < items()-1 ? esc(i+1).codice() : 0;
}
bool TEsercizi_contabili::exist(int codice)
{
const int i = esc2index(codice);
return i >= 0;
}
const TEsercizio& TEsercizi_contabili::esercizio(int codice)
{
const int i = esc2index(codice);
return esc(i);
}

View File

@ -509,9 +509,11 @@ TRiga_scadenze& TRiga_partite::new_row(int r)
return scad; return scad;
} }
void TRiga_partite::elimina_rate() void TRiga_partite::elimina_rata(int r)
{ {
for (int r = rate(); r > 0; r--) const int from = r <= 0 ? 1 : r;
const int to = r <= 0 ? rate() : r;
for (r = from; r <= to; r++)
{ {
TRiga_scadenze& scad = rata(r); TRiga_scadenze& scad = rata(r);
for (int p = scad.last(); p > 0; p = scad.pred(p)) for (int p = scad.last(); p > 0; p = scad.pred(p))
@ -1156,28 +1158,14 @@ bool TPartita::chiusa(bool update)
if (update) if (update)
{ {
bool forse_chiusa = TRUE; TImporto saldo, doc, pag, imp;
for (int p = last(); p > 0 && forse_chiusa; p = pred(p)) calcola_saldo(saldo, doc, pag, imp);
{
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.chiusa())
{
forse_chiusa = FALSE;
break;
}
}
}
}
if (chiusa != forse_chiusa) const bool ora_chiusa = saldo.is_zero();
if (chiusa != ora_chiusa)
{ {
chiusa = forse_chiusa; chiusa = ora_chiusa;
for (p = last(); p > 0; p = pred(p)) for (int p = last(); p > 0; p = pred(p))
{ {
TRiga_partite& part = riga(p); TRiga_partite& part = riga(p);
part.put(PART_CHIUSA, chiusa); part.put(PART_CHIUSA, chiusa);
@ -1192,10 +1180,11 @@ void TPartita::rimuovi_riga(int r)
{ {
TRiga_partite& row = riga(r); TRiga_partite& row = riga(r);
if (row.rate() > 0) if (row.rate() > 0)
row.elimina_rate(); row.elimina_rata(-1);
else else
CHECKD(!utilizzata(r), "Can't remove still referenced row ", r); CHECKD(!utilizzata(r), "Can't remove still referenced row ", r);
_part.destroy_row(r); _part.destroy_row(r);
chiusa(TRUE);
} }

View File

@ -161,7 +161,7 @@ public: // TTree_rectype
public: public:
int rate() const { return _recarr.rows(); } int rate() const { return _recarr.rows(); }
TRiga_scadenze& rata(int r) const { return (TRiga_scadenze&)_recarr.row(r); } TRiga_scadenze& rata(int r) const { return (TRiga_scadenze&)_recarr.row(r); }
void elimina_rate(); void elimina_rata(int r = 0);
TRiga_scadenze& new_row(int r = 0); TRiga_scadenze& new_row(int r = 0);
bool is_fattura() const; bool is_fattura() const;