ggiunti controlli alle righe di prima nota

git-svn-id: svn://10.65.10.50/trunk@326 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-10-07 08:52:39 +00:00
parent ff085e9cc4
commit 987c5ce882
13 changed files with 380 additions and 123 deletions

View File

@ -582,6 +582,7 @@ bool CG0500_application::conto_hndl (TMask_field& f, KEY k)
return TRUE; return TRUE;
} }
// 1. Se specifico il sottoconto devono essere non vuoti gruppo e conto // 1. Se specifico il sottoconto devono essere non vuoti gruppo e conto
// 2. g-c-s devono esistere // 2. g-c-s devono esistere
bool CG0500_application::sottoconto_hndl (TMask_field& f, KEY k) bool CG0500_application::sottoconto_hndl (TMask_field& f, KEY k)
@ -597,13 +598,16 @@ bool CG0500_application::sottoconto_hndl (TMask_field& f, KEY k)
if (g == 0 || c == 0) if (g == 0 || c == 0)
return f.warning_box("Non accetto un sottoconto con gruppo o conto vuoti"); return f.warning_box("Non accetto un sottoconto con gruppo o conto vuoti");
/* A che cavolo serve CHECKTYPE NORMAL ????????????????????????????????????????
TConto tc(g,c,s); TConto tc(g,c,s);
if (!tc.read(app()->conti().curr())) if (!tc.read(app()->conti().curr()))
return f.warning_box("Conto inesistente"); return f.warning_box("Conto inesistente");
*/
} }
return TRUE; return TRUE;
} }
// Handler del campo tipocf della maschera di edit dello sheet // Handler del campo tipocf della maschera di edit dello sheet
// Abilita 109 e 110 (rigaiva e codiva) SOLO SE registro 1 o 2 // Abilita 109 e 110 (rigaiva e codiva) SOLO SE registro 1 o 2
bool CG0500_application::tipocf_hndl (TMask_field& f, KEY k) bool CG0500_application::tipocf_hndl (TMask_field& f, KEY k)

View File

@ -84,7 +84,7 @@ BEGIN
HELP "Inserire il codice registro" HELP "Inserire il codice registro"
WARNING "Non trovo il registro" WARNING "Non trovo il registro"
CHECKTYPE NORMAL CHECKTYPE NORMAL
FLAGS "DUZ" FLAGS "DU"
END END
// Questo rimane sempre nascosto // Questo rimane sempre nascosto

View File

@ -22,7 +22,7 @@ NUMBER 103 3
BEGIN BEGIN
PROMPT 1 3 "Gruppo " PROMPT 1 3 "Gruppo "
FIELD LF_RCAUSALI->GRUPPO FIELD LF_RCAUSALI->GRUPPO
USE LF_PCON KEY 1 SELECT (CONTO="") && (SOTTOCONTO="") USE LF_PCON KEY 1 SELECT (CONTO="")
INPUT GRUPPO 103 INPUT GRUPPO 103
DISPLAY "Gruppo" GRUPPO DISPLAY "Gruppo" GRUPPO
DISPLAY "Descrizione@50" DESCR DISPLAY "Descrizione@50" DESCR
@ -170,7 +170,6 @@ BEGIN
OUTPUT 205 CODCF OUTPUT 205 CODCF
OUTPUT 207 RAGSOC OUTPUT 207 RAGSOC
GROUP 1 GROUP 1
FLAGS "H"
END END
// Descrizione FORNITORE // Descrizione FORNITORE
@ -189,7 +188,6 @@ BEGIN
OUTPUT 305 CODCF OUTPUT 305 CODCF
OUTPUT 307 RAGSOC OUTPUT 307 RAGSOC
GROUP 1 GROUP 1
FLAGS "H"
END END
STRING 108 3 STRING 108 3

View File

