Gestione saldaconto (note di credito)
git-svn-id: svn://10.65.10.50/trunk@2256 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
c8b8bd1644
commit
29b6cc3b84
@ -393,9 +393,9 @@ bool TCaus_app::codcausim_hndl (TMask_field& f, KEY k)
|
||||
caus.put(CAU_CODCAUS, causim);
|
||||
if (caus.read() == NOERR)
|
||||
{
|
||||
const int tpm = caus.get_int(CAU_TIPOMOV);
|
||||
// const int tpm = caus.get_int(CAU_TIPOMOV);
|
||||
const TString& codreg = caus.get(CAU_REG);
|
||||
if (codreg.not_empty() || tpm != 0)
|
||||
if (codreg.not_empty() /* || tpm != 0 */)
|
||||
return f.warning_box("La causale per l'incasso/pagamento immediato deve essere puramente contabile");
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ BEGIN
|
||||
USE LF_CAUSALI
|
||||
INPUT CODCAUS F_COD_CAUS
|
||||
DISPLAY "Codice" CODCAUS
|
||||
DISPLAY "Descrizione @50" DESCR
|
||||
DISPLAY "Descrizione@50" DESCR
|
||||
DISPLAY "Documento" TIPODOC
|
||||
DISPLAY "Registro" REG
|
||||
DISPLAY "Tipo movimento" TIPOMOV
|
||||
@ -263,9 +263,11 @@ BEGIN
|
||||
PROMPT 34 8 "Codice causale per l'incasso immediato "
|
||||
FLAGS "UZ"
|
||||
FIELD CODCAUSIM
|
||||
COPY USE F_COD_CAUS
|
||||
USE LF_CAUSALI SELECT REG==""
|
||||
INPUT CODCAUS F_COD_CAUS_IM
|
||||
COPY DISPLAY F_COD_CAUS
|
||||
DISPLAY "Codice" CODCAUS
|
||||
DISPLAY "Descrizione@50" DESCR
|
||||
DISPLAY "Documento" TIPODOC
|
||||
OUTPUT F_COD_CAUS_IM CODCAUS
|
||||
CHECKTYPE NORMAL
|
||||
GROUP 2
|
||||
|
@ -27,15 +27,11 @@
|
||||
|
||||
// Scadenze
|
||||
|
||||
#define S_ANNO 101
|
||||
#define S_NUM 102
|
||||
#define S_RIGA 103
|
||||
#define S_DATADOC 104
|
||||
#define S_NUMPROT 105
|
||||
#define S_NUMDOC 106
|
||||
#define S_DESCR 107
|
||||
#define S_RATA 108
|
||||
#define S_DATA_SCAD 109
|
||||
#define S_IMPORTO_SCAD 110
|
||||
#define S_IMPORTOVAL_SCAD 111
|
||||
#define S_SEZIONE_SCAD 112
|
||||
|
@ -20,7 +20,7 @@ PAGE "PARTITE" -1 -1 77 20
|
||||
|
||||
LIST P_TIPOC 1 12
|
||||
BEGIN
|
||||
PROMPT 1 0 "Tipo conto "
|
||||
PROMPT 1 0 ""
|
||||
ITEM " |Conto"
|
||||
ITEM "C|Cliente"
|
||||
ITEM "F|Fornitore"
|
||||
@ -29,31 +29,31 @@ END
|
||||
|
||||
NUMBER P_GRUPPO 3
|
||||
BEGIN
|
||||
PROMPT 26 0 "Gruppo "
|
||||
PROMPT 14 0 ""
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
NUMBER P_CONTO 3
|
||||
BEGIN
|
||||
PROMPT 40 0 "Conto "
|
||||
PROMPT 19 0 ""
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
NUMBER P_SOTTOCONTO 6
|
||||
BEGIN
|
||||
PROMPT 54 0 "Sottoconto "
|
||||
PROMPT 24 0 ""
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING P_DESCR 50 58
|
||||
STRING P_DESCR 50 38
|
||||
BEGIN
|
||||
PROMPT 1 1 "Descrizione "
|
||||
PROMPT 33 0 ""
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING P_VALUTA 3
|
||||
BEGIN
|
||||
PROMPT 1 2 "Valuta "
|
||||
PROMPT 1 2 "Valuta "
|
||||
HELP "Codice della valuta per movimento"
|
||||
FLAGS "DUZ"
|
||||
END
|
||||
@ -85,13 +85,13 @@ END
|
||||
|
||||
NUMBER P_ANNO 4
|
||||
BEGIN
|
||||
PROMPT 1 3 "Anno "
|
||||
FLAGS "A"
|
||||
PROMPT 1 3 "Partita "
|
||||
FLAGS "U"
|
||||
END
|
||||
|
||||
STRING P_NUMERO 7
|
||||
BEGIN
|
||||
PROMPT 21 3 "Numero "
|
||||
PROMPT 21 3 ""
|
||||
FLAGS "U"
|
||||
END
|
||||
|
||||
@ -132,7 +132,7 @@ BEGIN
|
||||
ITEM "Num. doc."
|
||||
ITEM "Prot. IVA"
|
||||
ITEM "Pagamento"
|
||||
FLAGS "D"
|
||||
// FLAGS "D"
|
||||
END
|
||||
|
||||
BOOLEAN P_SHOWALL
|
||||
|
@ -23,45 +23,11 @@ ENDPAGE
|
||||
|
||||
PAGE "Pagamento" -1 -1 77 20
|
||||
|
||||
GROUPBOX DLG_NULL 78 7
|
||||
GROUPBOX S_RATA 78 6
|
||||
BEGIN
|
||||
PROMPT 1 0 "@BScadenza"
|
||||
PROMPT 1 1 "@BPartita ANNO PARTITA Riga: RIGA Rata: RATA del DATA"
|
||||
END
|
||||
|
||||
NUMBER S_ANNO 4
|
||||
BEGIN
|
||||
PROMPT 2 1 "Anno "
|
||||
FLAGS "D"
|
||||
FIELD ANNO
|
||||
END
|
||||
|
||||
STRING S_NUM 7
|
||||
BEGIN
|
||||
PROMPT 15 1 "Numero "
|
||||
FLAGS "D_"
|
||||
FIELD NUMPART
|
||||
END
|
||||
|
||||
NUMBER S_RIGA 4
|
||||
BEGIN
|
||||
PROMPT 32 1 "Riga "
|
||||
FLAGS "D"
|
||||
FIELD NRIGA
|
||||
END
|
||||
|
||||
NUMBER S_RATA 4
|
||||
BEGIN
|
||||
PROMPT 44 1 "Rata "
|
||||
FLAGS "D"
|
||||
FIELD NRATA
|
||||
END
|
||||
|
||||
DATE S_DATA_SCAD
|
||||
BEGIN
|
||||
PROMPT 57 1 "Scadenza "
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING S_NUMDOC 7
|
||||
BEGIN
|
||||
PROMPT 2 2 "Numero Documento "
|
||||
@ -122,7 +88,7 @@ BEGIN
|
||||
PICTURE "."
|
||||
FLAGS "DRV"
|
||||
END
|
||||
|
||||
|
||||
GROUPBOX DLG_NULL 78 12
|
||||
BEGIN
|
||||
PROMPT 1 7 "@BPagamento"
|
||||
@ -176,8 +142,7 @@ BEGIN
|
||||
ITEM "7|Tratta accettata"
|
||||
ITEM "8|Rapporti interbancari diretti"
|
||||
ITEM "9|Bonifico"
|
||||
ITEM "10|Altro"
|
||||
FIELD TIPOPAG
|
||||
ITEM "0|Altro"
|
||||
END
|
||||
|
||||
DATE S_DATAPAG
|
||||
@ -371,7 +336,6 @@ BEGIN
|
||||
CHECKTYPE NORMAL
|
||||
END
|
||||
|
||||
|
||||
NUMBER S_NSABI 5
|
||||
BEGIN
|
||||
PROMPT 2 17 "Ns. Banca ABI "
|
||||
|
@ -12,42 +12,6 @@
|
||||
#include <rmoviva.h>
|
||||
#include <utility.h>
|
||||
|
||||
/*
|
||||
// Calcola l'anno di esercizio di una data, e se prevesc != NULL calcola anche l'anno precedente
|
||||
// Certified 99%
|
||||
int date2esc(const TDate& d, int* prevesc)
|
||||
{
|
||||
int anno = 0;
|
||||
TDate inizio, fine;
|
||||
|
||||
TTable esc("ESC");
|
||||
for (int err = esc.first(); err == NOERR; err = esc.next())
|
||||
{
|
||||
inizio = esc.get_date("D0"); // Data inizio esercizio
|
||||
fine = esc.get_date("D1"); // Data fine esercizio
|
||||
if (d >= inizio && d <= fine)
|
||||
{
|
||||
const TString& sanno = esc.get("CODTAB").left(4);
|
||||
anno = atoi(sanno);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (prevesc != NULL)
|
||||
{
|
||||
if (anno != 0)
|
||||
{
|
||||
--inizio;
|
||||
*prevesc = date2esc(inizio);
|
||||
}
|
||||
else
|
||||
*prevesc = 0;
|
||||
}
|
||||
|
||||
return anno;
|
||||
}
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Movimento di prima nota
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -148,7 +112,7 @@ int TMovimentoPN::date2liq(const TDate& data) const
|
||||
}
|
||||
|
||||
|
||||
bool TMovimentoPN::controlla_liquidazione(const TDate& data, bool reset) const
|
||||
bool TMovimentoPN::controlla_liquidazione(const TDate& data, TRegistro& registro, bool reset) const
|
||||
{
|
||||
bool calcolata = FALSE;
|
||||
|
||||
@ -171,6 +135,31 @@ bool TMovimentoPN::controlla_liquidazione(const TDate& data, bool reset) const
|
||||
lim.rewrite();
|
||||
}
|
||||
|
||||
if (reset)
|
||||
{
|
||||
const bool att_mista = registro.name().empty() ? FALSE : registro.attivita_mista();
|
||||
const int att = att_mista ? 2 : 1;
|
||||
|
||||
// Chiave di PLM: Anno (1-4), Cod. Att. (5-9), Tipo att. (10-10), Mese (11-12)
|
||||
TTable plm("PLM");
|
||||
for (int a = 1; a <= att; a++)
|
||||
{
|
||||
TString16 chiave;
|
||||
TString16 attivita(registro.attivita()); attivita.right_just(5, '0');
|
||||
chiave << data.year() << attivita << a << format("%02d", data.month());
|
||||
plm.put("CODTAB", chiave);
|
||||
if (plm.read() == NOERR)
|
||||
{
|
||||
const bool calcolato = plm.get_bool("B0");
|
||||
if (calcolato)
|
||||
{
|
||||
plm.zero("B0");
|
||||
plm.rewrite();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return calcolata;
|
||||
}
|
||||
|
||||
@ -230,30 +219,9 @@ int TMovimentoPN::registra(bool re, bool force)
|
||||
|
||||
// Aggiorna flags di ricalcolo liquidazione
|
||||
|
||||
controlla_liquidazione(datareg, TRUE);
|
||||
controlla_liquidazione(datareg, registro, TRUE);
|
||||
if (re && datareg != _olddate)
|
||||
controlla_liquidazione(_olddate, TRUE);
|
||||
|
||||
const int att = att_mista ? 2 : 1;
|
||||
// Chiave di PLM: Anno (1-4), Cod. Att. (5-9), Tipo att. (10-10), Mese (11-12)
|
||||
TTable plm("PLM");
|
||||
plm.setkey(1);
|
||||
for (int a = 1; a <= att; a++)
|
||||
{
|
||||
TString16 chiave;
|
||||
TString16 attivita(registro.attivita()); attivita.right_just(5, '0');
|
||||
chiave << annoiva << attivita << a << format("%02d", datareg.month());
|
||||
plm.put("CODTAB", chiave);
|
||||
if (plm.read() == NOERR)
|
||||
{
|
||||
const bool calcolato = plm.get_bool("B0");
|
||||
if (calcolato)
|
||||
{
|
||||
plm.put("B0", FALSE);
|
||||
plm.rewrite();
|
||||
}
|
||||
}
|
||||
}
|
||||
controlla_liquidazione(_olddate, registro, TRUE);
|
||||
|
||||
return err;
|
||||
}
|
||||
@ -282,9 +250,13 @@ int TMovimentoPN::remove(TDate&)
|
||||
err = TRelation::remove();
|
||||
|
||||
if (err == NOERR)
|
||||
{
|
||||
const TDate datareg(curr().get("DATAREG"));
|
||||
controlla_liquidazione(datareg, TRUE);
|
||||
{
|
||||
const TRectype& m = curr();
|
||||
const TDate datareg(m.get("DATAREG"));
|
||||
const int annoiva = m.get_int("ANNOIVA");
|
||||
const TString16 reg(m.get_str("REG"));
|
||||
TRegistro registro(reg, annoiva);
|
||||
controlla_liquidazione(datareg, registro, TRUE);
|
||||
}
|
||||
|
||||
return err;
|
||||
|
@ -5,6 +5,10 @@
|
||||
#include <relation.h>
|
||||
#endif
|
||||
|
||||
#ifndef __CG2103_H
|
||||
class TRegistro;
|
||||
#endif
|
||||
|
||||
class TMovimentoPN : public TRelation
|
||||
{
|
||||
// class TMovimentoPN : public TRelation
|
||||
@ -42,7 +46,7 @@ public:
|
||||
|
||||
int date2liq(const TDate& data) const; // Estrae dalla data il mese di liquidazione
|
||||
char frequenza_versamenti(int year) const; // Ritorna 'M'ensile o 'T'rimestrale
|
||||
bool controlla_liquidazione(const TDate& data, bool reset = FALSE) const;
|
||||
bool controlla_liquidazione(const TDate& data, TRegistro& reg, bool reset = FALSE) const;
|
||||
|
||||
TMovimentoPN();
|
||||
virtual ~TMovimentoPN() {}
|
||||
|
@ -550,7 +550,7 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
|
||||
if (importo != speso)
|
||||
{
|
||||
const char* ss = speso.valore().string(".");
|
||||
return f.error_box("L'importo della riga %d deve essere %s %c",
|
||||
return f.error_box("L'importo sulla riga %d deve essere %s %c",
|
||||
currig, ss, speso.sezione());
|
||||
}
|
||||
}
|
||||
@ -841,11 +841,12 @@ bool TPrimanota_application::dareavere_handler(TMask_field& f, KEY k)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// cazzorate
|
||||
|
||||
TSheet_field& TPrimanota_application::pags() const
|
||||
{
|
||||
TSheet_field& s = (TSheet_field&)_msk[2]->field(FS_RATESHEET);
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1493,7 +1494,7 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key)
|
||||
reg.last_reg().string(), (const char*)codreg, dr.year());
|
||||
}
|
||||
|
||||
if (reg.iva() != nessuna_iva && app()._rel->controlla_liquidazione(dr) == TRUE)
|
||||
if (reg.iva() != nessuna_iva && app()._rel->controlla_liquidazione(dr, reg) == TRUE)
|
||||
{
|
||||
const char* const mese = itom(dr.month());
|
||||
f.warning_box("La liquidazione IVA relativa al mese di %s e' gia' stata calcolata", mese);
|
||||
@ -1587,7 +1588,7 @@ bool TPrimanota_application::doc_handler(TMask_field& f, KEY key)
|
||||
const TDate dd(val);
|
||||
m.set(F_ANNORIF, dd.year()); // copia anno documento
|
||||
|
||||
if (app().pagamento() != NULL)
|
||||
if (app().is_fattura())
|
||||
app().recalc_scadenze(dd);
|
||||
}
|
||||
else
|
||||
@ -1726,7 +1727,7 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key)
|
||||
TEdit_field& upi = m.efield(F_RIEPILOGO);
|
||||
upi.check_type(alleg == 3 ? CHECK_REQUIRED : CHECK_NORMAL);
|
||||
|
||||
if (m.insert_mode() && m.get(F_CODPAG).empty())
|
||||
if (m.insert_mode() && app().is_fattura() && m.get(F_CODPAG).empty())
|
||||
{
|
||||
const TString& s = clifo.get(CLI_CODPAG);
|
||||
m.set(F_CODPAG, s, s.not_empty());
|
||||
@ -1757,7 +1758,7 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key)
|
||||
}
|
||||
}
|
||||
|
||||
const bool occas = clifo.get_bool(CLI_OCCAS);
|
||||
const bool occas = clifo.get_bool(CLI_OCCAS) && !app().is_saldaconto();
|
||||
m.show(F_OCCASEDIT, occas); // Bottone Dati anagrafici
|
||||
m.show(F_STATOPAIV, !occas); // Stato partita IVA
|
||||
m.show(cf == 'C' ? F_PIVACLIENTE : F_PIVAFORNITORE, !occas); // Partita IVA
|
||||
@ -1770,6 +1771,7 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key)
|
||||
m.send_key(K_SPACE, F_OCCASEDIT); // Lancia maschera occasionali
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1893,23 +1895,23 @@ bool TPrimanota_application::totdocval_handler(TMask_field& f, KEY key)
|
||||
if (totale.is_zero())
|
||||
{
|
||||
totval *= cambio;
|
||||
m.set(F_TOTALE, totval.string(), TRUE);
|
||||
m.set(F_TOTALE, totval, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cambio.is_zero())
|
||||
{
|
||||
totale /= totval;
|
||||
m.set(SK_CAMBIO, totale.string(), TRUE);
|
||||
m.set(SK_CAMBIO, totale, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
TPagamento* pag = app().pagamento();
|
||||
if (pag != NULL) // Se e' una vera fattura
|
||||
if (app().is_fattura()) // Se e' una vera fattura
|
||||
{
|
||||
pag->set_total(totval, ZERO, ZERO);
|
||||
pag->set_rate_auto();
|
||||
pag->set_sheet(app().pags());
|
||||
TPagamento& pag = app().pagamento();
|
||||
pag.set_total(totval, ZERO, ZERO);
|
||||
pag.set_rate_auto();
|
||||
pag.set_sheet(app().pags());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1961,8 +1963,8 @@ bool TPrimanota_application::protiva_handler(TMask_field& f, KEY key)
|
||||
if (key == K_TAB && app().is_saldaconto() &&
|
||||
m.insert_mode() && m.get(F_NUMRIF).empty())
|
||||
{
|
||||
const TString16 piva(f.get());
|
||||
if (app().npart_is_prot() && piva.not_empty())
|
||||
const TString& piva = f.get();
|
||||
if (piva.not_empty() && app().npart_is_prot())
|
||||
m.set(F_NUMRIF, piva);
|
||||
}
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ protected:
|
||||
void reset_cgs_row(int n) { reset_sheet_row(cgs(), n); }
|
||||
void reset_ivas_row(int n) { reset_sheet_row(ivas(), n); }
|
||||
|
||||
TPagamento* pagamento() { /* CHECK(_pag, "Pagamento nullo"); */ return _pag; }
|
||||
TPagamento& pagamento() const;
|
||||
|
||||
void set_pagamento(const char* c, const char* d);
|
||||
void reset_pagamento(TMask& m);
|
||||
|
101
cg/cg2104.cpp
101
cg/cg2104.cpp
@ -15,13 +15,14 @@
|
||||
#include <scadenze.h>
|
||||
#include <pagsca.h>
|
||||
|
||||
TPagamento& TPrimanota_application::pagamento() const
|
||||
{
|
||||
CHECK(_pag, "Pagamento nullo");
|
||||
return *_pag;
|
||||
}
|
||||
bool TPrimanota_application::pag_notify(TSheet_field& ps, int r, KEY k)
|
||||
{
|
||||
TPagamento* pg = app().pagamento();
|
||||
if (pg == NULL)
|
||||
return TRUE;
|
||||
|
||||
TPagamento& pag = *pg;
|
||||
TPagamento& pag = app().pagamento();
|
||||
TMask* msk = &(ps.mask());
|
||||
TString_array& rws = app().pag_rows();
|
||||
|
||||
@ -146,17 +147,14 @@ bool TPrimanota_application::pag_sheet_handler(TMask_field& f, KEY key)
|
||||
bool ok = TRUE;
|
||||
if (key == K_TAB || key == K_ENTER)
|
||||
{
|
||||
TPagamento* pag = app().pagamento();
|
||||
if (pag != NULL)
|
||||
TPagamento& pag = app().pagamento();
|
||||
const word err = pag.validate();
|
||||
if (err != P_OK)
|
||||
{
|
||||
const word err = pag->validate();
|
||||
if (err != P_OK)
|
||||
{
|
||||
TString256 s;
|
||||
pag->strerr(err, s);
|
||||
error_box(s);
|
||||
ok = FALSE;
|
||||
}
|
||||
TString s(256);
|
||||
pag.strerr(err, s);
|
||||
error_box(s);
|
||||
ok = FALSE;
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
@ -229,18 +227,18 @@ bool TPrimanota_application::cambio_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
if (key == K_TAB && f.focusdirty())
|
||||
{
|
||||
TPagamento* pag = app().pagamento();
|
||||
if (pag != NULL)
|
||||
if (app().is_fattura())
|
||||
{
|
||||
TPagamento& pag = app().pagamento();
|
||||
const real ex(f.get());
|
||||
pag->set_cambio(ex);
|
||||
pag.set_cambio(ex);
|
||||
|
||||
TMask& m = f.mask();
|
||||
if (m.insert_mode())
|
||||
{
|
||||
pag->set_rate_auto();
|
||||
pag.set_rate_auto();
|
||||
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
|
||||
pag->set_sheet(ps);
|
||||
pag.set_sheet(ps);
|
||||
app().pag_rows() = ps.rows_array();
|
||||
}
|
||||
const TValuta val(m, SK_VALUTA, SK_DATACAMBIO, SK_CAMBIO);
|
||||
@ -269,8 +267,8 @@ bool TPrimanota_application::recalc_handler(TMask_field& f, KEY key)
|
||||
const TMask& m = f.mask();
|
||||
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
|
||||
ps.enable_column(3, on);
|
||||
TPagamento* pag = app().pagamento();
|
||||
if (pag->tipo_prima_rata() >= 4)
|
||||
TPagamento& pag = app().pagamento();
|
||||
if (pag.tipo_prima_rata() >= 4)
|
||||
{
|
||||
ps.enable_cell(0, 1, on);
|
||||
ps.enable_cell(0, 2, on);
|
||||
@ -284,14 +282,13 @@ bool TPrimanota_application::nrate_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
if (key == K_TAB && f.focusdirty())
|
||||
{
|
||||
TPagamento* pag = app().pagamento();
|
||||
CHECK(pag != NULL, "Null pagament");
|
||||
pag->set_numero_rate(atoi(f.get()));
|
||||
if (pag->dirty())
|
||||
TPagamento& pag = app().pagamento();
|
||||
pag.set_numero_rate(atoi(f.get()));
|
||||
if (pag.dirty())
|
||||
{
|
||||
TMask& m = f.mask();
|
||||
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
|
||||
pag->set_sheet(ps);
|
||||
pag.set_sheet(ps);
|
||||
app().pag_rows() = ps.rows_array();
|
||||
}
|
||||
}
|
||||
@ -320,50 +317,23 @@ bool TPrimanota_application::codcab_handler(TMask_field& f, KEY key)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TPrimanota_application::reset_pagamento(TMask& m)
|
||||
void TPrimanota_application::reset_pagamento(TMask&)
|
||||
{
|
||||
// se in modifica, rilegge totali e date dalla maschera; altrimenti
|
||||
// rilegge il pagamento da disco
|
||||
if (_pag != NULL)
|
||||
{
|
||||
/* if (!m.edit_mode())*/ _pag->read();
|
||||
/*
|
||||
else
|
||||
{
|
||||
const real spese(0.0);
|
||||
real imponibile, imposta;
|
||||
const real cambio(m.get(S_CAMBIO));
|
||||
if (cambio.is_zero())
|
||||
{
|
||||
imponibile = real(m.get(F_IMPONIBILI));
|
||||
imposta = real(m.get(F_IMPOSTE));
|
||||
}
|
||||
else
|
||||
{
|
||||
_pag->set_cambio(cambio);
|
||||
imponibile = real(m.get(S_TOTDOCVAL));
|
||||
imposta = ZERO;
|
||||
}
|
||||
_pag->set_inizio(m.get_date(F_DATADOC));
|
||||
_pag->set_total(imponibile, imposta, spese);
|
||||
}
|
||||
*/
|
||||
_pag->set_rate_auto();
|
||||
}
|
||||
TPagamento& pag = pagamento();
|
||||
pag.read();
|
||||
pag.set_rate_auto();
|
||||
}
|
||||
|
||||
void TPrimanota_application::recalc_scadenze(const TDate& d)
|
||||
{
|
||||
CHECK(_pag != NULL, "Can't handle null pagament");
|
||||
|
||||
_pag->set_inizio(d);
|
||||
TPagamento& pag = pagamento();
|
||||
pag.set_inizio(d);
|
||||
// ridefinisci lo sheet sulla base delle nuove rate
|
||||
TSheet_field& ps = pags();
|
||||
TString_array& rws = pag_rows();
|
||||
|
||||
_pag->set_sheet(ps);
|
||||
pag.set_sheet(ps);
|
||||
rws = ps.rows_array();
|
||||
// ps.force_update();
|
||||
}
|
||||
|
||||
void TPrimanota_application::set_pagamento(const char* c, const char* d)
|
||||
@ -382,7 +352,7 @@ void TPrimanota_application::set_scadenze(TMask& m)
|
||||
real imponibile, imposta;
|
||||
const real spese(0.0);
|
||||
const real cambio(m.get(SK_CAMBIO));
|
||||
TPagamento& pag = *pagamento();
|
||||
TPagamento& pag = pagamento();
|
||||
|
||||
if (cambio <= 1.0)
|
||||
{
|
||||
@ -431,8 +401,7 @@ bool TPrimanota_application::read_scadenze(TMask& m)
|
||||
real imponibile, imposta;
|
||||
const real spese(0.0);
|
||||
|
||||
TPagamento& pag = *pagamento();
|
||||
|
||||
TPagamento& pag = pagamento();
|
||||
bool in_valuta = FALSE;
|
||||
if (cambio.sign() > 0)
|
||||
{
|
||||
@ -581,7 +550,7 @@ void TPrimanota_application::write_scadenze(const TMask& m)
|
||||
|
||||
const int row = newgame->prima_fattura(nreg);
|
||||
TRiga_partite& partita = row <= 0 ? newgame->new_row() : newgame->riga(row);
|
||||
TPagamento& pag = *pagamento();
|
||||
TPagamento& pag = pagamento();
|
||||
|
||||
// put data on partita
|
||||
partita.put(PART_TIPOMOV, tmov);
|
||||
@ -934,4 +903,4 @@ bool TPrimanota_application::notify_cgline_deletion(int numrig)
|
||||
for (TPartita* game = partite().first(); game; game = partite().next())
|
||||
found |= notify_cgline_deletion(*game, nreg, numrig);
|
||||
return found;
|
||||
}
|
||||
}
|
||||
|
141
cg/cg2105.cpp
141
cg/cg2105.cpp
@ -48,6 +48,14 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad,
|
||||
const int nrigp = oldpag.get_int(PAGSCA_NRIGP);
|
||||
const TRiga_partite& sum = p.riga(nrigp);
|
||||
const TRiga_partite& fatt = scad.riga();
|
||||
|
||||
TMask_field& group = field(S_RATA);
|
||||
TString prompt(80);
|
||||
prompt << "Partita:" << p.anno() << ' ' << p.numero()
|
||||
<< " Riga:" << fatt.get_int(PART_NRIGA)
|
||||
<< " Rata:" << scad.get_int(SCAD_NRATA)
|
||||
<< " del " << scad.get_date(SCAD_DATASCAD).string();
|
||||
group.set(prompt);
|
||||
|
||||
set(S_NUMDOC, fatt.get(PART_NUMDOC)); // Numero documento
|
||||
set(S_DATADOC, fatt.get(PART_DATADOC)); // Data documento
|
||||
@ -55,8 +63,8 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad,
|
||||
|
||||
set(S_DESCR, sum.get(PART_DESCR)); // Descrizione documento
|
||||
set(S_DATAPAG, sum.get(PART_DATAPAG)); // Data pagamento
|
||||
set(S_TIPOPAG, sum.get(PART_TIPOPAG)); // Tipo pagamento
|
||||
|
||||
set(S_DATA_SCAD, scad.get(SCAD_DATASCAD)); // Data della scadenza
|
||||
set(S_SEZIONE_SCAD, scad.riga().sezione()); // Sezione della rata
|
||||
set(S_IMPORTO_SCAD, scad.get(SCAD_IMPORTO)); // Importo della rata
|
||||
set(S_IMPORTOVAL_SCAD, scad.get(SCAD_IMPORTOVAL)); // Importo in valuta
|
||||
@ -109,7 +117,8 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad,
|
||||
{
|
||||
hide(S_RESIDUORATA); // Se non assegnato nascondi residuo rata
|
||||
}
|
||||
enable(S_SALDOACC, sa); // Mostra saldo solo se non e' un acconto
|
||||
// Mostra saldo solo se non e' ne' un acconto, ne' una nota di credito
|
||||
enable(S_SALDOACC, sa && !sum.is_nota_credito());
|
||||
|
||||
show(-3, in_valuta); // Attiva campi relativi alla valuta
|
||||
|
||||
@ -205,7 +214,7 @@ class TGame_mask : public TMask
|
||||
int _riga_partite; // Riga corrente delle partite
|
||||
bool _changed;
|
||||
|
||||
int _tipomov; // Dati per la creazione di un nuovo movimento
|
||||
tipo_movimento _tipomov; // Dati per la creazione di un nuovo movimento
|
||||
char _sezione;
|
||||
TDate _datadoc;
|
||||
TString _codpag, _descr, _numdoc;
|
||||
@ -242,8 +251,10 @@ protected:
|
||||
bool prima_nota(const long nreg);
|
||||
#endif
|
||||
|
||||
const TRiga_partite* cerca_prima_riga() const;
|
||||
bool cerca_valuta(TValuta& val) const;
|
||||
void aggiorna_valuta(const TValuta& val);
|
||||
void aggiorna_sorelle(const TRiga_partite& part) const;
|
||||
|
||||
public:
|
||||
TSheet_field& partite() const { return (TSheet_field&)field(P_PARTITE); }
|
||||
@ -375,23 +386,31 @@ real TGame_mask::aggiorna_residuo()
|
||||
#endif
|
||||
}
|
||||
|
||||
// Scandisce tutte le partite per cercare la prima del movimento corrente e la sua valuta
|
||||
bool TGame_mask::cerca_valuta(TValuta& val) const
|
||||
{
|
||||
bool found = FALSE;
|
||||
// Scandisce tutte le partite per cercare la prima del movimento corrente
|
||||
const TRiga_partite* TGame_mask::cerca_prima_riga() const
|
||||
{
|
||||
const TRiga_partite* riga = NULL;
|
||||
TPartite_array& pa = app().partite();
|
||||
for (const TPartita* game = pa.first(); game; game = pa.next())
|
||||
{
|
||||
for (const TPartita* game = pa.first(); game != NULL; game = pa.next())
|
||||
{
|
||||
const int r = game->mov2rig(_numreg, _numrig);
|
||||
if (r > 0)
|
||||
{
|
||||
const TRiga_partite& row = game->riga(r);
|
||||
val.get(row);
|
||||
found = TRUE;
|
||||
{
|
||||
riga = &game->riga(r);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return found;
|
||||
return riga;
|
||||
}
|
||||
|
||||
|
||||
// Cerca la valuta della prima riga di partita relativa al movimento corrente
|
||||
bool TGame_mask::cerca_valuta(TValuta& val) const
|
||||
{
|
||||
const TRiga_partite* row = cerca_prima_riga();
|
||||
if (row != NULL)
|
||||
val.get(*row);
|
||||
return row != NULL;
|
||||
}
|
||||
|
||||
void TGame_mask::aggiorna_valuta(const TValuta& val)
|
||||
@ -453,6 +472,24 @@ void TGame_mask::aggiorna_valuta(const TValuta& val)
|
||||
fill_partite(annorif, numrif);
|
||||
}
|
||||
|
||||
void TGame_mask::aggiorna_sorelle(const TRiga_partite& part) const
|
||||
{
|
||||
TPartite_array& pa = app().partite();
|
||||
for (TPartita* game = pa.first(); game; game = pa.next())
|
||||
{
|
||||
for (int r = game->last(); r > 0; r = game->pred(r))
|
||||
{
|
||||
TRiga_partite& row = game->riga(r);
|
||||
if (row.get_long(PART_NREG) == _numreg && row.get_int(PART_NUMRIG) == _numrig)
|
||||
{
|
||||
row.put(PART_DESCR, part.get(PART_DESCR));
|
||||
row.put(PART_DATAPAG, part.get(PART_DATAPAG));
|
||||
row.put(PART_TIPOPAG, part.get(PART_TIPOPAG));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
{
|
||||
TGame_mask& gm = (TGame_mask&)partite.mask();
|
||||
@ -685,7 +722,7 @@ int TGame_mask::nuova_riga(TPartita& partita) const
|
||||
valuta.put(part);
|
||||
|
||||
#ifdef __EXTRA__
|
||||
part.put(PART_TIPOMOV, _tipomov);
|
||||
part.put(PART_TIPOMOV, (int)_tipomov);
|
||||
part.put(PART_DESCR, _descr);
|
||||
part.put(PART_NUMDOC, _numdoc);
|
||||
part.put(PART_DATADOC, _datadoc);
|
||||
@ -694,7 +731,7 @@ int TGame_mask::nuova_riga(TPartita& partita) const
|
||||
part.put(PART_SEZ, _sezione);
|
||||
part.put(PART_SEZABB, _sezione);
|
||||
part.put(PART_SEZDIFCAM,_sezione);
|
||||
if (_tipomov == 1)
|
||||
if (_tipomov == tm_fattura)
|
||||
{
|
||||
part.put(PART_IMPORTO, _importo.valore());
|
||||
if (valuta.in_valuta())
|
||||
@ -706,14 +743,23 @@ int TGame_mask::nuova_riga(TPartita& partita) const
|
||||
#else
|
||||
TMask& cm = app().curr_mask();
|
||||
const TCausale& causale = app().causale();
|
||||
const int tipomov = causale.tipomov();
|
||||
part.put(PART_TIPOMOV, tipomov);
|
||||
part.put(PART_DESCR, cm.get(F_DESCR));
|
||||
const tipo_movimento tm = (tipo_movimento)causale.tipomov();
|
||||
part.put(PART_TIPOMOV, (int)tm);
|
||||
part.put(PART_NUMDOC, cm.get(F_NUMDOC));
|
||||
part.put(PART_DATADOC, cm.get(F_DATADOC));
|
||||
part.put(PART_DATAREG, cm.get(F_DATAREG));
|
||||
part.put(PART_DESCR, cm.get(F_DESCR));
|
||||
part.put(PART_DATAPAG, cm.get(F_DATAREG));
|
||||
|
||||
part.put(PART_TIPOPAG, 1);
|
||||
|
||||
const TRiga_partite* prima = (tm != tm_fattura) ? cerca_prima_riga() : NULL;
|
||||
if (prima != NULL && prima != &part)
|
||||
{
|
||||
part.put(PART_DESCR, prima->get(PART_DESCR));
|
||||
part.put(PART_DATAPAG, prima->get(PART_DATAPAG));
|
||||
part.put(PART_TIPOPAG, prima->get(PART_TIPOPAG));
|
||||
}
|
||||
|
||||
// Copia dati causale corrente
|
||||
part.put(PART_CODCAUS, causale.codice());
|
||||
if (causale.iva() != nessuna_iva)
|
||||
@ -727,16 +773,16 @@ int TGame_mask::nuova_riga(TPartita& partita) const
|
||||
char sezione = causale.sezione(1); // Usa la sezione della causale
|
||||
if (sezione <= ' ') // Se non c'e' la sezione bell'e' ch'e' pronta
|
||||
{
|
||||
if (tipomov == 1 || tipomov == 5) // calcola in base al tipo movimento e
|
||||
sezione = (tipoc == 'C') ? 'D' : 'A'; // al tipo cliente/fornitore
|
||||
if (tm == tm_fattura || tm == tm_insoluto) // calcola in base al tipo movimento e
|
||||
sezione = (tipoc == 'C') ? 'D' : 'A'; // al tipo cliente/fornitore
|
||||
else
|
||||
sezione = (tipoc == 'C') ? 'A' : 'D';
|
||||
}
|
||||
if (tipoc > ' ') // Se il tipo e' C o F
|
||||
if (tipoc > ' ') // Se il tipo e' C o F
|
||||
{
|
||||
TBill bill; causale.bill(1, bill); // Legge primo conto causale
|
||||
TBill bill; causale.bill(1, bill); // Legge primo conto causale
|
||||
if (bill.tipo() != tipoc)
|
||||
sezione = (sezione == 'D') ? 'A' : 'D'; // scambia segno
|
||||
sezione = (sezione == 'D') ? 'A' : 'D'; // scambia segno
|
||||
}
|
||||
// Memorizza solo la sezione (importi nulli)
|
||||
part.put(PART_SEZ, sezione);
|
||||
@ -790,7 +836,9 @@ int TGame_mask::nuovo_pagamento(TPartita& partita, int nriga, int rata) const
|
||||
caus = 2; break;
|
||||
}
|
||||
|
||||
pagamento.put(PAGSCA_TIPOPAG, tp);
|
||||
TRiga_partite& somma = partita.riga(nrigp);
|
||||
somma.put(PART_TIPOPAG, tp);
|
||||
|
||||
pagamento.put(PAGSCA_CODABIPR, scad.get(SCAD_CODABIPR));
|
||||
pagamento.put(PAGSCA_CODCABPR, scad.get(SCAD_CODCABPR));
|
||||
pagamento.put(PAGSCA_CODABI, scad.get(SCAD_CODABI));
|
||||
@ -914,7 +962,7 @@ bool TGame_mask::nuovo_handler(TMask_field& f, KEY k)
|
||||
#ifndef __EXTRA__
|
||||
const TMask& cm = app().curr_mask();
|
||||
new_game.disable(-1);
|
||||
gm._tipomov = app().causale().tipomov();
|
||||
gm._tipomov = (tipo_movimento)app().causale().tipomov();
|
||||
new_game.set(P_NUOVO, gm._tipomov);
|
||||
new_game.set(P_SEZIONE, gm._importo.sezione());
|
||||
new_game.set(P_RESIDUO, gm.get(P_RESIDUO));
|
||||
@ -934,7 +982,7 @@ bool TGame_mask::nuovo_handler(TMask_field& f, KEY k)
|
||||
anno = new_game.get_int(P_ANNO);
|
||||
numero = new_game.get(P_NUMERO);
|
||||
|
||||
gm._tipomov = new_game.get_int(P_NUOVO);
|
||||
gm._tipomov = (tipo_movimento)new_game.get_int(P_NUOVO);
|
||||
gm._codpag = new_game.get(P_CODPAG);
|
||||
gm._sezione = new_game.get(P_SEZIONE)[0];
|
||||
gm._importo.set(gm._sezione, real(new_game.get(P_RESIDUO)));
|
||||
@ -1186,8 +1234,9 @@ bool TGame_mask::edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) co
|
||||
{
|
||||
TRectype oldpag = p.pagamento(nriga, nrata, nrigp);
|
||||
TRiga_partite& somma = p.riga(nrigp);
|
||||
|
||||
TPay_mask m;
|
||||
|
||||
TPay_mask* pm = new TPay_mask;
|
||||
TPay_mask& m = *pm;
|
||||
|
||||
if (nriga == TPartita::UNASSIGNED)
|
||||
{
|
||||
@ -1207,28 +1256,33 @@ bool TGame_mask::edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) co
|
||||
const bool nuovo = oldpag.get(PAGSCA_ACCSAL) != "S" &&
|
||||
oldpag.get_real(PAGSCA_IMPORTO).is_zero() &&
|
||||
oldpag.get_real(PAGSCA_RITENUTE).is_zero();
|
||||
|
||||
|
||||
KEY key = m.run();
|
||||
|
||||
|
||||
if (key == K_ESC && nuovo)
|
||||
key = K_DEL;
|
||||
|
||||
if (key == K_ENTER || key == K_DEL)
|
||||
{
|
||||
TRectype newpag(oldpag);
|
||||
|
||||
if (key == K_DEL)
|
||||
{
|
||||
m.reset(S_SALDOACC); // Non puo' essere un saldo
|
||||
m.reset(S_IMPORTO); // Azzera importo ...
|
||||
m.reset(S_IMPORTOVAL); // .. anche in valuta
|
||||
m.reset(S_RITENUTE); // Azzera ritenute
|
||||
newpag.zero(PAGSCA_ACCSAL); // Non puo' essere un saldo
|
||||
newpag.zero(PAGSCA_IMPORTO); // Azzera importo ...
|
||||
newpag.zero(PAGSCA_IMPORTOVAL); // .. anche in valuta
|
||||
newpag.zero(PAGSCA_RITENUTE); // Azzera ritenute
|
||||
}
|
||||
else
|
||||
{
|
||||
m.get_pag(newpag);
|
||||
somma.put(PART_DESCR, m.get(S_DESCAGG)); // Aggiorna descrizione (comune alla riga)
|
||||
somma.put(PART_DATAPAG, m.get(S_DATAPAG)); // Aggiorna data pagamento (comune alla riga)
|
||||
somma.put(PART_TIPOPAG, m.get(S_TIPOPAG)); // Aggiorna tipo pagamento (comune alla riga)
|
||||
#ifndef __EXTRA__
|
||||
aggiorna_sorelle(somma);
|
||||
#endif
|
||||
}
|
||||
TRectype newpag(oldpag);
|
||||
m.get_pag(newpag);
|
||||
|
||||
TValuta val;
|
||||
#ifdef __EXTRA__
|
||||
@ -1241,6 +1295,8 @@ bool TGame_mask::edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) co
|
||||
app().notify_edit_pagamento(p, newpag, val);
|
||||
#endif
|
||||
}
|
||||
|
||||
delete pm;
|
||||
|
||||
return key != K_ESC;
|
||||
}
|
||||
@ -1270,10 +1326,11 @@ bool TPrimanota_application::edit_partite(const TMask& m, int riga)
|
||||
partite().update_reg(mov);
|
||||
|
||||
// Esecuzione maschera di selezione partite
|
||||
TGame_mask mask(b, mov.get_long(MOV_NUMREG), riga+1);
|
||||
mask.run();
|
||||
TGame_mask* mask = new TGame_mask(b, mov.get_long(MOV_NUMREG), riga+1);
|
||||
mask->run();
|
||||
const bool changed = mask->changed();
|
||||
delete mask;
|
||||
|
||||
const bool changed = mask.changed();
|
||||
if (changed)
|
||||
{
|
||||
cgs().force_update(); // Aggiornamento righe contabili
|
||||
|
@ -10,7 +10,7 @@ class TBill : public TSortable
|
||||
char _tipo; // ' ' = Conto, 'C' = Cliente, 'F' = 'Fornitore'
|
||||
int _gruppo, _conto;
|
||||
long _sottoconto; // Sottoconto, codice cliente o fornitore
|
||||
TString80 _descrizione; // Vuota fino alla chiamata di describe
|
||||
TString _descrizione; // Vuota fino alla chiamata di describe
|
||||
int _tipo_cr; // Tipo costo/ricavo
|
||||
bool _sospeso;
|
||||
char _sezione;
|
||||
|
@ -1037,7 +1037,7 @@ TImporto TPartita::importo_speso(long nreg, int numrig) const
|
||||
{
|
||||
const TRiga_partite& row = riga(r);
|
||||
if (nreg == row.get_long(PART_NREG) && numrig == row.get_int(PART_NUMRIG))
|
||||
imp += row.importo(FALSE); // Importo in lire
|
||||
imp += row.importo(FALSE, 0x7); // Importo in lire
|
||||
}
|
||||
|
||||
return imp;
|
||||
|
Loading…
x
Reference in New Issue
Block a user