Patch level : 12.0 488

Files correlati     : cg0.exe cg0500a.msk cg2.exe cg4.exe

Reverse charge :
Implemetata la possibilità di mettere il fornitore sulla regolarizzazione.
Nelle causali di sola iva si può mettere un fornitore anche se identificano un registro delle vendite.
Il movimento di regolarizzazione viene creato come prima se inserisco un cliente corrispondente altrimenti viene usato il codice del fornitore stesso.
Fatture in ritardo :
implementata la gestione delle fatture in ritardo (con data documento anno precedente). Fino ad aprile le fatture non vengono detratte e vengono poi detratte a Maggio come credito. Da maggio in poi sono indetraibili.
Sul registro le fatture vengono identificate con tipo documento e "CD" quelle fino ad aprile e con tipo documento e "CI" quelle fino da maggio in poi.



git-svn-id: svn://10.65.10.50/branches/R_10_00@24241 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
bonazzi 2017-12-19 23:31:20 +00:00
parent 6072e16b98
commit ead18cd8f5
10 changed files with 522 additions and 433 deletions

View File

@ -589,6 +589,11 @@ bool TCaus_app::conto_hndl (TMask_field& f, KEY k)
sezione_consigliata = app().ss().row(0).get_char(1) == 'D' ? 'A' : 'D'; sezione_consigliata = app().ss().row(0).get_char(1) == 'D' ? 'A' : 'D';
} }
const bool solaIVA = (TipoIVA)app().curr_mask().get_bool(F_SOLAIVA);
if (!ok && solaIVA && cf == 'F')
ok = true; // le regolarizzazioni possono avere un fornitore sulla vendita fittizia
if (!ok) if (!ok)
return cfld.error_box( return cfld.error_box(
FR("%s non valido con registro %s"), cf == 'C' ? TR("Cliente") : TR("Fornitore"), iva2name(tpr)); FR("%s non valido con registro %s"), cf == 'C' ? TR("Cliente") : TR("Fornitore"), iva2name(tpr));

View File

@ -172,6 +172,12 @@ BEGIN
FLAGS "H" FLAGS "H"
END END
BOOLEAN F_SOLAIVA
BEGIN
PROMPT 2 6 "Movimento di sola IVA"
FIELD SOLOIVA
END
SPREADSHEET F_SHEET_GCS SPREADSHEET F_SHEET_GCS
BEGIN BEGIN
PROMPT 0 7 "Righe" PROMPT 0 7 "Righe"
@ -288,12 +294,6 @@ BEGIN
GROUP 2 GROUP 2
END END
BOOLEAN F_SOLAIVA
BEGIN
PROMPT 34 11 "Movimento di sola IVA"
FIELD SOLOIVA
END
BOOLEAN F_MOV_SEZ BOOLEAN F_MOV_SEZ
BEGIN BEGIN
PROMPT 34 11 "Movimento solo sezionale" PROMPT 34 11 "Movimento solo sezionale"

View File

