sc0101.cpp Corretti conflitti

sc1200.cpp  Corretta apertura partite da saldi
sc1200a.uml Aggiustata maschera


git-svn-id: svn://10.65.10.50/trunk@2100 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-11-07 10:07:04 +00:00
parent 24492c5ec1
commit 7cb6b921f8
3 changed files with 104 additions and 64 deletions

View File

@ -23,27 +23,32 @@ protected: // TMask
virtual void start_run(); virtual void start_run();
virtual bool stop_run(KEY k); virtual bool stop_run(KEY k);
protected: protected:
static bool totdoc_handler(TMask_field& f, KEY k);
static bool pag_notify(TSheet_field& ps, int r, KEY k); static bool pag_notify(TSheet_field& ps, int r, KEY k);
static bool pag_handler(TMask_field& f, KEY key); static bool pag_handler(TMask_field& f, KEY key);
static bool reset_handler(TMask_field& f, KEY key); static bool reset_handler(TMask_field& f, KEY key);
static bool recalc_handler(TMask_field& f, KEY key); static bool recalc_handler(TMask_field& f, KEY key);
static bool nrate_handler(TMask_field& f, KEY key); static bool nrate_handler(TMask_field& f, KEY key);
static bool codcab_handler(TMask_field& f, KEY key); static bool codcab_handler(TMask_field& f, KEY key);
TPagamento& pagamento() const { return *_pag; }
TSheet_field& pag_sheet() const { return (TSheet_field&)field(FS_RATESHEET); } TSheet_field& pag_sheet() const { return (TSheet_field&)field(FS_RATESHEET); }
void pag2sheet();
void read_scadenze(); void read_scadenze();
void write_scadenze() const; void write_scadenze() const;
public: public:
TFattura_mask(TRiga_partite& fattura, const TString& codpag); TFattura_mask(TRiga_partite& fattura, const TString& codpag);
virtual ~TFattura_mask() {} virtual ~TFattura_mask();
}; };
TFattura_mask::TFattura_mask(TRiga_partite& fattura, const TString& codpag) TFattura_mask::TFattura_mask(TRiga_partite& fattura, const TString& codpag)
: TMask("sc0100b"), _fattura(fattura), _pag(NULL) : TMask("sc0100b"), _fattura(fattura), _pag(NULL)
{ {
enable(FS_IMPONIBILI);
set_handler(FS_IMPONIBILI, totdoc_handler);
set_handler(FS_RESET, reset_handler); set_handler(FS_RESET, reset_handler);
set_handler(FS_RECALC, recalc_handler); set_handler(FS_RECALC, recalc_handler);
set_handler(FS_NRATE, nrate_handler); set_handler(FS_NRATE, nrate_handler);
@ -54,10 +59,15 @@ TFattura_mask::TFattura_mask(TRiga_partite& fattura, const TString& codpag)
pag_sheet().set_handler(pag_handler); pag_sheet().set_handler(pag_handler);
const TRiga_partite& partita = _fattura; const TRiga_partite& partita = _fattura;
const TString16 datadoc = partita.get(PART_DATADOC); const TString datadoc = partita.get(PART_DATADOC);
_pag = new TPagamento(codpag, datadoc); _pag = new TPagamento(codpag, datadoc);
} }
TFattura_mask::~TFattura_mask()
{
delete _pag;
}
void TFattura_mask::start_run() void TFattura_mask::start_run()
{ {
read_scadenze(); read_scadenze();
@ -71,6 +81,14 @@ bool TFattura_mask::stop_run(KEY k)
return ok; return ok;
} }
void TFattura_mask::pag2sheet()
{
TPagamento& pag = pagamento();
TSheet_field& ps = pag_sheet();
pag.set_sheet(ps);
_pag_rows = ps.rows_array();
}
bool TFattura_mask::pag_notify(TSheet_field& ps, int r, KEY k) bool TFattura_mask::pag_notify(TSheet_field& ps, int r, KEY k)
{ {
if (k == K_INS || k == K_DEL) if (k == K_INS || k == K_DEL)
@ -87,7 +105,7 @@ bool TFattura_mask::pag_notify(TSheet_field& ps, int r, KEY k)
const int impos = in_valuta ? 2 : 1; const int impos = in_valuta ? 2 : 1;
bool doit = TRUE, m_imp = FALSE, m_perc = FALSE, m_pag = FALSE; bool doit = TRUE, m_imp = FALSE, m_perc = FALSE, m_pag = FALSE;
bool m_scad = FALSE, m_tipo = FALSE, mod = FALSE; bool m_scad = FALSE, m_tipo = FALSE, m_ulc = FALSE, mod = FALSE;
word ahiahi = P_OK; word ahiahi = P_OK;
const bool recalc = fm.get_bool(FS_RECALC); const bool recalc = fm.get_bool(FS_RECALC);
@ -100,6 +118,7 @@ bool TFattura_mask::pag_notify(TSheet_field& ps, int r, KEY k)
const TString newi = ns.get(impos); // Imponibile (lire o valuta) const TString newi = ns.get(impos); // Imponibile (lire o valuta)
const TString newp = ns.get(3); // Percentuale const TString newp = ns.get(3); // Percentuale
const TString newt = ns.get(4); // Tipo pagamento const TString newt = ns.get(4); // Tipo pagamento
const TString newu = ns.get(5); // Ulteriore classificazione
// qui viene il bello, si fa per dire // qui viene il bello, si fa per dire
if (news != ts.get(0)) // modificata data scadenza if (news != ts.get(0)) // modificata data scadenza
@ -114,7 +133,8 @@ bool TFattura_mask::pag_notify(TSheet_field& ps, int r, KEY k)
} }
if (newt != ts.get(4)) // modificato tipo pagamento if (newt != ts.get(4)) // modificato tipo pagamento
mod = m_tipo = TRUE; mod = m_tipo = TRUE;
if (newu != ts.get(5)) // modificato tipo pagamento
mod = m_ulc = TRUE;
// settato da recalc_rate se occorre ridefinire lo sheet // settato da recalc_rate se occorre ridefinire lo sheet
// aggiungendo o togliendo righe // aggiungendo o togliendo righe
@ -128,7 +148,8 @@ bool TFattura_mask::pag_notify(TSheet_field& ps, int r, KEY k)
(m_perc ? (const char*)newp : (const char*)newi) : (m_perc ? (const char*)newp : (const char*)newi) :
NULL), NULL),
(m_scad ? (const char*)news : NULL), (m_scad ? (const char*)news : NULL),
(m_tipo ? (const char*)newt : NULL), (m_tipo ? (const char*)newt : NULL),
(m_ulc ? (const char*)newu : NULL),
rdiff, mcomm, need_recalc); rdiff, mcomm, need_recalc);
// see if rdiff changed // see if rdiff changed
fm.set(FS_RDIFFER, pag.rate_differenziate() ? "1" : "2"); fm.set(FS_RDIFFER, pag.rate_differenziate() ? "1" : "2");
@ -163,13 +184,27 @@ bool TFattura_mask::pag_notify(TSheet_field& ps, int r, KEY k)
else if (recalc && mod && need_recalc) else if (recalc && mod && need_recalc)
{ {
// ridefinisci lo sheet sulla base delle nuove rate // ridefinisci lo sheet sulla base delle nuove rate
pag.set_sheet(ps); fm.pag2sheet();
rws = ps.rows_array();
} }
return doit; return doit;
} }
bool TFattura_mask::totdoc_handler(TMask_field& f, KEY k)
{
if (k == K_TAB && f.focusdirty())
{
TFattura_mask& fm = (TFattura_mask&)f.mask();
TPagamento& pag = fm.pagamento();
const real tot(f.get());
pag.set_total(tot, ZERO, ZERO);
pag.set_rate_auto();
fm.pag2sheet();
}
return TRUE;
}
bool TFattura_mask::pag_handler(TMask_field& f, KEY key) bool TFattura_mask::pag_handler(TMask_field& f, KEY key)
{ {
if (key == K_TAB || key == K_ENTER) if (key == K_TAB || key == K_ENTER)
@ -218,13 +253,9 @@ bool TFattura_mask::nrate_handler(TMask_field& f, KEY key)
{ {
TFattura_mask& fm = (TFattura_mask&)f.mask(); TFattura_mask& fm = (TFattura_mask&)f.mask();
TPagamento& pag = *fm._pag; TPagamento& pag = *fm._pag;
pag.set_numero_rate(atoi(f.get())); pag.set_numero_rate(atoi(f.get()));
if (pag.dirty()) if (pag.dirty())
{ fm.pag2sheet();
TSheet_field& ps = (TSheet_field&)fm.field(FS_RATESHEET);
pag.set_sheet(ps);
}
} }
return TRUE; return TRUE;
} }
@ -235,7 +266,7 @@ bool TFattura_mask::codcab_handler(TMask_field& f, KEY key)
{ {
const TMask& m = f.mask(); const TMask& m = f.mask();
const short id = f.dlg() == FS_NSCAB ? FS_NSABI : FS_VSABI; const short id = f.dlg() == FS_NSCAB ? FS_NSABI : FS_VSABI;
const int pos = id == FS_NSABI ? 6 : 8; const int pos = id == FS_NSABI ? 7 : 9;
const TString16 abi = m.get(id); const TString16 abi = m.get(id);
const TString16 cab = m.get(id+1); const TString16 cab = m.get(id+1);
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET); TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
@ -284,11 +315,11 @@ void TFattura_mask::read_scadenze()
for (int i = 1; i <= partita.rate(); i++) for (int i = 1; i <= partita.rate(); i++)
{ {
const TRiga_scadenze& scadenza = partita.rata(i); const TRiga_scadenze& scadenza = partita.rata(i);
real importo = scadenza.get(SCAD_IMPORTO); real importo = scadenza.get(SCAD_IMPORTO);
const TDate scad = scadenza.get(SCAD_DATASCAD); const TDate scad = scadenza.get(SCAD_DATASCAD);
const int tipop = scadenza.get_int(SCAD_TIPOPAG); const int tipop = scadenza.get_int(SCAD_TIPOPAG);
const bool paid = scadenza.get_bool(SCAD_PAGATA); const bool paid = scadenza.get_bool(SCAD_PAGATA);
const TString16 ulc = scadenza.get(SCAD_ULTCLASS); const TString ulc = scadenza.get(SCAD_ULTCLASS);
if (scadenza.in_valuta()) if (scadenza.in_valuta())
{ {
const real impval(scadenza.get(SCAD_IMPORTOVAL)); const real impval(scadenza.get(SCAD_IMPORTOVAL));
@ -298,23 +329,22 @@ void TFattura_mask::read_scadenze()
pag.set_rata(i-1, importo, ZERO, scad, tipop, ulc, paid); pag.set_rata(i-1, importo, ZERO, scad, tipop, ulc, paid);
TToken_string& str = ps.row(i-1); TToken_string& str = ps.row(i-1);
str.add(scadenza.get(SCAD_CODABIPR), 6); str.add(scadenza.get(SCAD_CODABIPR), 7);
str.add(scadenza.get(SCAD_CODCABPR), 7); str.add(scadenza.get(SCAD_CODCABPR), 8);
str.add(scadenza.get(SCAD_CODABI), 8); str.add(scadenza.get(SCAD_CODABI), 9);
str.add(scadenza.get(SCAD_CODCAB), 9); str.add(scadenza.get(SCAD_CODCAB), 10);
if (i == 1) if (i == 1)
{ {
set(FS_NSABI, str.get(6)); set(FS_NSABI, str.get(7));
set(FS_NSCAB, str.get(7)); set(FS_NSCAB, str.get(8));
set(FS_VSABI, str.get(8)); set(FS_VSABI, str.get(9));
set(FS_VSCAB, str.get(9)); set(FS_VSCAB, str.get(10));
set(FS_AGENTE, scadenza.get(SCAD_CODAG)); set(FS_AGENTE, scadenza.get(SCAD_CODAG));
} }
} }
} }
else else
{ {
pag.set_rate_auto(); pag.set_rate_auto();
} }
@ -324,13 +354,12 @@ void TFattura_mask::read_scadenze()
set(FS_MCOMM, pag.mese_commerciale() ? "X" : ""); set(FS_MCOMM, pag.mese_commerciale() ? "X" : "");
set(FS_RECALC, "X", TRUE); set(FS_RECALC, "X", TRUE);
set(FS_NRATE, pag.n_rate()); set(FS_NRATE, pag.n_rate());
pag.set_sheet(ps);
_pag_rows = ps.rows_array();
// se la prima rata e' fissa non si tocca // se la prima rata e' fissa non si tocca
if (pag.tipo_prima_rata() > 3) if (pag.tipo_prima_rata() > 3)
ps.disable_cell(0,-1); ps.disable_cell(0,-1);
pag2sheet();
} }
void TFattura_mask::write_scadenze() const void TFattura_mask::write_scadenze() const
@ -379,8 +408,6 @@ void TFattura_mask::write_scadenze() const
bool TGame_mask::edit_fattura(TPartita& p, int nriga) bool TGame_mask::edit_fattura(TPartita& p, int nriga)
{ {
TString16 codpag;
const bool nuova = nriga <= 0; const bool nuova = nriga <= 0;
if (nuova) if (nuova)
nriga = nuova_riga(p); nriga = nuova_riga(p);
@ -404,10 +431,11 @@ bool TGame_mask::edit_fattura(TPartita& p, int nriga)
void TSaldaconto_app::edit_partite(const TMask& m) void TSaldaconto_app::edit_partite(const TMask& m)
{ {
TBill b; // Legge il conto della riga selezionata const char t = m.get(F_TIPO)[0];
b.set(m.get_int(F_GRUPPO), m.get_int(F_CONTO), const int g = m.get_int(F_GRUPPO);
m.get_long(F_SOTTOCONTO), m.get(F_TIPO)[0]); const int c = m.get_int(F_CONTO);
const long s = m.get_long(F_SOTTOCONTO)
const TBill b(g, c, s, t); // Legge il conto della riga selezionata
TGame_mask gm(b, 0, 0); TGame_mask gm(b, 0, 0);
gm.run(); gm.run();
if (gm.changed() && yesno_box("Si vogliono salvare le partite modificate?")) if (gm.changed() && yesno_box("Si vogliono salvare le partite modificate?"))

View File

@ -1,4 +1,5 @@
#include <applicat.h> #include <applicat.h>
#include <config.h>
#include <mask.h> #include <mask.h>
#include <progind.h> #include <progind.h>
#include <relation.h> #include <relation.h>
@ -24,7 +25,10 @@ class TCreatepart_app : public TApplication
TLocalisamfile* _scadenze; TLocalisamfile* _scadenze;
TLocalisamfile* _pagsca; TLocalisamfile* _pagsca;
int _anno; bool _num_cli, _num_for;
protected: // Applicat
virtual void on_config_change();
protected: protected:
@ -32,7 +36,7 @@ protected:
virtual bool destroy(); virtual bool destroy();
virtual bool menu(MENU_TAG m); virtual bool menu(MENU_TAG m);
bool zap_partite(); bool zap_partite(int anno);
public: public:
@ -65,14 +69,20 @@ bool TCreatepart_app::destroy()
return TApplication::destroy(); return TApplication::destroy();
} }
void TCreatepart_app::on_config_change()
{
TConfig cd(CONFIG_DITTA);
_num_cli = cd.get_bool("NrCliDx");
_num_for = cd.get_bool("NrForDx");
}
bool TCreatepart_app::zap_partite() bool TCreatepart_app::zap_partite(int anno)
{ {
bool first = TRUE; bool first = TRUE;
for (_partite->first(); !_partite->eof(); _partite->read(_isgreat)) for (_partite->first(); !_partite->eof(); _partite->next())
{ {
// ignora saldaconto altri esercizi // ignora saldaconto altri esercizi
if (_partite->get_long(PART_ANNO) != _anno) if (_partite->get_long(PART_ANNO) != anno)
continue; continue;
if (first) if (first)
@ -127,7 +137,7 @@ bool TCreatepart_app::menu(MENU_TAG)
while (m.run() == K_ENTER) while (m.run() == K_ENTER)
{ {
_anno = m.get_int(F_ANNO); const int anno = m.get_int(F_ANNO);
desccl = m.get(F_DESCCL); desccl = m.get(F_DESCCL);
descfo = m.get(F_DESCFO); descfo = m.get(F_DESCFO);
@ -135,11 +145,11 @@ bool TCreatepart_app::menu(MENU_TAG)
m.set(F_NUMPART, n_part); m.set(F_NUMPART, n_part);
// sputtana tutto il saldaculo // sputtana tutto il saldaculo
if (!zap_partite()) if (!zap_partite(anno))
continue; continue;
TRelation saldi(LF_SALDI); TRelation saldi(LF_SALDI);
saldi.curr().put(SLD_ANNOES, _anno); saldi.curr().put(SLD_ANNOES, anno);
TCursor cur(&saldi, "", 1, &saldi.curr(), &saldi.curr()); TCursor cur(&saldi, "", 1, &saldi.curr(), &saldi.curr());
const long items = cur.items(); const long items = cur.items();
@ -162,7 +172,7 @@ bool TCreatepart_app::menu(MENU_TAG)
TSaldo sld; TSaldo sld;
// ciuccia il saldo e vedi se e' movimentato nell'esercizio corrente // ciuccia il saldo e vedi se e' movimentato nell'esercizio corrente
if (!sld.ultima_immissione_verifica(_anno, gruppo, conto, sottoc, indbil, 1)) if (!sld.ultima_immissione_verifica(anno, gruppo, conto, sottoc, indbil, 1))
{ {
// non movimentato: se e' conto patrimoniale.... // non movimentato: se e' conto patrimoniale....
if (!(indbil == 1 || indbil == 2 || indbil == 5)) if (!(indbil == 1 || indbil == 2 || indbil == 5))
@ -171,12 +181,12 @@ bool TCreatepart_app::menu(MENU_TAG)
continue; continue;
} }
// .. vedi saldo esercizio precedente, altrimenti inkul // .. vedi saldo esercizio precedente, altrimenti inkul
sld.saldofin_esprec(_anno, gruppo, conto, sottoc); sld.saldofin_esprec(anno, gruppo, conto, sottoc);
} }
// genera importo con sezione appropriata // genera importo con sezione appropriata
TImporto saldo(cur.curr().get_char(SLD_FLAGSALINI), sld.saldoini()); TImporto saldo(cur.curr().get_char(SLD_FLAGSALINI), sld.saldoini());
TImporto pdare('D', sld.prgdare()); TImporto pdare('D', sld.prgdare());
TImporto pavere('A', sld.prgavere()); TImporto pavere('A', sld.prgavere());
saldo += pdare; saldo += pdare;
@ -188,13 +198,16 @@ bool TCreatepart_app::menu(MENU_TAG)
if (!saldo.is_zero()) if (!saldo.is_zero())
{ {
const TBill clifo(gruppo, conto, sottoc, cf); const TBill clifo(gruppo, conto, sottoc, cf);
TPartita game(clifo, _anno, "*"); TString16 numero("*");
if ((cf == 'C' && _num_cli) || (cf == 'F' && _num_for))
numero.right_just(7);
TPartita game(clifo, anno, numero);
TRiga_partite& riga = game.new_row(); TRiga_partite& riga = game.new_row();
riga.put(PART_DATAREG, today); riga.put(PART_DATAREG, today);
riga.put(PART_DATADOC, today); riga.put(PART_DATADOC, today);
riga.put(PART_SEZ, saldo.sezione()); riga.put(PART_SEZ, saldo.sezione());
riga.put(PART_IMPORTO, saldo.valore()); riga.put(PART_IMPORTO, saldo.valore());
riga.put(PART_DESCR, cf == 'C' ? desccl : descfo); riga.put(PART_DESCR, cf == 'C' ? desccl : descfo);
// cazzata dare/avere/fare/baciare/cagare // cazzata dare/avere/fare/baciare/cagare
@ -226,7 +239,7 @@ bool TCreatepart_app::menu(MENU_TAG)
end_wait(); end_wait();
} }
else else
message_box("Nessun saldo presente per l'esercizio %d", _anno); message_box("Nessun saldo presente per l'esercizio %d", anno);
} // while run } // while run
return FALSE; return FALSE;

View File

@ -10,17 +10,17 @@ END
TEXT DLG_NULL TEXT DLG_NULL
BEGIN BEGIN
PROMPT 31 1 "@bATTENZIONE" PROMPT 31 1 "@bATTENZIONE"
END END
TEXT DLG_NULL TEXT DLG_NULL
BEGIN BEGIN
PROMPT 14 3 "@bLa generazione della partite puo' richiedere" PROMPT 14 3 "@bLa generazione della partite puo' richiedere"
END END
TEXT DLG_NULL TEXT DLG_NULL
BEGIN BEGIN
PROMPT 18 4 "@btempo. Siate certi di voler proseguire." PROMPT 18 4 "@btempo. Siate certi di voler proseguire."
END END
NUMBER F_ANNO 4 NUMBER F_ANNO 4
@ -33,8 +33,7 @@ BEGIN
DISPLAY "Data fine esercizio " D1 DISPLAY "Data fine esercizio " D1
OUTPUT F_ANNO CODTAB OUTPUT F_ANNO CODTAB
CHECKTYPE REQUIRED CHECKTYPE REQUIRED
HELP "Anno di esercizio del quale si desidera la generazione delle partite" WARNING "Anno di esercizio assente"
WARNING "L' anno di esercizio e' obbligatorio"
END END