Patch level : 12.0 402
Files correlati : tf Commento : tf0500 - Sistemata scrittura trimestre nel file (Adesso prende direttamente dal record, non so perchè non lo facevo anche prima) tf0200 - Rivisto completamente il calcolo degli imponibili, adesso creo un cursore da RMOVIVA JOIN MOV e sommo i valori corretti. Inoltre adesso calcolo insieme gli imponibili x cassa e differiti (tolti dalla funzione calc_inc_diff) - Messe le somme dei valori nei campi (ivaes = ivaes + ivaesxc + ivaesdiff) - Spostate constanti reg_att e reg_pas e definite con dei #define - Aggiunto booleano ivaxcassa così evito di calcolarlo 2 volte git-svn-id: svn://10.65.10.50/branches/R_10_00@23842 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
13cab7cc4e
commit
01d4243219
@ -15,6 +15,8 @@
|
|||||||
#include "tf0200a.h"
|
#include "tf0200a.h"
|
||||||
|
|
||||||
#define CAMPI_CON_BOOLEAN F_TOTOPATT
|
#define CAMPI_CON_BOOLEAN F_TOTOPATT
|
||||||
|
#define REG_ATT 1
|
||||||
|
#define REG_PAS 2
|
||||||
|
|
||||||
// ComLiqPerIva: Comunicazione Liquidazioni Periodiche IVA
|
// ComLiqPerIva: Comunicazione Liquidazioni Periodiche IVA
|
||||||
|
|
||||||
@ -89,13 +91,17 @@ const TRectype getVER(int anno, int mese)
|
|||||||
return rowRet;
|
return rowRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scopiazzata brutalmente da cg4304.cpp, aggiunto controllo indetraibilità per le imposte, non devono essere prese in considerazione se indetraibili
|
/* Scopiazzata e divisa in due da cg4304.cpp
|
||||||
int calc_inc_diff(int anno, int mese, int tipoiva, real& imponibile_diff, real& imposta_diff, real& imponibile_xcas, real& imposta_xcas)
|
* Calcola solo le imposte, aggiunto controllo indetraibilità, non devono essere presi in considerazione
|
||||||
|
* i movimenti se indetraibili
|
||||||
|
*/
|
||||||
|
|
||||||
|
int calc_inc_diff(int anno, int mese, int tipoiva, real& imposta_diff, real& imposta_xcas)
|
||||||
{
|
{
|
||||||
CHECKD(tipoiva == 1 || tipoiva == 2, "Bad tipo iva:", tipoiva);
|
CHECKD(tipoiva == 1 || tipoiva == 2, "Bad tipo iva:", tipoiva);
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
|
|
||||||
imponibile_diff = imposta_diff = imponibile_xcas = imposta_xcas = ZERO;
|
imposta_diff = imposta_xcas = ZERO;
|
||||||
|
|
||||||
TString limit; limit << "ANNOLIQ=" << anno;
|
TString limit; limit << "ANNOLIQ=" << anno;
|
||||||
if (mese < 13) limit << " MESELIQ=" << mese;
|
if (mese < 13) limit << " MESELIQ=" << mese;
|
||||||
@ -108,20 +114,15 @@ int calc_inc_diff(int anno, int mese, int tipoiva, real& imponibile_diff, real&
|
|||||||
for (bool ok = id.move_first(); ok; ok = id.move_next())
|
for (bool ok = id.move_first(); ok; ok = id.move_next())
|
||||||
{
|
{
|
||||||
const real iva = rec.get_real(RMI_IMPOSTA);
|
const real iva = rec.get_real(RMI_IMPOSTA);
|
||||||
const real imp = rec.get_real(RMI_IMPONIBILE);
|
if (!iva.is_zero() && !rec.get_bool("INDETR"))
|
||||||
if (!iva.is_zero() || !imp.is_zero())
|
|
||||||
{
|
{
|
||||||
const int tipodiff = rec.get_int("TIPODIFF");
|
const int tipodiff = rec.get_int("TIPODIFF");
|
||||||
switch (tipodiff)
|
switch (tipodiff)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
imponibile_diff += imp;
|
|
||||||
if(!rec.get_bool("INDETR"))
|
|
||||||
imposta_diff += iva;
|
imposta_diff += iva;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
imponibile_xcas += imp;
|
|
||||||
if(!rec.get_bool("INDETR"))
|
|
||||||
imposta_xcas += iva;
|
imposta_xcas += iva;
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
@ -327,8 +328,8 @@ bool ComLiqPerIva_mask::on_field_event(TOperable_field& o, TField_event e, long
|
|||||||
case F_IVADETXC :
|
case F_IVADETXC :
|
||||||
case F_IVADETDIFF :
|
case F_IVADETDIFF :
|
||||||
{
|
{
|
||||||
real ivaes = get_real(F_IVAES) + get_real(F_IVAESXC) + get_real(F_IVAESDIFF);
|
real ivaes = get_real(F_IVAES);
|
||||||
real ivadet = get_real(F_IVADET) + get_real(F_IVADETXC) + get_real(F_IVADETDIFF);
|
real ivadet = get_real(F_IVADET);
|
||||||
if((ivaes - ivadet) >= ZERO)
|
if((ivaes - ivadet) >= ZERO)
|
||||||
{
|
{
|
||||||
set(F_IVADOV, ivaes - ivadet);
|
set(F_IVADOV, ivaes - ivadet);
|
||||||
@ -433,14 +434,11 @@ void ComLiqPerIva_mask::extractinator() // Per gli amici GTFO
|
|||||||
real ivaver = ZERO;
|
real ivaver = ZERO;
|
||||||
real ivaverc = ZERO;
|
real ivaverc = ZERO;
|
||||||
|
|
||||||
// Costanti
|
|
||||||
static const int reg_att = 1;
|
|
||||||
static const int reg_pas = 2;
|
|
||||||
|
|
||||||
for(; start <= end; start++)
|
for(; start <= end; start++)
|
||||||
{
|
{
|
||||||
TDate data_da(1, start, anno);
|
TDate data_da(1, start, anno);
|
||||||
TDate data_a(31, start, anno);
|
TDate data_a(31, start, anno);
|
||||||
|
bool hasIXC = gestione_IVAxCassa(data_da);
|
||||||
|
|
||||||
/****************************************************************************************************************
|
/****************************************************************************************************************
|
||||||
* TOTOPATT, TOTOPATTXC, TOTOPPAS, TOTOPPASXC, IVAES, IVAESXC, IVAESDIFF,
|
* TOTOPATT, TOTOPATTXC, TOTOPPAS, TOTOPPASXC, IVAES, IVAESXC, IVAESDIFF,
|
||||||
@ -460,20 +458,6 @@ void ComLiqPerIva_mask::extractinator() // Per gli amici GTFO
|
|||||||
// Riga LIA
|
// Riga LIA
|
||||||
const TRectype rowLia = getLIA(anno);
|
const TRectype rowLia = getLIA(anno);
|
||||||
|
|
||||||
/* Sembra che in PAM ci sia già tutto quello che mi serve!
|
|
||||||
* Chiave PAM: ANNO + COD_ATTIVITA' + MESE */
|
|
||||||
static TRelation rpam(LF_TAB);
|
|
||||||
TRectype pamFrom(rpam.curr()); pamFrom.put("COD", "PAM");pamFrom.put("CODTAB", anno);
|
|
||||||
TRectype pamTo(rpam.curr()); pamTo.put("COD" , "PAM");pamTo.put("CODTAB", anno);
|
|
||||||
TCursor curPam(&rpam, "", 1, &pamFrom, &pamTo);
|
|
||||||
for(curPam = 0; curPam.pos() < curPam.items(); ++curPam)
|
|
||||||
{
|
|
||||||
TRectype rowPam = curPam.curr();
|
|
||||||
if(atoi(rowPam.get("CODTAB").right(2)) != start) continue;
|
|
||||||
totopatt = totopatt + rowPam.get_real("R1");
|
|
||||||
totoppas = totoppas + rowPam.get_real("R0");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Devo sottrarre gli indetraibili, quindi prendo prm e sottraggo
|
// Devo sottrarre gli indetraibili, quindi prendo prm e sottraggo
|
||||||
static TRelation rprm(LF_TAB);
|
static TRelation rprm(LF_TAB);
|
||||||
TRectype prmFrom(rprm.curr()); prmFrom.put("COD", "PRM");prmFrom.put("CODTAB", anno);
|
TRectype prmFrom(rprm.curr()); prmFrom.put("COD", "PRM");prmFrom.put("CODTAB", anno);
|
||||||
@ -489,55 +473,60 @@ void ComLiqPerIva_mask::extractinator() // Per gli amici GTFO
|
|||||||
|
|
||||||
// Verifico su che registro mi trovo
|
// Verifico su che registro mi trovo
|
||||||
int tiporeg = rowPrm.get_int("I1");
|
int tiporeg = rowPrm.get_int("I1");
|
||||||
/*
|
|
||||||
bool detraibile = atoi(rowPrm.get("CODTAB").mid(20,1)) == 0; // Se > è indetraibile
|
|
||||||
// Tutti i non detraibili sono passivi ma un controllo in più non fa mai male
|
|
||||||
if(!detraibile && tiporeg == reg_pas)
|
|
||||||
{
|
|
||||||
totoppas = totoppas + rowPrm.get_real("R0");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// Verifico che sia Non soggetto
|
// Verifico che sia Non soggetto
|
||||||
bool nonSogg = rowPrm.get("S5") == "NS";
|
bool nonSogg = rowPrm.get("S5") == "NS";
|
||||||
if(nonSogg && tiporeg == reg_pas && totoppas > ZERO)
|
if(nonSogg && tiporeg == REG_PAS && totoppas > ZERO)
|
||||||
{
|
{
|
||||||
totoppas = totoppas - rowPrm.get_real("R0");
|
totoppas = totoppas - rowPrm.get_real("R0");
|
||||||
}
|
}
|
||||||
else if (nonSogg && tiporeg == reg_att && totopatt > ZERO)
|
else if (nonSogg && tiporeg == REG_ATT && totopatt > ZERO)
|
||||||
{
|
{
|
||||||
totopatt = totopatt - rowPrm.get_real("R0");
|
totopatt = totopatt - rowPrm.get_real("R0");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
TString queryIva = "USE RMOVIVA\n";
|
||||||
|
queryIva << "SELECT (23.REG!=\"\")&&BETWEEN(23.DATAREG,#DADATAREG,#ADATAREG)";
|
||||||
|
queryIva << "\nJOIN MOV INTO NUMREG==NUMREG\n";
|
||||||
|
|
||||||
/* Il reverse charge va sottratto dal totale delle operazioni attive!
|
TISAM_recordset curIva(queryIva);
|
||||||
* Creo un cursore su MOV e RMOVIVA e sottraggo
|
curIva.set_var("#DADATAREG", data_da);
|
||||||
*/
|
curIva.set_var("#ADATAREG", data_a);
|
||||||
TString queryMov = "USE RMOVIVA\n";
|
|
||||||
queryMov << "SELECT BETWEEN(23.DATAREG,#DADATAREG,#ADATAREG)\n";
|
|
||||||
queryMov << "JOIN MOV INTO NUMREG==NUMREG\n";
|
|
||||||
|
|
||||||
TISAM_recordset cmov(queryMov);
|
for(bool ok = curIva.move_first(); ok; ok = curIva.move_next())
|
||||||
|
|
||||||
cmov.set_var("#DADATAREG", TDate(01,start, anno));
|
|
||||||
cmov.set_var("#ADATAREG", TDate(31, start, anno));
|
|
||||||
|
|
||||||
for (bool ok = cmov.move_first(); ok; ok = cmov.move_next())
|
|
||||||
{
|
{
|
||||||
// Vado a prendere la prima riga in RMOV
|
// Controllo che sia un movimento con codice non "non soggetto"
|
||||||
TString key = cmov.get("23.NUMREG").as_string();
|
TCodiceIVA codiva(curIva.get("25.CODIVA").as_string());
|
||||||
key << "|1";
|
if(codiva.tipo() == "NS" || curIva.get("23.TIPOMOV").as_int() == tm_nessuno) continue;
|
||||||
TRectype rmov = cache().get(LF_RMOV, key);
|
|
||||||
|
|
||||||
// Controllo di essere sul registro vendite
|
// Prendo il tipo di registro
|
||||||
bool regVen = TRegistro(cmov.get("23.REG").as_string()).tipo() == reg_att;
|
int tiporeg = TRegistro(curIva.get("23.REG").as_string()).tipo();
|
||||||
|
// Prendiamo l'imponibile
|
||||||
|
real imp = curIva.get("25.IMPONIBILE").as_real();
|
||||||
|
|
||||||
// Salto se il registro non è di tipo vendite o ci sono delle righe in RMOV
|
// Se è un movimento IvaXCassa o LiqDiff
|
||||||
if(!regVen || !rmov.empty()) continue;
|
if(hasIXC && (curIva.get("23.IVAXCASSA").as_bool() || curIva.get("23.LIQDIFF").as_bool()))
|
||||||
|
{
|
||||||
totopatt -= cmov.get("25.IMPONIBILE").as_real();
|
if(tiporeg == REG_ATT)
|
||||||
|
totopattxc += imp;
|
||||||
|
else
|
||||||
|
totoppasxc += imp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(tiporeg == REG_ATT)
|
||||||
|
{
|
||||||
|
// Controllo il reverse charge, non va calcolato nel totale delle operazioni attive!
|
||||||
|
// Se non ha una riga di movimento non lo sommo
|
||||||
|
TString keyRC = curIva.get("23.NUMREG").as_string(); keyRC << "|1";
|
||||||
|
if(!cache().get(LF_RMOV, keyRC).empty())
|
||||||
|
totopatt += imp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
totoppas += imp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Aggiungo gli indeducibili per articolo 19, e indeducibili su ricavi esenti
|
// Aggiungo gli indeducibili per articolo 19, e indeducibili su ricavi esenti
|
||||||
static TRelation rpom(LF_TAB);
|
static TRelation rpom(LF_TAB);
|
||||||
@ -552,23 +541,21 @@ void ComLiqPerIva_mask::extractinator() // Per gli amici GTFO
|
|||||||
totoppas = totoppas + rowPom.get_real("R9"); // Ricavi esenti
|
totoppas = totoppas + rowPom.get_real("R9"); // Ricavi esenti
|
||||||
}
|
}
|
||||||
|
|
||||||
// Se ha attiva l'IVA x cassa
|
// Se ha attiva l'IVA x cassa calcolo le imposte (imponibili per comodità già calcolati sopra)
|
||||||
if(gestione_IVAxCassa(data_da))
|
if(hasIXC)
|
||||||
{
|
{
|
||||||
// IVA esigibile
|
// IVA esigibile
|
||||||
real imponibile_diff, imposta_diff, imponibile_xcas, imposta_xcas;
|
real imponibile_diff, imposta_diff, imponibile_xcas, imposta_xcas;
|
||||||
imponibile_diff = imposta_diff = imponibile_xcas = imposta_xcas = ZERO;
|
imponibile_diff = imposta_diff = imponibile_xcas = imposta_xcas = ZERO;
|
||||||
// 1 = Vendite
|
// 1 = Vendite
|
||||||
calc_inc_diff(anno, start, reg_att, imponibile_diff, imposta_diff, imponibile_xcas, imposta_xcas);
|
calc_inc_diff(anno, start, REG_ATT, imposta_diff, imposta_xcas);
|
||||||
totopattxc = totopattxc + imponibile_xcas;
|
|
||||||
ivaesxc = ivaesxc + imposta_xcas;
|
ivaesxc = ivaesxc + imposta_xcas;
|
||||||
ivaesdiff = ivaesdiff + imposta_diff;
|
ivaesdiff = ivaesdiff + imposta_diff;
|
||||||
|
|
||||||
// IVA detraibile
|
// IVA detraibile
|
||||||
imponibile_diff = imposta_diff = imponibile_xcas = imposta_xcas = ZERO;
|
imponibile_diff = imposta_diff = imponibile_xcas = imposta_xcas = ZERO;
|
||||||
// 2 = Acquisti
|
// 2 = Acquisti
|
||||||
calc_inc_diff(anno, start, reg_pas, imponibile_diff, imposta_diff, imponibile_xcas, imposta_xcas);
|
calc_inc_diff(anno, start, REG_PAS, imposta_diff, imposta_xcas);
|
||||||
totoppasxc = totoppasxc + imponibile_xcas;
|
|
||||||
ivadetxc = ivadetxc + imposta_xcas;
|
ivadetxc = ivadetxc + imposta_xcas;
|
||||||
ivadetdiff = ivadetdiff + imposta_diff;
|
ivadetdiff = ivadetdiff + imposta_diff;
|
||||||
}
|
}
|
||||||
@ -586,7 +573,6 @@ void ComLiqPerIva_mask::extractinator() // Per gli amici GTFO
|
|||||||
ivaes += rowLam.get_real("R0");
|
ivaes += rowLam.get_real("R0");
|
||||||
ivadet += rowLam.get_real("R1");
|
ivadet += rowLam.get_real("R1");
|
||||||
}
|
}
|
||||||
// Non sappiamo che fa per queste, quindi speriamo sia giusta sta roba
|
|
||||||
ivaes += ivaesxc + ivaesdiff;
|
ivaes += ivaesxc + ivaesdiff;
|
||||||
ivadet += ivadetxc + ivadetdiff;
|
ivadet += ivadetxc + ivadetdiff;
|
||||||
|
|
||||||
@ -650,6 +636,9 @@ void ComLiqPerIva_mask::extractinator() // Per gli amici GTFO
|
|||||||
ivaver = ZERO;
|
ivaver = ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sommo i totali con i totali xc
|
||||||
|
totopatt += totopattxc;
|
||||||
|
totoppas += totoppasxc;
|
||||||
|
|
||||||
// Imposto tutti i campi
|
// Imposto tutti i campi
|
||||||
set(F_TOTOPATT, totopatt);
|
set(F_TOTOPATT, totopatt);
|
||||||
@ -765,7 +754,7 @@ void ComLiqPerIva_mask::checkOldValue(int field, real val)
|
|||||||
trueVal = trueData.get_real("IVADETXC");
|
trueVal = trueData.get_real("IVADETXC");
|
||||||
break;
|
break;
|
||||||
case F_IVADETDIFF:
|
case F_IVADETDIFF:
|
||||||
trueVal = trueData.get_real("IVADETDIF");
|
trueVal = trueData.get_real("IVADETDIFF");
|
||||||
break;
|
break;
|
||||||
case F_IVADOV:
|
case F_IVADOV:
|
||||||
trueVal = trueData.get_real("IVADOV");
|
trueVal = trueData.get_real("IVADOV");
|
||||||
|
@ -225,23 +225,16 @@ bool TIvaSend_app::generate(TIvaSend_msk& msk)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
riga.add(""); // Mese
|
riga.add(""); // Mese
|
||||||
riga.add(start/3); // Trimestre
|
riga.add(rowLiq.get("TRIMESTRE")); // Trimestre
|
||||||
}
|
}
|
||||||
|
|
||||||
char subfor = rowLiq.get_bool("SUBFOR") ? 'X' : '\0';
|
char subfor = rowLiq.get_bool("SUBFOR") ? 'X' : '\0';
|
||||||
riga.add(subfor); // Flag Subfornitura
|
riga.add(subfor); // Flag Subfornitura
|
||||||
riga.add(""); // Eventi eccezionali
|
riga.add(""); // Eventi eccezionali
|
||||||
real totopatt = rowLiq.get_real("TOTOPATT") + rowLiq.get_real("TOTOPATTXC");
|
riga.add(formatCurrency(rowLiq.get("TOTOPATT"))); // Totale operazioni attive (al netto dell'IVA)
|
||||||
real totoppas = rowLiq.get_real("TOTOPPAS") + rowLiq.get_real("TOTOPPAS");
|
riga.add(formatCurrency(rowLiq.get("TOTOPPAS"))); // Totale operazioni passive (al netto dell'IVA)
|
||||||
riga.add(formatCurrency(totopatt.string())); // Totale operazioni attive (al netto dell'IVA)
|
riga.add(formatCurrency(rowLiq.get("IVAES"))); // IVA esigibile
|
||||||
riga.add(formatCurrency(totoppas.string())); // Totale operazioni passive (al netto dell'IVA)
|
riga.add(formatCurrency(rowLiq.get("IVADET"))); // IVA detratta
|
||||||
|
|
||||||
real ivaes = rowLiq.get_real("IVAES") + rowLiq.get_real("IVAESXC") + rowLiq.get_real("IVAESDIFF");
|
|
||||||
riga.add(formatCurrency(ivaes.string())); // IVA esigibile
|
|
||||||
|
|
||||||
real ivadet = rowLiq.get_real("IVADET") + rowLiq.get_real("IVADETXC") + rowLiq.get_real("IVADETDIFF");
|
|
||||||
riga.add(formatCurrency(ivadet.string())); // IVA detratta
|
|
||||||
|
|
||||||
riga.add(formatCurrency(rowLiq.get("IVADOV"))); // IVA dovuta
|
riga.add(formatCurrency(rowLiq.get("IVADOV"))); // IVA dovuta
|
||||||
riga.add(formatCurrency(rowLiq.get("IVADOVC"))); // IVA a credito VP6 col 2
|
riga.add(formatCurrency(rowLiq.get("IVADOVC"))); // IVA a credito VP6 col 2
|
||||||
riga.add(formatCurrency(rowLiq.get("DEBPREC"))); // Debito periodo precedente
|
riga.add(formatCurrency(rowLiq.get("DEBPREC"))); // Debito periodo precedente
|
||||||
|
Loading…
x
Reference in New Issue
Block a user