Nuova stampa registri IVA con IVA per cassa

Correzione nc in prima nota

git-svn-id: svn://10.65.10.50/branches/R_10_00@22771 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2012-12-21 06:57:15 +00:00
parent ab46443149
commit 948465ced7
14 changed files with 1471 additions and 1246 deletions

View File

@ -196,12 +196,13 @@ void TCaus_app::causale_vendite()
set_descr(i++, TR("C Di ricavo"));
set_descr(i++, TR("C Iva vendite"));
set_descr(i++, TR("C Iva non detraibile"));
set_descr(i++, TR("C Imp. esenti"));
set_descr(i++, TR("C Imp. esenti")); // 5
set_descr(i++, TR("C Imp. non imponibili"));
set_descr(i++, TR("C Imp. non soggetti"));
set_descr(i++, TR("C Ritenute fiscali"));
set_descr(i++, TR("C Ritenute soc."));
set_descr(i++, TR("C Iva ad esig.diff."));
set_descr(i++, TR("C Iva ad esig.diff.")); // 10
set_descr(i++, TR("C Iva per cassa"));
_tipo_des = vendita;
carica_righe_libere(i);
}
@ -217,12 +218,13 @@ void TCaus_app::causale_acquisti()
set_descr(i++, TR("C Di costo"));
set_descr(i++, TR("C Iva acquisti"));
set_descr(i++, TR("C Iva non detraibile"));
set_descr(i++, TR("C Imp. esenti"));
set_descr(i++, TR("C Imp. esenti")); // 5
set_descr(i++, TR("C Imp. non imponibili"));
set_descr(i++, TR("C Imp. non soggetti"));
set_descr(i++, TR("C Ritenute fiscali"));
set_descr(i++, TR("C Ritenute soc."));
set_descr(i++, TR("C Iva ad esig.diff."));
set_descr(i++, TR("C Iva ad esig.diff.")); // 10
set_descr(i++, TR("C Iva per cassa"));
_tipo_des = acquisto;
carica_righe_libere(i);
}

View File

@ -90,6 +90,7 @@ TMask* TPrimanota_application::load_mask(int n)
m->set_handler(F_CODIVA, main_codiva_handler);
if (_liqdiff)
m->set_handler(F_LIQDIFF, liqdiff_handler);
m->set_handler(F_IVAXCASSA, ivaxcassa_handler);
m->set_handler(F_OCCASEDIT, occas_handler);
m->set_handler(F_SOLAIVA, solaiva_handler);
m->set_handler(F_SHEETIVA, iva_handler);
@ -395,7 +396,7 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
}
else
{
if (nriga >= 2 && nriga <= RIGA_IVA_DIFFERITA)
if (nriga >= 2 && nriga <= RIGA_IVA_PER_CASSA)
continue; // Conti per IVA detraibile e non, ritenute sociali e fiscali
const char tipo = nriga == 1 ? 'T' : ' ';
@ -800,8 +801,10 @@ void TPrimanota_application::init_insert_mode(TMask& m)
{
occas_mask().reset();
m.hide(F_OCCASEDIT);
#ifdef PRORATA100
m.hide(F_ADJUST_PRORATA); // In inserimento non puo' esistere un pro-rata errato!
if (causale().soloiva())
#endif
if (causale().soloiva())
m.set(F_SOLAIVA, "X", true); // Propone movimento di sola iva
if (iva() == iva_acquisti && causale().intra())
m.field(F_RITFIS).set_prompt(PR("IVA intracomun. "));
@ -905,6 +908,7 @@ void TPrimanota_application::init_modify_mode(TMask& m)
m.disable(SK_TIPORIGA); // Disabilita la sua modifica
}
#ifdef PRORATA100
// Non controllare il prorata durante la cancellazione automatica
if (autodeleting() != 0x3)
{
@ -927,6 +931,7 @@ void TPrimanota_application::init_modify_mode(TMask& m)
}
}
}
#endif
const TRectype& mov = get_relation()->curr();
if (!mov.empty())

View File

@ -703,11 +703,13 @@ BEGIN
CHECKTYPE NORMAL
END
#ifdef PRORATA100
BUTTON F_ADJUST_PRORATA 40
BEGIN
PROMPT 1 -1 "Corre~zione automatica righe contabili"
FLAGS "H"
END
#endif
ENDPAGE

View File

