Gestione saldaconto
git-svn-id: svn://10.65.10.50/trunk@2165 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
0245a5243a
commit
f770af567e
@ -52,7 +52,6 @@ END
|
||||
DATE F_DATAREG
|
||||
BEGIN
|
||||
PROMPT 1 3 "Data operazione "
|
||||
HELP "Data in cui viene registrata l'operazione"
|
||||
FIELD DATAREG
|
||||
MESSAGE COPY,H_DATAREG|COPY,F_ANNOIVA,7,10
|
||||
CHECKTYPE REQUIRED
|
||||
@ -68,7 +67,6 @@ END
|
||||
DATE F_DATACOMP
|
||||
BEGIN
|
||||
PROMPT 1 4 "Data competenza "
|
||||
HELP "Data di competenza dell'operazione"
|
||||
FIELD DATACOMP
|
||||
CHECKTYPE REQUIRED
|
||||
END
|
||||
@ -91,7 +89,6 @@ END
|
||||
STRING F_CODCAUS 3
|
||||
BEGIN
|
||||
PROMPT 1 5 "Causale "
|
||||
HELP "Codice della causale generante l'operazione"
|
||||
FLAGS "UZ"
|
||||
FIELD CODCAUS
|
||||
USE LF_CAUSALI SELECT REG!=""
|
||||
@ -113,7 +110,6 @@ END
|
||||
STRING F_DESCRCAUS 50
|
||||
BEGIN
|
||||
PROMPT 25 5 ""
|
||||
HELP "Descrizione della causale generante l'operazione"
|
||||
USE LF_CAUSALI KEY 2 SELECT REG!=""
|
||||
INPUT DESCR F_DESCRCAUS
|
||||
DISPLAY "Descrizione@50" DESCR
|
||||
@ -130,7 +126,6 @@ DATE F_DATADOC
|
||||
BEGIN
|
||||
PROMPT 1 6 "Data documento "
|
||||
FIELD DATADOC
|
||||
HELP "Data del documento che ha generato il movimento"
|
||||
WARNING "Inserire una data documento non superiore alla data dell'operazione"
|
||||
VALIDATE DATE_CMP_FUNC <= F_DATAREG
|
||||
END
|
||||
@ -152,7 +147,6 @@ END
|
||||
STRING F_NUMDOC 7
|
||||
BEGIN
|
||||
PROMPT 57 6 "Documento n. "
|
||||
HELP "Numero del documento che ha generato il movimento"
|
||||
FIELD NUMDOC
|
||||
WARNING "La causale o il saldaconto richiedono il numero documento"
|
||||
END
|
||||
@ -160,13 +154,11 @@ END
|
||||
BOOLEAN F_SOLAIVA
|
||||
BEGIN
|
||||
PROMPT 1 7 "Movimento di sola IVA"
|
||||
HELP "Indicare se non vi sono righe di contabilita'"
|
||||
END
|
||||
|
||||
LIST F_PROVVISORIO 1 25
|
||||
BEGIN
|
||||
PROMPT 31 7 "Movimento provvisorio "
|
||||
HELP "Indicare se si tratta di movimento provvisorio"
|
||||
FIELD PROVVIS
|
||||
ITEM " |No (movimento normale)"
|
||||
ITEM "P|Si (cancellabile)"
|
||||
@ -177,7 +169,6 @@ END
|
||||
STRING F_DESCAGG 5
|
||||
BEGIN
|
||||
PROMPT 1 8 "Descrizione "
|
||||
HELP "Codice della descrizione del movimento"
|
||||
FLAGS "UZ"
|
||||
USE %DPN
|
||||
INPUT CODTAB F_DESCAGG
|
||||
@ -192,7 +183,6 @@ END
|
||||
STRING F_DESCR 50
|
||||
BEGIN
|
||||
PROMPT 25 8 ""
|
||||
HELP "Descrizione del movimento"
|
||||
FIELD DESCR
|
||||
USE %DPN KEY 2
|
||||
INPUT S0 F_DESCR
|
||||
@ -204,14 +194,12 @@ END
|
||||
NUMBER F_PROTIVA 5
|
||||
BEGIN
|
||||
PROMPT 1 9 "Protocollo IVA "
|
||||
HELP "Numero progressivo di protocollo IVA"
|
||||
FIELD PROTIVA
|
||||
END
|
||||
|
||||
NUMBER F_RIEPILOGO 5
|
||||
BEGIN
|
||||
PROMPT 25 9 "Riepilogo fino al n. "
|
||||
HELP "Numero finale del documento ripilogativo di protocollo IVA"
|
||||
FIELD UPROTIVA
|
||||
NUM_EXPR {(#F_RIEPILOGO==0)||(#F_RIEPILOGO>=#F_PROTIVA)}
|
||||
WARNING "Inserire un riepilogo non inferiore al protocollo IVA (Obbigatorio se il cliete/fornitore ha codice inserimento in allegati uguale a 3)"
|
||||
@ -243,7 +231,6 @@ END
|
||||
NUMBER F_CLIENTE 6
|
||||
BEGIN
|
||||
PROMPT 1 10 "Cliente "
|
||||
HELP "Codice del cliente"
|
||||
FLAGS "R"
|
||||
FIELD CODCF
|
||||
GROUP 1
|
||||
@ -270,7 +257,6 @@ NUMBER F_FORNITORE 6
|
||||
BEGIN
|
||||
PROMPT 1 10 "Fornitore "
|
||||
FLAGS "R"
|
||||
HELP "Codice del fornitore"
|
||||
FIELD CODCF
|
||||
GROUP 2
|
||||
USE LF_CLIFO KEY 1
|
||||
@ -295,7 +281,6 @@ END
|
||||
STRING F_RAGSOCFORNITORE 50
|
||||
BEGIN
|
||||
PROMPT 25 10 ""
|
||||
HELP "Ragione sociale del fornitore"
|
||||
GROUP 2
|
||||
USE LF_CLIFO KEY 2
|
||||
INPUT TIPOCF "F"
|
||||
@ -312,7 +297,6 @@ END
|
||||
STRING F_RAGSOCCLIENTE 50
|
||||
BEGIN
|
||||
PROMPT 25 10 ""
|
||||
HELP "Ragione sociale del cliente del documento"
|
||||
GROUP 1
|
||||
USE LF_CLIFO KEY 2
|
||||
INPUT TIPOCF "C"
|
||||
@ -328,7 +312,6 @@ END
|
||||
STRING F_COFICLIENTE 16
|
||||
BEGIN
|
||||
PROMPT 1 11 "C.F. "
|
||||
HELP "Codice fiscale del cliente del documento"
|
||||
GROUP 1
|
||||
USE LF_CLIFO KEY 4
|
||||
INPUT TIPOCF "C"
|
||||
@ -344,7 +327,6 @@ END
|
||||
STRING F_COFIFORNITORE 16
|
||||
BEGIN
|
||||
PROMPT 1 11 "C.F. "
|
||||
HELP "Codice fiscale del fornitore del documento"
|
||||
GROUP 2
|
||||
USE LF_CLIFO KEY 4
|
||||
INPUT TIPOCF "F"
|
||||
@ -358,7 +340,6 @@ END
|
||||
STRING F_PIVACLIENTE 12
|
||||
BEGIN
|
||||
PROMPT 28 11 "Partita IVA "
|
||||
HELP "Partita IVA del cliente del documento"
|
||||
GROUP 1
|
||||
USE LF_CLIFO KEY 5
|
||||
INPUT TIPOCF "C"
|
||||
@ -375,7 +356,6 @@ END
|
||||
STRING F_PIVAFORNITORE 12
|
||||
BEGIN
|
||||
PROMPT 28 11 "Partita IVA "
|
||||
HELP "Partita IVA del fornitore del documento"
|
||||
GROUP 2
|
||||
USE LF_CLIFO KEY 5
|
||||
INPUT TIPOCF "F"
|
||||
@ -390,7 +370,6 @@ END
|
||||
LIST F_STATOPAIV 18
|
||||
BEGIN
|
||||
PROMPT 57 11 ""
|
||||
HELP "Codice ISO dello stato per la partita IVA"
|
||||
ITEM " |Italia o extra CEE"
|
||||
ITEM "BE|Belgio"
|
||||
ITEM "DE|Germania"
|
||||
@ -416,7 +395,6 @@ END
|
||||
STRING S_VALUTA 3
|
||||
BEGIN
|
||||
PROMPT 1 12 "Valuta "
|
||||
HELP "Codice della valuta per operazione con l'estero"
|
||||
FIELD CODVAL
|
||||
FLAGS "UZ"
|
||||
GROUP 3
|
||||
@ -452,7 +430,6 @@ END
|
||||
NUMBER S_CAMBIO 15 5
|
||||
BEGIN
|
||||
PROMPT 55 12 "Cambio "
|
||||
HELP "Cambio della valuta per operazione con l'estero"
|
||||
FIELD CAMBIO
|
||||
FLAGS "RU"
|
||||
GROUP 3
|
||||
@ -463,7 +440,6 @@ END
|
||||
NUMBER F_TOTALE 15
|
||||
BEGIN
|
||||
PROMPT 1 13 "Totale documento "
|
||||
HELP "Totale del documento generante il movimento"
|
||||
FIELD TOTDOC
|
||||
PICTURE "."
|
||||
END
|
||||
@ -471,7 +447,6 @@ 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"
|
||||
@ -481,7 +456,6 @@ END
|
||||
STRING F_CODIVA 4
|
||||
BEGIN
|
||||
PROMPT 67 13 "IVA "
|
||||
HELP "Codice IVA del documento generante il movimento"
|
||||
FLAGS "U"
|
||||
USE %IVA
|
||||
INPUT CODTAB F_CODIVA
|
||||
@ -498,7 +472,6 @@ END
|
||||
NUMBER F_RITFIS 15
|
||||
BEGIN
|
||||
PROMPT 1 14 "Ritenute fiscali "
|
||||
HELP "Ritenute fiscali del documento generante il movimento"
|
||||
FIELD RITFIS
|
||||
FLAGS "RV"
|
||||
PICTURE "."
|
||||
@ -507,7 +480,6 @@ END
|
||||
NUMBER F_RITSOC 15
|
||||
BEGIN
|
||||
PROMPT 1 15 "Ritenute sociali "
|
||||
HELP "Ritenute fiscali del documento generante il movimento"
|
||||
FIELD RITSOC
|
||||
FLAGS "RV"
|
||||
PICTURE "."
|
||||
@ -516,7 +488,6 @@ END
|
||||
DATE F_DATA74TER
|
||||
BEGIN
|
||||
PROMPT 54 14 "Data 74/ter "
|
||||
HELP "Data per aliquota IVA ex art.74 ter"
|
||||
WARNING "E' richiesta la data del 74/ter"
|
||||
CHECKTYPE REQUIRED
|
||||
FIELD DATA74TER
|
||||
@ -535,13 +506,11 @@ BEGIN
|
||||
PROMPT 68 15 "/ "
|
||||
FIELD LF_PARTITE->NUMPART
|
||||
FLAGS "U"
|
||||
HELP "Numero di riferimento partita (documento o protocollo)"
|
||||
END
|
||||
|
||||
STRING F_VALUTAINTRA 3
|
||||
BEGIN
|
||||
PROMPT 1 17 "Valuta intracom. "
|
||||
HELP "Codice della valuta per operazione intracomunitaria"
|
||||
FIELD CODVALI
|
||||
FLAGS "UZ"
|
||||
GROUP 4
|
||||
@ -552,7 +521,6 @@ BEGIN
|
||||
DISPLAY "Cambio@15" R10
|
||||
DISPLAY "Ultimo aggiornamento" D0
|
||||
OUTPUT F_VALUTAINTRA CODTAB
|
||||
// OUTPUT F_CAMBIOINTRA R10
|
||||
CHECKTYPE NORMAL
|
||||
WARNING "Codice valuta assente"
|
||||
VALIDATE REQIF_FUNC 1 F_CORRVALUTA
|
||||
@ -561,7 +529,6 @@ END
|
||||
NUMBER F_CAMBIOINTRA 12 5
|
||||
BEGIN
|
||||
PROMPT 37 17 "Cambio intracom. "
|
||||
HELP "Cambio della valuta per operazione intracomunitaria"
|
||||
FIELD CAMBIOI
|
||||
FLAGS "RU"
|
||||
GROUP 4
|
||||
@ -571,7 +538,6 @@ END
|
||||
NUMBER F_CORRLIRE 15
|
||||
BEGIN
|
||||
PROMPT 1 18 "Corrispett. Lire "
|
||||
HELP "Corrispettivo in Lit. per operazioni intracomunitarie. Il tasto F8 lo pone uguale alla somma degli imponibili"
|
||||
FIELD CORRLIRE
|
||||
FLAGS "R"
|
||||
PICTURE "."
|
||||
@ -581,7 +547,6 @@ END
|
||||
NUMBER F_CORRVALUTA 15 2
|
||||
BEGIN
|
||||
PROMPT 37 18 "Corrispettivo valuta "
|
||||
HELP "Corrispettivo in valuta per operazioni intracomunitarie"
|
||||
FIELD CORRVALUTA
|
||||
FLAGS "R"
|
||||
PICTURE ".2"
|
||||
|
@ -1514,7 +1514,8 @@ bool TPrimanota_application::datacomp_handler(TMask_field& f, KEY key)
|
||||
f.set(datacomp);
|
||||
}
|
||||
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";
|
||||
if (f.dlg() == F_DATACOMP)
|
||||
@ -1525,8 +1526,8 @@ bool TPrimanota_application::datacomp_handler(TMask_field& f, KEY key)
|
||||
|
||||
if (ae)
|
||||
{
|
||||
int pr; // Esercizio precedente
|
||||
const int ar = date2esc(dr, &pr); // Esercizio in corso
|
||||
const int ar = esc.date2esc(dr); // Esercizio in corso
|
||||
const int pr = esc.pred(ar); // Esercizio precedente
|
||||
if (ae != ar && ae != pr)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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());
|
||||
|
||||
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
|
||||
if (f.dlg() == F_DATADOC)
|
||||
{
|
||||
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);
|
||||
}
|
||||
else
|
||||
if (m.insert_mode() && !app().npart_is_prot())
|
||||
if (!app().npart_is_prot())
|
||||
{
|
||||
if (m.get(F_NUMRIF).empty())
|
||||
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())
|
||||
{
|
||||
TMask& m = f.mask();
|
||||
const char cf = app().clifo();
|
||||
|
||||
const long codice = atol(f.get());
|
||||
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;
|
||||
}
|
||||
|
||||
TMask& m = f.mask();
|
||||
|
||||
const char cf = app().clifo();
|
||||
TRelation cliforel(LF_CLIFO); cliforel.add(LF_CFVEN, "TIPOCF=TIPOCF|CODCF=CODCF");
|
||||
TRectype& clifo = cliforel.curr();
|
||||
clifo.put(CLI_TIPOCF, cf);
|
||||
|
12
cg/cg2103.h
12
cg/cg2103.h
@ -11,13 +11,13 @@
|
||||
|
||||
enum TipoIVA
|
||||
{
|
||||
iva_errata = -1,
|
||||
nessuna_iva = 0,
|
||||
iva_vendite = 1,
|
||||
iva_acquisti = 2,
|
||||
iva_errata = -1,
|
||||
nessuna_iva = 0,
|
||||
iva_vendite = 1,
|
||||
iva_acquisti = 2,
|
||||
libro_giornale = 5,
|
||||
iva_generica = 9
|
||||
};
|
||||
iva_generica = 9
|
||||
};
|
||||
|
||||
enum TipoConto
|
||||
{
|
||||
|
@ -204,7 +204,7 @@ protected:
|
||||
|
||||
#ifdef __EXTRA__
|
||||
bool edit_fattura(TPartita& p, int nriga);
|
||||
void prima_nota(const long nreg);
|
||||
bool prima_nota(const long nreg);
|
||||
#endif
|
||||
|
||||
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
|
||||
{
|
||||
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
|
||||
|
||||
if (nrigp <= 0) // Devo creare una nuova riga di partita
|
||||
nrigp = nuova_riga(partita);
|
||||
|
||||
#endif
|
||||
TRectype& pagamento = partita.pagamento(nriga, rata, nrigp); // Crea nuovo 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;
|
||||
}
|
||||
|
||||
bool cambiato = FALSE;
|
||||
|
||||
if (nrigp > 0) // Si vuole editare un pagamento
|
||||
{
|
||||
if (nreg == gm._numreg)
|
||||
{
|
||||
const bool dirty = gm.edit_pagamento(game, nriga, nrata, nrigp);
|
||||
if (dirty)
|
||||
cambiato = gm.edit_pagamento(game, nriga, nrata, nrigp);
|
||||
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))
|
||||
m.stop_run(K_ESC);
|
||||
}
|
||||
@ -832,7 +833,7 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
|
||||
if (nreg > 0)
|
||||
gm.prima_nota(nreg);
|
||||
else
|
||||
gm.edit_fattura(game, nriga);
|
||||
cambiato = gm.edit_fattura(game, nriga);
|
||||
#else
|
||||
if (nreg != gm._numreg || nrata == 0)
|
||||
{
|
||||
@ -844,6 +845,12 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (cambiato)
|
||||
{
|
||||
gm.update_partita(game, gm._riga_partite);
|
||||
partite_notify(gm.partite(), gm._riga_partite, K_TAB);
|
||||
gm._changed = 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);
|
||||
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)
|
||||
{
|
||||
@ -1038,7 +1045,7 @@ void TGame_mask::update_saldo_clifo()
|
||||
r << "cliente";
|
||||
else
|
||||
r << "fornitore";
|
||||
r << conto().sottoconto();
|
||||
r << ' ' << conto().sottoconto();
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
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);
|
||||
partita.zero();
|
||||
@ -1102,7 +1109,7 @@ void TGame_mask::fill_partite(int annorif, const char* numrif)
|
||||
|
||||
if (a.items() > 1)
|
||||
{
|
||||
partite_notify(partite(), 0, K_TAB);
|
||||
partite_notify(partite(), r, K_TAB);
|
||||
}
|
||||
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));
|
||||
|
||||
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_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)
|
||||
{
|
||||
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;
|
||||
|
||||
const char tipo = m.get(103)[0];
|
||||
|
@ -50,6 +50,9 @@ protected: // TApplication
|
||||
virtual bool create();
|
||||
virtual bool destroy();
|
||||
virtual bool menu(MENU_TAG m);
|
||||
|
||||
protected:
|
||||
static bool date_handler(TMask_field& f, KEY k);
|
||||
|
||||
public:
|
||||
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)
|
||||
{
|
||||
TLocalisamfile& mov = rel->lfile();
|
||||
if (mov.get_char(MOV_PROVVIS) <= ' ')
|
||||
return FALSE;
|
||||
{
|
||||
bool ok = FALSE;
|
||||
|
||||
const char* caus = mov.get(MOV_CODCAUS);
|
||||
if (app()._from_caus.not_empty() && app()._from_caus < caus)
|
||||
return FALSE;
|
||||
const TRectype& mov = rel->curr();
|
||||
if (mov.get_char(MOV_PROVVIS) > ' ')
|
||||
{
|
||||
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 FALSE;
|
||||
|
||||
return TRUE;
|
||||
return ok;
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
TMask m("cg2200a");
|
||||
m.set_handler(F_FROMDATE, date_handler);
|
||||
|
||||
TCursor& cur = *m.efield(F_FROMDATE).browse()->cursor();
|
||||
TLocalisamfile& mov = cur.file(LF_MOV);
|
||||
|
||||
KEY key;
|
||||
while ((key = m.run()) != K_QUIT)
|
||||
{
|
||||
mov.zero();
|
||||
TRectype from(mov.curr());
|
||||
TRectype to(mov.curr());
|
||||
TRectype from(LF_MOV);
|
||||
TRectype to(LF_MOV);
|
||||
|
||||
const char* s = m.get(F_FROMDATE);
|
||||
|
||||
@ -306,7 +320,7 @@ bool TProvvisori_app::menu(MENU_TAG)
|
||||
action[0] = toupper(action[0]);
|
||||
TProgind pi(total, action, FALSE, TRUE, 24);
|
||||
|
||||
cur.freeze();
|
||||
cur.freeze(TRUE);
|
||||
|
||||
if (key == K_ENTER)
|
||||
confirm_provv(cur, pi);
|
||||
@ -317,6 +331,7 @@ bool TProvvisori_app::menu(MENU_TAG)
|
||||
from.zero(); to.zero();
|
||||
cur.setregion(from, to);
|
||||
cur.set_filterfunction(NULL);
|
||||
m.reset();
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
64
cg/cglib.h
64
cg/cglib.h
@ -1,14 +1,21 @@
|
||||
#ifndef __CGLIB_H
|
||||
#define __CGLIB_H
|
||||
|
||||
#ifndef __ISAM_H
|
||||
#include <isam.h>
|
||||
#ifndef __ASSOC_H
|
||||
#include <assoc.h>
|
||||
#endif
|
||||
|
||||
#include <assoc.h>
|
||||
#include "conto.h"
|
||||
#include "cg2103.h" // per TCausale
|
||||
#ifndef __TABUTIL_H
|
||||
#include <tabutil.h>
|
||||
#endif
|
||||
|
||||
#ifndef __CONTO_H
|
||||
#include "conto.h"
|
||||
#endif
|
||||
|
||||
#ifndef __CG2103_H
|
||||
#include "cg2103.h" // per TCausale
|
||||
#endif
|
||||
|
||||
class TCaus : public TCausale
|
||||
{
|
||||
@ -148,5 +155,52 @@ public:
|
||||
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
|
||||
|
||||
|
122
cg/cglib02.cpp
122
cg/cglib02.cpp
@ -7,14 +7,13 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <isam.h>
|
||||
#include <applicat.h>
|
||||
#include <utility.h>
|
||||
|
||||
#include <saldi.h>
|
||||
|
||||
#include "conto.h"
|
||||
#include "cglib.h"
|
||||
|
||||
#include <saldi.h>
|
||||
|
||||
TConto* TTab_conti::add(const TBill& c, int anno)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -509,9 +509,11 @@ TRiga_scadenze& TRiga_partite::new_row(int r)
|
||||
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);
|
||||
for (int p = scad.last(); p > 0; p = scad.pred(p))
|
||||
@ -1156,28 +1158,14 @@ bool TPartita::chiusa(bool update)
|
||||
|
||||
if (update)
|
||||
{
|
||||
bool forse_chiusa = TRUE;
|
||||
for (int p = last(); p > 0 && forse_chiusa; p = pred(p))
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
TImporto saldo, doc, pag, imp;
|
||||
calcola_saldo(saldo, doc, pag, imp);
|
||||
|
||||
if (chiusa != forse_chiusa)
|
||||
const bool ora_chiusa = saldo.is_zero();
|
||||
if (chiusa != ora_chiusa)
|
||||
{
|
||||
chiusa = forse_chiusa;
|
||||
for (p = last(); p > 0; p = pred(p))
|
||||
chiusa = ora_chiusa;
|
||||
for (int p = last(); p > 0; p = pred(p))
|
||||
{
|
||||
TRiga_partite& part = riga(p);
|
||||
part.put(PART_CHIUSA, chiusa);
|
||||
@ -1192,10 +1180,11 @@ void TPartita::rimuovi_riga(int r)
|
||||
{
|
||||
TRiga_partite& row = riga(r);
|
||||
if (row.rate() > 0)
|
||||
row.elimina_rate();
|
||||
row.elimina_rata(-1);
|
||||
else
|
||||
CHECKD(!utilizzata(r), "Can't remove still referenced row ", r);
|
||||
_part.destroy_row(r);
|
||||
chiusa(TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -161,7 +161,7 @@ public: // TTree_rectype
|
||||
public:
|
||||
int rate() const { return _recarr.rows(); }
|
||||
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);
|
||||
|
||||
bool is_fattura() const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user