@ -300,6 +300,11 @@ void TPrimanota_application::init_mask(TMask& m)
void TPrimanota_application::init_query_mode(TMask& m) void TPrimanota_application::init_query_mode(TMask& m)
{ {
<<<<<<< cg2100.cpp
read_firm_params();
enable_menu_item(M_FILE_PRINT);
=======
>>>>>>> 1.25
m.enable(DLG_NEWREC); m.enable(DLG_NEWREC);
} }
@ -360,7 +365,6 @@ void TPrimanota_application::init_insert_mode(TMask& m)
if (m.get(F_CODCAUS).empty()) return; if (m.get(F_CODCAUS).empty()) return;
TString80 desc;
for (int i = 1; i < _causale.size(); i++) for (int i = 1; i < _causale.size(); i++)
{ {
const TRectype* rcaus = (TRectype*)_causale.objptr(i); const TRectype* rcaus = (TRectype*)_causale.objptr(i);
@ -374,9 +378,9 @@ void TPrimanota_application::init_insert_mode(TMask& m)
char sezione = rcaus->get_char(RCA_SEZIONE); char sezione = rcaus->get_char(RCA_SEZIONE);
if (sezione != 'A') sezione = 'D'; if (sezione != 'A') sezione = 'D';
const TImporto zero(sezione, ZERO);
desc = rcaus->get(RCA_DESC); const TImporto zero(sezione, ZERO);
const TString80 desc(_causale.desc_agg(i));
if (nriga == 1) m.set(F_DESCR, desc); if (nriga == 1) m.set(F_DESCR, desc);
@ -604,8 +608,13 @@ void TPrimanota_application::mask2rel(const TMask& m)
int rcontr = 0; // Riga contropartita int rcontr = 0; // Riga contropartita
const TBill contro(row, -1, 0x3); // Conto contropartita const TBill contro(row, -1, 0x3); // Conto contropartita
const char tipo = row.get_char();
r.put("ROWTYPE", tipo); // Tipo riga
if (contro.ok()) if (contro.ok())
{ {
if (tipo == 'F' || tipo == 'S') n.swap_section();
rcontr = bill2contr(contro, n.sezione())+1; rcontr = bill2contr(contro, n.sezione())+1;
if (rcontr < 1) if (rcontr < 1)
{ {
@ -615,8 +624,6 @@ void TPrimanota_application::mask2rel(const TMask& m)
} }
r.put("RCONTR", rcontr); // Contropartita r.put("RCONTR", rcontr); // Contropartita
const char tipo = row.get_char();
r.put("ROWTYPE", tipo);
cur++; cur++;
} }
@ -715,7 +722,8 @@ int TPrimanota_application::write(const TMask& m)
const TString16 causimm(_causale.causale_inc_imm()); const TString16 causimm(_causale.causale_inc_imm());
if (causimm.not_empty()) if (causimm.not_empty())
genera_incasso(causimm); genera_incasso(causimm);
if (TRUE) // TBI controlla pagamento da scadenzare
if (gestione_saldaconto() && _causale.saldaconto())
aggiorna_scadenzario(m); aggiorna_scadenzario(m);
} }
return err; return err;
@ -728,8 +736,7 @@ int TPrimanota_application::rewrite(const TMask& m)
const int err = _rel->rewrite(TRUE); const int err = _rel->rewrite(TRUE);
if (err == NOERR) if (err == NOERR)
_saldi.registra(); _saldi.registra();
if (TRUE) // TBI controlla pagamento da scadenzare e/o variazione che ne implichi if (gestione_saldaconto() && _causale.saldaconto())
// la modifica
aggiorna_scadenzario(m); aggiorna_scadenzario(m);
return err; return err;
} }

View File

@ -40,7 +40,7 @@ END
STRING F_TIPODOC 2 STRING F_TIPODOC 2
BEGIN BEGIN
PROMPT 27 3 "Tipo documento " PROMPT 24 3 "Tipo documento "
FIELD LF_MOV->TIPODOC FIELD LF_MOV->TIPODOC
FLAGS "D" FLAGS "D"
END END
@ -173,7 +173,8 @@ END
BUTTON DLG_SAVEREC 9 2 BUTTON DLG_SAVEREC 9 2
BEGIN BEGIN
PROMPT -12 -1 "" PROMPT -12 -1 "~Registra"
MESSAGE EXIT,K_SAVEREC
END END
BUTTON DLG_CANCEL 9 2 BUTTON DLG_CANCEL 9 2

View File