@ -832,6 +832,14 @@ void TPrimanota_application::init_insert_mode(TMask& m)
{ {
occas_mask().reset(); occas_mask().reset();
m.hide(F_OCCASEDIT); m.hide(F_OCCASEDIT);
const TString& tipo = clifo();
m.set(F_CLIFO, tipo);
m.show(F_CLIENTE, tipo == "C");
m.show(F_RAGSOCCLIENTE, tipo == "C");
m.show(F_FORNITORE, tipo == "F");
m.show(F_RAGSOCFORNITORE, tipo == "F");
#ifdef PRORATA100 #ifdef PRORATA100
m.hide(F_ADJUST_PRORATA); // In inserimento non puo' esistere un pro-rata errato! m.hide(F_ADJUST_PRORATA); // In inserimento non puo' esistere un pro-rata errato!
#endif #endif
@ -931,7 +939,18 @@ void TPrimanota_application::init_modify_mode(TMask& m)
// Determina se il movimento è stato trasferito da AS/400: // Determina se il movimento è stato trasferito da AS/400:
// praticamente controlla che non ci sia nessun tipo movimento sulle righe contabili. // praticamente controlla che non ci sia nessun tipo movimento sulle righe contabili.
_as400 = false; _as400 = false;
if (is_saldaconto() || iva() != nessuna_iva) if (iva() != nessuna_iva)
{
const TString& tipo = clifo();
m.set(F_CLIFO, tipo);
m.show(F_CLIENTE, tipo == "C");
m.show(F_RAGSOCCLIENTE, tipo == "C");
m.show(F_FORNITORE, tipo == "F");
m.show(F_RAGSOCFORNITORE, tipo == "F");
}
if (is_saldaconto() || iva() != nessuna_iva)
{ {
if (cg.items() > 0) if (cg.items() > 0)
{ {
@ -1649,12 +1668,21 @@ void TPrimanota_application::genera_automatico(int tipo, const char* causimm)
break; break;
case 2: // Regolarizzazione IVA case 2: // Regolarizzazione IVA
{ {
TCausale caus_reg(_automatico->_causale);
TBill contocf; caus_reg.bill(1, contocf);
char tcf_reg = contocf.tipo();
// Reperisce l'eventuale cliente associato al fornitore e lo propone // Reperisce l'eventuale cliente associato al fornitore e lo propone
TString8 forn; forn.format("F|%ld", _automatico->_clifo.codclifo()); if (tcf_reg == 'F')
const TString& clnt = cache().get(LF_CLIFO, forn, CLI_CODCFASS); m.set(F_FORNITORE, _automatico->_clifo.codclifo());
m.set(F_CLIENTE, clnt); else
m.set(F_TOTALE, _automatico->_totale); // Imposta il totale documento e ... {
m.set(F_CODIVA, _automatico->_codiva, true); // ... scatena creazione prima riga IVA TString8 forn; forn.format("F|%ld", _automatico->_clifo.codclifo());
const TString& clnt = cache().get(LF_CLIFO, forn, CLI_CODCFASS);
m.set(F_CLIENTE, clnt);
}
m.set(F_TOTALE, _automatico->_totale); // Imposta il totale documento e ...
m.set(F_CODIVA, _automatico->_codiva, true); // ... scatena creazione prima riga IVA
if (TRelation_application::is_transaction()) if (TRelation_application::is_transaction())
m.send_key(K_CTRL+'R', 0); m.send_key(K_CTRL+'R', 0);

View File

@ -1672,7 +1672,9 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k)
TMask& m = a.curr_mask(); TMask& m = a.curr_mask();
// Controllo split-payment (dalla versione 12) // Controllo split-payment (dalla versione 12)
if (m.get_int(F_ANNOIVA) >= 2015 && a.clifo() == 'C' && a.get_version() >= 12) const TString4 tipocf(a.clifo());
if (m.get_int(F_ANNOIVA) >= 2015 && (tipocf == "C") && a.get_version() >= 12)
{ {
const int r_norm = type2pos('D'); const int r_norm = type2pos('D');
const bool split_needed = r_norm >= 0 && a.is_split_payment(); const bool split_needed = r_norm >= 0 && a.is_split_payment();
@ -1821,12 +1823,13 @@ bool TPrimanota_application::cg_conto_handler(TMask_field& f, KEY key)
TMask& m = f.mask(); TMask& m = f.mask();
if (m.get(CG_ROWTYPE)[0] == 'T' && !app().causale().corrispettivi()) if (m.get(CG_ROWTYPE)[0] == 'T' && !app().causale().corrispettivi())
{ {
const char tipo = app().clifo(); // Tipo conto richiesto dal movimento const TString4 tipo = app().clifo(); // Tipo conto richiesto dal movimento
char cf = m.get(f.dlg()-2)[0]; TString4 cf = m.get(f.dlg()-2);
if (cf < ' ') cf = ' '; // Tipo conto della riga
if (cf[0] < ' ') cf = " "; // Tipo conto della riga
if (cf != tipo) // Incongruenza! if (cf != tipo) // Incongruenza!
{ {
const char* d = tipo == 'C' ? TR("clienti") : TR("fornitori"); const char* d = tipo == "C" ? TR("clienti") : TR("fornitori");
ok = f.error_box(FR("La riga totale richiede un conto %s."), d); ok = f.error_box(FR("La riga totale richiede un conto %s."), d);
} }
} }
@ -2714,7 +2717,7 @@ bool TPrimanota_application::occas_handler(TMask_field& f, KEY key)
void TPrimanota_application::add_cgs_tot(TMask& m) void TPrimanota_application::add_cgs_tot(TMask& m)
{ {
const bool corri = causale().corrispettivi(); const bool corri = causale().corrispettivi();
const char tipo = corri ? ' ' : app().clifo(); const TString4 tipo = corri ? " " : app().clifo();
int gruppo = 0, conto = 0; int gruppo = 0, conto = 0;
long codice = corri ? 0L : m.get_long(tipo == 'C' ? F_CLIENTE : F_FORNITORE); long codice = corri ? 0L : m.get_long(tipo == 'C' ? F_CLIENTE : F_FORNITORE);
@ -2742,7 +2745,7 @@ void TPrimanota_application::add_cgs_tot(TMask& m)
} }
} }
TBill nuovo(gruppo, conto, codice, tipo); TBill nuovo(gruppo, conto, codice, tipo[0]);
if (!corri && (gruppo == 0 || conto == 0)) if (!corri && (gruppo == 0 || conto == 0))
nuovo.find(); // Compila anche gruppo e conto in base al codice clifo nuovo.find(); // Compila anche gruppo e conto in base al codice clifo
@ -2838,15 +2841,15 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key)
} }
} }
const char cf = a.clifo(); const TString4 cf = a.clifo();
const long codice = atol(f.get()); const long codice = atol(f.get());
if (codice == 0) if (codice == 0)
{ {
m.hide(F_OCCASEDIT); // Spegni bottone occasionali m.hide(F_OCCASEDIT); // Spegni bottone occasionali
m.show(F_STATOPAIV); // Stato partita IVA m.show(F_STATOPAIV); // Stato partita IVA
m.show(cf == 'C' ? F_PIVACLIENTE : F_PIVAFORNITORE); // Partita IVA m.show(cf == "C" ? F_PIVACLIENTE : F_PIVAFORNITORE); // Partita IVA
m.show(cf == 'C' ? F_COFICLIENTE : F_COFIFORNITORE); // Codice Fiscale m.show(cf == "C" ? F_COFICLIENTE : F_COFIFORNITORE); // Codice Fiscale
a.activate_numrif(m, true); a.activate_numrif(m, true);
return true; return true;
} }
@ -3100,7 +3103,7 @@ bool TPrimanota_application::activate_split_payment(TMask& m)
TMask_field* sp = m.find_by_id(F_SPLITPAY); TMask_field* sp = m.find_by_id(F_SPLITPAY);
if (sp != NULL) if (sp != NULL)
{ {
if (clifo() == 'C' && m.get_int(F_ANNOIVA) >= 2015 && !causale().reverse_charge()) if (clifo() == "C" && m.get_int(F_ANNOIVA) >= 2015 && !causale().reverse_charge())
{ {
const TRectype& cliente = cache().get_rec(LF_CLIFO, "C", m.get(F_CLIENTE)); const TRectype& cliente = cache().get_rec(LF_CLIFO, "C", m.get(F_CLIENTE));
yes = cliente.get_bool(CLI_SPLITPAY); yes = cliente.get_bool(CLI_SPLITPAY);
@ -3120,6 +3123,16 @@ bool TPrimanota_application::activate_split_payment(TMask& m)
return yes; return yes;
} }
const TString & TPrimanota_application::clifo() const
{
TCausale & caus = causale();
TBill conto; caus.bill(1, conto);
TString & tipo = get_tmp_string();
tipo << conto.tipo();
return tipo;
}
bool TPrimanota_application::is_split_payment() const bool TPrimanota_application::is_split_payment() const
{ {
const TMask& m = curr_mask(); const TMask& m = curr_mask();
@ -3135,7 +3148,7 @@ bool TPrimanota_application::is_split_payment() const
if (s != 'N' && s != 'S') if (s != 'N' && s != 'S')
{ {
s = 'N'; s = 'N';
if (clifo() == 'C' && m.get_int(F_ANNOIVA) >= 2015 && !causale().reverse_charge()) if (clifo() == "C" && m.get_int(F_ANNOIVA) >= 2015 && !causale().reverse_charge())
{ {
const TRectype& cliente = cache().get_rec(LF_CLIFO, "C", m.get(F_CLIENTE)); const TRectype& cliente = cache().get_rec(LF_CLIFO, "C", m.get(F_CLIENTE));
if (cliente.get_bool(CLI_SPLITPAY)) if (cliente.get_bool(CLI_SPLITPAY))

View File

@ -9,6 +9,10 @@
#include "cgpagame.h" #include "cgpagame.h"
#endif #endif
#ifndef __MOV_H
#include "mov.h"
#endif
#ifndef __CGSALDAC_H #ifndef __CGSALDAC_H
#include "cgsaldac.h" #include "cgsaldac.h"
#endif #endif
@ -21,6 +25,13 @@
#include "cg2101.h" #include "cg2101.h"
#endif #endif
#ifndef __CG2101_H
#include "cg2101.h"
#endif
#ifndef __CG2100_H
#include "cg2100.h"
#endif
class TDati_mov_auto; class TDati_mov_auto;
class TPrimanota_application : public TRelation_application class TPrimanota_application : public TRelation_application
@ -206,7 +217,7 @@ protected:
void mask2rel(const TMask& m); void mask2rel(const TMask& m);
TipoIVA iva() const { return _iva; } TipoIVA iva() const { return _iva; }
char clifo() const { return iva() == iva_vendite ? 'C' : 'F'; } const TString & clifo() const;
bool gestione_valuta() const { return _ges_val; } bool gestione_valuta() const { return _ges_val; }
bool gestione_saldaconto() const { return _ges_sal; } bool gestione_saldaconto() const { return _ges_sal; }
bool npart_is_month() const { return _npart_is_month; } bool npart_is_month() const { return _npart_is_month; }

View File

@ -337,8 +337,8 @@ bool TPrimanota_application::codpag_handler(TMask_field& f, KEY key)
// Nella maschera iva cerco di reperirlo dal cliente // Nella maschera iva cerco di reperirlo dal cliente
if (m.id2pos(F_CLIENTE) > 0) if (m.id2pos(F_CLIENTE) > 0)
{ {
const char typ = a.clifo(); const TString4 typ = a.clifo(m);
const long cod = m.get_long(typ == 'C' ? F_CLIENTE : F_FORNITORE); const long cod = m.get_long(typ == "C" ? F_CLIENTE : F_FORNITORE);
TLocalisamfile clifo(LF_CLIFO); TLocalisamfile clifo(LF_CLIFO);
clifo.put(CLI_TIPOCF, typ); clifo.put(CLI_TIPOCF, typ);
clifo.put(CLI_CODCF, cod); clifo.put(CLI_CODCF, cod);
@ -929,16 +929,16 @@ int TPrimanota_application::cerca_conto_cf(TBill& bill) const
TString_array& a = cgs().rows_array(); TString_array& a = cgs().rows_array();
if (iva() != nessuna_iva) if (iva() != nessuna_iva)
{ {
const char tipocf = clifo(); const TString4 tipocf = clifo(curr_mask());
const long codcf = curr_mask().get_long(tipocf == 'C' ? F_CLIENTE : F_FORNITORE); const long codcf = curr_mask().get_long(tipocf == 'C' ? F_CLIENTE : F_FORNITORE);
for (int r = 0; r < a.items(); r++) for (int r = 0; r < a.items(); r++)
{ {
TToken_string& row = a.row(r); TToken_string& row = a.row(r);
bill.get(row, 2, 0x1); bill.get(row, 2, 0x1);
if (bill.tipo() == tipocf && bill.codclifo() == codcf) if (bill.tipo() == tipocf[0] && bill.codclifo() == codcf)
return r; return r;
} }
bill.set(0, 0, codcf, tipocf); bill.set(0, 0, codcf, tipocf[0]);
} }
else else
{ {

View File

@ -909,6 +909,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
real esenti_c1a_bam = ZERO; // Beni ammorizzabili esenti c1a real esenti_c1a_bam = ZERO; // Beni ammorizzabili esenti c1a
real esenti_b14 = ZERO; real esenti_b14 = ZERO;
real vendite_rev = ZERO; // Vendire in reverse charge (da escludere in prorata) real vendite_rev = ZERO; // Vendire in reverse charge (da escludere in prorata)
real cred_fattrit;
/* Comunicazione dati iva annuale dal 2016 calcolata in cg5 /* Comunicazione dati iva annuale dal 2016 calcolata in cg5
// Comunicazione dati iva annuale (dal 2003) // Comunicazione dati iva annuale (dal 2003)
@ -1048,7 +1049,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
} }
} }
const TDate fromdate(1, month == 13 ? 1 : month, year_int); const TDate fromdate(1, (month == 5) || (month == 13) ? 1 : month, year_int);
TDate t; TDate t;
if (_recalc_regis) // Vecchia selezione prima del 1998 o calcolo progressivi per stampa registri bollati if (_recalc_regis) // Vecchia selezione prima del 1998 o calcolo progressivi per stampa registri bollati
@ -1119,8 +1120,8 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
#ifdef DBG #ifdef DBG
const long nr = _mov->get_long(MOV_NUMREG); const long nr = _mov->get_long(MOV_NUMREG);
if (nr == 214882) if (nr == 1931434 || nr == 1931437)
int i = 1 ; int i = 1;
#endif #endif
const int liqmonth = _mov->get_int(MOV_MESELIQ); const int liqmonth = _mov->get_int(MOV_MESELIQ);
@ -1148,10 +1149,10 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
const TRectype& rcs = _cur->curr(LF_CAUSALI); const TRectype& rcs = _cur->curr(LF_CAUSALI);
const TDate datareg = _mov->get_date(MOV_DATAREG); const TDate datareg = _mov->get_date(MOV_DATAREG);
const TDate datadoc = _mov->get_date(MOV_DATADOC); const TDate datadoc = _mov->get_date(MOV_DATADOC);
const bool dataritind = ((datareg.year() - datadoc.year()) > 1 ) || const bool dataritind = ((tipomov == acquisto) && (_year >= 2018)) && ((datareg.year() - datadoc.year()) > 1 ) ||
(((datareg.year() - datadoc.year()) == 1) && datareg.month() >= 5); (((datareg.year() - datadoc.year()) == 1) && datareg.month() >= 5);
const bool datarit = !dataritind && ((datareg.year() - datadoc.year()) == 1); const bool datarit = ((tipomov == acquisto) && !dataritind) && ((datareg.year() - datadoc.year()) == 1);
const bool fattritind = rcs.get_bool(CAU_RITFATTIND) || dataritind; const bool fattritind = (_year >= 2018) && (rcs.get_bool(CAU_RITFATTIND) || dataritind);
const bool fattrit = rcs.get_bool(CAU_RITFATT) || datarit; const bool fattrit = rcs.get_bool(CAU_RITFATT) || datarit;
const bool cau_intra = rcs.get_bool(CAU_INTRACOM); const bool cau_intra = rcs.get_bool(CAU_INTRACOM);
const bool cau_valintra = rcs.get_bool(CAU_VALINTRA); const bool cau_valintra = rcs.get_bool(CAU_VALINTRA);
@ -1196,12 +1197,13 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
TPointer_array pagscatt; // Righe di pagsca interessate TPointer_array pagscatt; // Righe di pagsca interessate
#ifdef DBG #ifdef DBG
// const long nr = _mov->get_long(MOV_NUMREG); if (nr == 1931434 || nr == 1931437)
int i = 1;
if (nr == 214882 )
int i = 1 ;
#endif #endif
if (fattrit && _month == 5)
dok = true;
if (bIsMovDiff && tm == tm_fattura) if (bIsMovDiff && tm == tm_fattura)
{ {
const bool id_chiusa = ivadiff_chiusa(_mov->curr(), TDate(31,12,inizio.year()-1)); const bool id_chiusa = ivadiff_chiusa(_mov->curr(), TDate(31,12,inizio.year()-1));
@ -1965,300 +1967,302 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
} }
// Le fatture in ritardo non vanno considerate nel periodo ma solo nell'annuale // Le fatture in ritardo non vanno considerate nel periodo ma solo nell'annuale
if (!fattrit || (fattrit && _month == 13)) // normale if (_year >= 2018 && fattrit && _month == 5)
{ cred_fattrit += imposta;
else
if (!fattrit || (fattrit && _month == 13)) // normale
{
// *****************************************
// casi particolari
// *****************************************
// ***************************************** // imposta acquisti intracomunitari
// casi particolari if (tipomov == acquisto && intra)
// ***************************************** totintra += imposta;
// imposta acquisti intracomunitari // Altre cose di cui tener conto
if (tipomov == acquisto && intra) // Separo pazientemente per movimenti d'acquisto e movimenti di vendita
totintra += imposta; // onde evitare rompicapi, rompicazzi ecc...
// Altre cose di cui tener conto switch (tipomov)
// Separo pazientemente per movimenti d'acquisto e movimenti di vendita
// onde evitare rompicapi, rompicazzi ecc...
switch (tipomov)
{
case acquisto: // ACQUISTO (per chi non l'avesse capito)
// Per le anguille delle Antille e le Saracche delle Molucche...
// Gli acquisti con tipocr 1,2,3,5,8 vanno totalizzati se e solo se
// il tipo iva e' diverso da NON SOGGETTO,
if (tipoiva != "NS")
{
if (tipocr == 1 || tipocr ==5)
// Acquisto beni per rivendita
{
acq_riv += imponibile;
acq_riv_iva += imposta;
}
else if (tipocr == 2 && tipodet == 0)
// Acquisto beni ammortizzabili detraibili
{
ammort_det += imponibile;
ammort_det_iva += imposta;
}
else if (tipocr == 2 && tipodet != 0)
// Acquisto beni ammortizzabili indetraibili
{
ammort_indet += imponibile;
ammort_indet_iva += imposta;
}
else if (tipocr == 3)
// Acquisto beni ammortizzabili detr. 6%
{
ammort_6 += imponibile;
ammort_6_iva += imposta;
// ult_detr += imponibile * real(DETRAZIONE_6PERCENTO); // CM500159
}
else if (tipocr == 8)
// Acquisto beni strum. acquisiti in leasing
{
leasing += imponibile;
leasing_iva += imposta;
}
} // fine if per tipo iva != da NON SOGGETTO
// Mi chiedo se effettivamente il tipo 9 sia esente da qualsiasi criterio...
if (tipocr == 9)
// Spese generali
{
spgen += imponibile;
spgen_iva += imposta;
}
// else fuck it up, dirty dick head.
break;
case vendita: // VENDITA
if (tipoiva != "NS") /* Segnalazione CM000219: I non soggetti non vanno considerati */
{
if (tipocr == 4)
/*
* Vendite strum. art 17 (cess. amm.)
* Comprende anche autofatture, anche nell'annuale
* (Sergio 1995)
*/
{
// Invece non le deve comprendere nell'annuale (Vladimiro 1995, piu' tardi)
if (!(_month == 13 && autodafe))
{
cess_amm += imponibile;
cess_amm_iva += imposta;
}
}
if (is_detraibile && !imponibile.is_zero() && is_reverse_charge(_mov->curr()))
vendite_rev += imponibile;
}
break;
default: // Chissa'... forse in futuro vi sara' un ulteriore tipo di movimento...
break;
} // Fine del malefico switch
// operazioni per calcolo rimborso infraanale
// Scudler 1995 e molti dopo di lei
// La breve estate vissuta dal metodo del 51% rende
// oramai superflua la tabella rimborsi, eliminata
// senza entusiasmo ed interrogandomi sul senso della vita
if (ivarimb)
{
bool ok = _isagricolo ? tipoagr == 2 : false;
if (tipomov == acquisto && !ok)
ok = (tipocr == 0 || tipocr == 1 || tipocr == 5 || tipocr == 9);
if (tipomov == vendita && !ok)
ok = tipoiva != "NS" && tipocr != 4;
ivarimb = ok;
}
// operazioni esenti
if (tipoiva == "ES" && !imponibile.is_zero())
{
if (tipomov == vendita)
{
if (sosp_imp != normale && sosp_imp != vol_affari) // CM500308
{
if (tipoes_v == "B1") // C1
esenti_c1 += imponibile;
else if (tipoes_v == "B2") // C2
esenti_c2 += imponibile;
else if (tipoes_v == "B3") // C3
{
esenti_c3 += imponibile;
if (tipocr == 4)
esenti_c3_bam += imponibile;
}
else if (tipoes_v == "B4") // C1A
{
esenti_c1a += imponibile;
if (tipocr == 4)
esenti_c1a_bam += imponibile;
}
// se e' il caso sommare esenti per rimborso
if (isrimbinfr)
esni_rimb += imponibile;
}
}
else if (tipoes_a == "14")
esenti_b14 += imponibile;
}
// non imponibili per rimborso
if (tipoiva == "NI" && tipomov == vendita && isrimbinfr)
esni_rimb += imponibile;
// bolle doganali
if (tipodoc == "BD")
{
bolld_imp = imponibile;
bolld_iva = imposta;
bdog_imp += bolld_imp;
bdog_iva += bolld_iva;
}
// plafond
if (_isplafond && tipomov == acquisto && month != 13 &&
tipoiva == "NI" && tipopla != 0)
{
add_plafond(month, codatt, tipopla, imponibile, tipodoc == "BD");
}
// agenzie viaggio (CHECK imponibili etc.)
if (_isviaggio)
switch (tipoag)
{
case 1:
if (tipomov == acquisto) acq_CEE += imponibile + imposta;
else corr_CEE += imponibile + imposta;
break;
case 2:
if (tipomov == acquisto) acq_noCEE += imponibile + imposta;
else corr_noCEE += imponibile + imposta;
break;
case 3: if (tipomov == vendita)
corr_misCEE += imponibile + imposta;
break;
case 4: if (tipomov == acquisto)
acq_misCEE += imponibile + imposta;
break;
case 5: if (tipomov == acquisto)
acq_misnoCEE += imponibile + imposta;
break;
}
if (_isagricolo)
{
/*
* rifatto sensu Scudler 1995 con invidiabile sicurezza
* senza porsi domande e mettendo NUMERI uguali
* al TIPO RECORD del frigorifero
*/
if (tipomov == vendita)
{
if (!noninc) // Salta i non incassati
{
agr_imp = imponibile;
agr_iva = imposta;
const real p = perciva;
const bool is_not_fs = tipodoc != "FS";
// Se si tratta di Fattura Fiscale o Fattura Scontrino, non scorpora
// In particolare le FS non vengono incluse ne' nello specchietto ne' nel totale
if (corrisp && tipodoc != "FF" && is_not_fs)
lordo2netto(agr_imp,agr_iva,p);
if (tipoagr == 1 && is_not_fs) // Ora si utilizza solo il segnalino 1
{
agr_1 += agr_iva;
agr_1i += agr_imp;
// Nuovo regime agricolo dal 1998: si sommino per codice iva di compensazione (da reperire su PCON)
TString ivacomp("00"); // Se non esiste o non si trova il conto questo e' il default (fa un poco schifo ma e' cosi')
if (_cur->is_first_match(-AGR_PCON1)) // Esiste il conto ?
// Bien, allora controlliamo se e' un ricavo...
if (_pcon_1_r->get_int(PCN_INDBIL) == 4)
if (_cur->is_first_match(-AGR_PCON2)) // Esiste il sottoconto ?
{
if (look_iva(_pcon_2_r->get(PCN_IVACOMP)))
ivacomp = _iva->get("CODTAB"); // Ecco il codice IVA di compensazione
}
look_pia(month, codatt, codiva, ivacomp, true); // Crea il record in tabella se non esiste
real pia_imp = _pia->get_real("R0") + agr_imp; // Aggiorna...
_pia->put("R0", pia_imp);
_pia->put("B0", true); // Seguo l'esempio dei PIM per il ricalcolo acquisti alla fine del ciclo
_pia->rewrite(); // infine scrive
}
else if (tipoagr == 2 && is_not_fs)
{
agr_2 += agr_iva;
agr_2i += agr_imp;
}
}
}
else if (tipodet == 0)
{
if (tipoagr == 2)
{
if (tipocr != 2 && tipocr != 3 && tipocr != 8)
agr_3 += imposta;
else
agr_4 += imposta;
}
else if (tipoagr == 3)
{
if (tipocr != 2 && tipocr != 3 && tipocr != 8)
agr_7 += imposta;
}
else // ne' 2 ne' 3
{
if (tipocr != 2 && tipocr != 3 && tipocr != 8)
agr_5 += imposta;
else
agr_6 += imposta;
}
}
} // __end of _agricolo
if (tipodet == 1) // acquisti indeducibili su ricavi esenti art. 10
{
if (is_reverse_charge(_mov->curr()))
{ {
acquisti += imponibile; case acquisto: // ACQUISTO (per chi non l'avesse capito)
acquisti_iva += imposta; // Per le anguille delle Antille e le Saracche delle Molucche...
} // Gli acquisti con tipocr 1,2,3,5,8 vanno totalizzati se e solo se
else // il tipo iva e' diverso da NON SOGGETTO,
if (tipoiva != "NS")
{
if (tipocr == 1 || tipocr ==5)
// Acquisto beni per rivendita
{
acq_riv += imponibile;
acq_riv_iva += imposta;
}
else if (tipocr == 2 && tipodet == 0)
// Acquisto beni ammortizzabili detraibili
{
ammort_det += imponibile;
ammort_det_iva += imposta;
}
else if (tipocr == 2 && tipodet != 0)
// Acquisto beni ammortizzabili indetraibili
{
ammort_indet += imponibile;
ammort_indet_iva += imposta;
}
else if (tipocr == 3)
// Acquisto beni ammortizzabili detr. 6%
{
ammort_6 += imponibile;
ammort_6_iva += imposta;
// ult_detr += imponibile * real(DETRAZIONE_6PERCENTO); // CM500159
}
else if (tipocr == 8)
// Acquisto beni strum. acquisiti in leasing
{
leasing += imponibile;
leasing_iva += imposta;
}
} // fine if per tipo iva != da NON SOGGETTO
// Mi chiedo se effettivamente il tipo 9 sia esente da qualsiasi criterio...
if (tipocr == 9)
// Spese generali
{
spgen += imponibile;
spgen_iva += imposta;
}
// else fuck it up, dirty dick head.
break;
case vendita: // VENDITA
if (tipoiva != "NS") /* Segnalazione CM000219: I non soggetti non vanno considerati */
{
if (tipocr == 4)
/*
* Vendite strum. art 17 (cess. amm.)
* Comprende anche autofatture, anche nell'annuale
* (Sergio 1995)
*/
{
// Invece non le deve comprendere nell'annuale (Vladimiro 1995, piu' tardi)
if (!(_month == 13 && autodafe))
{
cess_amm += imponibile;
cess_amm_iva += imposta;
}
}
if (is_detraibile && !imponibile.is_zero() && is_reverse_charge(_mov->curr()))
vendite_rev += imponibile;
}
break;
default: // Chissa'... forse in futuro vi sara' un ulteriore tipo di movimento...
break;
} // Fine del malefico switch
// operazioni per calcolo rimborso infraanale
// Scudler 1995 e molti dopo di lei
// La breve estate vissuta dal metodo del 51% rende
// oramai superflua la tabella rimborsi, eliminata
// senza entusiasmo ed interrogandomi sul senso della vita
if (ivarimb)
{ {
acq_ies += imponibile; bool ok = _isagricolo ? tipoagr == 2 : false;
acq_ies_iva += imposta;
if (tipomov == acquisto && !ok)
ok = (tipocr == 0 || tipocr == 1 || tipocr == 5 || tipocr == 9);
if (tipomov == vendita && !ok)
ok = tipoiva != "NS" && tipocr != 4;
ivarimb = ok;
} }
}
if (tipodet == 3) // passaggi interni (solo per ventilaz) // operazioni esenti
{ if (tipoiva == "ES" && !imponibile.is_zero())
acq_pint += imponibile; {
acq_pint_iva += imposta; if (tipomov == vendita)
} {
if (sosp_imp != normale && sosp_imp != vol_affari) // CM500308
{
if (tipoes_v == "B1") // C1
esenti_c1 += imponibile;
else if (tipoes_v == "B2") // C2
esenti_c2 += imponibile;
else if (tipoes_v == "B3") // C3
{
esenti_c3 += imponibile;
if (tipocr == 4)
esenti_c3_bam += imponibile;
}
else if (tipoes_v == "B4") // C1A
{
esenti_c1a += imponibile;
if (tipocr == 4)
esenti_c1a_bam += imponibile;
}
// se e' il caso sommare esenti per rimborso
if (isrimbinfr)
esni_rimb += imponibile;
}
}
else if (tipoes_a == "14")
esenti_b14 += imponibile;
}
// acquisti non detraibili art. 19 // non imponibili per rimborso
// possono valere per la ventilazione if (tipoiva == "NI" && tipomov == vendita && isrimbinfr)
if (tipodet == 9) esni_rimb += imponibile;
{
nond19_imp += imponibile;
nond19_iva += imposta;
}
// ***************************************** // bolle doganali
// Fine casi particolari if (tipodoc == "BD")
// Non che i casi normali siano tanto meglio {
// ***************************************** bolld_imp = imponibile;
} // non sosp_imp ne' altre casistiche che escludono la liq. bolld_iva = imposta;
bdog_imp += bolld_imp;
bdog_iva += bolld_iva;
}
// plafond
if (_isplafond && tipomov == acquisto && month != 13 &&
tipoiva == "NI" && tipopla != 0)
{
add_plafond(month, codatt, tipopla, imponibile, tipodoc == "BD");
}
// agenzie viaggio (CHECK imponibili etc.)
if (_isviaggio)
switch (tipoag)
{
case 1:
if (tipomov == acquisto) acq_CEE += imponibile + imposta;
else corr_CEE += imponibile + imposta;
break;
case 2:
if (tipomov == acquisto) acq_noCEE += imponibile + imposta;
else corr_noCEE += imponibile + imposta;
break;
case 3: if (tipomov == vendita)
corr_misCEE += imponibile + imposta;
break;
case 4: if (tipomov == acquisto)
acq_misCEE += imponibile + imposta;
break;
case 5: if (tipomov == acquisto)
acq_misnoCEE += imponibile + imposta;
break;
}
if (_isagricolo)
{
/*
* rifatto sensu Scudler 1995 con invidiabile sicurezza
* senza porsi domande e mettendo NUMERI uguali
* al TIPO RECORD del frigorifero
*/
if (tipomov == vendita)
{
if (!noninc) // Salta i non incassati
{
agr_imp = imponibile;
agr_iva = imposta;
const real p = perciva;
const bool is_not_fs = tipodoc != "FS";
// Se si tratta di Fattura Fiscale o Fattura Scontrino, non scorpora
// In particolare le FS non vengono incluse ne' nello specchietto ne' nel totale
if (corrisp && tipodoc != "FF" && is_not_fs)
lordo2netto(agr_imp,agr_iva,p);
if (tipoagr == 1 && is_not_fs) // Ora si utilizza solo il segnalino 1
{
agr_1 += agr_iva;
agr_1i += agr_imp;
// Nuovo regime agricolo dal 1998: si sommino per codice iva di compensazione (da reperire su PCON)
TString ivacomp("00"); // Se non esiste o non si trova il conto questo e' il default (fa un poco schifo ma e' cosi')
if (_cur->is_first_match(-AGR_PCON1)) // Esiste il conto ?
// Bien, allora controlliamo se e' un ricavo...
if (_pcon_1_r->get_int(PCN_INDBIL) == 4)
if (_cur->is_first_match(-AGR_PCON2)) // Esiste il sottoconto ?
{
if (look_iva(_pcon_2_r->get(PCN_IVACOMP)))
ivacomp = _iva->get("CODTAB"); // Ecco il codice IVA di compensazione
}
look_pia(month, codatt, codiva, ivacomp, true); // Crea il record in tabella se non esiste
real pia_imp = _pia->get_real("R0") + agr_imp; // Aggiorna...
_pia->put("R0", pia_imp);
_pia->put("B0", true); // Seguo l'esempio dei PIM per il ricalcolo acquisti alla fine del ciclo
_pia->rewrite(); // infine scrive
}
else if (tipoagr == 2 && is_not_fs)
{
agr_2 += agr_iva;
agr_2i += agr_imp;
}
}
}
else if (tipodet == 0)
{
if (tipoagr == 2)
{
if (tipocr != 2 && tipocr != 3 && tipocr != 8)
agr_3 += imposta;
else
agr_4 += imposta;
}
else if (tipoagr == 3)
{
if (tipocr != 2 && tipocr != 3 && tipocr != 8)
agr_7 += imposta;
}
else // ne' 2 ne' 3
{
if (tipocr != 2 && tipocr != 3 && tipocr != 8)
agr_5 += imposta;
else
agr_6 += imposta;
}
}
} // __end of _agricolo
if (tipodet == 1) // acquisti indeducibili su ricavi esenti art. 10
{
if (is_reverse_charge(_mov->curr()))
{
acquisti += imponibile;
acquisti_iva += imposta;
}
else
{
acq_ies += imponibile;
acq_ies_iva += imposta;
}
}
if (tipodet == 3) // passaggi interni (solo per ventilaz)
{
acq_pint += imponibile;
acq_pint_iva += imposta;
}
// acquisti non detraibili art. 19
// possono valere per la ventilazione
if (tipodet == 9)
{
nond19_imp += imponibile;
nond19_iva += imposta;
}
// *****************************************
// Fine casi particolari
// Non che i casi normali siano tanto meglio
// *****************************************
} // non sosp_imp ne' altre casistiche che escludono la liq.
/* /*
* se ign == true non bisogna neppure PROGRESSIVARLI * se ign == true non bisogna neppure PROGRESSIVARLI
@ -2862,6 +2866,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
_plm->put("R12", _prorata.percentuale(_year)); _plm->put("R12", _prorata.percentuale(_year));
_plm->put("R4", percentuale1); _plm->put("R4", percentuale1);
_plm->put("R16", percentuale2); _plm->put("R16", percentuale2);
_plm->put("R17", cred_fattrit);
_plm->put("R0", vendite_iva); _plm->put("R0", vendite_iva);
_plm->put("R1", acquisti_iva); _plm->put("R1", acquisti_iva);
_plm->put("R3", ult_detr); _plm->put("R3", ult_detr);
@ -3707,6 +3712,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
real fdiff_iva_acq = ZERO; real fdiff_iva_acq = ZERO;
real fdiffinc_imp_acq = ZERO; real fdiffinc_imp_acq = ZERO;
real fdiffinc_iva_acq = ZERO; real fdiffinc_iva_acq = ZERO;
real cred_fattrit;
// totali per annuali // totali per annuali
real vol_aff_1 = ZERO; real vol_aff_1 = ZERO;
@ -3842,6 +3848,8 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
fdiffinc_imp_acq += diffinc_imp_acq; fdiffinc_imp_acq += diffinc_imp_acq;
fdiffinc_iva_acq += diffinc_iva_acq; fdiffinc_iva_acq += diffinc_iva_acq;
} }
cred_fattrit += _plm->get_real("R17");
risultato -= _plm->get_real("R17");
detrazioni+= (_plm->get_real("R3")); detrazioni+= (_plm->get_real("R3"));
// detrazioni solo non in regime agricolo // detrazioni solo non in regime agricolo
@ -4001,7 +4009,9 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
// toglie credito precedente // toglie credito precedente
cred_prec = credito_prec(month+deltam); cred_prec = credito_prec(month+deltam);
risultato -= cred_prec; risultato -= cred_prec;
risultato -= cred_fattrit;
res_cred += cred_prec; res_cred += cred_prec;
res_cred += cred_fattrit;
// vedi se c'era un debito precedente per debiti < 50.000 // vedi se c'era un debito precedente per debiti < 50.000
debt_precd = debt_prec(month+deltam); debt_precd = debt_prec(month+deltam);
risultato += debt_precd; risultato += debt_precd;
@ -4225,12 +4235,14 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
lim.put("R2", cred_cost); lim.put("R2", cred_cost);
lim.put("R3", deb_mens); lim.put("R3", deb_mens);
lim.put("R4", perc_r); lim.put("R4", perc_r);
lim.put("R25", cred_fattrit);
if (almeno_una_normale) if (almeno_una_normale)
lim.put("R6", detrazioni); lim.put("R6", detrazioni);
else // per evitare sbagli nei ricalcoli esterni else // per evitare sbagli nei ricalcoli esterni
lim.zero("R6"); lim.zero("R6");
if (month == 13 || differita) if (month == 13 || differita)
{ {
// Arrotonda totali in quanto possono avere un arrotondamento diverso dal mensile // Arrotonda totali in quanto possono avere un arrotondamento diverso dal mensile
@ -4361,6 +4373,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
res_cred += detrazioni; res_cred += detrazioni;
risultato = res_debt - res_cred; risultato = res_debt - res_cred;
risultato -= cred_fattrit;
// tut ricalcule', riscrivem // tut ricalcule', riscrivem
_lam->put("R0", iva_vend); _lam->put("R0", iva_vend);

View File

@ -1237,6 +1237,7 @@ void TLiquidazione_app::describe_liq(int month, const char* codatts, _DescrItem*
d->_r6 = lim.get_real("R6"); d->_r6 = lim.get_real("R6");
d->_r7 = lim.get_real("R14"); d->_r7 = lim.get_real("R14");
d->_r9 = lim.get_real("R9"); d->_r9 = lim.get_real("R9");
d->_r25 = lim.get_real("R25"); // credito per fatture in ritardo
d->_r29 = lim.get_real("R29"); // fdiffinc_iva_ven d->_r29 = lim.get_real("R29"); // fdiffinc_iva_ven
d->_r33 = lim.get_real("R33"); // fdiffinc_iva_acq d->_r33 = lim.get_real("R33"); // fdiffinc_iva_acq
@ -1273,6 +1274,7 @@ void TLiquidazione_app::describe_liq(int month, const char* codatts, _DescrItem*
d->_r18 = lim.get_real("R18"); // Imposta non versata d->_r18 = lim.get_real("R18"); // Imposta non versata
d->_r19 = lim.get_real("R19"); // Crediti speciali d->_r19 = lim.get_real("R19"); // Crediti speciali
d->_r20 = lim.get_real("R20"); // Credito autorizzato in F24 d->_r20 = lim.get_real("R20"); // Credito autorizzato in F24
d->_r25 = lim.get_real("R25"); // Credito da fatture in ritardo
d->_d1 = lim.get_date("D1"); // Data autorizzazione d->_d1 = lim.get_date("D1"); // Data autorizzazione
@ -2564,6 +2566,7 @@ void TLiquidazione_app::set_grand_2000(_DescrItem& d, int &rw)
real& imposta_non_versata = d._r18; real& imposta_non_versata = d._r18;
real& crediti_speciali = d._r19; real& crediti_speciali = d._r19;
real& credito_autorizzato_F24 = d._r20; real& credito_autorizzato_F24 = d._r20;
real& cred_fattrit = d._r25;
const TDate &data_autorizzazione = d._d1; const TDate &data_autorizzazione = d._d1;
if (credito_autorizzato_F24 < ZERO) credito_autorizzato_F24 = ZERO; if (credito_autorizzato_F24 < ZERO) credito_autorizzato_F24 = ZERO;
@ -2622,6 +2625,8 @@ void TLiquidazione_app::set_grand_2000(_DescrItem& d, int &rw)
cre_deb_per = risultato + crediti_speciali + acc_dec + vers_int; cre_deb_per = risultato + crediti_speciali + acc_dec + vers_int;
if (cred_prec > ZERO) if (cred_prec > ZERO)
set_row(rw++,FR("@11gCredito da liquidazione precedente@58g%r"), &cred_prec); set_row(rw++,FR("@11gCredito da liquidazione precedente@58g%r"), &cred_prec);
if (cred_fattrit > ZERO)
set_row(rw++,FR("@11gCredito da fatture in ritardo@58g%r"), &cred_fattrit);
if (_month < 13 && credito_compensabile && credito_autorizzato_F24 > ZERO) if (_month < 13 && credito_compensabile && credito_autorizzato_F24 > ZERO)
{ {

View File

@ -44,7 +44,7 @@ bool TStampa_registri_app::filter_func (const TRelation * r)
const int annoiva = mov.get_int(MOV_ANNOIVA); const int annoiva = mov.get_int(MOV_ANNOIVA);
const TString& codreg = mov.get(MOV_REG); const TString& codreg = mov.get(MOV_REG);
if (codreg != (app()._codreg) || annoiva != (app()._annoes)) if (codreg != (app()._codreg) || annoiva != (app()._annoIVA))
return false; return false;
if (app()._tipo_stampa != prova) //stampa di bollato if (app()._tipo_stampa != prova) //stampa di bollato
@ -195,7 +195,7 @@ const TRectype& TStampa_registri_app::look_lia(long ditta)
if (ditta <= 0) if (ditta <= 0)
ditta = get_firm(); ditta = get_firm();
TString16 y; y.format("%05ld%04d", ditta, _annoes); TString16 y; y.format("%05ld%04d", ditta, _annoIVA);
const TRectype& lia = cache().get("%LIA", y); const TRectype& lia = cache().get("%LIA", y);
_credito = lia.get_real("R0"); _credito = lia.get_real("R0");
@ -221,7 +221,7 @@ bool TStampa_registri_app::ricalcola(int mese)
//dei trimestri a cui appartiene il mese modificato) //dei trimestri a cui appartiene il mese modificato)
if (_frequiva == 'M' || (m == 3 || m == 6 || m == 9 || m == 12)) if (_frequiva == 'M' || (m == 3 || m == 6 || m == 9 || m == 12))
{ {
TString8 key; key.format("%04d%02d", _annoes, m); TString8 key; key.format("%04d%02d", _annoIVA, m);
lim.put("CODTAB", key); lim.put("CODTAB", key);
if (lim.read() != NOERR) if (lim.read() != NOERR)
return true; return true;
@ -230,7 +230,7 @@ bool TStampa_registri_app::ricalcola(int mese)
//controllo il mese passato //controllo il mese passato
if (_frequiva == 'M') if (_frequiva == 'M')
{ {
TString8 key; key.format("%04d%02d", _annoes, mese); TString8 key; key.format("%04d%02d", _annoIVA, mese);
lim.put("CODTAB", key); lim.put("CODTAB", key);
if (lim.read() != NOERR) if (lim.read() != NOERR)
return true; return true;
@ -239,7 +239,7 @@ bool TStampa_registri_app::ricalcola(int mese)
{ {
//aggiusta il mese al trimestre a cui appartiene //aggiusta il mese al trimestre a cui appartiene
mese += 2 - ((mese-1) % 3); mese += 2 - ((mese-1) % 3);
TString8 key; key.format("%04d%02d", _annoes, mese); TString8 key; key.format("%04d%02d", _annoIVA, mese);
lim.put("CODTAB", key); lim.put("CODTAB", key);
if (lim.read() != NOERR) if (lim.read() != NOERR)
return true; return true;
@ -290,11 +290,11 @@ bool TStampa_registri_app::compila_reg(const TMask& m)
{ {
const TString& codtab = _tabreg->get("CODTAB"); const TString& codtab = _tabreg->get("CODTAB");
const int anno = atoi(codtab.mid(0,4)); const int anno = atoi(codtab.mid(0,4));
if (anno > _annoes) if (anno > _annoIVA)
{ {
if (_tipo_stampa != libro_unico) //per il libro unico e' gia' stato controllato nell'handler if (_tipo_stampa != libro_unico) //per il libro unico e' gia' stato controllato nell'handler
warning_box(FR("Non esistono registri IVA della Ditta %ld per l'anno %d"), warning_box(FR("Non esistono registri IVA della Ditta %ld per l'anno %d"),
_ditta, _annoes); _ditta, _annoIVA);
return false; return false;
} }
} }
@ -302,7 +302,7 @@ bool TStampa_registri_app::compila_reg(const TMask& m)
else // stampa un solo registro else // stampa un solo registro
{ {
_stampa_tutti_i_registri = false; _stampa_tutti_i_registri = false;
TString8 codtab; codtab << _annoes << _codreg; TString8 codtab; codtab << _annoIVA << _codreg;
_tabreg->zero(); _tabreg->zero();
_tabreg->put("CODTAB", codtab); _tabreg->put("CODTAB", codtab);
if (_tabreg->read() != NOERR) if (_tabreg->read() != NOERR)
@ -378,7 +378,7 @@ bool TStampa_registri_app::compila_reg(const TMask& m)
bool TStampa_registri_app::compila_lib() bool TStampa_registri_app::compila_lib()
{ {
TString8 cod; cod << _annoes << _codlib; TString8 cod; cod << _annoIVA << _codlib;
const TRectype& lib = cache().get("%LBU", cod); const TRectype& lib = cache().get("%LBU", cod);
_stampa_ind_ditta = lib.get_bool("B1"); _stampa_ind_ditta = lib.get_bool("B1");
return !lib.empty(); return !lib.empty();
@ -389,7 +389,7 @@ bool TStampa_registri_app::cerca_libro_gio(TDate& datas, bool& good)
TRelation reg("REG"); TRelation reg("REG");
TRectype& curr = reg.curr(); TRectype& curr = reg.curr();
TString16 filter; TString16 filter;
filter.format("%04d", _annoes); filter.format("%04d", _annoIVA);
curr.put("CODTAB", filter); curr.put("CODTAB", filter);
filter.format("I0=%d", giornale); filter.format("I0=%d", giornale);
TCursor cur(&reg, filter, 1, &curr, &curr); TCursor cur(&reg, filter, 1, &curr, &curr);
@ -918,7 +918,7 @@ bool TStampa_registri_app::user_create()
__firm = TApplication::get_firm(); __firm = TApplication::get_firm();
const TDate oggi(TODAY); const TDate oggi(TODAY);
_annoes = oggi.year(); // Anno per frequenza IVA ditte _annoIVA = oggi.year(); // Anno per frequenza IVA ditte
build_ditte_sheet(0x3); build_ditte_sheet(0x3);
add_cursor(_cur); add_cursor(_cur);
@ -953,9 +953,9 @@ void TStampa_registri_app::calcola_progressivi()
num = _datareg.month(); num = _datareg.month();
// Chiave per selezione records progressivi // Chiave per selezione records progressivi
chiave << _annoes << _codatt; chiave << _annoIVA << _codatt;
//calcolo i totali del periodo; calcola anche i totali da Periodo Precedente (se _annoes > 1997) //calcolo i totali del periodo; calcola anche i totali da Periodo Precedente (se _annoIVA > 1997)
//_codatt e' gia' Z perche' lo leggo dal registro //_codatt e' gia' Z perche' lo leggo dal registro
//calcolo i totali progressivi e del periodo (tra questi anche quelli di cui periodo precedente) //calcolo i totali progressivi e del periodo (tra questi anche quelli di cui periodo precedente)
for (int i=1; i<=num; i++) for (int i=1; i<=num; i++)
@ -1033,7 +1033,7 @@ void TStampa_registri_app::calcola_progressivi()
} // for i to num } // for i to num
} }
int TStampa_registri_app::riga_rmoviva() int TStampa_registri_app::riga_rmoviva(const bool fattrit)
{ {
int nrec = 0; int nrec = 0;
@ -1068,6 +1068,8 @@ int TStampa_registri_app::riga_rmoviva()
if (is_split_payment(mov)) if (is_split_payment(mov))
_riga_split.add_riga(impo, impos, codiva); _riga_split.add_riga(impo, impos, codiva);
if (_tipo_reg == acquisto && fattrit)
_riga_competenza.add_riga(impo, impos, codiva);
//stampa di prova, cumula progressivi dai movimenti, anziche' dalle tabelle (solo bollato) //stampa di prova, cumula progressivi dai movimenti, anziche' dalle tabelle (solo bollato)
if (_tipo_stampa == prova) if (_tipo_stampa == prova)
@ -1175,7 +1177,7 @@ messaggio TStampa_registri_app::controlla_liquidazione()
{ {
for (int i=3; i<=mese; i+=3) for (int i=3; i<=mese; i+=3)
{ {
chiave.format("%04d%02d", _annoes, i); chiave.format("%04d%02d", _annoIVA, i);
lim.put("CODTAB", chiave); lim.put("CODTAB", chiave);
if (lim.read() != NOERR || lim.get_bool("B0")) if (lim.read() != NOERR || lim.get_bool("B0"))
{ {
@ -1190,7 +1192,7 @@ messaggio TStampa_registri_app::controlla_liquidazione()
{ {
for (int i=1; i<=mese; i++) for (int i=1; i<=mese; i++)
{ {
chiave.format("%04d%02d", _annoes, i); chiave.format("%04d%02d", _annoIVA, i);
lim.put("CODTAB", chiave); lim.put("CODTAB", chiave);
if (lim.read() != NOERR || lim.get_bool("B0")) if (lim.read() != NOERR || lim.get_bool("B0"))
{ {
@ -1217,7 +1219,7 @@ messaggio TStampa_registri_app::controlla_liquidazione()
} }
else if (_tipo_riepilogativo == 'A') else if (_tipo_riepilogativo == 'A')
{ {
chiave.format("%04d%02d", _annoes, 13); chiave.format("%04d%02d", _annoIVA, 13);
lim.put("CODTAB", chiave); lim.put("CODTAB", chiave);
if (lim.read() != NOERR || lim.get_bool("B0")) if (lim.read() != NOERR || lim.get_bool("B0"))
{ {
@ -1235,7 +1237,7 @@ messaggio TStampa_registri_app::controlla_liquidazione()
if (_frequiva == 'M' || if (_frequiva == 'M' ||
(m==3 || m==6 || m==9 || m==12)) (m==3 || m==6 || m==9 || m==12))
{ {
chiave.format("%04d%02d", _annoes, m); chiave.format("%04d%02d", _annoIVA, m);
lim.put("CODTAB", chiave); lim.put("CODTAB", chiave);
if (lim.read() != NOERR || lim.get_bool("B0")) if (lim.read() != NOERR || lim.get_bool("B0"))
need_refresh |= !lim.get_bool("B1"); need_refresh |= !lim.get_bool("B1");
@ -1276,7 +1278,7 @@ bool TStampa_registri_app::controlla_mov()
{ {
const TDate datareg = mov.get_date(MOV_DATAREG); const TDate datareg = mov.get_date(MOV_DATAREG);
const bool stampato = mov.get_bool(MOV_REGST); const bool stampato = mov.get_bool(MOV_REGST);
if ( datareg.year() < _annoes ) if ( datareg.year() < _annoIVA )
{ {
const long numreg = mov.get_long(MOV_NUMREG); const long numreg = mov.get_long(MOV_NUMREG);
if (!stampato) if (!stampato)
@ -1291,7 +1293,7 @@ bool TStampa_registri_app::controlla_mov()
tiporeg TStampa_registri_app::cerca_reg(const TString& c) tiporeg TStampa_registri_app::cerca_reg(const TString& c)
{ {
tiporeg t = vendita; tiporeg t = vendita;
TString8 cod; cod << _annoes << c; TString8 cod; cod << _annoIVA << c;
_tabreg->zero(); _tabreg->zero();
_tabreg->put("CODTAB", cod); _tabreg->put("CODTAB", cod);
if (_tabreg->read() == NOERR) if (_tabreg->read() == NOERR)
@ -1316,7 +1318,7 @@ int TStampa_registri_app::stampa_prospetto_IVA(int rr, int tipo_prosp)
riga << TR("; 4=liquidazione differita"); riga << TR("; 4=liquidazione differita");
if (has_module(ICAUT)) if (has_module(ICAUT))
riga << TR("; 5=IVA per cassa"); riga << TR("; 5=IVA per cassa");
if (_annoes >= 2015) if (_annoIVA >= 2015)
riga << TR("; 6=Scissione pagamenti art.17 ter"); riga << TR("; 6=Scissione pagamenti art.17 ter");
set_row(rr++, riga); set_row(rr++, riga);
*/ */
@ -1349,47 +1351,50 @@ int TStampa_registri_app::stampa_prospetto_IVA(int rr, int tipo_prosp)
if (_esiste_riga_iva && _stampa) if (_esiste_riga_iva && _stampa)
{ {
if (tipo_prosp == 2) if (tipo_prosp == 2)
{ {
set_row(++rr, FR("@30g---- DI CUI SCISSIONE PAGAMENTI ----")); if (_tipo_reg == vendita)
} set_row(++rr, FR("@30g---- DI CUI SCISSIONE PAGAMENTI ----"));
else else
{ set_row(++rr, format(FR("@30g---- DI CUI COMPETENZA %04d ----"), _annoIVA - 1));
if (print_prec) }
set_row(++rr, TR("DI CUI PERIODO PRECEDENTE")); else
{
if (print_prec)
set_row(++rr, TR("DI CUI PERIODO PRECEDENTE"));
if (_tipo_reg == vendita && _corrispettivi) if (_tipo_reg == vendita && _corrispettivi)
set_row(++rr, FR("@30g------------------ P E R I O D O -------------------")); set_row(++rr, FR("@30g------------------ P E R I O D O -------------------"));
else else
set_row(++rr, FR("@30g---------- P E R I O D O -----------")); set_row(++rr, FR("@30g---------- P E R I O D O -----------"));
if (_tipo_stampa != prova && !print_prec) if (_tipo_stampa != prova && !print_prec)
{ {
if (_tipo_reg == vendita && _corrispettivi) if (_tipo_reg == vendita && _corrispettivi)
set_row(rr,FR("@84g----------- P R O G R E S S I V I --------------")); set_row(rr,FR("@84g----------- P R O G R E S S I V I --------------"));
else else
set_row(rr,FR("@82g------ P R O G R E S S I V I ------")); set_row(rr,FR("@82g------ P R O G R E S S I V I ------"));
} }
rr++; rr++;
set_row(rr, TR("Cod.")); set_row(rr, TR("Cod."));
if (_tipo_reg == acquisto) if (_tipo_reg == acquisto)
{ {
set_row(rr, FR("@40gA C Q U I S T I")); set_row(rr, FR("@40gA C Q U I S T I"));
if (_tipo_stampa != prova && !print_prec) if (_tipo_stampa != prova && !print_prec)
set_row(rr, FR("@92gA C Q U I S T I")); set_row(rr, FR("@92gA C Q U I S T I"));
} else } else
if (_tipo_reg == vendita) //un registro corrispettivi puo' solo essere un registro vendite if (_tipo_reg == vendita) //un registro corrispettivi puo' solo essere un registro vendite
{ {
set_row(rr, FR("@41gV E N D I T E")); set_row(rr, FR("@41gV E N D I T E"));
if (_corrispettivi) if (_corrispettivi)
set_row(rr, FR("@67gCORRISPETTIVI")); set_row(rr, FR("@67gCORRISPETTIVI"));
if (_tipo_stampa != prova && !print_prec) if (_tipo_stampa != prova && !print_prec)
{ {
if (_corrispettivi) if (_corrispettivi)
set_row(rr, FR("@94gV E N D I T E@118gCORRISPETTIVI")); set_row(rr, FR("@94gV E N D I T E@118gCORRISPETTIVI"));
else else
set_row(rr, FR("@93gV E N D I T E")); set_row(rr, FR("@93gV E N D I T E"));
} }
} }
} }
rr++; rr++;
set_row(rr, FR("IVA Descrizione@34gImponibile@53gImposta")); set_row(rr, FR("IVA Descrizione@34gImponibile@53gImposta"));
if (_tipo_reg == vendita && _corrispettivi) if (_tipo_reg == vendita && _corrispettivi)
@ -1556,9 +1561,9 @@ void TStampa_registri_app::set_page_tot_reg()
if (_esiste_riga_iva && _stampa) if (_esiste_riga_iva && _stampa)
{ {
for (int tipo_prosp = 0; tipo_prosp <= (_tipo_reg == vendita ? 2 : 1); tipo_prosp++) for (int tipo_prosp = 0; tipo_prosp <= 2/* (_tipo_reg == vendita ? 2 : 1) */; tipo_prosp++)
{ {
TRiga_array& arriva = tipo_prosp == 0 ? _tot_iva_array : (tipo_prosp == 1 ? _tot_prec_iva_array : _riga_split); TRiga_array& arriva = tipo_prosp == 0 ? _tot_iva_array : (tipo_prosp == 1 ? _tot_prec_iva_array : (_tipo_reg == vendita ? _riga_split : _riga_competenza));
if (arriva.empty()) if (arriva.empty())
continue; continue;
if (!printed) if (!printed)
@ -1673,7 +1678,7 @@ bool TStampa_registri_app::stampa_plafonds(int r, bool test_mode)
// forza il tipoatt a 1 // forza il tipoatt a 1
chiave.format("%05ld", get_firm()); chiave.format("%05ld", get_firm());
chiave << _annoes << _codatt << "1"; chiave << _annoIVA << _codatt << "1";
pla.put("CODTAB", chiave); pla.put("CODTAB", chiave);
const bool print_now = r == -1; const bool print_now = r == -1;
@ -1742,7 +1747,7 @@ bool TStampa_registri_app::stampa_plafonds(int r, bool test_mode)
real pri = ZERO; real pri = ZERO;
real pre = ZERO; real pre = ZERO;
chiave = ""; chiave = "";
chiave << _annoes << _codatt << "1" << nm << "1"; chiave << _annoIVA << _codatt << "1" << nm << "1";
ppa.put("CODTAB", chiave); ppa.put("CODTAB", chiave);
if (ppa.read() == NOERR) if (ppa.read() == NOERR)
{ {
@ -1750,7 +1755,7 @@ bool TStampa_registri_app::stampa_plafonds(int r, bool test_mode)
pre = ppa.get_real("R1"); pre = ppa.get_real("R1");
} }
chiave = ""; chiave = "";
chiave << _annoes << _codatt << "2" << nm << "1"; chiave << _annoIVA << _codatt << "2" << nm << "1";
ppa.put("CODTAB", chiave); ppa.put("CODTAB", chiave);
if (ppa.read() == NOERR) if (ppa.read() == NOERR)
{ {
@ -1792,7 +1797,7 @@ bool TStampa_registri_app::stampa_plafonds(int r, bool test_mode)
real pri = ZERO; real pri = ZERO;
real pre = ZERO; real pre = ZERO;
chiave = ""; chiave = "";
chiave << _annoes << _codatt << "1" << nm << "2"; chiave << _annoIVA << _codatt << "1" << nm << "2";
ppa.put("CODTAB", chiave); ppa.put("CODTAB", chiave);
if (ppa.read() == NOERR) if (ppa.read() == NOERR)
{ {
@ -1800,7 +1805,7 @@ bool TStampa_registri_app::stampa_plafonds(int r, bool test_mode)
pre = ppa.get_real("R1"); pre = ppa.get_real("R1");
} }
chiave = ""; chiave = "";
chiave << _annoes << _codatt << "2" << nm << "2"; chiave << _annoIVA << _codatt << "2" << nm << "2";
ppa.put("CODTAB", chiave); ppa.put("CODTAB", chiave);
if (ppa.read() == NOERR) if (ppa.read() == NOERR)
{ {
@ -1841,7 +1846,7 @@ bool TStampa_registri_app::stampa_plafonds(int r, bool test_mode)
real pri = ZERO; real pri = ZERO;
real pre = ZERO; real pre = ZERO;
chiave = ""; chiave = "";
chiave << _annoes << _codatt << "1" << nm << "3"; chiave << _annoIVA << _codatt << "1" << nm << "3";
ppa.put("CODTAB", chiave); ppa.put("CODTAB", chiave);
if (ppa.read() == NOERR) if (ppa.read() == NOERR)
{ {
@ -1849,7 +1854,7 @@ bool TStampa_registri_app::stampa_plafonds(int r, bool test_mode)
pre = ppa.get_real("R1"); pre = ppa.get_real("R1");
} }
chiave = ""; chiave = "";
chiave << _annoes << _codatt << "2" << nm << "3"; chiave << _annoIVA << _codatt << "2" << nm << "3";
ppa.put("CODTAB", chiave); ppa.put("CODTAB", chiave);
if (ppa.read() == NOERR) if (ppa.read() == NOERR)
{ {
@ -1909,7 +1914,7 @@ real TStampa_registri_app::stampa_valori_plafonds(const real& r1, const int mese
{ {
chiave = ""; chiave = "";
TString16 m; m.format("%02d", i); TString16 m; m.format("%02d", i);
chiave << _annoes << _codatt << "1" << m << tipo; chiave << _annoIVA << _codatt << "1" << m << tipo;
ppa.put("CODTAB", chiave); ppa.put("CODTAB", chiave);
if (ppa.read() == NOERR) if (ppa.read() == NOERR)
{ {
@ -1917,7 +1922,7 @@ real TStampa_registri_app::stampa_valori_plafonds(const real& r1, const int mese
se8 += ppa.get_real("R1"); se8 += ppa.get_real("R1");
} }
chiave = ""; chiave = "";
chiave << _annoes << _codatt << "2" << m << tipo; chiave << _annoIVA << _codatt << "2" << m << tipo;
ppa.put("CODTAB", chiave); ppa.put("CODTAB", chiave);
if (ppa.read() == NOERR) if (ppa.read() == NOERR)
{ {
@ -2290,7 +2295,7 @@ bool TStampa_registri_app::preprocess_page(int file, int counter)
if (!_st_liq[m]) if (!_st_liq[m])
if (stampo_liquidazione(m)) if (stampo_liquidazione(m))
{ {
_datareg = TDate(1, m, _annoes); // Meglio cosi' _datareg = TDate(1, m, _annoIVA); // Meglio cosi'
TFilename t; TFilename t;
t.temp("reg"); t.temp("reg");
if (_scelta == B0_settato || _scelta == prosegui_stampa) if (_scelta == B0_settato || _scelta == prosegui_stampa)
@ -2334,13 +2339,13 @@ bool TStampa_registri_app::preprocess_page(int file, int counter)
_dataregp = _datareg; _dataregp = _datareg;
TDate datadoc = mov.get_date(MOV_DATADOC); const TDate datadoc = mov.get_date(MOV_DATADOC);
long numreg = mov.get_long(MOV_NUMREG); const long numreg = mov.get_long(MOV_NUMREG);
long protiva = mov.get_long(MOV_PROTIVA); const long protiva = mov.get_long(MOV_PROTIVA);
long uprotiva = mov.get_long(MOV_UPROTIVA); const long uprotiva = mov.get_long(MOV_UPROTIVA);
TString16 numdoc = mov.get(MOV_NUMDOC); const TString16 numdoc = mov.get(MOV_NUMDOC);
int meseliq = mov.get_int(MOV_MESELIQ); const int meseliq = mov.get_int(MOV_MESELIQ);
char tipocf = mov.get(MOV_TIPO)[0]; const char tipocf = mov.get(MOV_TIPO)[0];
TString16 ocfpi = mov.get(MOV_OCFPI); TString16 ocfpi = mov.get(MOV_OCFPI);
long codcf = mov.get_long(MOV_CODCF); long codcf = mov.get_long(MOV_CODCF);
long numgio = mov.get_long(MOV_NUMGIO); long numgio = mov.get_long(MOV_NUMGIO);
@ -2348,7 +2353,11 @@ bool TStampa_registri_app::preprocess_page(int file, int counter)
TString4 codval = mov.get(MOV_CODVALI); TString4 codval = mov.get(MOV_CODVALI);
real corrval = mov.get_real(MOV_CORRVALUTA); real corrval = mov.get_real(MOV_CORRVALUTA);
const bool autof = caus.get_bool(CAU_AUTOFATT); const bool autof = caus.get_bool(CAU_AUTOFATT);
const bool dataritind = ((_tipo_reg == acquisto) && (_annoIVA >= 2018)) && ((_datareg.year() - datadoc.year()) > 1 ) ||
(((_datareg.year() - datadoc.year()) == 1) && _datareg.month() >= 5);
const bool datarit = ((_tipo_reg == acquisto) && !dataritind) && ((_datareg.year() - datadoc.year()) == 1);
const bool fattritind = (_annoIVA >= 2018) && (caus.get_bool(CAU_RITFATTIND) || dataritind);
const bool fattrit = caus.get_bool(CAU_RITFATT) || datarit;
const bool splitpay = tipocf == 'C' && is_split_payment(mov.curr()); const bool splitpay = tipocf == 'C' && is_split_payment(mov.curr());
const bool liqdiff = !splitpay && mov.get_bool(MOV_LIQDIFF) && is_IVA_diff(mov.curr()); const bool liqdiff = !splitpay && mov.get_bool(MOV_LIQDIFF) && is_IVA_diff(mov.curr());
@ -2454,7 +2463,12 @@ bool TStampa_registri_app::preprocess_page(int file, int counter)
set_row(_r, "@31g%6ld", codcf); set_row(_r, "@31g%6ld", codcf);
if (meseliq > 0) if (meseliq > 0)
set_row(_r, "@62g%02d", meseliq); set_row(_r, "@62g%02d", meseliq);
set_row(_r, "@68g%2s", (const char*) _tipodoc); set_row(_r, "@65g%2s", (const char*) _tipodoc);
if (fattrit)
set_row(_r, "@67gCD");
else
if (fattritind)
set_row(_r, "@67gCI");
if (_stampa_width == 132) if (_stampa_width == 132)
set_row(_r, "@70g%r", &totdoc); set_row(_r, "@70g%r", &totdoc);
else else
@ -2521,7 +2535,7 @@ bool TStampa_registri_app::preprocess_page(int file, int counter)
_progr_doc = 0; _progr_doc = 0;
_progr_impn = 0; _progr_impn = 0;
_progr_imps = 0; _progr_imps = 0;
const TRecnotype nrec = riga_rmoviva(); const TRecnotype nrec = riga_rmoviva(fattrit);
if (nrec > 0L) if (nrec > 0L)
{ {
_esiste_riga_iva = true; _esiste_riga_iva = true;
@ -2673,7 +2687,7 @@ void TStampa_registri_app::fine_mese()
const int m2 = _dataregs.month(); const int m2 = _dataregs.month();
for (int kk = m1; kk < m2; kk++) for (int kk = m1; kk < m2; kk++)
{ {
_datareg = TDate(1, kk, _annoes); _datareg = TDate(1, kk, _annoIVA);
if (stampa_plafonds(-1, true)) if (stampa_plafonds(-1, true))
{ {
printer().formfeed(); printer().formfeed();
@ -2736,7 +2750,7 @@ void TStampa_registri_app::fine_mese()
int a = _data_a.month(); int a = _data_a.month();
for (int m=da; m<=a; m++) for (int m=da; m<=a; m++)
{ {
TDate data(1, m, _annoes); TDate data(1, m, _annoIVA);
data.set_end_month(); data.set_end_month();
scrivi_reg(data); scrivi_reg(data);
} }
@ -2827,7 +2841,7 @@ void TStampa_registri_app::preprocess_header()
else //se _tipo_stampa == 3 (su libro unico) sto stampando un solo mese else //se _tipo_stampa == 3 (su libro unico) sto stampando un solo mese
{ {
mese = _fino_a_mese; mese = _fino_a_mese;
anno = _annoes; anno = _annoIVA;
} }
TString data; TString data;
@ -2849,7 +2863,7 @@ void TStampa_registri_app::preprocess_header()
if (_stampa_num_pag) // Stampa numero di pagina in alto a destra if (_stampa_num_pag) // Stampa numero di pagina in alto a destra
{ {
TString16 numpag, riga; TString16 numpag, riga;
numpag.format("%d/%d", _annoes, _numini+printer().getcurrentpage()); numpag.format("%d/%d", _annoIVA, _numini+printer().getcurrentpage());
const int tab = _stampa_width - numpag.len(); const int tab = _stampa_width - numpag.len();
riga.format("@%dg%s", tab, (const char*)numpag); riga.format("@%dg%s", tab, (const char*)numpag);
set_header(1, riga); // Sempre sulla prima riga! set_header(1, riga); // Sempre sulla prima riga!
@ -2880,7 +2894,7 @@ void TStampa_registri_app::preprocess_header()
(const char*)_desc_lib, (const char*) data); (const char*)_desc_lib, (const char*) data);
else else
{ {
if (_annoes > 2007) if (_annoIVA > 2007)
{ {
TString key; TString key;
@ -3054,7 +3068,7 @@ void TStampa_registri_app::preprocess_footer()
riga << TR("; 4=liquidazione differita"); riga << TR("; 4=liquidazione differita");
if (has_module(ICAUT)) if (has_module(ICAUT))
riga << TR("; 5=IVA per cassa"); riga << TR("; 5=IVA per cassa");
if (_annoes >= 2015) if (_annoIVA >= 2015)
riga << TR("; 6=Scissione pagamenti art.17 ter"); riga << TR("; 6=Scissione pagamenti art.17 ter");
set_footer(r++, riga); set_footer(r++, riga);
@ -3115,7 +3129,7 @@ void TStampa_registri_app::liq_b0_settato()
void TStampa_registri_app::liq_other_case() void TStampa_registri_app::liq_other_case()
{ {
const bool calc_reg = _annoes > 1997; // Flag per effettuare nuovo calcolo registri const bool calc_reg = _annoIVA > 1997; // Flag per effettuare nuovo calcolo registri
char tipo_messaggio; // Tipo messaggio per chiamata a programma calcolo/stampa liquidazione char tipo_messaggio; // Tipo messaggio per chiamata a programma calcolo/stampa liquidazione
switch (_scelta) switch (_scelta)
@ -3175,7 +3189,7 @@ void TStampa_registri_app::stampa_vidi()
printer().open(); printer().open();
IndBil.zero(); IndBil.zero();
IndBil.put("ANNO", _annoes); IndBil.put("ANNO", _annoIVA);
IndBil.put("CODLIB", _codlib); IndBil.put("CODLIB", _codlib);
TRectype rec (IndBil.curr()); TRectype rec (IndBil.curr());
IndBil.read (_isgteq); IndBil.read (_isgteq);
@ -3236,7 +3250,7 @@ void TStampa_registri_app::scrivi_reg(const TDate& data)
TString16 codtab; TString16 codtab;
TTable Tabreg ("REG"); TTable Tabreg ("REG");
codtab << _annoes << _codreg; codtab << _annoIVA << _codreg;
Tabreg.zero(); Tabreg.zero();
Tabreg.put("CODTAB", codtab); Tabreg.put("CODTAB", codtab);
if (Tabreg.read() == NOERR) if (Tabreg.read() == NOERR)
@ -3267,7 +3281,7 @@ void TStampa_registri_app::scrivi_reg(const TDate& data)
TString16 cod = ""; TString16 cod = "";
TTable lbu ("%LBU"); TTable lbu ("%LBU");
cod << _annoes << _codlib; cod << _annoIVA << _codlib;
lbu.zero(); lbu.zero();
lbu.put("CODTAB", cod); lbu.put("CODTAB", cod);
if (lbu.read() == NOERR) if (lbu.read() == NOERR)
@ -3284,7 +3298,7 @@ void TStampa_registri_app::aggiorna_reg(const bool aggiorna_vidi)
TTable Tabreg ("REG"); TTable Tabreg ("REG");
TLocalisamfile IndBil (LF_INDLIB); TLocalisamfile IndBil (LF_INDLIB);
codtab << _annoes << _codreg; codtab << _annoIVA << _codreg;
Tabreg.zero(); Tabreg.zero();
Tabreg.put("CODTAB", codtab); Tabreg.put("CODTAB", codtab);
if (Tabreg.read() == NOERR) if (Tabreg.read() == NOERR)
@ -3335,7 +3349,7 @@ void TStampa_registri_app::aggiorna_reg(const bool aggiorna_vidi)
TRectype nuovo(IndBil.curr()); TRectype nuovo(IndBil.curr());
IndBil.put("ANNO", _annoes); IndBil.put("ANNO", _annoIVA);
IndBil.put("CODLIB", _codlib); IndBil.put("CODLIB", _codlib);
TRectype rec (IndBil.curr()); TRectype rec (IndBil.curr());
@ -3348,7 +3362,7 @@ void TStampa_registri_app::aggiorna_reg(const bool aggiorna_vidi)
long cditta = IndBil.get_long("CODDITTA"); long cditta = IndBil.get_long("CODDITTA");
TString16 codreg = IndBil.get("CODREG"); TString16 codreg = IndBil.get("CODREG");
TString16 codvid = IndBil.get("CODVID"); TString16 codvid = IndBil.get("CODVID");
if (_annoes == annoreg && _fino_a_mese == mesereg if (_annoIVA == annoreg && _fino_a_mese == mesereg
&& _ditta == cditta && codreg == _codreg && _codice_vidi == codvid) && _ditta == cditta && codreg == _codreg && _codice_vidi == codvid)
{ {
trovato = true; trovato = true;
@ -3360,11 +3374,11 @@ void TStampa_registri_app::aggiorna_reg(const bool aggiorna_vidi)
// due righe per lo stesso mese e registro => la stampa di vidimazione // due righe per lo stesso mese e registro => la stampa di vidimazione
// mi sballa!!!, // mi sballa!!!,
} }
nuovo.put("ANNO", _annoes); nuovo.put("ANNO", _annoIVA);
nuovo.put("CODLIB", _codlib); nuovo.put("CODLIB", _codlib);
nuovo.put("NUMREG", numero_riga); nuovo.put("NUMREG", numero_riga);
nuovo.put("ANNOREG", _annoes); nuovo.put("ANNOREG", _annoIVA);
nuovo.put("MESEREG", _fino_a_mese); // su libro unico ho un solo mese in gioco! nuovo.put("MESEREG", _fino_a_mese); // su libro unico ho un solo mese in gioco!
nuovo.put("PAGINI", _primast + 1); // numero iniziale pagina libro unico nuovo.put("PAGINI", _primast + 1); // numero iniziale pagina libro unico
nuovo.put("PAGFIN", _u_stampata); // numero finale pagina libro unico nuovo.put("PAGFIN", _u_stampata); // numero finale pagina libro unico
@ -3387,7 +3401,7 @@ void TStampa_registri_app::aggiorna_lib()
TString16 cod = ""; TString16 cod = "";
TTable lbu ("%LBU"); TTable lbu ("%LBU");
cod << _annoes << _codlib; cod << _annoIVA << _codlib;
lbu.zero(); lbu.zero();
lbu.put("CODTAB", cod); lbu.put("CODTAB", cod);
if (lbu.read() == NOERR) if (lbu.read() == NOERR)
@ -3475,7 +3489,7 @@ void TStampa_registri_app::no_movimenti()
//a causa della separazione dei progressivi per registri, ma //a causa della separazione dei progressivi per registri, ma
//solo se l'anno in questione e oltre il 1997, cioè prima della effettiva //solo se l'anno in questione e oltre il 1997, cioè prima della effettiva
//separazione dei progressivi. //separazione dei progressivi.
const bool calc = _tipo_reg == riepilogativo && _annoes > 1997; const bool calc = _tipo_reg == riepilogativo && _annoIVA > 1997;
if (ricalcola(a) || calc) if (ricalcola(a) || calc)
{ {
TFilename app; TFilename app;
@ -3520,7 +3534,7 @@ void TStampa_registri_app::no_movimenti()
if (_freq_riepilogo == 'M' || if (_freq_riepilogo == 'M' ||
(m == 3 || m == 6 || m == 9 || m == 12)) (m == 3 || m == 6 || m == 9 || m == 12))
{ {
_datareg = TDate(1, m, _annoes); _datareg = TDate(1, m, _annoIVA);
if (stampa_riepilogo(m)) if (stampa_riepilogo(m))
printer().formfeed(); printer().formfeed();
} }
@ -3534,7 +3548,7 @@ void TStampa_registri_app::no_movimenti()
{ {
if (! printer().isopen()) if (! printer().isopen())
printer().open(); printer().open();
_datareg = TDate(1, m, _annoes); _datareg = TDate(1, m, _annoIVA);
if (stampa_plafonds(-1)) // Con -1 compone e stampa printrows all'istante if (stampa_plafonds(-1)) // Con -1 compone e stampa printrows all'istante
printer().formfeed(); printer().formfeed();
} }
@ -3555,7 +3569,7 @@ void TStampa_registri_app::no_movimenti()
TFilename f; TFilename f;
f.temp("rgp"); f.temp("rgp");
_datareg = TDate(1, m, _annoes); // serve alla preprocess_header _datareg = TDate(1, m, _annoIVA); // serve alla preprocess_header
if (_scelta == B0_settato || _scelta == prosegui_stampa) if (_scelta == B0_settato || _scelta == prosegui_stampa)
{ {
if (_tipo_stampa == prova) if (_tipo_stampa == prova)
@ -3596,7 +3610,7 @@ void TStampa_registri_app::stampa_liq_mesi_succ()
int a = _data_a.month(); int a = _data_a.month();
for (int m = da; m <= a; m++) for (int m = da; m <= a; m++)
{ {
_datareg = TDate(1, m, _annoes); _datareg = TDate(1, m, _annoIVA);
if (_stampa_plafonds && stampa_plafonds(-1, true)) if (_stampa_plafonds && stampa_plafonds(-1, true))
{ {
printer().formfeed(); printer().formfeed();
@ -3647,7 +3661,7 @@ void TStampa_registri_app::send_message(char tipo, const TFilename& nome, int me
app = "cg4 -2"; app = "cg4 -2";
TToken_string ss(36); TToken_string ss(36);
ss.add(_annoes); ss.add(_annoIVA);
if (_tipo_riepilogativo == 'A' && mese == 12) if (_tipo_riepilogativo == 'A' && mese == 12)
ss.add(13); ss.add(13);
else else
@ -3710,10 +3724,10 @@ bool TStampa_registri_app::set_print(int n)
_riporti = false; _riporti = false;
_totali_stampati = false; _totali_stampati = false;
_annoes = m.get_int(ANNO);//in realta' e' l'anno IVA !!! _annoIVA = m.get_int(ANNO);//in realta' e' l'anno IVA !!!
_tipo_stampa = (tipo_stampa) m.get_int(TIPO_STAMPA); _tipo_stampa = (tipo_stampa) m.get_int(TIPO_STAMPA);
_stampa_len = m.get_int(STAMPA_LEN); _stampa_len = m.get_int(STAMPA_LEN);
_tabname = (_annoes > 1997) ? "PRM" : "PIM"; // Dal 1998 in poi utilizza i PRM e non i PIM _tabname = (_annoIVA > 1997) ? "PRM" : "PIM"; // Dal 1998 in poi utilizza i PRM e non i PIM
if (m.get_int(STAMPA_WIDTH) == 1) if (m.get_int(STAMPA_WIDTH) == 1)
_stampa_width = 132; _stampa_width = 132;
else else
@ -3729,12 +3743,12 @@ bool TStampa_registri_app::set_print(int n)
_data_a = m.get(A_DATA); _data_a = m.get(A_DATA);
if (!_data_da.ok()) if (!_data_da.ok())
_data_da = TDate(1, 1, _annoes); // Meglio cosi' _data_da = TDate(1, 1, _annoIVA); // Meglio cosi'
if (!_data_a.ok()) if (!_data_a.ok())
_data_a = TDate(31, 12, _annoes); // Meglio cosi' _data_a = TDate(31, 12, _annoIVA); // Meglio cosi'
const TDate d(31,12,_annoes); const TDate d(31,12,_annoIVA);
if (_data_a == d) if (_data_a == d)
_tipo_riepilogativo = m.get(TIPO_RIEPILOGATIVO)[0]; _tipo_riepilogativo = m.get(TIPO_RIEPILOGATIVO)[0];
else else
@ -3746,7 +3760,7 @@ bool TStampa_registri_app::set_print(int n)
if (_tipo_stampa == bollato || _tipo_stampa == rif_giornale) if (_tipo_stampa == bollato || _tipo_stampa == rif_giornale)
{ {
_fino_a_mese = m.get_int(FINO_A_MESE); _fino_a_mese = m.get_int(FINO_A_MESE);
_data_da = TDate(1, 1, _annoes); // Meglio cosi' _data_da = TDate(1, 1, _annoIVA); // Meglio cosi'
} }
else //stampa su libro unico else //stampa su libro unico
{ {
@ -3755,7 +3769,7 @@ bool TStampa_registri_app::set_print(int n)
_u_stampata = m.get_int(ULTIMA_PAGINA); _u_stampata = m.get_int(ULTIMA_PAGINA);
_rif_vid = m.get_bool(RIF_VID); _rif_vid = m.get_bool(RIF_VID);
_primast = _u_stampata; _primast = _u_stampata;
_data_da = TDate(1, _fino_a_mese, _annoes); // Meglio cosi' _data_da = TDate(1, _fino_a_mese, _annoIVA); // Meglio cosi'
} }
int giorni_del_mese = 31; int giorni_del_mese = 31;
@ -3767,11 +3781,11 @@ bool TStampa_registri_app::set_print(int n)
else else
{ {
_tipo_riepilogativo = ' '; _tipo_riepilogativo = ' ';
TDate primo(1, _fino_a_mese, _annoes); TDate primo(1, _fino_a_mese, _annoIVA);
primo.set_end_month(); // Meglio cosi' primo.set_end_month(); // Meglio cosi'
giorni_del_mese = primo.day(); giorni_del_mese = primo.day();
} }
_data_a = TDate(giorni_del_mese, _fino_a_mese, _annoes); // Meglio cosi' _data_a = TDate(giorni_del_mese, _fino_a_mese, _annoIVA); // Meglio cosi'
} }
_stampa_data_reg = stampa_datareg(); _stampa_data_reg = stampa_datareg();
if (_tipo_stampa == libro_unico) if (_tipo_stampa == libro_unico)
@ -3877,9 +3891,9 @@ bool TStampa_registri_app::stampa_registri_IVA(const TMask& m)
_tipo_reg = (tiporeg)_tabreg->get_int("I0"); _tipo_reg = (tiporeg)_tabreg->get_int("I0");
const TString16 codtab = _tabreg->get("CODTAB"); const TString16 codtab = _tabreg->get("CODTAB");
const int anno = atoi(codtab.left(4)); const int anno = atoi(codtab.left(4));
if (anno > _annoes) if (anno > _annoIVA)
break; break;
if (anno == _annoes) if (anno == _annoIVA)
//registro iva //registro iva
if (_tipo_reg == vendita || _tipo_reg == acquisto || _tipo_reg == riepilogativo) if (_tipo_reg == vendita || _tipo_reg == acquisto || _tipo_reg == riepilogativo)
{ {
@ -4013,17 +4027,17 @@ bool TStampa_registri_app::stampa_riepilogo(int m)
if (!printer().isopen()) if (!printer().isopen())
printer().open(); printer().open();
_tabreg->put("CODTAB", _annoes); _tabreg->put("CODTAB", _annoIVA);
for (int err = _tabreg->read(_isgteq); err == NOERR; err = _tabreg->next()) // Scorre i registri for (int err = _tabreg->read(_isgteq); err == NOERR; err = _tabreg->next()) // Scorre i registri
{ {
const TString8 codtab = _tabreg->get("CODTAB"); const TString8 codtab = _tabreg->get("CODTAB");
const int a = atoi(codtab.mid(0,4)); const int a = atoi(codtab.mid(0,4));
if (a > _annoes) if (a > _annoIVA)
break; break;
const tiporeg tipo = (tiporeg)_tabreg->get_int("I0"); const tiporeg tipo = (tiporeg)_tabreg->get_int("I0");
if (a == _annoes && (tipo == vendita || tipo == acquisto)) if (a == _annoIVA && (tipo == vendita || tipo == acquisto))
{ {
const TString4 codreg = codtab.mid(4,3); const TString4 codreg = codtab.mid(4,3);
const TString8 codatt = _tabreg->get("S8"); const TString8 codatt = _tabreg->get("S8");
@ -4032,7 +4046,7 @@ bool TStampa_registri_app::stampa_riepilogo(int m)
vect.destroy(); vect.destroy();
vect_prec.destroy(); vect_prec.destroy();
vect_det.destroy(); vect_det.destroy();
TString80 chiave; chiave << _annoes << _tabreg->get("S8"); TString80 chiave; chiave << _annoIVA << _tabreg->get("S8");
// Calcolo riepilogo del periodo e progressivi in caso di stampa su bollato // Calcolo riepilogo del periodo e progressivi in caso di stampa su bollato
for (int i=1; i<=m; i++) for (int i=1; i<=m; i++)
@ -4134,7 +4148,7 @@ void TStampa_registri_app::stampa_prospetto_riepilogo(tiporeg tipo, const TStrin
row.put(format("%-.40s",(const char*)_tabreg->get("S0")), 18); row.put(format("%-.40s",(const char*)_tabreg->get("S0")), 18);
row.put(TR("Attività"), 60); row.put(TR("Attività"), 60);
if (_annoes > 2007) if (_annoIVA > 2007)
{ {
TString16 key; TString16 key;
key.format("%ld|%s", _ditta, (const char*)codatt); key.format("%ld|%s", _ditta, (const char*)codatt);

View File

@ -37,7 +37,7 @@ class TStampa_registri_app : public TPrintapp
TRelation *_rel, *_nditte; TRelation *_rel, *_nditte;
TTable *_tabreg; TTable *_tabreg;
TRigaiva_array _iva_array, _riga_rmi; TRigaiva_array _iva_array, _riga_rmi;
TRiga_array _riga_prospettoXcassa, _riga_split; TRiga_array _riga_prospettoXcassa, _riga_split,_riga_competenza;
TTipodoc_array _doc_array; TTipodoc_array _doc_array;
TRiga_array _tot_iva_array, _tot_prec_iva_array; TRiga_array _tot_iva_array, _tot_prec_iva_array;
TArray_sheet *_ditte; TArray_sheet *_ditte;
@ -57,7 +57,7 @@ class TStampa_registri_app : public TPrintapp
long _u_stampata, _primast, __firm, _uprotivap, _ditta; long _u_stampata, _primast, __firm, _uprotivap, _ditta;
long _numini, _pagine_stampate; long _numini, _pagine_stampate;
int _fino_a_mese, _cod_un_loc; int _fino_a_mese, _cod_un_loc;
int _annoes, _r, _stampa_width, _mese_ultima_liq, _mese_credito; int _annoIVA, _r, _stampa_width, _mese_ultima_liq, _mese_credito;
int _stampa_len, _stampa_mese, _size_header; int _stampa_len, _stampa_mese, _size_header;
real _totale_doc, _credito; real _totale_doc, _credito;
real _totdoc_prog, _totimpn_prog, _totimps_prog; //totali progressivi real _totdoc_prog, _totimpn_prog, _totimps_prog; //totali progressivi
@ -99,7 +99,7 @@ public:
const TRectype& look_comuni(const char* cod); const TRectype& look_comuni(const char* cod);
TArray_sheet* get_ditte_sheet() { return _ditte; } TArray_sheet* get_ditte_sheet() { return _ditte; }
int setta_riga (int, const TRigaiva&, real&, real&, real&, real&); int setta_riga (int, const TRigaiva&, real&, real&, real&, real&);
int riga_rmoviva(); int riga_rmoviva(const bool fattrit);
bool set_print(int); bool set_print(int);
bool set_ditte(TMask&); bool set_ditte(TMask&);
bool compila_reg(const TMask&); bool compila_reg(const TMask&);
@ -151,7 +151,7 @@ public:
bool print_IVAxCassa(int da_month, int a_month); bool print_IVAxCassa(int da_month, int a_month);
void build_nomiditte(); void build_nomiditte();
void set_year(int y) { if (_annoes != y) { _annoes = y; build_nomiditte(); } } void set_year(int y) { if (_annoIVA != y) { _annoIVA = y; build_nomiditte(); } }
void clear_stliq(); void clear_stliq();
virtual bool preprocess_print(int, int); virtual bool preprocess_print(int, int);
virtual bool user_create(); virtual bool user_create();