@ -1487,7 +1487,9 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k)
if (d)
{
if (iva.mask().get_bool(F_LIQDIFF))
cau.bill(ri = RIGA_IVA_DIFFERITA, c);
cau.bill(ri = RIGA_IVA_DIFFERITA, c); else
if (iva.mask().get_bool(F_IVAXCASSA))
cau.bill(ri = RIGA_IVA_PER_CASSA, c);
if (!c.ok())
cau.bill(ri = RIGA_IVA_DETRAIBILE, c);
}
@ -1612,21 +1614,23 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k)
if (!imposta.is_zero()) // Se c'e' imposta ...
{ // ... crea nuova riga per l'IVA
TBill contoiva;
int ri;
int ri = 0;
if (d)
{
if (iva.mask().get_bool(F_LIQDIFF))
cau.bill(ri = RIGA_IVA_DIFFERITA, contoiva);
cau.bill(ri = RIGA_IVA_DIFFERITA, contoiva); else
if (iva.mask().get_bool(F_IVAXCASSA))
cau.bill(ri = RIGA_IVA_PER_CASSA, contoiva);
if (!contoiva.ok())
cau.bill(ri = RIGA_IVA_DETRAIBILE, contoiva);
}
else
cau.bill(ri = RIGA_IVA_NON_DETRAIBILE, contoiva);
const TString desc(cau.desc_agg(ri));
cau.bill(ri, contoiva);
newposiva = a.set_cgs_row(-1, newiva, contoiva, desc, tipod);
const TString desc(cau.desc_agg(ri));
cau.bill(ri, contoiva);
newposiva = a.set_cgs_row(-1, newiva, contoiva, desc, tipod);
}
}
else
@ -2242,7 +2246,14 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key)
const TDate oggi(TODAY);
TDate dr(f.get()); // Data dell'operazione
if (dr > oggi)
{
#ifdef DBG
if (!yesno_box(TR("La data dell'operazione è superiore quella di sistema:\nContinuare ugualmente?")))
return false;
#else
return f.error_box(TR("La data dell'operazione è superiore quella di sistema"));
#endif
}
TMask& m = f.mask();
if (dr == oggi && m.query_mode() && !m.field(F_NUMREG).empty())
@ -2922,46 +2933,53 @@ bool TPrimanota_application::main_codiva_handler(TMask_field& f, KEY key)
return true;
}
// Scandisce le righe IVA detraibili e forza il conto corretto in base ai flag IVA in testata
static void force_iva_det_bill()
{
TSheet_field& cgs = app().cgs();
TMask& mask = cgs.mask();
const TCausale& cau = app().causale();
TBill contoiva;
int ri = 0;
if (mask.get_bool(F_LIQDIFF))
cau.bill(ri = RIGA_IVA_DIFFERITA, contoiva); else
if (mask.get_bool(F_IVAXCASSA))
cau.bill(ri = RIGA_IVA_PER_CASSA, contoiva);
if (ri <= 0 || !contoiva.ok())
cau.bill(ri = RIGA_IVA_DETRAIBILE, contoiva);
TToken_string conto(contoiva.string(0x3));
const TString80 descragg(cau.desc_agg(ri));
const int rowtype = cgs.cid2index(CG_ROWTYPE);
const int tp = cgs.cid2index(CG_TIPO);
const int gr = cgs.cid2index(CG_GRUPPO);
const int co = cgs.cid2index(CG_CONTO);
const int sc = cgs.cid2index(CG_SOTTOCONTO);
const int des = cgs.cid2index(CG_DESCR);
FOR_EACH_SHEET_ROW(cgs, r, row)
{
const TString4 type(row->get(rowtype));
if (type == "D")
{
row->add(conto.get(0), tp);
row->add(conto.get(), gr);
row->add(conto.get(), co);
row->add(conto.get(), sc);
row->add(conto.get(), sc + 1);
row->add(descragg, des);
}
}
cgs.force_update();
}
// Handler of the F_LIQDIFF
// Certified 99%
bool TPrimanota_application::liqdiff_handler(TMask_field& f, KEY key)
{
if (key == K_SPACE && f.mask().is_running())
{
TSheet_field & cgs = app().cgs();
const bool liqdiff = f.get().full();
const TCausale& cau = app().causale();
TBill contoiva;
int ri;
if (f.mask().get_bool(F_LIQDIFF))
cau.bill(ri = RIGA_IVA_DIFFERITA, contoiva);
if (!contoiva.ok())
cau.bill(ri = RIGA_IVA_DETRAIBILE, contoiva);
TToken_string conto(contoiva.string(0x3));
const TString80 descragg(cau.desc_agg(ri));
int rowtype = cgs.cid2index(CG_ROWTYPE);
int tp = cgs.cid2index(CG_TIPO);
int gr = cgs.cid2index(CG_GRUPPO);
int co = cgs.cid2index(CG_CONTO);
int sc = cgs.cid2index(CG_SOTTOCONTO);
int des = cgs.cid2index(CG_DESCR);
FOR_EACH_SHEET_ROW(cgs, r, row)
{
const TString4 type(row->get(rowtype));
if (type == "D")
{
row->add(conto.get(0), tp);
row->add(conto.get(), gr);
row->add(conto.get(), co);
row->add(conto.get(), sc);
row->add(conto.get(), sc + 1);
row->add(descragg, des);
}
}
cgs.force_update();
}
force_iva_det_bill();
if (key == K_ENTER)
{
@ -2972,6 +2990,23 @@ bool TPrimanota_application::liqdiff_handler(TMask_field& f, KEY key)
return true;
}
// Handler of the F_IVAXCASSA
// Certified 99%
bool TPrimanota_application::ivaxcassa_handler(TMask_field& f, KEY key)
{
if (key == K_SPACE && f.mask().is_running())
force_iva_det_bill();
if (key == K_ENTER)
{
if (f.get().full() && f.mask().get_bool(F_LIQDIFF))
return f.error_box(TR("Non è ammesso selezionare IVA per cassa e liquidazione differita"));
}
return true;
}
// Riempie i campi valuta a zero in base agli altri
void TPrimanota_application::gioca_cambi(int force)
{

View File

@ -103,6 +103,7 @@ class TPrimanota_application : public TRelation_application
static bool ritsoc_handler(TMask_field& f, KEY key);
static bool main_codiva_handler(TMask_field& f, KEY key);
static bool liqdiff_handler(TMask_field& f, KEY key);
static bool ivaxcassa_handler(TMask_field& f, KEY key);
static bool dataintra_handler(TMask_field& f, KEY key);
static bool corrlire_handler(TMask_field& f, KEY key);
static bool corrvaluta_handler(TMask_field& f, KEY key);
@ -137,7 +138,6 @@ class TPrimanota_application : public TRelation_application
static bool recalc_handler(TMask_field& f, KEY key);
static bool codcab_handler(TMask_field& f, KEY key);
static bool tipopag_handler(TMask_field& f, KEY key);
static bool prorata_handler(TMask_field& f, KEY k);
static bool linkdoc_handler(TMask_field& f, KEY k);
static bool mastrino_handler(TMask_field& f, KEY k);
@ -278,8 +278,11 @@ protected:
void renumber_partita(TMask& m, const char* oldp, const char* newp);
void recalc_scadenze(const TDate& d);
#ifdef PRORATA100
static bool prorata_handler(TMask_field& f, KEY k);
bool test_prorata();
bool aggiusta_prorata();
#endif
int cerca_conto_cf(TBill& bill) const;

View File

@ -73,20 +73,20 @@ public:
virtual ~TCausale() {}
};
#define RIGA_IVA_DETRAIBILE 3
#define RIGA_IVA_NON_DETRAIBILE 4
#define RIGA_IVA_DIFFERITA 10
// Fatture
#define RIGA_RITENUTE_FISCALI 8
#define RIGA_RITENUTE_SOCIALI 9
#define RIGA_IVA_DETRAIBILE 3
#define RIGA_IVA_NON_DETRAIBILE 4
#define RIGA_RITENUTE_FISCALI 8
#define RIGA_RITENUTE_SOCIALI 9
#define RIGA_IVA_DIFFERITA 10
#define RIGA_IVA_PER_CASSA 11
// Pagamenti
#define RIGA_ABBUONI_PASSIVI 9
#define RIGA_ABBUONI_ATTIVI 10
#define RIGA_SPESE 11
#define RIGA_PAG_RITFIS 12
#define RIGA_DIFFCAM 13
#define RIGA_PAG_RITSOC 14
#define RIGA_ABBUONI_PASSIVI 9
#define RIGA_ABBUONI_ATTIVI 10
#define RIGA_SPESE 11
#define RIGA_PAG_RITFIS 12
#define RIGA_DIFFCAM 13
#define RIGA_PAG_RITSOC 14
#endif

View File

@ -254,6 +254,8 @@ bool TPrimanota_application::colors_handler(TMask_field& f, KEY k)
return true;
}
#ifdef PRORATA100
///////////////////////////////////////////////////////////
// Gestione cambiamento prorata
///////////////////////////////////////////////////////////
@ -348,3 +350,4 @@ bool TPrimanota_application::prorata_handler(TMask_field& f, KEY k)
return TRUE;
}
#endif

View File