@ -348,8 +348,8 @@ int TPrimanota_application::set_cgs_row(int n, const TImporto& imp,
row = ""; row = "";
imp.add_to(row); imp.add_to(row);
row.add(conto.string(0x3)); row.add(conto.string(0x3));
row.add(""); row.add(""); // Codice decrizione
row.add(desc); row.add(desc); // Descrizione aggiuntiva
switch(tipo) // Calcolo contropartita switch(tipo) // Calcolo contropartita
{ {
@ -422,7 +422,7 @@ void TPrimanota_application::cgs_pack()
real TPrimanota_application::calcola_saldo() const real TPrimanota_application::calcola_saldo() const
{ {
TArray& rows = cgs().rows_array(); TArray& rows = cgs().rows_array();
const int max = rows.items(); const int max = rows.size();
real tdare, tavere; real tdare, tavere;
for (int i = 0; i < max; i++) for (int i = 0; i < max; i++)
@ -470,8 +470,23 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
return f.error_box("Il movimento e' sbilanciato di %s lire.", ss); return f.error_box("Il movimento e' sbilanciato di %s lire.", ss);
} }
else else
if (app().get_cgs_imp(0).valore() == ZERO) if (app().get_cgs_imp(0).valore().is_zero())
return f.error_box("Il movimento non ha una prima riga contabile valida!"); return f.error_box("Il movimento non ha una prima riga contabile valida!");
const int max = cg.items();
for (int i = 0; i < max; i++)
{
const TImporto im(get_cgs_imp(i));
if (!im.valore().is_zero())
{
const TBill c(cg.row(i), 3, 0x0);
if (!c.ok())
return error_box("Il conto della riga %d non e' completo", i+1);
const TBill co(cg.row(i), 9, 0x0);
if (!co.ok())
return error_box("La contropartita della riga %d non e' completa", i+1);
}
}
} }
} }
return TRUE; return TRUE;
@ -665,6 +680,7 @@ bool TPrimanota_application::iva_notify(int r, KEY k)
TSheet_field& iva = app().ivas(); TSheet_field& iva = app().ivas();
TToken_string& row = iva.row(r); TToken_string& row = iva.row(r);
const TCausale& cau = app().causale();
if (k == K_SPACE) if (k == K_SPACE)
{ {
@ -681,14 +697,15 @@ bool TPrimanota_application::iva_notify(int r, KEY k)
oldposiva = type2pos(tipod); oldposiva = type2pos(tipod);
if (oldposiva < 0 && oldiva != ZERO) if (oldposiva < 0 && oldiva != ZERO)
{ {
TBill c; app().causale().bill(tipod == 'D' ? 3 : 4, c); const int r = tipod == 'D' ? 3 : 4;
oldposiva = app().set_cgs_row(-1, app().real2imp(ZERO, 'I'), c, "", tipod); TBill c; cau.bill(r, c);
oldposiva = app().set_cgs_row(-1, app().real2imp(ZERO, 'I'), c, cau.desc_agg(r), tipod);
} }
TBill oldconto(row, 6, 0x0); // g/c/s 6 7 8 TBill oldconto(row, 6, 0x0); // g/c/s 6 7 8
oldpos = bill2pos(oldconto, 'I'); oldpos = bill2pos(oldconto, 'I');
if (oldpos < 0 && oldconto.ok()) if (oldpos < 0 && oldconto.ok())
oldpos = app().set_cgs_row(-1, app().real2imp(ZERO, 'I'), oldconto, "", 'I'); oldpos = app().set_cgs_row(-1, app().real2imp(ZERO, 'I'), oldconto, cau.desc_agg(2), 'I');
} }
if (k == K_DEL) if (k == K_DEL)
{ {
@ -724,7 +741,7 @@ bool TPrimanota_application::iva_notify(int r, KEY k)
{ {
const TImporto val(app().real2imp(imp, 'I')); const TImporto val(app().real2imp(imp, 'I'));
if (val.valore() != ZERO) if (val.valore() != ZERO)
app().set_cgs_row(-1, val, conto, app().causale().descr(2), 'I'); app().set_cgs_row(-1, val, conto, cau.desc_agg(2), 'I');
} }
else else
{ {
@ -742,7 +759,8 @@ bool TPrimanota_application::iva_notify(int r, KEY k)
// Aggiorna conto IVA sulla riga contabile // Aggiorna conto IVA sulla riga contabile
const bool detrarre = detraibile(row); // Determina se IVA detraibile const bool detrarre = detraibile(row); // Determina se IVA detraibile
app().causale().bill(detrarre ? 3 : 4, conto); const int r = detrarre ? 3 : 4;
app().causale().bill(r, conto);
const char tipod = detrarre ? 'D' : 'N'; const char tipod = detrarre ? 'D' : 'N';
int newposiva = type2pos(tipod); int newposiva = type2pos(tipod);
@ -750,7 +768,7 @@ bool TPrimanota_application::iva_notify(int r, KEY k)
{ {
const TImporto val(app().real2imp(imposta, 'I')); const TImporto val(app().real2imp(imposta, 'I'));
if (val.valore() != ZERO) if (val.valore() != ZERO)
newposiva = app().set_cgs_row(-1, val, conto, "", tipod); newposiva = app().set_cgs_row(-1, val, conto, cau.desc_agg(r), tipod);
} }
else else
{ {
@ -1204,7 +1222,7 @@ void TPrimanota_application::add_cgs_rit(bool fiscali)
{ {
const int riga = fiscali ? 8 : 9; const int riga = fiscali ? 8 : 9;
TBill conto; _causale.bill(riga, conto); TBill conto; _causale.bill(riga, conto);
set_cgs_row(-1, real2imp(imp, tipo), conto, conto.descrizione(), tipo); set_cgs_row(-1, real2imp(imp, tipo), conto, _causale.desc_agg(riga), tipo);
} }
else else
set_cgs_imp(pos, real2imp(imp, tipo)); set_cgs_imp(pos, real2imp(imp, tipo));

View File

@ -320,10 +320,16 @@ TBill& TCausale::bill(int num, TBill& conto) const
return conto; return conto;
} }
const char* TCausale::descr(int num) const const char* TCausale::desc_agg(int num) const
{ {
const TRectype& rec = row(num); const TRectype& rec = row(num);
return rec.get(RCA_DESC); TString16 cod(rec.get(RCA_CODDESC));
TTable da("%DPN");
da.put("CODTAB", cod);
if (da.read() != NOERR)
da.zero();
return da.get("S0");
} }

View File

@ -80,7 +80,7 @@ protected:
public: public:
TBill& bill(int num, TBill& c) const; TBill& bill(int num, TBill& c) const;
const char* descr(int num) const; const char* desc_agg(int num) const;
bool data_doc() const; bool data_doc() const;
bool num_doc() const; bool num_doc() const;

View File

@ -1,3 +1,225 @@
<<<<<<< cg2104.cpp
// --------------------------------------------------------------------------
// Scadenzario
// fv 24/8/94
// --------------------------------------------------------------------------
#include "cg2102.h"
#include "cg2100.h"
#include "cg2104a.h"
#include "pagament.h"
struct shuttle
{
Pagamento* _pag; // pagamento
TSheet_field* _sheet; // sheet
TMask* _mask; // maschera
TArray* _rows; // righe spreadsheet nella versione originale
};
bool TPrimanota_application::pag_notify(int r, KEY k)
{
// questo e' il bello
shuttle* sh = (shuttle*)(((TPrimanota_application*)MainApp())->get_app_data());
Pagamento* pag = sh->_pag;
TSheet_field* ps = sh->_sheet;
TMask* msk = sh->_mask;
TArray* rws = sh->_rows;
int rdiff = atoi(msk->get(F_RDIFFER));
// ts contiene la vecchia riga, ns la nuova
TToken_string ts(36), ns(36);
bool doit = TRUE, m_imp = FALSE, m_perc = FALSE, m_pag = FALSE;
bool m_scad = FALSE, m_tipo = FALSE, mod = FALSE;
word ahiahi = P_OK;
TString news(15), newi(15), newp(15), newt(2);
bool recalc = msk->get_bool(F_RECALC);
bool mcomm = msk->get_bool(F_MCOMM);
switch (k)
{
case K_SPACE:
break;
case K_ENTER:
ns = ps->row(r);
ts = (TToken_string&)(*rws)[r];
news = ns.get(0);
newp = ns.get(1);
newi = ns.get(2);
newt = ns.get(3);
// qui viene il bello, si fa per dire
if (strcmp(ts.get(0),news) != 0) // modificata data scadenza
{
mod = m_scad = TRUE;
}
if (strcmp(ts.get(1),newp) != 0) // modificata percentuale
{
mod = m_perc = TRUE;
}
if (strcmp(ts.get(2),newi) != 0) // modificato importo
{
if ((recalc && !m_perc) || (!recalc)) // se si modifica la percentuale l'importo non viene cagato
{
mod = m_imp = TRUE;
}
}
if (strcmp(ts.get(3),newt) != 0) // modificato tipo pagamento
{
mod = m_tipo = TRUE;
}
break;
case K_DEL:
case K_INS:
doit = FALSE;
break;
default:
break;
}
// settato da recalc_rate se occorre ridefinire lo sheet
// aggiungendo o togliendo righe
bool need_recalc = FALSE;
if (k == K_ENTER)
{
if (mod && recalc)
{
// ricalcola sheet come sai fare tu
ahiahi = pag->recalc_rate(r, m_perc,
((m_perc || m_imp) ?
(m_perc ? (const char*)newp : (const char*)newi) :
NULL),
(m_scad ? (const char*)news : NULL),
(m_tipo ? (const char*)newt : NULL),
rdiff, mcomm, need_recalc);
// see if rdiff changed
msk->field(F_RDIFFER).set(pag->rate_differenziate() ? "1" : "2");
}
if (!recalc)
{
ahiahi = P_OK;
// put data as they are
TToken_string& trw = pag->rata(r);
TToken_string srw = trw;
if (m_scad) trw.add(news,3);
if (m_perc) trw.add(newp,1);
if (m_imp) trw.add(newi,4);
if (m_tipo) trw.add(newt,2);
// validate the payment
if ((ahiahi = pag->validate()) != P_OK)
pag->rata(r) = srw;
}
if (ahiahi) // any error?
// rimetti le righe com'erano prima
{
beep();
// se gli errori sono voluti, spiegali
if (!recalc)
{
TString s(256);
pag->strerr(ahiahi,s);
warning_box(s);
}
ps->row(r) = (TToken_string&)(*rws)[r];
ps->force_update(r);
}
else if (recalc && mod && need_recalc)
{
// ridefinisci lo sheet sulla base delle nuove rate
pag->set_sheet(*ps);
ps->force_update(-1);
rws->destroy();
(*rws) = ps->rows_array();
}
}
return doit;
}
void TPrimanota_application::aggiorna_scadenzario(const TMask& m)
{
real imponibile(0.0);
real imposta(0.0);
real spese(0.0);
TString dt(m.get(F_DATAREG));
Pagamento pag(m.get(F_CODPAG), (const char*)dt);
if (pag.is_new()) return;
TMask ms("cg2104a");
TSheet_field& ps = (TSheet_field&)ms.field(F_RATESHEET);
ps.set_notify(pag_notify);
ms.field(F_RDIFFER).set(pag.rate_differenziate() ? "1" : "2");
ms.field(F_NAMEPAG).set(pag.name());
ms.field(F_TIPOPR).set(pag.desc_tpr());
ms.field(F_MCOMM).set(pag.mese_commerciale() ? "X" : "");
TSheet_field& iva_sh = ivas();
for (int i = 0; i < iva_sh.items(); i++)
{
TToken_string& tt = iva_sh.row(i);
real mpo(tt.get(0));
real imp(tt.get(3));
imponibile += mpo;
imposta += imp;
// TBI: le spese che cazzo sono?
// -----------------------------
}
ms.field(F_IMPONIBILE).set(imponibile.string());
ms.field(F_IMPOSTA).set(imposta.string());
ms.field(F_SPESE).set(spese.string());
ms.field(F_RECALC).set("X");
pag.set_total(imponibile, imposta, spese);
// TBI TBI TBI TBI TBI TBI TBI TBI TBI
// controllare se c'e' una rateazione non standard gia' registrata
// in tal caso occorre zappare e settare le rate a mano
pag.set_rate_auto();
// se la prima rata e' fissa non si tocca
if (pag.tipo_prima_rata() > 0)
{
ps.disable_cell(0,0);
ps.disable_cell(0,1);
ps.disable_cell(0,2);
ps.disable_cell(0,3);
}
// prepara lo sheet
pag.set_sheet(ps);
TArray rows(ps.rows_array());
shuttle sh;
sh._pag = &pag;
sh._sheet = &ps;
sh._mask = &ms;
sh._rows = &rows;
set_app_data(&sh);
ms.run();
// TBI se modificato riaggiustare i files
// chiamando la write del caso
// -------------------------------------------------
}
=======
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Scadenzario // Scadenzario
// fv 24/8/94 // fv 24/8/94
@ -218,3 +440,4 @@ void TPrimanota_application::aggiorna_scadenzario(const TMask& m)
// chiamando la write del caso // chiamando la write del caso
// ------------------------------------------------- // -------------------------------------------------
} }
>>>>>>> 1.2

View File

@ -204,8 +204,8 @@ END
NUMBER 103 1 NUMBER 103 1
BEGIN BEGIN
PROMPT 2 9 "Detraz. " PROMPT 2 9 "Det. "
SHEET "Codice|Descrizione@60" SHEET "Codice|Descrizione@53"
INPUT 103 INPUT 103
ITEM " |Regime normale" ITEM " |Regime normale"
ITEM "1|IVA indetraibile su acquisti riferiti a ricavi esenti" ITEM "1|IVA indetraibile su acquisti riferiti a ricavi esenti"
@ -215,9 +215,9 @@ BEGIN
OUTPUT 213 OUTPUT 213
END END
STRING 213 50 STRING 213 53
BEGIN BEGIN
PROMPT 15 9 "" PROMPT 12 9 ""
FLAGS "D" FLAGS "D"
END END