Patch level : 2.0
Files correlati : cg2.exe cg2100a.msk cg2100b.msk cg2100c.msk Ricompilazione Demo : [ ] Commento : Nuove implementazioni: 18 Implementare la possibilità di portare nel saldaconto anche le partite su conti normali. (Creazione scadenze) 28 Implementare la visualizzazione del saldo in fase di inserimento. Nuovo bottone o funzione automatica di visualizzazione git-svn-id: svn://10.65.10.50/trunk@11457 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
015ff08914
commit
e6f0d3a92d
@ -49,7 +49,7 @@ TMask* TPrimanota_application::load_mask(int n)
|
||||
if (_msk[n] != NULL)
|
||||
return _msk[n];
|
||||
|
||||
TFilename name("cg2100"); name << char(n == 3 ? 'o' : 'a'+n);
|
||||
TString8 name = "cg2100"; name << char(n == 3 ? 'o' : 'a'+n);
|
||||
TMask* m = new TMask(name);
|
||||
|
||||
switch (n)
|
||||
@ -74,8 +74,6 @@ TMask* TPrimanota_application::load_mask(int n)
|
||||
case 2:
|
||||
if (m)
|
||||
{
|
||||
m->set_handler(F_DATADOC, datadoc_handler);
|
||||
m->set_handler(F_NUMDOC, numdoc_handler);
|
||||
m->set_handler(F_DATA74TER, data74ter_handler);
|
||||
m->set_handler(F_PROTIVA, protiva_handler);
|
||||
m->set_handler(F_CLIENTE, clifo_handler);
|
||||
@ -90,7 +88,7 @@ TMask* TPrimanota_application::load_mask(int n)
|
||||
m->set_handler(F_SHEETIVA, iva_handler);
|
||||
m->set_handler(F_CODPAG, codpag_handler);
|
||||
|
||||
TSheet_field& is = (TSheet_field&)m->field(F_SHEETIVA);
|
||||
TSheet_field& is = m->sfield(F_SHEETIVA);
|
||||
is.set_notify(iva_notify);
|
||||
TMask& ism = is.sheet_mask();
|
||||
ism.set_handler(101, imponibile_handler);
|
||||
@ -115,27 +113,6 @@ TMask* TPrimanota_application::load_mask(int n)
|
||||
ism.hide(id); // Descrizioni commessa e fase
|
||||
}
|
||||
}
|
||||
|
||||
// Se esiste lo sheet delle rate
|
||||
if (is_fattura())
|
||||
{
|
||||
TSheet_field& ps = (TSheet_field&)m->field(FS_RATESHEET);
|
||||
ps.set_notify(pag_notify);
|
||||
m->set_handler(FS_RATESHEET, pag_sheet_handler);
|
||||
m->set_handler(F_ANNORIF, annorif_handler);
|
||||
m->set_handler(F_NUMRIF, numrif_handler);
|
||||
m->set_handler(FS_RESET, reset_handler);
|
||||
m->set_handler(FS_NRATE, nrate_handler);
|
||||
m->set_handler(FS_RECALC, recalc_handler);
|
||||
m->set_handler(FS_NSCAB, codcab_handler);
|
||||
m->set_handler(FS_VSCAB, codcab_handler);
|
||||
|
||||
TMask& sm = ps.sheet_mask();
|
||||
sm.set_handler(102, ratalit_handler);
|
||||
sm.set_handler(103, rataval_handler);
|
||||
sm.set_handler(105, tipopag_handler);
|
||||
sm.set_handler(106, tipopag_handler);
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
if (m)
|
||||
@ -143,6 +120,8 @@ TMask* TPrimanota_application::load_mask(int n)
|
||||
m->first_focus(_firstfocus);
|
||||
m->set_handler(F_DATAREG, datareg_handler);
|
||||
m->set_handler(F_DATACOMP, datacomp_handler);
|
||||
m->set_handler(F_DATADOC, datadoc_handler);
|
||||
m->set_handler(F_NUMDOC, numdoc_handler);
|
||||
m->set_handler(F_DESCR, descr_handler);
|
||||
m->set_handler(F_CODCAUS, caus_modify_handler);
|
||||
m->set_handler(F_TOTALE, totdoc_handler);
|
||||
@ -152,7 +131,7 @@ TMask* TPrimanota_application::load_mask(int n)
|
||||
m->set_handler(SK_CAMBIO, cambio_handler);
|
||||
m->set_handler(SK_TOTDOCVAL, totdocval_handler);
|
||||
|
||||
TSheet_field& cg = (TSheet_field&)m->field(F_SHEETCG);
|
||||
TSheet_field& cg = m->sfield(F_SHEETCG);
|
||||
cg.set_notify(cg_notify);
|
||||
TMask& cgm = cg.sheet_mask();
|
||||
|
||||
@ -179,6 +158,26 @@ TMask* TPrimanota_application::load_mask(int n)
|
||||
cg.delete_column(CG_DESC_FASE); cg.delete_column(CG_DESC_CDC);
|
||||
cg.delete_column(CG_FASE); cg.delete_column(CG_COMMESSA);
|
||||
}
|
||||
// Se esiste lo sheet delle rate
|
||||
if (is_fattura())
|
||||
{
|
||||
TSheet_field& ps = (TSheet_field&)m->field(FS_RATESHEET);
|
||||
ps.set_notify(pag_notify);
|
||||
m->set_handler(FS_RATESHEET, pag_sheet_handler);
|
||||
m->set_handler(F_ANNORIF, annorif_handler);
|
||||
m->set_handler(F_NUMRIF, numrif_handler);
|
||||
m->set_handler(FS_RESET, reset_handler);
|
||||
m->set_handler(FS_NRATE, nrate_handler);
|
||||
m->set_handler(FS_RECALC, recalc_handler);
|
||||
m->set_handler(FS_NSCAB, codcab_handler);
|
||||
m->set_handler(FS_VSCAB, codcab_handler);
|
||||
|
||||
TMask& sm = ps.sheet_mask();
|
||||
sm.set_handler(102, ratalit_handler);
|
||||
sm.set_handler(103, rataval_handler);
|
||||
sm.set_handler(105, tipopag_handler);
|
||||
sm.set_handler(106, tipopag_handler);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
@ -284,6 +283,7 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
|
||||
m->enable(F_PROVVISORIO, !_is_saldaconto); // Il saldaconto vieta i movimenti provvisori
|
||||
m->show(SK_TIPORIGA, is_pagamento()); // Abilita scelta tipo riga
|
||||
m->enable(SK_TIPORIGA);
|
||||
activate_numrif(*m, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -473,6 +473,8 @@ void TPrimanota_application::init_mask(TMask& m)
|
||||
if (_iva == nessuna_iva)
|
||||
{
|
||||
m.show(-5, _is_saldaconto); // Abilita campi saldaconto
|
||||
m.show(-6, _is_saldaconto && is_fattura()); // Abilita gestione rate
|
||||
m.show(K_RESIDUO, _is_saldaconto && !is_fattura());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -809,6 +811,16 @@ int TPrimanota_application::read(TMask& m)
|
||||
disable_cgs_cells(i, tipo);
|
||||
}
|
||||
|
||||
if (_iva == nessuna_iva && is_fattura()) // Ci dovrebbero essere delle scadenze
|
||||
{
|
||||
pags().reset(); // Azzera sheet rate
|
||||
if (!read_scadenze(m)) // Se non esiste fattura
|
||||
{
|
||||
const TString dd(m.get(F_DATADOC));
|
||||
set_pagamento(NULL, dd); // Ignora codice pagamento in testata
|
||||
}
|
||||
}
|
||||
|
||||
if (_iva == nessuna_iva)
|
||||
return _rel->status();
|
||||
|
||||
@ -1093,7 +1105,6 @@ int TPrimanota_application::write(const TMask& m)
|
||||
check_saldi();
|
||||
|
||||
bool salvaconto = FALSE;
|
||||
// const long old_nreg = numreg - (lasterr == _isreinsert ? 1 : 0);
|
||||
const long old_nreg = NUMREG_PROVVISORIO;
|
||||
|
||||
if (iva() != nessuna_iva)
|
||||
@ -1104,7 +1115,6 @@ int TPrimanota_application::write(const TMask& m)
|
||||
switch (causale().tipomov())
|
||||
{
|
||||
case tm_fattura:
|
||||
// partite().update_reg(_rel->curr(), old_nreg); // L'array e' sempre vuoto!
|
||||
write_scadenze(m); // Salva fattura
|
||||
break;
|
||||
case tm_nota_credito:
|
||||
@ -1127,6 +1137,9 @@ int TPrimanota_application::write(const TMask& m)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_fattura())
|
||||
write_scadenze(m); // Salva fattura
|
||||
|
||||
salvaconto = is_pagamento();
|
||||
}
|
||||
|
||||
@ -1170,6 +1183,8 @@ int TPrimanota_application::rewrite(const TMask& m)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_fattura())
|
||||
write_scadenze(m); // Salva fattura
|
||||
salvaconto = is_pagamento();
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,10 @@
|
||||
#define F_REGST 144
|
||||
#define F_DIFFERITA 145
|
||||
#define F_ADJUST_PRORATA 146
|
||||
#define F_EASYDOC 147
|
||||
#define F_GRUPPO 180
|
||||
#define F_CONTO 181
|
||||
#define F_SOTTOCONTO 182
|
||||
#define F_SALDOCONTO 183
|
||||
|
||||
#define F_SHEETCG 190
|
||||
#define F_SHEETIVA 191
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "cg2100.h"
|
||||
|
||||
TOOLBAR "" 0 -4 0 4
|
||||
TOOLBAR "" 0 -2 0 2
|
||||
#include <toolbar.h>
|
||||
ENDPAGE
|
||||
|
||||
|
142
cg/cg2100b.uml
142
cg/cg2100b.uml
@ -1,15 +1,10 @@
|
||||
#include "cg2100.h"
|
||||
#include "cg21sld.h"
|
||||
|
||||
TOOLBAR "" 0 -4 0 4
|
||||
TOOLBAR "" 0 -2 0 2
|
||||
|
||||
#include <toolbar.h>
|
||||
|
||||
BUTTON F_EASYDOC 10
|
||||
BEGIN
|
||||
PROMPT -66 -3 "&Immagine"
|
||||
FLAGS "H"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
PAGE "Testata" -1 -1 77 20
|
||||
@ -165,9 +160,9 @@ BEGIN
|
||||
COPY OUTPUT F_DESCAGG
|
||||
END
|
||||
|
||||
GROUPBOX DLG_NULL 78 5
|
||||
GROUPBOX DLG_NULL 78 8
|
||||
BEGIN
|
||||
PROMPT 1 10 "Voci per saldaconto"
|
||||
PROMPT 1 10 "@bVoci per saldaconto"
|
||||
GROUP 5
|
||||
END
|
||||
|
||||
@ -213,22 +208,13 @@ BEGIN
|
||||
WARNING "E' stata specificata una valuta senza il cambio relativo"
|
||||
END
|
||||
|
||||
/*
|
||||
BOOLEAN SK_CONTROEURO
|
||||
BEGIN
|
||||
PROMPT 70 11 "Euro"
|
||||
FIELD CONTROEURO
|
||||
GROUP 3 5
|
||||
END
|
||||
*/
|
||||
|
||||
CURRENCY F_TOTALE 18
|
||||
BEGIN
|
||||
PROMPT 2 12 "Importo movimento "
|
||||
GROUP 5
|
||||
FIELD TOTDOC
|
||||
VALIDATE REQIF_FUNC 1 SK_TOTDOCVAL
|
||||
MESSAGE COPY,K_TOTALE
|
||||
MESSAGE COPY,K_TOTALE|COPY,FS_IMPONIBILI
|
||||
END
|
||||
|
||||
CURRENCY SK_TOTDOCVAL 18
|
||||
@ -240,6 +226,51 @@ BEGIN
|
||||
FIELD TOTDOCVAL
|
||||
END
|
||||
|
||||
STRING F_CODPAG 4
|
||||
BEGIN
|
||||
PROMPT 2 14 "Cod. Pagamento "
|
||||
FIELD CODPAG
|
||||
FLAGS "U#"
|
||||
USE %CPG
|
||||
INPUT CODTAB F_CODPAG
|
||||
DISPLAY "Codice" CODTAB
|
||||
DISPLAY "Descrizione@50" S0
|
||||
OUTPUT F_CODPAG CODTAB
|
||||
OUTPUT F_DESPAG S0
|
||||
CHECKTYPE NORMAL
|
||||
ADD RUN ba3 -6
|
||||
WARNING "Codice pagamento assente"
|
||||
GROUP 5 6
|
||||
END
|
||||
|
||||
STRING F_DESPAG 50
|
||||
BEGIN
|
||||
PROMPT 25 14 ""
|
||||
USE %CPG KEY 2
|
||||
INPUT S0 F_DESPAG
|
||||
DISPLAY "Descrizione@60" S0
|
||||
DISPLAY "Codice" CODTAB
|
||||
COPY OUTPUT F_CODPAG
|
||||
ADD RUN ba3 -6
|
||||
GROUP 5 6
|
||||
END
|
||||
|
||||
NUMBER F_ANNORIF 4
|
||||
BEGIN
|
||||
PROMPT 48 15 "Rif.partita "
|
||||
FIELD LF_PARTITE->ANNO
|
||||
FLAGS "U"
|
||||
GROUP 5 6
|
||||
END
|
||||
|
||||
STRING F_NUMRIF 7
|
||||
BEGIN
|
||||
PROMPT 66 15 "/ "
|
||||
FIELD LF_PARTITE->NUMPART
|
||||
FLAGS "U#"
|
||||
GROUP 5 6
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
PAGE "Righe" -1 -1 77 20
|
||||
@ -255,91 +286,91 @@ BEGIN
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING K_RAGSOC 50 52
|
||||
STRING K_RAGSOC 50 56
|
||||
BEGIN
|
||||
PROMPT 17 1 "Ragione "
|
||||
PROMPT 21 1 ""
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
NUMBER K_NUMREG 7
|
||||
BEGIN
|
||||
PROMPT 56 3 "Operazione n. "
|
||||
PROMPT 1 3 "Operazione "
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
DATE K_DATAREG
|
||||
BEGIN
|
||||
PROMPT 1 3 "Data operazione "
|
||||
PROMPT 22 3 "del "
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
DATE K_DATACOMP
|
||||
BEGIN
|
||||
PROMPT 1 4 "Data di competenza "
|
||||
PROMPT 41 3 "Competenza "
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
NUMBER K_ANNOES 4
|
||||
BEGIN
|
||||
PROMPT 56 4 "Codice esercizio "
|
||||
PROMPT 64 3 "Esercizio "
|
||||
FLAGS "DZ"
|
||||
END
|
||||
|
||||
DATE K_DATADOC
|
||||
BEGIN
|
||||
PROMPT 1 5 "Data del documento "
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING K_NUMDOC 7
|
||||
BEGIN
|
||||
PROMPT 38 5 "Numero documento "
|
||||
PROMPT 1 4 "Documento "
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
DATE K_DATADOC
|
||||
BEGIN
|
||||
PROMPT 22 4 "del "
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING K_TIPODOC 2
|
||||
BEGIN
|
||||
PROMPT 65 5 "Tipo doc. "
|
||||
PROMPT 41 4 "Tipo documento "
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING K_CODCAUS 3
|
||||
BEGIN
|
||||
PROMPT 1 6 "Causale "
|
||||
PROMPT 1 5 "Causale "
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING K_DESCRCAUS 50 52
|
||||
BEGIN
|
||||
PROMPT 25 6 ""
|
||||
PROMPT 26 5 ""
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
CURRENCY K_TOTALE 18
|
||||
BEGIN
|
||||
PROMPT 1 7 "Imp. mov. "
|
||||
PROMPT 1 6 "Imp. mov. "
|
||||
FLAGS "D"
|
||||
GROUP 5
|
||||
END
|
||||
|
||||
CURRENCY K_RESIDUO 18
|
||||
BEGIN
|
||||
PROMPT 32 7 "Residuo "
|
||||
PROMPT 32 6 "Residuo "
|
||||
FLAGS "D"
|
||||
GROUP 5
|
||||
END
|
||||
|
||||
LIST SK_TIPORIGA 1 12
|
||||
BEGIN
|
||||
PROMPT 60 7 "Riga "
|
||||
PROMPT 60 6 "Riga "
|
||||
ITEM "K|Saldaconto"
|
||||
ITEM "G|Spese"
|
||||
ITEM "A|Normale"
|
||||
END
|
||||
|
||||
SPREADSHEET F_SHEETCG 0 -2
|
||||
SPREADSHEET F_SHEETCG 0 -3
|
||||
BEGIN
|
||||
PROMPT 0 8 ""
|
||||
PROMPT 0 7 ""
|
||||
ITEM "Dare@15F"
|
||||
ITEM "Avere@15F"
|
||||
ITEM "CF@2"
|
||||
@ -361,6 +392,30 @@ BEGIN
|
||||
ITEM "Tipo@4"
|
||||
END
|
||||
|
||||
NUMBER F_GRUPPO 3
|
||||
BEGIN
|
||||
PROMPT 1 -2 "Conto riga corrente "
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
NUMBER F_CONTO 3
|
||||
BEGIN
|
||||
PROMPT 31 -2 ""
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
NUMBER F_SOTTOCONTO 6
|
||||
BEGIN
|
||||
PROMPT 36 -2 ""
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING F_SALDOCONTO 20
|
||||
BEGIN
|
||||
PROMPT 51 -2 "Saldo "
|
||||
FLAGS "DR"
|
||||
END
|
||||
|
||||
CURRENCY F_DARE 18
|
||||
BEGIN
|
||||
PROMPT 1 -1 "Sbilancio Dare "
|
||||
@ -369,14 +424,15 @@ END
|
||||
|
||||
CURRENCY F_AVERE 18
|
||||
BEGIN
|
||||
PROMPT 41 -1 "Sbilancio Avere "
|
||||
PROMPT 42 -1 "Sbilancio Avere "
|
||||
FLAGS "DRV"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
#include "cg21sld.uml"
|
||||
|
||||
ENDMASK
|
||||
|
||||
#include "cg21cg.uml"
|
||||
|
||||
|
||||
#include "cg21rata.uml"
|
||||
|
@ -1,22 +1,10 @@
|
||||
#include "cg2100.h"
|
||||
#include "cg21sld.h"
|
||||
|
||||
TOOLBAR "" 0 -4 0 4
|
||||
TOOLBAR "" 0 -2 0 2
|
||||
|
||||
#include <toolbar.h>
|
||||
|
||||
BUTTON F_ADJUST_PRORATA 40
|
||||
BEGIN
|
||||
PROMPT 1 -3 "Corre~zione automatica righe contabili"
|
||||
FLAGS "H"
|
||||
END
|
||||
|
||||
BUTTON F_EASYDOC 10
|
||||
BEGIN
|
||||
PROMPT -66 -3 "~Immagine"
|
||||
FLAGS "H"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
PAGE "Testata" -1 -1 77 20
|
||||
@ -598,6 +586,12 @@ BEGIN
|
||||
DRIVENBY F_VALUTAINTRA
|
||||
END
|
||||
|
||||
BUTTON F_ADJUST_PRORATA 40
|
||||
BEGIN
|
||||
PROMPT 1 -1 "Corre~zione automatica righe contabili"
|
||||
FLAGS "H"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
PAGE "IVA" -1 -1 77 20
|
||||
@ -668,7 +662,7 @@ BEGIN
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
SPREADSHEET F_SHEETCG 0 -2
|
||||
SPREADSHEET F_SHEETCG 0 -3
|
||||
BEGIN
|
||||
PROMPT 0 11 ""
|
||||
ITEM "Dare@15F"
|
||||
@ -692,6 +686,30 @@ BEGIN
|
||||
ITEM "Tipo@4"
|
||||
END
|
||||
|
||||
NUMBER F_GRUPPO 3
|
||||
BEGIN
|
||||
PROMPT 1 -2 "Conto riga corrente "
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
NUMBER F_CONTO 3
|
||||
BEGIN
|
||||
PROMPT 31 -2 ""
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
NUMBER F_SOTTOCONTO 6
|
||||
BEGIN
|
||||
PROMPT 36 -2 ""
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING F_SALDOCONTO 20
|
||||
BEGIN
|
||||
PROMPT 51 -2 "Saldo "
|
||||
FLAGS "DR"
|
||||
END
|
||||
|
||||
CURRENCY F_DARE 18
|
||||
BEGIN
|
||||
PROMPT 1 -1 "Sbilancio Dare "
|
||||
|
110
cg/cg2102.cpp
110
cg/cg2102.cpp
@ -1,5 +1,4 @@
|
||||
#include <colors.h>
|
||||
#include <currency.h>
|
||||
#include <msksheet.h>
|
||||
#include <progind.h>
|
||||
#include <tabutil.h>
|
||||
@ -981,6 +980,83 @@ int TPrimanota_application::crea_somma_spese(TImporto& imp)
|
||||
return r;
|
||||
}
|
||||
|
||||
void TPrimanota_application::update_saldo_riga(int r)
|
||||
{
|
||||
TSheet_field& sheet = cgs();
|
||||
TToken_string row = sheet.row(r);
|
||||
TBill bill; bill.get(row, 2, 0x1);
|
||||
|
||||
if (bill.ok())
|
||||
{
|
||||
const int annoes = _saldi.anno_es();
|
||||
|
||||
// Legge il saldo finale del conto
|
||||
TBalance bilancio;
|
||||
bilancio.read(bill, annoes, false, false);
|
||||
TImporto saldo = bilancio.saldo_finale();
|
||||
|
||||
// Sottrae (somma algebricamente) il valore iniziale del conto
|
||||
const TConto* conto = _saldi.find(bill, annoes);
|
||||
if (conto != NULL)
|
||||
{
|
||||
saldo += TImporto('D', conto->dare());
|
||||
saldo += TImporto('A', conto->avere());
|
||||
}
|
||||
|
||||
// Somma l'importo delle singole righe con quel conto
|
||||
for (int i = sheet.items()-1; i >= 0; i--)
|
||||
{
|
||||
row = sheet.row(i);
|
||||
if (!row.empty_items())
|
||||
{
|
||||
TBill zio; bill.get(row, 2, 0x1);
|
||||
if (zio == bill)
|
||||
{
|
||||
TImporto da; da = row;
|
||||
saldo += da;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TString80 s; // Stringa di lavoro
|
||||
|
||||
// Trasforma il saldo in stringa
|
||||
saldo.normalize();
|
||||
if (!saldo.is_zero())
|
||||
{
|
||||
const TCurrency imp = saldo.valore();
|
||||
s = imp.string(true);
|
||||
s << ' ' << saldo.sezione();
|
||||
}
|
||||
|
||||
TMask& m = curr_mask();
|
||||
bill.set(m, F_GRUPPO, F_CONTO, F_SOTTOCONTO); // Stampa conto
|
||||
m.set(F_SALDOCONTO, s); // Stampa saldo
|
||||
|
||||
// Controlla se il conto ha attivato il controllo del segno
|
||||
s = bill.string(); // Chiave del sottoconto da controllare
|
||||
if (bill.tipo() > ' ') // Per i clienti/fornitori devo controllare il solo gruppo/conto
|
||||
{
|
||||
const int pipe = s.rfind('|');
|
||||
s.cut(pipe);
|
||||
}
|
||||
const TRectype& pcon = cache().get(LF_PCON, s);
|
||||
const char sez = pcon.get_char(PCN_SEZSALDI);
|
||||
bool red = false;
|
||||
if (sez > ' ' && !saldo.is_zero()) // Il conto ha impostato il controllo della sezione!
|
||||
red = sez != saldo.sezione();
|
||||
|
||||
// Scrive in nero o rosso la parola Saldo
|
||||
s = TR("Saldo");
|
||||
if (red)
|
||||
{
|
||||
s.upper();
|
||||
s.insert("@b$[r]");
|
||||
}
|
||||
m.field(F_SALDOCONTO).set_prompt(s);
|
||||
}
|
||||
}
|
||||
|
||||
bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k)
|
||||
{
|
||||
static TImporto old_spesa;
|
||||
@ -1028,6 +1104,7 @@ bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k)
|
||||
cg.select(r, 1); // Vado alla prima colonna delle righe vuote
|
||||
selecting = FALSE;
|
||||
}
|
||||
a.update_saldo_riga(r);
|
||||
}
|
||||
break;
|
||||
case K_DEL:
|
||||
@ -1063,7 +1140,9 @@ bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k)
|
||||
a.generazione_righe_cg(r);
|
||||
}
|
||||
if (k == K_ENTER)
|
||||
{
|
||||
a.calcola_saldo(); // Altrimenti ci pensa CTRL-DEL
|
||||
}
|
||||
break;
|
||||
case K_CTRL+K_INS: // Post inserimento
|
||||
if (a.is_pagamento())
|
||||
@ -1155,6 +1234,7 @@ bool TPrimanota_application::dareavere_handler(TMask_field& f, KEY k)
|
||||
TPrimanota_application& a = app();
|
||||
TSheet_field& cgs = a.cgs();
|
||||
const int currig = cgs.selected();
|
||||
TMask& m = f.mask();
|
||||
|
||||
if (k == K_F8 && a.is_pagamento())
|
||||
{
|
||||
@ -1163,7 +1243,6 @@ bool TPrimanota_application::dareavere_handler(TMask_field& f, KEY k)
|
||||
const TImporto speso = a.partite().importo_speso(numreg, currig+1);
|
||||
|
||||
const char* ss = speso.valore().string();
|
||||
TMask& m = f.mask();
|
||||
m.set(CG_DARE, speso.sezione() == 'D' ? ss : "");
|
||||
m.set(CG_AVERE, speso.sezione() == 'A' ? ss : "");
|
||||
|
||||
@ -1171,6 +1250,7 @@ bool TPrimanota_application::dareavere_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
speso.add_to(cgs.row(currig), 0); // Aggiorna riga sheet
|
||||
a.calcola_saldo(); // Aggiorna saldo e residuo
|
||||
a.update_saldo_riga(currig);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1184,12 +1264,21 @@ bool TPrimanota_application::dareavere_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
// Calcola id del campo da resettare
|
||||
const int id = f.dlg() == CG_DARE ? CG_AVERE : CG_DARE;
|
||||
f.mask().reset(id); // Aggiorna maschera e ...
|
||||
m.reset(id); // Aggiorna maschera e ...
|
||||
row.add("", id - CG_DARE); // ... riga dello sheet
|
||||
}
|
||||
|
||||
if (!f.mask().is_running())
|
||||
if (!m.is_running())
|
||||
{
|
||||
a.calcola_saldo(); // Aggiorna saldo e residuo
|
||||
a.update_saldo_riga(currig);
|
||||
}
|
||||
}
|
||||
|
||||
if (k == K_ENTER && f.dirty() && m.is_running())
|
||||
{
|
||||
a.calcola_saldo(); // Aggiorna saldo e residuo
|
||||
a.update_saldo_riga(currig);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -1211,10 +1300,8 @@ bool TPrimanota_application::fase_handler(TMask_field& f, KEY k)
|
||||
TSheet_field& TPrimanota_application::pags() const
|
||||
{
|
||||
CHECK(is_fattura(), "Can't use rate sheet without a fattura");
|
||||
const int pos = _msk[2]->id2pos(FS_RATESHEET);
|
||||
CHECK(pos > 0, "Can't find rate sheet");
|
||||
TSheet_field& s = (TSheet_field&)_msk[2]->fld(pos);
|
||||
return s;
|
||||
TMask& m = *_msk[iva() == nessuna_iva ? 1 : 2];
|
||||
return m.sfield(FS_RATESHEET);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -2231,13 +2318,13 @@ bool TPrimanota_application::numdoc_handler(TMask_field& f, KEY key)
|
||||
}
|
||||
|
||||
// Controllo documenti duplicati
|
||||
if (key == K_ENTER && app().iva() == iva_acquisti)
|
||||
if (key == K_ENTER && !f.empty() && app().iva() == iva_acquisti)
|
||||
{
|
||||
TMask& m = f.mask();
|
||||
|
||||
const int annodoc = m.get_date(F_DATADOC).year();
|
||||
const long fornitore = m.get_long(F_FORNITORE);
|
||||
if (annodoc > 0 && fornitore > 0 && !f.empty())
|
||||
if (annodoc > 0 && fornitore > 0)
|
||||
{
|
||||
// SELECT NUMREG,DATAREG,DATADOC,NUMDOC FROM MOV
|
||||
// WHERE TIPO='F' AND CODCF=F_FORNITORE AND
|
||||
@ -2946,10 +3033,13 @@ bool TPrimanota_application::activate_numrif(TMask& m, bool init_pag)
|
||||
bool shown = is_saldaconto(); // Il numero riferimento esiste
|
||||
|
||||
if (shown)
|
||||
{
|
||||
if (m.id2pos(F_SOLAIVA) >= 0) // Maschera moviventi IVA
|
||||
{
|
||||
const bool hide = m.get_bool(F_SOLAIVA) || m.field(F_OCCASEDIT).shown();
|
||||
if (hide) shown = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (shown != m.field(F_NUMRIF).shown())
|
||||
{
|
||||
|
@ -159,6 +159,7 @@ class TPrimanota_application : public TRelation_application
|
||||
|
||||
void reset_sheet_row(TSheet_field& s, int n);
|
||||
int crea_somma_spese(TImporto& imp);
|
||||
void update_saldo_riga(int r);
|
||||
|
||||
protected: // TApplication
|
||||
virtual void on_firm_change();
|
||||
|
@ -3,10 +3,7 @@
|
||||
// fv 24/8/94
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <currency.h>
|
||||
#include <msksheet.h>
|
||||
#include <utility.h>
|
||||
|
||||
#include "cgpagame.h"
|
||||
#include "cgsaldac.h"
|
||||
|
||||
@ -360,7 +357,7 @@ bool TPrimanota_application::annorif_handler(TMask_field& f, KEY key)
|
||||
if (f.to_check(key))
|
||||
{
|
||||
const TMask& m = f.mask();
|
||||
if (!m.get(F_NUMRIF).blank() && f.get().empty())
|
||||
if (f.empty() && !m.get(F_NUMRIF).blank())
|
||||
{
|
||||
const TString& anno = m.get(F_DATADOC).right(4);
|
||||
f.set(anno);
|
||||
@ -378,14 +375,16 @@ bool TPrimanota_application::numrif_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
TPrimanota_application& a = app();
|
||||
TMask& m = f.mask();
|
||||
const bool moviva = a.iva() != nessuna_iva; // Maschera IVA?
|
||||
|
||||
bool required = m.insert_mode() && a.is_fattura();
|
||||
required &= key == K_ENTER || f.focusdirty();
|
||||
if (moviva)
|
||||
required &= !(m.get_bool(F_SOLAIVA) || m.field(F_OCCASEDIT).active());
|
||||
|
||||
if (required && f.get().blank())
|
||||
{
|
||||
if (m.get(F_CODPAG).empty())
|
||||
if (moviva && m.field(F_CODPAG).empty())
|
||||
{
|
||||
TMask_field& clifo = m.field(a.iva() == iva_vendite ? F_CLIENTE : F_FORNITORE);
|
||||
clifo.set_dirty();
|
||||
@ -608,7 +607,8 @@ bool TPrimanota_application::nrate_handler(TMask_field& f, KEY key)
|
||||
app().set_banche(m);
|
||||
app().pag_rows() = ps.rows_array();
|
||||
}
|
||||
f.set(format("%d", pag.n_rate()));
|
||||
TString8 r; r.format("%d", pag.n_rate());
|
||||
f.set(r);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -707,7 +707,7 @@ void TPrimanota_application::set_totale_pagamento(bool update)
|
||||
const TMask& m = curr_mask();
|
||||
TPagamento& pag = pagamento();
|
||||
|
||||
const real imposta = m.get_real(F_IMPOSTE);
|
||||
const real imposta = m.id2pos(F_IMPOSTE) >= 0 ? m.get_real(F_IMPOSTE) : ZERO;
|
||||
const real imponibile = m.get_real(F_TOTALE) - imposta;
|
||||
const real spese = ZERO;
|
||||
|
||||
@ -827,6 +827,8 @@ bool TPrimanota_application::read_scadenze(TMask& m)
|
||||
warning_box(FR("Il totale documento (%s) non corrisponde a quello del saldaconto (%s)."),
|
||||
(const char*)i1, (const char*)i2);
|
||||
}
|
||||
if (iva() != nessuna_iva)
|
||||
{
|
||||
if (m.get_real(F_IMPOSTE) != partita.get_real(PART_IMPOSTA))
|
||||
{
|
||||
const TCurrency imposte_c(m.get_real(F_IMPOSTE));
|
||||
@ -836,6 +838,7 @@ bool TPrimanota_application::read_scadenze(TMask& m)
|
||||
warning_box(FR("Il totale delle imposte (%s) non corrisponde a quello del saldaconto (%s)."),
|
||||
(const char*)i1, (const char*)i2);
|
||||
}
|
||||
}
|
||||
|
||||
set_totale_pagamento(FALSE);
|
||||
|
||||
@ -891,11 +894,12 @@ bool TPrimanota_application::read_scadenze(TMask& m)
|
||||
}
|
||||
|
||||
int TPrimanota_application::cerca_conto_cf(TBill& bill) const
|
||||
{
|
||||
TString_array& a = cgs().rows_array();
|
||||
if (iva() != nessuna_iva)
|
||||
{
|
||||
const char tipocf = clifo();
|
||||
const long codcf = curr_mask().get_long(tipocf == 'C' ? F_CLIENTE : F_FORNITORE);
|
||||
|
||||
TString_array& a = cgs().rows_array();
|
||||
for (int r = 0; r < a.items(); r++)
|
||||
{
|
||||
TToken_string& row = a.row(r);
|
||||
@ -903,8 +907,26 @@ int TPrimanota_application::cerca_conto_cf(TBill& bill) const
|
||||
if (bill.tipo() == tipocf && bill.codclifo() == codcf)
|
||||
return r;
|
||||
}
|
||||
|
||||
bill.set(0, 0, codcf, tipocf);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int r = 0; r < a.items(); r++)
|
||||
{
|
||||
TToken_string& row = a.row(r);
|
||||
bill.get(row, 2, 0x1);
|
||||
if (bill.tipo() > ' ')
|
||||
return r;
|
||||
}
|
||||
if (a.items() > 0)
|
||||
{
|
||||
TToken_string& row = a.row(0);
|
||||
bill.get(row, 2, 0x1);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
bill.set(0, 0, 0, ' ');
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -950,8 +972,9 @@ void TPrimanota_application::write_scadenze(const TMask& m)
|
||||
partita.put(PART_DESCR, desc);
|
||||
partita.put(PART_CODCAUS, codcaus);
|
||||
partita.put(PART_REG, causale().reg().name());
|
||||
partita.put(PART_PROTIVA, m.get_long(F_PROTIVA));
|
||||
partita.put(PART_SEZ, sezione);
|
||||
if (iva() != nessuna_iva)
|
||||
partita.put(PART_PROTIVA, m.get_long(F_PROTIVA));
|
||||
|
||||
const TImporto totdoc = get_cgs_imp(riga_clifo);
|
||||
partita.put(PART_IMPTOTDOC, totdoc.valore());
|
||||
@ -972,8 +995,9 @@ void TPrimanota_application::write_scadenze(const TMask& m)
|
||||
|
||||
partita.put(PART_IMPORTO, imponibile);
|
||||
partita.put(PART_IMPORTOVAL, imponibile_val);
|
||||
partita.put(PART_IMPOSTA, m.get(F_IMPOSTE));
|
||||
partita.put(PART_SPESE, pag.spese());
|
||||
if (iva() != nessuna_iva)
|
||||
partita.put(PART_IMPOSTA, m.get(F_IMPOSTE));
|
||||
|
||||
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
|
||||
|
||||
|
180
cg/cg3600.cpp
180
cg/cg3600.cpp
@ -3,7 +3,6 @@
|
||||
#include <applicat.h>
|
||||
#include <colors.h>
|
||||
#include <controls.h>
|
||||
#include <currency.h>
|
||||
#include <execp.h>
|
||||
#include <mailbox.h>
|
||||
#include <progind.h>
|
||||
@ -15,6 +14,7 @@
|
||||
|
||||
#include "cg3.h"
|
||||
#include "cglib01.h"
|
||||
#include "cglib02.h"
|
||||
#include "cg3600.h"
|
||||
|
||||
#include <causali.h>
|
||||
@ -353,184 +353,6 @@ long TList::append(TObject* obj, long index)
|
||||
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TBalance
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TBalance : public TObject
|
||||
{
|
||||
TImporto _saldo_ini, _progr_dare, _progr_avere, _saldo_fin;
|
||||
|
||||
protected:
|
||||
bool find(const TBill& b, int esercizio,
|
||||
TImporto& si, TImporto& da, TImporto& av, TImporto& sf,
|
||||
TImporto& pd, TImporto& pa) const;
|
||||
int indicatore_bilancio(const TBill& b) const;
|
||||
|
||||
public:
|
||||
void read(int g, int c, long s, int esercizio, bool ignora_movap, bool provvis);
|
||||
void read(const TBill& b, int esercizio, bool ignora_movap, bool provvis);
|
||||
void reread();
|
||||
|
||||
const TImporto& saldo_iniziale() const;
|
||||
const real& progressivo_dare_iniziale() const;
|
||||
const real& progressivo_avere_iniziale() const;
|
||||
real progressivo_dare_finale() const;
|
||||
real progressivo_avere_finale() const;
|
||||
TImporto saldo_finale(bool chiusura = FALSE) const;
|
||||
TImporto saldo_finale_chiusura() const;
|
||||
|
||||
TBalance();
|
||||
TBalance(int g, int c, long s, int esercizio, bool ignora_movap, bool provvis);
|
||||
TBalance(const TBill& b, int esercizio, bool ignora_movap, bool provvis);
|
||||
virtual ~TBalance() { }
|
||||
};
|
||||
|
||||
TBalance::TBalance()
|
||||
{
|
||||
}
|
||||
|
||||
TBalance::TBalance(int g, int c, long s, int esercizio, bool ignora_movap, bool provvis)
|
||||
{
|
||||
read(g, c, s, esercizio, ignora_movap, provvis);
|
||||
}
|
||||
|
||||
TBalance::TBalance(const TBill& b, int esercizio, bool ignora_movap, bool provvis)
|
||||
{
|
||||
read(b, esercizio, ignora_movap, provvis);
|
||||
}
|
||||
|
||||
bool TBalance::find(const TBill& b, int esercizio,
|
||||
TImporto& si, TImporto& da, TImporto& av, TImporto& sf,
|
||||
TImporto& pd, TImporto& pa) const
|
||||
{
|
||||
CHECK(b.sottoconto() > 0L, "Sottoconto mancante");
|
||||
|
||||
TString key(30);
|
||||
key.format("%d||%d|%d|%ld", esercizio, b.gruppo(), b.conto(), b.sottoconto());
|
||||
const TRectype & saldi = cache().get(LF_SALDI, key);
|
||||
if (!saldi.empty())
|
||||
{
|
||||
si.set(saldi.get_char(SLD_FLAGSALINI), saldi.get_real(SLD_SALDO));
|
||||
da.set('D', saldi.get_real(SLD_PDARE));
|
||||
av.set('A', saldi.get_real(SLD_PAVERE));
|
||||
sf.set(saldi.get_char(SLD_FLAGSALFIN), saldi.get_real(SLD_SALDOFIN));
|
||||
pd.set('D', saldi.get_real(SLD_PDAREPRO));
|
||||
pa.set('A', saldi.get_real(SLD_PAVEREPRO));
|
||||
}
|
||||
else
|
||||
{
|
||||
si.set('D', ZERO);
|
||||
da = av = sf = pd = pa = si;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
void TBalance::read(int gruppo, int conto, long sottoconto, int esercizio, bool ignora_movap, bool provvis)
|
||||
{
|
||||
const TBill zio(gruppo, conto, sottoconto);
|
||||
read(zio, esercizio, ignora_movap, provvis);
|
||||
}
|
||||
|
||||
int TBalance::indicatore_bilancio(const TBill& b) const
|
||||
{
|
||||
TString16 str;
|
||||
str.format("%d|%d", b.gruppo(), b.conto());
|
||||
const int ib = atoi(cache().get(LF_PCON, str, PCN_INDBIL));
|
||||
if (ib == 0)
|
||||
NFCHECK("Impossibile stabilire l'indicatore di bilancio");
|
||||
return ib;
|
||||
}
|
||||
|
||||
void TBalance::read(const TBill& b, int esercizio, bool ignora_movap, bool provvis)
|
||||
{
|
||||
TImporto si, sf, pd, pa, prd, pra;
|
||||
|
||||
find(b, esercizio, si, pd, pa, sf, prd, pra);
|
||||
if (provvis)
|
||||
{
|
||||
pd += prd;
|
||||
pa += pra;
|
||||
}
|
||||
_saldo_ini = si;
|
||||
_progr_dare = pd;
|
||||
_progr_avere = pa;
|
||||
_saldo_fin = sf;
|
||||
|
||||
if (_saldo_ini.is_zero())
|
||||
{
|
||||
const int indbil = indicatore_bilancio(b);
|
||||
if (indbil == 1 || indbil == 2 || indbil == 5)
|
||||
{
|
||||
TEsercizi_contabili esercizi;
|
||||
const int precedente = esercizi.pred(esercizio);
|
||||
if (precedente > 0 && find(b, precedente, si, pd, pa, sf, prd, pra))
|
||||
{
|
||||
if (provvis)
|
||||
{
|
||||
pd += prd;
|
||||
pa += pra;
|
||||
}
|
||||
_saldo_ini = si;
|
||||
_saldo_ini += pd;
|
||||
_saldo_ini += pa;
|
||||
_saldo_ini += sf;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ignora_movap)
|
||||
_saldo_ini.set('D', ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
const TImporto& TBalance::saldo_iniziale() const
|
||||
{ return _saldo_ini; }
|
||||
|
||||
const real& TBalance::progressivo_dare_iniziale() const
|
||||
{
|
||||
return _saldo_ini.sezione() == 'D' ? _saldo_ini.valore() : ZERO;
|
||||
}
|
||||
|
||||
const real& TBalance::progressivo_avere_iniziale() const
|
||||
{
|
||||
return _saldo_ini.sezione() == 'A' ? _saldo_ini.valore() : ZERO;
|
||||
}
|
||||
|
||||
real TBalance::progressivo_dare_finale() const
|
||||
{
|
||||
real pd = progressivo_dare_iniziale();
|
||||
pd += _progr_dare.valore();
|
||||
if (_saldo_fin.sezione() == 'D')
|
||||
pd += _saldo_fin.valore();
|
||||
return pd;
|
||||
}
|
||||
|
||||
real TBalance::progressivo_avere_finale() const
|
||||
{
|
||||
real pa = progressivo_avere_iniziale();
|
||||
pa += _progr_avere.valore();
|
||||
if (_saldo_fin.sezione() == 'A')
|
||||
pa += _saldo_fin.valore();
|
||||
return pa;
|
||||
}
|
||||
|
||||
TImporto TBalance::saldo_finale(bool chiusura) const
|
||||
{
|
||||
TImporto sf(_saldo_ini);
|
||||
sf += _progr_dare;
|
||||
sf += _progr_avere;
|
||||
if (chiusura)
|
||||
sf += _saldo_fin;
|
||||
return sf;
|
||||
}
|
||||
|
||||
TImporto TBalance::saldo_finale_chiusura() const
|
||||
{
|
||||
return saldo_finale(TRUE);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TMastrino
|
||||
///////////////////////////////////////////////////////////
|
||||
|
153
cg/cglib02.cpp
153
cg/cglib02.cpp
@ -468,7 +468,7 @@ bool TSaldo::ultima_immissione_bilancio(int annoes,int g,int c,long s,int indbil
|
||||
return esito;
|
||||
}
|
||||
|
||||
real & TSaldo::saldo_periodo(int g, int c, long s, const TDate& dal, const TDate& al,
|
||||
const real& TSaldo::saldo_periodo(int g, int c, long s, const TDate& dal, const TDate& al,
|
||||
int indbil, bool provv, const TString & codcomm)
|
||||
|
||||
{
|
||||
@ -499,7 +499,6 @@ real & TSaldo::saldo_periodo(int g, int c, long s, const TDate& dal, const TDate
|
||||
|
||||
if (_prec)
|
||||
{
|
||||
_prec = TRUE;
|
||||
_saldo_iniziale = saldofin_esprec(codes,g,c,s);
|
||||
}
|
||||
else
|
||||
@ -948,3 +947,153 @@ void TSaldo_agg::registra()
|
||||
tcon.saldo_finale() = sf;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TBalance
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TBalance::TBalance()
|
||||
{
|
||||
}
|
||||
|
||||
TBalance::TBalance(int g, int c, long s, int esercizio, bool ignora_movap, bool provvis)
|
||||
{
|
||||
read(g, c, s, esercizio, ignora_movap, provvis);
|
||||
}
|
||||
|
||||
TBalance::TBalance(const TBill& b, int esercizio, bool ignora_movap, bool provvis)
|
||||
{
|
||||
read(b, esercizio, ignora_movap, provvis);
|
||||
}
|
||||
|
||||
bool TBalance::find(const TBill& b, int esercizio,
|
||||
TImporto& si, TImporto& da, TImporto& av, TImporto& sf,
|
||||
TImporto& pd, TImporto& pa) const
|
||||
{
|
||||
CHECK(b.sottoconto() > 0L, "Sottoconto mancante");
|
||||
|
||||
TString key(30);
|
||||
key.format("%d||%d|%d|%ld", esercizio, b.gruppo(), b.conto(), b.sottoconto());
|
||||
const TRectype & saldi = cache().get(LF_SALDI, key);
|
||||
if (!saldi.empty())
|
||||
{
|
||||
si.set(saldi.get_char(SLD_FLAGSALINI), saldi.get_real(SLD_SALDO));
|
||||
da.set('D', saldi.get_real(SLD_PDARE));
|
||||
av.set('A', saldi.get_real(SLD_PAVERE));
|
||||
sf.set(saldi.get_char(SLD_FLAGSALFIN), saldi.get_real(SLD_SALDOFIN));
|
||||
pd.set('D', saldi.get_real(SLD_PDAREPRO));
|
||||
pa.set('A', saldi.get_real(SLD_PAVEREPRO));
|
||||
}
|
||||
else
|
||||
{
|
||||
si.set('D', ZERO);
|
||||
da = av = sf = pd = pa = si;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
void TBalance::read(int gruppo, int conto, long sottoconto, int esercizio, bool ignora_movap, bool provvis)
|
||||
{
|
||||
const TBill zio(gruppo, conto, sottoconto);
|
||||
read(zio, esercizio, ignora_movap, provvis);
|
||||
}
|
||||
|
||||
int TBalance::indicatore_bilancio(const TBill& b) const
|
||||
{
|
||||
TString16 str;
|
||||
str.format("%d|%d", b.gruppo(), b.conto());
|
||||
const int ib = atoi(cache().get(LF_PCON, str, PCN_INDBIL));
|
||||
if (ib == 0)
|
||||
NFCHECK("Impossibile stabilire l'indicatore di bilancio");
|
||||
return ib;
|
||||
}
|
||||
|
||||
void TBalance::read(const TBill& b, int esercizio, bool ignora_movap, bool provvis)
|
||||
{
|
||||
TImporto si, sf, pd, pa, prd, pra;
|
||||
|
||||
find(b, esercizio, si, pd, pa, sf, prd, pra);
|
||||
if (provvis)
|
||||
{
|
||||
pd += prd;
|
||||
pa += pra;
|
||||
}
|
||||
_saldo_ini = si;
|
||||
_progr_dare = pd;
|
||||
_progr_avere = pa;
|
||||
_saldo_fin = sf;
|
||||
|
||||
if (_saldo_ini.is_zero())
|
||||
{
|
||||
const int indbil = indicatore_bilancio(b);
|
||||
if (indbil == 1 || indbil == 2 || indbil == 5)
|
||||
{
|
||||
TEsercizi_contabili esercizi;
|
||||
const int precedente = esercizi.pred(esercizio);
|
||||
if (precedente > 0 && find(b, precedente, si, pd, pa, sf, prd, pra))
|
||||
{
|
||||
if (provvis)
|
||||
{
|
||||
pd += prd;
|
||||
pa += pra;
|
||||
}
|
||||
_saldo_ini = si;
|
||||
_saldo_ini += pd;
|
||||
_saldo_ini += pa;
|
||||
_saldo_ini += sf;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ignora_movap)
|
||||
_saldo_ini.set('D', ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
const TImporto& TBalance::saldo_iniziale() const
|
||||
{ return _saldo_ini; }
|
||||
|
||||
const real& TBalance::progressivo_dare_iniziale() const
|
||||
{
|
||||
return _saldo_ini.sezione() == 'D' ? _saldo_ini.valore() : ZERO;
|
||||
}
|
||||
|
||||
const real& TBalance::progressivo_avere_iniziale() const
|
||||
{
|
||||
return _saldo_ini.sezione() == 'A' ? _saldo_ini.valore() : ZERO;
|
||||
}
|
||||
|
||||
real TBalance::progressivo_dare_finale() const
|
||||
{
|
||||
real pd = progressivo_dare_iniziale();
|
||||
pd += _progr_dare.valore();
|
||||
if (_saldo_fin.sezione() == 'D')
|
||||
pd += _saldo_fin.valore();
|
||||
return pd;
|
||||
}
|
||||
|
||||
real TBalance::progressivo_avere_finale() const
|
||||
{
|
||||
real pa = progressivo_avere_iniziale();
|
||||
pa += _progr_avere.valore();
|
||||
if (_saldo_fin.sezione() == 'A')
|
||||
pa += _saldo_fin.valore();
|
||||
return pa;
|
||||
}
|
||||
|
||||
TImporto TBalance::saldo_finale(bool chiusura) const
|
||||
{
|
||||
TImporto sf(_saldo_ini);
|
||||
sf += _progr_dare;
|
||||
sf += _progr_avere;
|
||||
if (chiusura)
|
||||
sf += _saldo_fin;
|
||||
return sf;
|
||||
}
|
||||
|
||||
TImporto TBalance::saldo_finale_chiusura() const
|
||||
{
|
||||
return saldo_finale(TRUE);
|
||||
}
|
||||
|
||||
|
42
cg/cglib02.h
42
cg/cglib02.h
@ -106,15 +106,10 @@ public:
|
||||
|
||||
bool causale_mov(long, const TDate&, const TDate&, TString&);
|
||||
|
||||
/* Inutilizzate!
|
||||
const TString& causale_chiusura_es() const;
|
||||
const TString& causale_apertura_es() const;
|
||||
*/
|
||||
|
||||
bool ultima_immissione_bilancio(int anno,int g,int c,long s,int indbil,int prov,bool saldo_chiusura = TRUE);
|
||||
bool ultima_immissione_verifica(int anno,int g,int c,long s,int indbil,int prov);
|
||||
bool data_limite_bilancio(int,int,int,long,const TDate&,const TDate&,int,int, const char* = NULL);
|
||||
real & saldo_periodo(int g,int c,long s,const TDate& dal,const TDate& al,int indbil, bool provv, const TString & codcomm = EMPTY_STRING);
|
||||
const real& saldo_periodo(int g,int c,long s,const TDate& dal,const TDate& al,int indbil, bool provv, const TString & codcomm = EMPTY_STRING);
|
||||
|
||||
bool ricerca_progr_prec(int, int, int, long);
|
||||
|
||||
@ -140,7 +135,6 @@ public:
|
||||
virtual ~TSaldo() {}
|
||||
};
|
||||
|
||||
|
||||
class TTab_conti : public TAssoc_array
|
||||
{
|
||||
public:
|
||||
@ -152,7 +146,6 @@ public:
|
||||
void remove(const TBill& c, int anno, bool provv = FALSE);
|
||||
};
|
||||
|
||||
|
||||
class TSaldo_agg : public TObject
|
||||
{
|
||||
TTab_conti _tab_conti;
|
||||
@ -199,4 +192,37 @@ public:
|
||||
virtual ~TSaldo_agg() { }
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TBalance
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TBalance : public TObject
|
||||
{
|
||||
TImporto _saldo_ini, _progr_dare, _progr_avere, _saldo_fin;
|
||||
|
||||
protected:
|
||||
bool find(const TBill& b, int esercizio,
|
||||
TImporto& si, TImporto& da, TImporto& av, TImporto& sf,
|
||||
TImporto& pd, TImporto& pa) const;
|
||||
int indicatore_bilancio(const TBill& b) const;
|
||||
|
||||
public:
|
||||
void read(int g, int c, long s, int esercizio, bool ignora_movap, bool provvis);
|
||||
void read(const TBill& b, int esercizio, bool ignora_movap, bool provvis);
|
||||
void reread();
|
||||
|
||||
const TImporto& saldo_iniziale() const;
|
||||
const real& progressivo_dare_iniziale() const;
|
||||
const real& progressivo_avere_iniziale() const;
|
||||
real progressivo_dare_finale() const;
|
||||
real progressivo_avere_finale() const;
|
||||
TImporto saldo_finale(bool chiusura = FALSE) const;
|
||||
TImporto saldo_finale_chiusura() const;
|
||||
|
||||
TBalance();
|
||||
TBalance(int g, int c, long s, int esercizio, bool ignora_movap, bool provvis);
|
||||
TBalance(const TBill& b, int esercizio, bool ignora_movap, bool provvis);
|
||||
virtual ~TBalance() { }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
// se settato, si usa per rate nuove l'intervallo rate default (letto da tab. pagamenti)
|
||||
#define USE_DEFAULT_INT_RATE 1
|
||||
#define PERC_DECIMALS 2
|
||||
|
||||
inline void swap(int& x, int& y) {int tmp = x; x = y; y = tmp; }
|
||||
|
||||
@ -203,11 +204,11 @@ void TPagamento::set_numero_rate(int n, int sscad, int rdiff)
|
||||
int nact = first == 1 ? n - 1 : n;
|
||||
|
||||
real p = real(100) / real(nact);
|
||||
p.round(2);
|
||||
p.round(PERC_DECIMALS);
|
||||
|
||||
if (_inited || (!_inited && rdiff == 1)) // se e' inited rdiff e' 2 per forza
|
||||
{
|
||||
real tot = _inited ? importo_da_dividere(FALSE) : real(100.0);
|
||||
real tot = _inited ? importo_da_dividere(FALSE) : CENTO;
|
||||
real oot;
|
||||
if (inv)
|
||||
oot = importo_da_dividere(TRUE);
|
||||
@ -219,7 +220,7 @@ void TPagamento::set_numero_rate(int n, int sscad, int rdiff)
|
||||
set_imprata(first, tot, FALSE);
|
||||
if (inv) set_imprata(first, oot, TRUE);
|
||||
}
|
||||
set_percrata(first, real(100.0));
|
||||
set_percrata(first, CENTO);
|
||||
if (_inited && _tpr > 0 && _tpr < 4)
|
||||
{
|
||||
set_imprata(first, importo_rata(first,FALSE) + importo_da_non_dividere(FALSE), FALSE);
|
||||
@ -243,13 +244,13 @@ void TPagamento::set_numero_rate(int n, int sscad, int rdiff)
|
||||
div.round(_roundlit);
|
||||
if (inv) oiv.round(_roundval);
|
||||
}
|
||||
real perc = (100.0 * div) / tot;
|
||||
real perc = (CENTO * div) / tot;
|
||||
|
||||
real rem(tot);
|
||||
real oem(oot);
|
||||
real p(perc);
|
||||
|
||||
p.round(2);
|
||||
p.round(PERC_DECIMALS);
|
||||
|
||||
for (i = first; i < n; i++)
|
||||
{
|
||||
@ -297,7 +298,7 @@ void TPagamento::set_numero_rate(int n, int sscad, int rdiff)
|
||||
r -= importo_da_non_dividere(FALSE);
|
||||
if (inv) or -= importo_da_non_dividere(TRUE);
|
||||
}
|
||||
set_percrata(first, 100 * r / tot);
|
||||
set_percrata(first, CENTO * r / tot);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -337,12 +338,11 @@ void TPagamento::set_numero_rate(int n, int sscad, int rdiff)
|
||||
if (inv)
|
||||
oiv.round(_roundval);
|
||||
}
|
||||
real perc = (100.0 * div)/tot;
|
||||
real perc = (CENTO * div)/tot;
|
||||
real rem(rest);
|
||||
real oem(oest);
|
||||
real p(perc);
|
||||
|
||||
p.round(2);
|
||||
p.round(PERC_DECIMALS);
|
||||
for (i = 1; i < n; i++)
|
||||
{
|
||||
if (i >= nr)
|
||||
@ -380,12 +380,11 @@ void TPagamento::set_numero_rate(int n, int sscad, int rdiff)
|
||||
if (inv) set_imprata(first, or, TRUE);
|
||||
if (_inited && _tpr > 0 && _tpr < 4)
|
||||
r -= importo_da_non_dividere(FALSE);
|
||||
set_percrata(first, 100 * r / tot);
|
||||
set_percrata(first, CENTO * r / tot);
|
||||
}
|
||||
else
|
||||
{
|
||||
const real r(perc_rata(first) + rem);
|
||||
|
||||
set_percrata(first, r);
|
||||
}
|
||||
}
|
||||
@ -394,21 +393,21 @@ void TPagamento::set_numero_rate(int n, int sscad, int rdiff)
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = first; sum < real(100.0); i++)
|
||||
for (i = first; sum < CENTO; i++)
|
||||
{
|
||||
if ((real(100.0) - sum) < p)
|
||||
p = real(100.0) - sum;
|
||||
if ((CENTO - sum) < p)
|
||||
p = CENTO - sum;
|
||||
|
||||
sum += p;
|
||||
|
||||
// if necessary add remainder on first one
|
||||
if ((real(100.0) - sum) /* still */ < p)
|
||||
if ((CENTO - sum) /* still */ < p)
|
||||
{
|
||||
real prc = perc_rata(first);
|
||||
prc += real(100.0) - sum;
|
||||
prc += CENTO - sum;
|
||||
TToken_string& rt = rata(first);
|
||||
rt.add(prc.string(),1),
|
||||
sum = 100;
|
||||
sum = CENTO;
|
||||
}
|
||||
|
||||
int scd = i == 0 ? (i < nr ? scad_rata(0) : 0) :
|
||||
@ -588,10 +587,11 @@ void TPagamento::set_imprata(int i, const real& r, bool v)
|
||||
tt.add(r.string(), v ? 4 : 7);
|
||||
}
|
||||
|
||||
void TPagamento::set_percrata(int i, real r)
|
||||
void TPagamento::set_percrata(int i, real perc)
|
||||
{
|
||||
TToken_string& tt = (TToken_string&)_rate[i];
|
||||
tt.add(r.string(), 1);
|
||||
perc.round(PERC_DECIMALS);
|
||||
tt.add(perc.string(), 1);
|
||||
}
|
||||
|
||||
void TPagamento::set_datarata(int i, const TDate & d)
|
||||
@ -602,15 +602,14 @@ void TPagamento::set_datarata(int i, const TDate & d)
|
||||
|
||||
real TPagamento::recalc_percrata(int i, bool v)
|
||||
{
|
||||
real hm(importo_da_dividere(v));
|
||||
if (i == 0 && _tpr > 3)
|
||||
return ZERO;
|
||||
|
||||
if (i == 0 && _tpr > 3) return ZERO;
|
||||
|
||||
real tpay(importo_rata(i,v));
|
||||
const real hm = importo_da_dividere(v);
|
||||
real tpay = importo_rata(i,v);
|
||||
if (i == 0 && _tpr > 0 && _tpr < 4)
|
||||
tpay -= importo_da_non_dividere(v);
|
||||
real perc = tpay * 100.0 / hm;
|
||||
perc.round(2);
|
||||
const real perc = tpay * CENTO / hm;
|
||||
set_percrata(i, perc);
|
||||
|
||||
return perc;
|
||||
@ -637,8 +636,8 @@ TToken_string& TPagamento::set_rata(int index, const real& impval, const real& i
|
||||
hm -= importo_da_non_dividere(in_valuta());
|
||||
|
||||
real perc = (_tpr > 3 && index == 0) ? ZERO : hm/toshare;
|
||||
perc *= real(100.0);
|
||||
perc.round(2);
|
||||
perc *= CENTO;
|
||||
perc.round(PERC_DECIMALS);
|
||||
|
||||
tt->cut(0);
|
||||
tt->add(day); // 0 - scadenza
|
||||
@ -669,14 +668,14 @@ word TPagamento::validate() const
|
||||
{
|
||||
word res = 0x0000;
|
||||
int warnscad = 0;
|
||||
real r(0.0);
|
||||
real r;
|
||||
|
||||
int first = _tpr < 4 ? 0 : 1;
|
||||
|
||||
// check percentages & prepare slicer
|
||||
for (int i = first; i < n_rate(); i++)
|
||||
r += perc_rata(i);
|
||||
r -= real(100.0);
|
||||
r -= CENTO;
|
||||
real delta(0.005);
|
||||
delta = delta * real(n_rate());
|
||||
r = abs(r);
|
||||
@ -870,11 +869,11 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
|
||||
real rsum(0.0), newv(0.0), rmax(0.0);
|
||||
const int last_rata = _rate.items() - 1;
|
||||
int oldtype = tipo_rata(last_rata);
|
||||
TString oldulc = ulc_rata(last_rata);
|
||||
TString8 oldulc = ulc_rata(last_rata);
|
||||
int oldscad = scad_rata(last_rata);
|
||||
TDate lastdate = data_rata(0);
|
||||
int first = _tpr < 4 ? 0 : 1;
|
||||
TString_array srate(_rate); // rate come erano
|
||||
const TString_array srate(_rate); // rate come erano
|
||||
int warnscad = 0;
|
||||
|
||||
if (oldscad <= 0) oldscad = _int_rate;
|
||||
@ -1078,7 +1077,7 @@ bool TPagamento::sign_ok(const real& val, int row) const
|
||||
word TPagamento::change_value_differenziate(int row, real user_val, bool is_perc, bool v)
|
||||
{
|
||||
// importi totali, da non suddividere, da suddividere
|
||||
real to_share = is_perc ? real(100.0) : importo_da_dividere(v);
|
||||
real to_share = is_perc ? CENTO : importo_da_dividere(v);
|
||||
real to_subtract = ZERO;
|
||||
if (row == 0 && _tpr > 0 && _tpr < 4 && !is_perc)
|
||||
to_subtract = importo_da_non_dividere(v);
|
||||
@ -1118,7 +1117,7 @@ word TPagamento::change_value_differenziate(int row, real user_val, bool is_perc
|
||||
word TPagamento::change_value_uguali(int row, real user_val, bool is_perc, bool v)
|
||||
{
|
||||
// importi totali, da non suddividere, da suddividere
|
||||
real to_share = is_perc ? real(100.0) : importo_da_dividere(v);
|
||||
real to_share = is_perc ? CENTO : importo_da_dividere(v);
|
||||
real to_subtract = ZERO;
|
||||
if (row == 0 && _tpr > 0 && _tpr < 4 && !is_perc)
|
||||
to_subtract = importo_da_non_dividere(v);
|
||||
@ -1161,7 +1160,7 @@ word TPagamento::change_value_uguali(int row, real user_val, bool is_perc, bool
|
||||
else // n. rate > 1, modificata la rata 0: _tpr e' per forza < 4
|
||||
{
|
||||
real div = remainder / real(n_rate() - 1);
|
||||
div.round(is_perc ? 2 : round(v));
|
||||
div.round(is_perc ? PERC_DECIMALS : round(v));
|
||||
real delta = remainder - (div * real(n_rate() - 1));
|
||||
|
||||
rata(0).add(user_val.string(), tok_ind);
|
||||
@ -1223,7 +1222,7 @@ word TPagamento::change_value_uguali_prossima(int row, real user_val, bool is_pe
|
||||
_rdiff = TRUE;
|
||||
// uguali finche' possibile da row in poi; residuo su first
|
||||
// importi totali, da non suddividere, da suddividere
|
||||
real to_share = is_perc ? real(100.0) : importo_da_dividere(v);
|
||||
real to_share = is_perc ? CENTO : importo_da_dividere(v);
|
||||
real to_subtract = ZERO;
|
||||
if (row == 0 && _tpr > 0 && _tpr < 4 && !is_perc)
|
||||
to_subtract = importo_da_non_dividere(v);
|
||||
@ -1266,7 +1265,7 @@ word TPagamento::change_value_uguali_possible(int row, real user_val, bool is_pe
|
||||
{
|
||||
_rdiff = TRUE;
|
||||
// uguali finche' possibile da row in poi; residuo come rata a parte
|
||||
real to_share = is_perc ? real(100.0) : importo_da_dividere(v);
|
||||
real to_share = is_perc ? CENTO : importo_da_dividere(v);
|
||||
real to_subtract = ZERO;
|
||||
if (row == 0 && _tpr > 0 && _tpr < 4 && !is_perc)
|
||||
to_subtract = importo_da_non_dividere(v);
|
||||
@ -1357,8 +1356,8 @@ void TPagamento::adjust_perc(int rdiff, bool v)
|
||||
// togli pezzo di troppo
|
||||
if (j == first && _tpr > 0 && _tpr < 4)
|
||||
rvl -= importo_da_non_dividere(v);
|
||||
real zpx = (rvl * 100.0) / other; // percentuale
|
||||
zpx.round(2);
|
||||
real zpx = (rvl * CENTO) / other; // percentuale
|
||||
zpx.round(PERC_DECIMALS);
|
||||
set_percrata(j, zpx);
|
||||
}
|
||||
if (in_valuta())
|
||||
@ -1394,7 +1393,7 @@ void TPagamento::adjust_perc_imp(bool is_perc, int rdiff, bool v)
|
||||
}
|
||||
|
||||
real toshare(importo_da_dividere(v));
|
||||
const real other(100.0);
|
||||
const real other = CENTO;
|
||||
bool inv = in_valuta();
|
||||
|
||||
TDistrib dt(toshare, round(v));
|
||||
@ -1618,7 +1617,7 @@ void TPagamento::set_rate_auto()
|
||||
const int rut = _tpr > 3 ? n_rate() - 1 : n_rate();
|
||||
if (rut > 1) // Guy was here! Don't kill me for this
|
||||
{
|
||||
real refrata = real(100.0)/real(rut); refrata.round(2);
|
||||
real refrata = CENTO/real(rut); refrata.round(PERC_DECIMALS);
|
||||
if (perc_rata(first+1) == refrata) // tutte uguali nonostante perc arrotondate
|
||||
{
|
||||
ro = toslice / real(rut);
|
||||
@ -1628,7 +1627,7 @@ void TPagamento::set_rate_auto()
|
||||
else // la prima e' diversa
|
||||
{
|
||||
// usa la percentuale per la prima rata
|
||||
r1 = (toslice * perc_rata(first))/real(100.0);
|
||||
r1 = (toslice * perc_rata(first))/CENTO;
|
||||
|
||||
const real reminder = toslice - r1;
|
||||
if (!reminder.is_zero())
|
||||
@ -1650,7 +1649,7 @@ void TPagamento::set_rate_auto()
|
||||
{
|
||||
if (_rdiff)
|
||||
{
|
||||
rdi = toslice*(perc_rata(i)/real(100.0));
|
||||
rdi = toslice*(perc_rata(i)/CENTO);
|
||||
rdi.round(round(v));
|
||||
if (i > first) rdsum += rdi;
|
||||
}
|
||||
@ -1774,7 +1773,7 @@ void TPagamento::set_sheet(TSheet_field& sf, int sscad)
|
||||
{
|
||||
if (_tpr > 3)
|
||||
add_rata(ZERO, sscad <= 0 ? 0 : sscad, _def_tpr, _def_ulc);
|
||||
add_rata(real(100.0), sscad <= 0 ? (_tpr < 4 ? 0 : 30) : sscad, _def_tpr, _def_ulc);
|
||||
add_rata(CENTO, sscad <= 0 ? (_tpr < 4 ? 0 : 30) : sscad, _def_tpr, _def_ulc);
|
||||
_dirty = TRUE;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user