@ -626,40 +626,87 @@ bool TEasySolder_mask::on_field_event(TOperable_field& o, TField_event e, long j
static int nrigp_pagamento_locale(const TSolder_tree& st)
{
const long nreg_mov = st.num_reg();
const int nrig_mov = st.num_rig();
const TToken_string& curr = *(TToken_string*)st.curr_node();
const int level = curr.items();
if (level == 3)
if (level >= 3)
{
const TRiga_scadenze* scad = st.scadenza();
if (scad != NULL) // Vera scadenza
const long nreg_mov = st.num_reg();
const int nrig_mov = st.num_rig();
if (level == 3)
{
for (int nrigp = scad->last(); nrigp > 0; nrigp = scad->pred(nrigp))
const TRiga_scadenze* scad = st.scadenza();
if (scad != NULL) // Vera scadenza
{
const TRiga_partite& riga = scad->partita().riga(nrigp);
const long nreg_riga = riga.get_long(PART_NREG);
const int nrig_riga = riga.get_int(PART_NUMRIG);
if (nreg_riga == nreg_mov && nrig_riga == nrig_mov)
return nrigp;
for (int nrigp = scad->last(); nrigp > 0; nrigp = scad->pred(nrigp))
{
const TRiga_partite& riga = scad->partita().riga(nrigp);
const long nreg_riga = riga.get_long(PART_NREG);
const int nrig_riga = riga.get_int(PART_NUMRIG);
if (nreg_riga == nreg_mov && nrig_riga == nrig_mov)
return nrigp;
}
}
} else
if (level == 4)
{
// const int nrigp = st.pagamento()->get_int(PAGSCA_NRIGP);
int nrigp = 0; curr.get(3, nrigp);
const TRiga_partite& riga = st.partita()->riga(nrigp);
const long nreg_riga = riga.get_long(PART_NREG);
const int nrig_riga = riga.get_int(PART_NUMRIG);
if (nreg_riga == nreg_mov && nrig_riga == nrig_mov)
return nrigp;
}
} else
if (level == 4)
{
const int nrigp = st.pagamento()->get_int(PAGSCA_NRIGP);
const TRiga_partite& riga = st.partita()->riga(nrigp);
const long nreg_riga = riga.get_long(PART_NREG);
const int nrig_riga = riga.get_int(PART_NUMRIG);
if (nreg_riga == nreg_mov && nrig_riga == nrig_mov)
return nrigp;
}
return 0;
}
static bool sheet_rate_filler(TTree& tree, void* jolly, word flags)
// Aggiunge una nota di credito non associata a fattura
static bool add_lonely_nc(TPartita& game, TSheet_field& sheet, int rigasheet)
{
const int nrigp = game.first();
if (nrigp <= 0)
return false;
const TRiga_partite& riga = game.riga(nrigp);
if (riga.tipo() != tm_nota_credito)
return false;
TToken_string& row = sheet.row(rigasheet);
row.add(game.codice_valuta(), sheet.cid2index(S_VALUTA));
const char expected_section = riga.get_char(PART_TIPOCF) == 'C' ? 'D' : 'A';
TImporto res = game.calcola_saldo(true);
res.normalize(expected_section);
set_row_currency(sheet, row, S_RESIDUO, res.valore());
TImporto tot = riga.importo(true);
tot.normalize(expected_section);
set_row_currency(sheet, row, S_TOTALE, tot.valore());
set_row_int(sheet, row, S_ANNO, game.anno());
set_row_str(sheet, row, S_PARTITA, game.numero());
set_row_int(sheet, row, S_RIGAF, TPartita::UNASSIGNED);
set_row_int(sheet, row, S_RATA, TPartita::UNASSIGNED);
set_row_int(sheet, row, S_RIGAP, 0); // Lasciare 0 e NON mettere assultamente nrigp o la scambia per pagamento!
set_row_str(sheet, row, S_DATASCAD, riga.get(PART_DATAPAG));
if (game.in_valuta())
{
TImporto reseur = riga.importo(false);
reseur.normalize(expected_section);
set_row_currency(sheet, row, S_RESIDUO_EUR, reseur.valore());
}
set_row_str(sheet, row, S_NUMDOC, riga.get(PART_NUMDOC));
set_row_str(sheet, row, S_DATADOC, riga.get(PART_DATADOC));
const int nrow = sheet.items()-1;
sheet.disable_cell(nrow, S_SALDO);
return true;
}
static bool sheet_rate_filler(TTree& tree, void* jolly, word /* flags */)
{
const TSolder_tree& st = (const TSolder_tree&)tree;
const TToken_string& curr = *(TToken_string*)st.curr_node();
@ -667,30 +714,27 @@ static bool sheet_rate_filler(TTree& tree, void* jolly, word flags)
if (level < 3)
return false;
const tipo_movimento tm = app().causale().tipomov();
int nriga; curr.get(1, nriga);
int nrata; curr.get(2, nrata);
int nrigp = nrigp_pagamento_locale(st);
if (level == 3 && nrata >= TPartita::UNASSIGNED)
return false; // Falso nodo dell'albero padre dei non assegnati
TPartita& game = *st.partita();
if (!same_values(st.codval(), game.codice_valuta()))
return false; // Scadenza in valuta diversa da quella selezionata
int nrigp = nrigp_pagamento_locale(st);
bool good_rat = level >= 3 && nrata > 0 && nrata < TPartita::UNASSIGNED;
bool good_pag = level == 4 && nrigp > 0;
const TRiga_scadenze* scad = good_rat ? st.scadenza() : NULL;
if (scad != NULL)
if (good_rat && scad == NULL)
{
if (!same_values(st.codval(), scad->codice_valuta()))
return false; // Scadenza in valuta diversa da quella selezionata
}
else
{
if (good_rat)
{
CHECKD(false, "Rata nulla inattesa ", nrata); // Segnalazione 1867
return false;
}
CHECKD(false, "Rata nulla inattesa ", nrata); // Segnalazione 1867
return false;
}
const tipo_movimento tm = app().causale().tipomov();
switch (tm)
{
case tm_nota_credito:
@ -701,13 +745,16 @@ static bool sheet_rate_filler(TTree& tree, void* jolly, word flags)
if (good_rat)
{
good_rat = nrigp <= 0 && !scad->chiusa() && !scad->get_bool(SCAD_BLOCCATA);
/* Commentato in quanto impedisce di saldare le note di credito
if (good_rat)
{
const char expected_section = scad->get_char(SCAD_TIPOCF) == 'C' ? 'D' : 'A';
TImporto res = scad->residuo(true);
res.normalize(scad->riga().sezione());
if (res.valore() <= ZERO) // In realtà ha residuo negativo, per cui è chiusa!
res.normalize(expected_section); // res.normalize(scad->riga().sezione());
if (res.valore () <= ZERO) // In realtà è chiusa!
good_rat = false;
}
*/
}
}
else
@ -729,17 +776,24 @@ static bool sheet_rate_filler(TTree& tree, void* jolly, word flags)
break;
}
TSheet_field& sheet = *(TSheet_field*)jolly;
if (good_rat || good_pag) // Creo una nuova riga solo se necessario
{
TPartita& game = *st.partita();
TSheet_field& sheet = *(TSheet_field*)jolly;
TToken_string& row = sheet.row(-1);
row.add(game.codice_valuta(), sheet.cid2index(S_VALUTA));
if (good_rat)
{
const TImporto res = tm == tm_insoluto ? scad->importo_pagato(true) : scad->residuo(true);
TImporto res;
if (tm == tm_insoluto)
{
res = scad->importo_pagato(true);
}
else
{
const char expected_section = scad->get_char(SCAD_TIPOCF) == 'C' ? 'D' : 'A';
res = scad->residuo(true);
res.normalize(expected_section);
}
set_row_currency(sheet, row, S_RESIDUO, res.valore());
const TImporto tot = scad->importo(true);
set_row_currency(sheet, row, S_TOTALE, tot.valore());
@ -749,7 +803,7 @@ static bool sheet_rate_filler(TTree& tree, void* jolly, word flags)
set_row_int(sheet, row, S_RATA, nrata);
set_row_str(sheet, row, S_DATASCAD, scad->get(SCAD_DATASCAD));
set_row_str(sheet, row, S_MODOPAG, scad->get(SCAD_TIPOPAG)); // Solo proposta
if (scad->in_valuta())
if (game.in_valuta())
{
// Calcola il residuo rata utilizzando il cambio della fattura e non quello del pagamento
const TImporto reseur = tm == tm_insoluto ? scad->importo_pagato(false) : scad->residuo(false);
@ -777,6 +831,9 @@ static bool sheet_rate_filler(TTree& tree, void* jolly, word flags)
}
if (good_pag)
{
if (!good_rat && nrigp > 1 && game.prima_riga(-1, tm_nota_credito) < nrigp)
add_lonely_nc(game, sheet, sheet.items()-1);
const TRiga_partite& rigp = game.riga(nrigp);
set_row_int(sheet, row, S_RIGAP, nrigp);
set_row_int(sheet, row, S_NREG, rigp.get_long(PART_NREG));
@ -787,9 +844,7 @@ static bool sheet_rate_filler(TTree& tree, void* jolly, word flags)
if (!imp.is_zero())
{
set_row_bool(sheet, row, S_SPUNTA, true);
const TString& codval = rigp.get(PART_CODVAL);
if (is_true_value(codval))
if (rigp.in_valuta())
{
const real impval = pag.get_real(PAGSCA_IMPORTOVAL);
set_row_currency(sheet, row, S_IMPORTO, impval);
@ -798,7 +853,7 @@ static bool sheet_rate_filler(TTree& tree, void* jolly, word flags)
else
set_row_currency(sheet, row, S_IMPORTO, imp);
}
set_row_str(sheet, row, S_SALDO, pag.get_char(PAGSCA_ACCSAL)=='S'?"X":"");
set_row_str(sheet, row, S_SALDO, (good_rat && pag.get_char(PAGSCA_ACCSAL)=='S') ? "X" : "");
set_row_int(sheet, row, S_MODOPAG, rigp.get_int(PART_TIPOPAG));
set_row_currency(sheet, row, S_RITFIS, pag.get_real(PAGSCA_RITENUTE));
set_row_currency(sheet, row, S_RITSOC, pag.get_real(PAGSCA_RITSOC));
@ -820,6 +875,12 @@ static bool sheet_rate_filler(TTree& tree, void* jolly, word flags)
}
}
}
else
{
// Nota di credito non assegnata e senza pagamenti successivi
if (level == 4 && nriga == TPartita::UNASSIGNED && game.last() == game.first())
add_lonely_nc(game, sheet, -1);
}
return false;
}
@ -1039,9 +1100,9 @@ void TEasySolder_mask::init(const TBill& conto, long numreg, int numrig)
}
else
app().causale().bill(2, controbill);
if (controbill.ok())
if (controbill.gruppo() > 0) // con controbill.ok() non presentava assolutamente i conti parziali
{
controbill.set(*this, G_GRUPPOC, G_CONTOC, G_SOTTOCONTOC);
controbill.set(*this, G_GRUPPOC, G_CONTOC, G_SOTTOCONTOC, 0, G_DESCONTOC);
}
else
{

View File

@ -87,7 +87,7 @@ _year(4), _nomiditte(100), _menu(m), _firm_bookmark(-1)
_isplafond = _printonly = _is_visliq = false;
_isvent = _isagricolo = _isbenzinaro = _isviaggio = _isdiff = false;
_row = 1; _what = all; _comp_acconto = false;
_isriepilogo = FALSE; _calcall = false;
_isriepilogo = false; _calcall = false;
_recalc_only = _recalc_regis = _isfinal = _isregis = false;
_stampa_vers = _stampa_acc = false;
_recalc = needed;
@ -95,23 +95,33 @@ _year(4), _nomiditte(100), _menu(m), _firm_bookmark(-1)
bool TLiquidazione_app::user_create()
{
// vediamo se c'e' il messaggio per calcolare in batch
TMailbox mail;
TProgind* pnd = NULL;
TMessage* msg = mail.next_s("RCL");
TToken_string subj(36);
_is_interactive = msg == NULL;
bool is_header = TRUE;
int bodylen;
bool is_header = true;
int bodylen = 60;
TDate printdate;
TString filename;
long ditta;
bool nocalc = FALSE;
long ditta = 0;
bool nocalc = false;
_prind = NULL;
if (msg != NULL) subj = msg->body();
// vediamo se c'e' il messaggio per calcolare in batch
TMailbox mail;
TMessage* msg = mail.next_s("RCL");
_is_interactive = msg == NULL;
TToken_string subj;
if (!_is_interactive)
subj = msg->body();
#ifdef DBG
else if (argv(2)[1] == 'C')
{
subj = "2012|12|9058|R|12-12-2012|c:/Temp/110|X|60";
_is_interactive = false;
}
#endif
TProgind* pnd = NULL;
if (_is_interactive)
pnd = new TProgind (3,TR("Preparazione archivi"), false, true);
else
@ -178,8 +188,7 @@ bool TLiquidazione_app::user_create()
_rel->add(LF_PCON,"GRUPPO=GRUPPO|CONTO=CONTO|SOTTOCONTO=SOTTOCONTO",1,LF_RMOVIVA,AGR_PCON2);
_rel->add(LF_CAUSALI,"CODCAUS=CODCAUS");
// _cur = new TCursor(_rel, "", 2);
_cur = new TCursor(_rel, "", 4);
_cur = new TCursor(_rel, "", 4); // Was _cur = new TCursor(_rel, "", 2);
_ver = new TInteressi_IVA_table();
_pim = new TTable("PIM");
@ -320,7 +329,8 @@ bool TLiquidazione_app::user_create()
if (_recalc_only)
_isprint = FALSE;
//else printer().set_export_file(filename, is_header, headerlen);
else printer().set_export_file(filename, is_header);
else
printer().set_export_file(filename, is_header);
// calcola liquidazione
printer().setdate(printdate);

View File

@ -618,20 +618,23 @@ bool TLiquidazione_app::sarebbe_da_pagare(const TRectype& mov, const TDate& fine
const TRectype& clifo = cache().get(LF_CLIFO, key);
const int alleg = clifo.get_int(CLI_ALLEG);
if (alleg == 5 || alleg == 6 || alleg == 9) // Privati, import ed export non hanno IVA per cassa
return true;
if (alleg == 7 || alleg == 8) // Ente pubblico e amministrazione controllata ...
return false; // ... possono aspettare le calende greche
TString16 paiv = clifo.get(CLI_PAIV);
if (paiv.empty() && clifo.get_bool(CLI_OCCAS))
if (mov.get_bool(MOV_IVAXCASSA))
{
const TRectype& occas = cache().get(LF_OCCAS, mov.get(MOV_OCFPI));
paiv = occas.get(OCC_PAIV);
if (alleg == 5 || alleg == 6 || alleg == 9) // Privati, import ed export non hanno IVA per cassa
return true;
TString16 paiv = clifo.get(CLI_PAIV);
if (paiv.empty() && clifo.get_bool(CLI_OCCAS))
{
const TRectype& occas = cache().get(LF_OCCAS, mov.get(MOV_OCFPI));
paiv = occas.get(OCC_PAIV);
}
if (paiv.blank())
return true; // In assenza di Partita IVA non c'è IVA per cassa
}
if (paiv.blank())
return true; // In assenza di Partita IVA non c'è IVA per cassa
if (ivadiff_chiusa(mov, fine))
return false;
@ -944,7 +947,16 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
const TString4 tipodoc = _mov->get(MOV_TIPODOC);
const bool corrisp = _reg->get_bool("B0");
const tiporeg tipomov = (tiporeg)_reg->get_int("I0");
const tipo_movimento tm = (tipo_movimento)_mov->get_int(MOV_TIPOMOV);
tipo_movimento tm = (tipo_movimento)_mov->get_int(MOV_TIPOMOV);
if (tm == tm_nessuno)
{
if (tipodoc == "FV" || tipodoc == "FA")
tm = tm_fattura; else
if (tipodoc == "NC")
tm = tm_nota_credito;
}
// Controlla se la data del documento si riferisce all'anno precedente (PRORATA 1998)
const TDate datedoc = _mov->get(MOV_DATADOC);
@ -960,13 +972,13 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
const bool cau_intra = rcs.get_bool("INTRACOM");
const bool cau_valintra = rcs.get_bool("VALINTRA");
if (_mov->get_long(MOV_NUMREG) == 20339)
if (_mov->get_long(MOV_NUMREG) == 31838)
int cazzone = 1;
// Inizio gestione IVA differita
const bool iva_diff = _isdiff && _mov->get_bool(MOV_LIQDIFF);
const bool iva_cass = !iva_diff && _mov->get_bool(MOV_IVAXCASSA) && tm > 0;
const bool movdiff = iva_diff || iva_cass;
const bool movdiff = (iva_diff || iva_cass) && !_recalc_regis; // Aggiunto test su ricalcolo da registri 13-12-2012
bool dok = is_date_ok(date, month, liqmonth, year_int);
TPartite_array arrpart; // Partite interessate
@ -1153,7 +1165,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
CHECKD(rmi_tipoatt > 0, "Invalid tipo att ", rmi_tipoatt);
id.put("TIPOATT", rmi_tipoatt);
id.put("ANNOLIQ", datareg.year());
int mesereg = mesereg = datareg.month();
int mesereg = datareg.month();
if (_freqviva[0] == 'T')
{
const int resto = mesereg % 3;
@ -2072,9 +2084,10 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
stop = 3;
}
else
{
if (year_int < 1998)
stop = 0; // Solo PIM
}
for (int i=start; i<=stop; i++) // Ciclo per le tabelle
{
if (i == 1 || i == 3) //Is it a valid PIS/PRP (vedi anche sel. cursore & date_ok())?
@ -2098,31 +2111,32 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
}
TTable *tab = arr[i];
TRectype& curr = tab->curr();
if (!ign)
{
tab->put("R0", tab->get_real("R0") + imp);
tab->put("R1", tab->get_real("R1") + ivp);
tab->put("R2", tab->get_real("R2") + lor);
tab->put("R3", tab->get_real("R3") + lorcor); // Corrispettivi, non inclusi quelli da ventilare
tab->put("R5", tab->get_real("R5") + ifs);
tab->put("R6", tab->get_real("R6") + vfs);
tab->put("R7", tab->get_real("R7") + adf);
tab->put("R8", tab->get_real("R8") + adi);
tab->put("R9", tab->get_real("R9") + bdi);
tab->put("R10", tab->get_real("R10") + bdv);
tab->put("R13", tab->get_real("R13") + fci);
tab->put("R14", tab->get_real("R14") + fcv);
curr.add("R0", imp);
curr.add("R1", ivp);
curr.add("R2", lor);
curr.add("R3", lorcor); // Corrispettivi, non inclusi quelli da ventilare
curr.add("R5", ifs);
curr.add("R6", vfs);
curr.add("R7", adf);
curr.add("R8", adi);
curr.add("R9", bdi);
curr.add("R10", bdv);
curr.add("R13", fci);
curr.add("R14", fcv);
}
// questi servono per i ricalcoli altrui (classify_pim) o
// per trucchetti di ricalcolo successivi
tab->put("R11",tab->get_real("R11")+fsi);
tab->put("R12",tab->get_real("R12")+fsv);
tab->put("I1", (long)tipomov);
tab->put("B3", ivarimb ? "X" : "");
tab->put("B4", (_isricacq && was_riv) ? "X" : "");
tab->put("S5", tipoiva);
curr.add("R11",fsi);
curr.add("R12",fsv);
curr.put("I1", (long)tipomov);
curr.put("B3", ivarimb ? "X" : "");
curr.put("B4", (_isricacq && was_riv) ? "X" : "");
curr.put("S5", tipoiva);
// art 40 c. 5/6/8 per VA7.
real r,v;

View File

@ -12,6 +12,7 @@
#include <defmask.h>
#include <execp.h>
#include <mailbox.h>
#include <modaut.h>
#include <progind.h>
#include <recarray.h>
#include <recset.h>
@ -66,8 +67,6 @@ HIDDEN int compare_rows(const TObject** o1, const TObject** o2)
{
const TRiga& r1 = *(const TRiga*)*o1;
const TRiga& r2 = *(const TRiga*)*o2;
//return (strcmp((const char*)r1->_codiva, (const char*)r2->_codiva));
return r1._codiva.compare(r2._codiva);
}
@ -121,7 +120,7 @@ const char* TStampa_registri_app::desc_attivita(const TString& cod)
const TRectype& TStampa_registri_app::ricerca_cf(char tipocf, long codcf)
{
TString16 key;
TString8 key;
key.format("%c|%ld", tipocf, codcf);
return cache().get(LF_CLIFO, key);
}
@ -1066,7 +1065,7 @@ int TStampa_registri_app::riga_rmoviva()
_riga_rmi.add_riga(iva);
if (!mov.get_bool(MOV_LIQDIFF) && !(mov.get_bool(MOV_IVAXCASSA) && mov.get_int(MOV_TIPOMOV)>0))
_riga_prospettoXcassa.add_riga(impo, impos, ZERO, ZERO, codiva, 0, 0, false, 0);
_riga_prospettoXcassa.add_riga(impo, impos, ZERO, ZERO, ZERO, ZERO, codiva);
//stampa di prova, cumula progressivi dai movimenti, anziche' dalle tabelle (solo bollato)
if (_tipo_stampa == prova)
@ -1299,7 +1298,8 @@ int TStampa_registri_app::stampa_prospetto(int rr, bool print_prec)
if (_auto_intraf)
riga << TR("; 3=intra e AF art.34 comma 3");
riga << TR("; 4=liquidazione differita");
riga << TR("; 5=IVA per cassa");
if (has_module(ICAUT))
riga << TR("; 5=IVA per cassa");
set_row(rr++, riga);
_stampa = _st_tot_fin;
@ -1496,22 +1496,24 @@ int TStampa_registri_app::stampa_acquisti(int row)
}
}
if (_iva_array.items() > 0)
{
if (tdetprec == 1 || tdetprec == 3 || tdetprec == 9)
{
set_row(++rw, TR("TOTALE"));
if (tot_imponib != ZERO)
set_row(rw, "@29g%r", &tot_imponib);
if (tot_imposta != ZERO)
set_row(rw, "@45g%r", &tot_imposta);
if (_tipo_stampa != prova)
{
if (tot_imponibp != ZERO)
set_row(rw, "@81g%r", &tot_imponibp);
if (tot_impostap != ZERO)
set_row(rw, "@98g%r", &tot_impostap);
}
set_row(++rw, TR("TOTALE"));
if (tot_imponib != ZERO)
set_row(rw, "@29g%r", &tot_imponib);
if (tot_imposta != ZERO)
set_row(rw, "@45g%r", &tot_imposta);
if (_tipo_stampa != prova)
{
if (tot_imponibp != ZERO)
set_row(rw, "@81g%r", &tot_imponibp);
if (tot_impostap != ZERO)
set_row(rw, "@98g%r", &tot_impostap);
}
}
_iva_array.destroy();
_iva_array.destroy();
}
rw++;
return rw;
}
@ -1900,25 +1902,11 @@ real TStampa_registri_app::stampa_valori_plafonds(const real& r1, const int mese
return r;
}
bool TStampa_registri_app::some_IVAxCassa() const
bool TStampa_registri_app::some_IVAxCassa(int da_mese, int a_mese) const
{
if (_tipo_reg != vendita && _tipo_reg != acquisto)
return false;
int da_mese = _data_da.month();
int a_mese = _data_a.month();
if (_frequiva == 'T')
{
const int dr = da_mese % 3;
if (dr != 1)
da_mese -= (dr == 0 ? 2 : 1);
const int ar = a_mese % 3;
if (ar != 0)
a_mese += (ar == 1 ? 2 : 1);
}
TString query;
query = "USE IVADIFF KEY 2 SELECT (TIPOMOV>2)";
query << "\nFROM ANNOLIQ=" << _data_da.year() << " MESELIQ=" << da_mese;
@ -1927,7 +1915,7 @@ bool TStampa_registri_app::some_IVAxCassa() const
return id.items() > 0;
}
bool TStampa_registri_app::print_IVAxCassa(int month)
bool TStampa_registri_app::print_IVAxCassa(int da_month, int a_month)
{
if (_tipo_reg != vendita && _tipo_reg != acquisto)
return false;
@ -1936,16 +1924,26 @@ bool TStampa_registri_app::print_IVAxCassa(int month)
TPrintrow riga;
const TString linea(_stampa_width, '-');
TDate data_da(1, da_month, _data_da.year());
if (data_da < _data_da)
data_da = _data_da;
TDate data_a = _data_a;
if (a_month < data_a.month())
{
data_a = TDate(1, a_month, _data_da.year());
data_a.set_end_month();
}
TString query;
query = "USE IVADIFF SELECT (BETWEEN(DATAREGP,#DAL,#AL))&&(MOV.REG=#REG)&&(TIPOMOV>2)&&(STR(IMPONIBILE>0))&&(STR(MESELIQ==#MON))";
query = "USE IVADIFF SELECT (BETWEEN(DATAREGP,#DAL,#AL))&&(MOV.REG=#REG)&&(TIPOMOV>2)&&(STR(IMPONIBILE>0))";
query << "\nBY DATAREGP DATAREG";
query << "\nJOIN MOV INTO NUMREG==NUMREG";
query << "\nJOIN CLIFO TO MOV INTO TIPOCF==TIPO CODCF==CODCF";
TISAM_recordset id(query);
id.set_var("#DAL", _data_da);
id.set_var("#AL", _data_a);
id.set_var("#DAL", data_da);
id.set_var("#AL", data_a);
id.set_var("#REG", _codreg);
id.set_var("#MON", long(month));
// Sporco trucco per evitare intestazioni inutili
const bool il = _intesta_liq;
@ -1954,7 +1952,11 @@ bool TStampa_registri_app::print_IVAxCassa(int month)
if (id.items() > 0)
{
riga.reset();
riga.put(linea, 0);
if (pr.rows_left() < id.items()+8)
{
pr.formfeed();
riga.put(linea, 0);
}
pr.print(riga);
riga.reset();
@ -1972,7 +1974,8 @@ bool TStampa_registri_app::print_IVAxCassa(int month)
riga.put(TR("Documento"), 19);
riga.put(TR("T Tipo"), 66);
riga.put(TR("Forz"), 123);
riga.put(TR("Num"), 128);
if (_tipo_stampa == prova)
riga.put(TR("Num"), 128);
pr.print(riga);
riga.reset();
@ -1985,7 +1988,8 @@ bool TStampa_registri_app::print_IVAxCassa(int month)
riga.put(TR("IVA"), 102);
riga.put(TR("Imposta"), 115);
riga.put(TR("Scad"), 123);
riga.put(TR("Reg"), 128);
if (_tipo_stampa == prova)
riga.put(TR("Reg"), 128);
pr.print(riga);
riga.put(linea, 0); pr.print(riga);
@ -1997,8 +2001,11 @@ bool TStampa_registri_app::print_IVAxCassa(int month)
const real importo = rec.get("IMPORTO");
const real imponibile = rec.get("IMPONIBILE");
const real imposta = rec.get("IMPOSTA");
const int tipodiff = rec.get_int("TIPODIFF");
TParagraph_string clifo(id.get("CLIFO.RAGSOC").as_string(), 27);
TString rs = id.get("CLIFO.RAGSOC").as_string();
rs.strip_double_spaces();
TParagraph_string clifo(rs, 27);
riga.reset();
riga.put(rec.get_date("DATAREGP").string(brief, '/'), 0);
@ -2007,75 +2014,137 @@ bool TStampa_registri_app::print_IVAxCassa(int month)
riga.put(id.get("MOV.NUMDOC").as_string(), 24);
riga.put(format("%6ld", id.get("CLIFO.CODCF").as_int()), 31);
riga.put(clifo.get(), 38);
riga.put(rec.get_int("TIPODIFF") == 2 ? "5" : "4", 66); // 4 = Differita; 5 = x Cassa
riga.put(tipodiff == 2 ? "5" : "4", 66); // 4 = Differita; 5 = x Cassa
riga.put(id.get("MOV.TIPODOC").as_string(), 68);
print_real(riga, importo, 70);
print_real(riga, imponibile, 85);
riga.put(rec.get("CODIVA"), 102);
print_real(riga, imposta, 107);
riga.put(rec.get_int("NUMPRO") >= 999 ? "X" : "", 123);
riga.put(format("%6ld", rec.get_long(MOV_NUMREG)), 125);
if (_tipo_stampa == prova)
riga.put(format("%6ld", rec.get_long(MOV_NUMREG)), 125);
pr.print(riga);
_riga_prospettoXcassa.add_riga(ZERO, ZERO, imponibile, imposta, codiva, 0, 0, false, 0);
switch (tipodiff)
{
case 1: _riga_prospettoXcassa.add_riga(ZERO, ZERO, imponibile, imposta, ZERO, ZERO, codiva); break;
case 2: _riga_prospettoXcassa.add_riga(ZERO, ZERO, ZERO, ZERO, imponibile, imposta, codiva); break;
default: break;
}
}
}
if (_riga_prospettoXcassa.items() <= 0)
return id.items() > 0; // Ho stampato qualcosa?
riga.reset();
if (pr.rows_left() < _riga_prospettoXcassa.items()+5)
else
{
pr.formfeed();
riga.put(linea, 0);
_intesta_liq = il; // Ripristina flag intestazioni
return false; // Ho stampato qualcosa?
}
pr.print(riga);
riga.reset();
riga.put(TR("PROSPETTO IMPORTI CON IVA ORDINARIA ED IVA DIFFERITA O PER CASSA"), 40);
pr.print(riga);
riga.reset();
pr.print(riga);
riga.reset();
riga.put(TR("IVA Descrizione"), 0);
riga.put(TR("Imponibile"), 34);
riga.put(TR("Imposta"), 53);
riga.put(TR("Imponibile diff."), 84);
riga.put(TR("Imposta diff."), 109);
pr.print(riga);
real tot_imponib, tot_imposta, tot_imponibp, tot_impostap;
_riga_prospettoXcassa.sort(compare_righeiva);
for (int s = 0; s < _riga_prospettoXcassa.items(); s++)
int flags = 0x0;
FOR_EACH_ARRAY_ITEM(_riga_prospettoXcassa, r, obj)
{
const TRigaiva& ri = _riga_prospettoXcassa.riga(s);
const TRiga& ri = *(const TRiga*)obj;
if (!ri._implordo.is_zero())
flags |= 0x1;
if (!ri._impostap.is_zero())
flags |= 0x2;
}
if (flags != 0x0)
{
riga.reset();
riga.put(ri._codiva, 0);
riga.put(descr_iva(ri._codiva), 5);
print_real(riga, ri._imponibile, 29);
print_real(riga, ri._imposta, 45);
print_real(riga, ri._imponibilep,85);
print_real(riga, ri._impostap, 107);
if (pr.rows_left() < _riga_prospettoXcassa.items()+8)
{
pr.formfeed();
riga.put(linea, 0);
}
pr.print(riga);
tot_imponib += ri._imponibile;
tot_imposta += ri._imposta;
tot_imponibp+= ri._imponibilep;
tot_impostap+= ri._impostap;
}
riga.reset();
pr.print(riga);
riga.reset();
pr.print(riga);
riga.put(TR("TOTALE"), 0);
print_real(riga, tot_imponib, 29);
print_real(riga, tot_imposta, 45);
print_real(riga, tot_imponibp, 85);
print_real(riga, tot_impostap,107);
pr.print(riga);
TString str = TR("PROSPETTO IMPORTI CON IVA NORMALE");
if (flags & 0x1)
str << ((flags == 0x1) ? TR(" ED ") : ", ") << TR("IVA DIFFERITA");
if (flags & 0x2)
str << " ED " << TR("IVA PER CASSA");
riga.put(str, (132-str.len())/2);
pr.print(riga);
riga.reset();
pr.print(riga);
riga.put(TR("NORMALE"), 45);
if (flags & 0x1)
riga.put(TR("DIFFERITA"), 78);
if (flags & 0x2)
riga.put(TR("PER CASSA"), 112);
pr.print(riga);
riga.reset();
riga.put(TR("IVA Descrizione"), 0);
riga.put(TR("Imponibile"), 34);
riga.put(TR("Imposta"), 53);
if (flags & 0x1)
{
riga.put(TR("Imponibile"), 68);
riga.put(TR("Imposta"), 87);
}
if (flags & 0x2)
{
riga.put(TR("Imponibile"), 102);
riga.put(TR("Imposta"), 121);
}
pr.print(riga);
real tot_imponib0, tot_imposta0, tot_imponib1, tot_imposta1, tot_imponib2, tot_imposta2;
_riga_prospettoXcassa.sort(compare_rows);
for (int s = 0; s < _riga_prospettoXcassa.items(); s++)
{
const TRiga& ri = _riga_prospettoXcassa.riga(s);
riga.reset();
riga.put(ri._codiva, 0);
riga.put(descr_iva(ri._codiva), 5);
print_real(riga, ri._imponibile, 29);
print_real(riga, ri._imposta, 45);
if (flags & 0x1)
{
print_real(riga, ri._implordo, 63);
print_real(riga, ri._imponibilep, 79);
}
if (flags & 0x2)
{
print_real(riga, ri._impostap, 97);
print_real(riga, ri._implordop, 113);
}
pr.print(riga);
tot_imponib0 += ri._imponibile;
tot_imposta0 += ri._imposta;
tot_imponib1 += ri._implordo;
tot_imposta1 += ri._imponibilep;
tot_imponib2 += ri._impostap;
tot_imposta2 += ri._implordop;
}
riga.reset();
pr.print(riga);
riga.put(TR("TOTALI"), 0);
print_real(riga, tot_imponib0, 29);
print_real(riga, tot_imposta0, 45);
if (flags & 0x1)
{
print_real(riga, tot_imponib1, 63);
print_real(riga, tot_imposta1, 79);
}
if (flags & 0x2)
{
print_real(riga, tot_imponib2, 97);
print_real(riga, tot_imposta2, 113);
}
pr.print(riga);
}
_riga_prospettoXcassa.destroy();
@ -2228,7 +2297,7 @@ bool TStampa_registri_app::preprocess_page(int file, int counter)
if (ocfpi.empty())
{
TRectype dep = ricerca_cf(tipocf, codcf);
ragsoc = dep.get (CLI_RAGSOC);
ragsoc = dep.get (CLI_RAGSOC); ragsoc.strip_double_spaces();
viacf = dep.get (CLI_INDCF);
civcf = dep.get (CLI_CIVCF);
capcf = dep.get (CLI_CAPCF);
@ -2248,7 +2317,7 @@ bool TStampa_registri_app::preprocess_page(int file, int counter)
nome = ragsoc.mid(30,20);
cognome.trim(); nome.trim();
ragsoc = cognome;
ragsoc << " " << nome;
ragsoc << ' ' << nome;
}
}
else
@ -2522,19 +2591,36 @@ print_action TStampa_registri_app::postprocess_page (int file, int counter)
_datareg = save_date;
}
if (last_mov)
const int a_mese = _datareg.month();
int da_mese = 0;
if (_frequiva == 'T')
{
printer().formfeed();
print_IVAxCassa(_datareg.month());
if (a_mese % 3 == 0)
da_mese = a_mese-2;
}
else
da_mese = a_mese;
if (da_mese > 0)
{
if (some_IVAxCassa(da_mese, a_mese))
{
printer().formfeed();
print_IVAxCassa(da_mese, a_mese);
da_mese = 0; // vieta ristampa!
}
else
_riga_prospettoXcassa.destroy(); // Elimina comunque tracking movimenti
}
if (_liquidazione)
{
if (!_st_liq[_datareg.month()] && stampo_liquidazione(_datareg.month()))
if (!_st_liq[a_mese] && stampo_liquidazione(a_mese))
{
_st_liq[_datareg.month()] = true;
_st_liq[a_mese] = true;
if (_scelta == B0_settato)
liq_b0_settato();
if (_scelta == prosegui_stampa || _scelta == prosegui_cal_stampa)
{
if (_t.exist())
@ -2762,20 +2848,20 @@ void TStampa_registri_app::preprocess_header()
set_header(r++,TR("RIEPILOGO TOTALI REGISTRI IVA"));
else
{
if (_stampa_width == 132)
{
set_header(r,FR("@10gNum.@19gDocumento@61gMese@66gT Tipo@102gCod %c@123gT %c@128gNum"), nd1, tipo);
r++;
set_header(r, FR("Data reg. prot.@17gData@24gNumero Codice Ragione sociale/descr. liq.@66gO Doc.@74gTotale doc.@90gImponibile Iva %c@115gImposta@123g%c %c@128gReg"), nd2, cor, type);
r++;
}
else //stampa a 198
{
set_header(r,FR("Registrazione Documento@61gMese@66gT Tipo@110gCod %c@132g%c T@139gNum."), nd1, tipo, cor);
r++;
set_header(r, FR("Data Protocollo Data@24gNumero Codice Ragione sociale/descr. liq.@66gO Documento@80gTot.Documento@98gImponibile Iva %c@124gImposta@132g%c %c@139gReg."), nd2, type, cor);
r++;
}
if (_stampa_width == 132)
{
set_header(r,FR("@10gNum.@19gDocumento@61gMese@66gT Tipo@102gCod %c@123gT %c@128gNum"), nd1, tipo);
r++;
set_header(r, FR("Data reg. prot.@17gData@24gNumero Codice Ragione sociale/descr. liq.@66gO Doc.@74gTotale doc.@90gImponibile Iva %c@115gImposta@123g%c %c@128gReg"), nd2, cor, type);
r++;
}
else //stampa a 198
{
set_header(r,FR("Registrazione Documento@61gMese@66gT Tipo@110gCod %c@132g%c T@139gNum."), nd1, tipo, cor);
r++;
set_header(r, FR("Data Protocollo Data@24gNumero Codice Ragione sociale/descr. liq.@66gO Documento@80gTot.Documento@98gImponibile Iva %c@124gImposta@132g%c %c@139gReg."), nd2, type, cor);
r++;
}
}
}
else if (!_intesta_vidi)
@ -2906,8 +2992,9 @@ void TStampa_registri_app::liq_b0_settato()
TFilename f;
f.temp("rg");
if (_tipo_stampa == prova)
send_message('S',f, _datareg.month());
else send_message('s',f, _datareg.month());
send_message('S', f, _datareg.month());
else
send_message('s', f, _datareg.month());
if (f.exist())
{
@ -2955,14 +3042,13 @@ void TStampa_registri_app::liq_other_case()
// sarebbe necessario un ricalcolo progressivi per sicurezza.
if (ricalcola(_fino_a_mese) || calc_reg)
{
TFilename app;
app.temp();
int mese = _fino_a_mese;
//se la frequenza e' trimestrale
//aggiusta il mese al trimestre a cui appartiene
if (_frequiva == 'T')
mese += 2 - ((mese-1) % 3);
send_message(calc_reg ? 'R' : 'C', app, calc_reg ? _datareg.month() : mese);
TFilename app; app.temp();
int mese = _fino_a_mese;
//se la frequenza e' trimestrale
//aggiusta il mese al trimestre a cui appartiene
if (_frequiva == 'T')
mese += 2 - ((mese-1) % 3);
send_message(calc_reg ? 'R' : 'C', app, calc_reg ? _datareg.month() : mese);
}
}
}
@ -3248,7 +3334,7 @@ void TStampa_registri_app::no_movimenti()
{
TRecnotype rec = _tabreg->recno();
_mov_empty = true;
int da, a;
int da = 1, a = _fino_a_mese;
if (_tipo_stampa == bollato || _tipo_stampa == rif_giornale)
da = 1;
if (_tipo_stampa == libro_unico)
@ -3257,7 +3343,8 @@ void TStampa_registri_app::no_movimenti()
da = _data_da.month();
if (_tipo_stampa == prova)
a = _data_a.month();
else a = _fino_a_mese;
else
a = _fino_a_mese;
//RICALCOLO PROGRESSIVI per registro riepilogativo
//il ricalcolo dei progressivi mensili viene sempre
@ -3288,15 +3375,11 @@ void TStampa_registri_app::no_movimenti()
send_message(calc ? 'R' : 'C', app, calc ? a : mese);
}
if (some_IVAxCassa())
if (some_IVAxCassa(da, a))
{
if (! printer().isopen())
printer().open();
int mese = a;
if (_frequiva == 'T')
mese += 2 - ((mese-1) % 3);
print_IVAxCassa(mese);
print_IVAxCassa(da, a);
}
if (_tipo_reg == riepilogativo || _liquidazione || _stampa_plafonds)
@ -3433,13 +3516,14 @@ void TStampa_registri_app::stampa_liq_mesi_succ()
void TStampa_registri_app::send_message(char tipo, const TFilename& nome, int mese)
{
const char* app;
const char* app = "cg4 -2";
if (tipo == 'S' || tipo == 's')
app = "cg4 -2 -S";
else if (tipo == 'C' || tipo == 'R')
app = "cg4 -2 -C";
else app = "cg4 -2";
else
app = "cg4 -2";
TToken_string ss(36);
ss.add(_annoes);
@ -3451,10 +3535,7 @@ void TStampa_registri_app::send_message(char tipo, const TFilename& nome, int me
ss.add(tipo);
ss.add(_data_stampa.string());
ss.add(nome);
if (_riep_liq)
ss.add('X');
else ss.add(' ');
ss.add(_riep_liq ? 'X' : ' ');
ss.add(printer().formlen() - _size_header - RIGHE_FOOTER);
TMessage liq (app, "RCL", ss);
@ -3666,6 +3747,10 @@ bool TStampa_registri_app::stampa_registri_IVA(const TMask& m)
}
else //stampa tutti i registri
{
_scelta = controlla_liquidazione();
if (_scelta == non_proseguire)
return false;
TDate sca_vid;
bool one_printed = false; // Flag per vedere se ha stampato almeno un registro (solo per rif. al libro giornale)
for (_tabreg->first(); !_tabreg->eof(); _tabreg->next())
@ -3711,7 +3796,7 @@ bool TStampa_registri_app::stampa_registri_IVA(const TMask& m)
one_printed = true;
else
continue;
}
} else
if (_tipo_stampa == libro_unico) //stampa su libro unico
{
if (cod_lib_un != _codlib)
@ -3747,7 +3832,8 @@ bool TStampa_registri_app::stampa_registri_IVA(const TMask& m)
if (_liquidazione)
{
_size_header = 3;
if ((_tipo_stampa == bollato || _tipo_stampa == rif_giornale) && !_stampa_ind_ditta) _size_header++;
if ((_tipo_stampa == bollato || _tipo_stampa == rif_giornale) && !_stampa_ind_ditta)
_size_header++;
clear_stliq();
//N.B. E' fondamentale che _scelta venga ri-inizializzata ad ogni
//registro(cioe' dopo la stampa di ciascuno). Infatti il B0 di un
@ -3806,9 +3892,11 @@ bool TStampa_registri_app::stampa_riepilogo(int m)
TRiga_array vect, vect_prec;
TRigaiva_array vect_det;
bool stampato = false;
if (!printer().isopen()) printer().open();
if (!printer().isopen())
printer().open();
for (_tabreg->first(); !_tabreg->eof(); _tabreg->next()) // Scorre i registri
_tabreg->put("CODTAB", _annoes);
for (int err = _tabreg->read(_isgteq); err == NOERR; err = _tabreg->next()) // Scorre i registri
{
const TString8 codtab = _tabreg->get("CODTAB");
const int a = atoi(codtab.mid(0,4));

View File

@ -35,10 +35,9 @@ class TStampa_registri_app : public TPrintapp
{
TSorted_cursor * _cur;
TRelation *_rel, *_nditte;
// TLocalisamfile *_clifo, *_occas, *_com, *_anag, *_unloc, *_attiv, *_indlib;
// TTable *_tablia, *_tabpim, *_tabprm, *_tabprp, *_table;
TTable *_tabreg;
TRigaiva_array _iva_array, _riga_rmi, _riga_prospettoXcassa;
TRigaiva_array _iva_array, _riga_rmi;
TRiga_array _riga_prospettoXcassa;
TTipodoc_array _doc_array;
TRiga_array _tot_iva_array, _tot_prec_iva_array;
TBit_array _selected;
@ -147,8 +146,8 @@ public:
int stampa_acquisti(int);
real stampa_valori_plafonds(const real&, const int, TTable&, const char*);
bool some_IVAxCassa() const; // C'e' IVA per cassa o differita da stampare?
bool print_IVAxCassa(int month);
bool some_IVAxCassa(int da_month, int a_month) const; // C'e' IVA per cassa o differita da stampare?
bool print_IVAxCassa(int da_month, int a_month);
void build_nomiditte(TProgind* pnd = NULL);
void set_year(int y) { _annoes = y; }

View File

@ -116,8 +116,9 @@ public:
void set_prorata(int annodoc, const real& pro);
real prorata(int annodoc);
bool prorata100(int annodoc) { return prorata(annodoc) >= 100.0; }
#ifdef PRORATA100
bool prorata100(int annodoc) { return prorata(annodoc) >= CENTO; }
#endif
bool update(long uprotiva, const TDate& lastreg);
TRegistro(const char* code = "", int year = 0);

View File

@ -42,13 +42,15 @@ real indetraibile_al(const TString& codind, const TCausale& caus, int annodoc, i
case iva_acquisti:
case nessuna_iva:
case iva_errata:
#ifdef PRORATA100
if (!is_liq && caus.reg().prorata100(annodoc)) // Se prorata = 100% e' indetraibile
{
perc = CENTO;
tipodet = 9;
}
else
tipodet = codind2tipodet(codind, perc);
#endif
tipodet = codind2tipodet(codind, perc);
break;
default:
tipodet = 0; // Vendite sempre detraibili