Patch level :
Files correlati : fe0.exe fe0100a.msk Ricompilazione Demo : [ ] Commento : Aggiornata comunicazione dati rilevanti in base all'ultima circolare del 16-9-2011 git-svn-id: svn://10.65.10.50/branches/R_10_00@22428 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
1d5ebee16d
commit
55a173256f
446
fe/fe0100.cpp
446
fe/fe0100.cpp
@ -148,6 +148,7 @@ bool TContratto::totale_annuale(int anno, real& importo, real& imposta) const
|
||||
return importo > ZERO;
|
||||
}
|
||||
|
||||
|
||||
bool TContratto::init(const TRectype& rec)
|
||||
{
|
||||
_rec = rec;
|
||||
@ -380,63 +381,59 @@ void TDati_rilevanti_trc::create_fields(int tipo, TAS400_recordset& recset)
|
||||
add_field( 3, 7, 8, 2, "Codice numerico fornitura", NU, "47", OBBLIG);
|
||||
add_field( 4, 9, 9, 1, "Tipologia di invio", NU, "0", OBBLIG);
|
||||
add_field( 5, 10, 26,17, "Protocollo da sostituire", NU);
|
||||
add_field( 6, 27, 42,16, "Codice fiscale", CF, "", OBBLIG);
|
||||
add_field( 7, 43, 53,11, "Partita IVA", PI);
|
||||
add_field( 6, 27, 32, 6, "Protocollo documento", NU);
|
||||
|
||||
add_field( 8, 54,113,60, "Denominazione", AN);
|
||||
add_field( 9,114,153,40, "Comune domicilio fiscale", AN);
|
||||
add_field(10,154,155, 2, "Provincia domicilio fiscale", AN);
|
||||
add_field( 7, 33, 48,16, "Codice fiscale", CF, "", OBBLIG);
|
||||
add_field( 8, 49, 59,11, "Partita IVA", PI);
|
||||
|
||||
add_field(11,156,179,24, "Cognome", AN);
|
||||
add_field(12,180,199,20, "Nome", AN);
|
||||
add_field(13,200,200, 1, "Sesso", AN);
|
||||
add_field(14,201,208, 8, "Data di nascita", DT);
|
||||
add_field(15,209,248,40, "Comune o stato di nascita", AN);
|
||||
add_field(16,249,250, 2, "Provincia di nascita", AN);
|
||||
add_field( 9, 60,119,60, "Denominazione", AN);
|
||||
add_field(10,120,159,40, "Comune domicilio fiscale", AN);
|
||||
add_field(11,160,161, 2, "Provincia domicilio fiscale", AN);
|
||||
|
||||
add_field(17,251,254, 4, "Anno di riferimento", NU);
|
||||
add_field(18,255,255, 1, "Comunicazione società incorp.", AN, "0", OBBLIG);
|
||||
add_field(19,256,259, 4, "Progressivo invio telmatico", NU, "1");
|
||||
add_field(20,260,263, 4, "Numero totale invii telematici", NU, "1");
|
||||
add_field(12,162,185,24, "Cognome", AN);
|
||||
add_field(13,186,205,20, "Nome", AN);
|
||||
add_field(14,206,206, 1, "Sesso", AN);
|
||||
add_field(15,207,214, 8, "Data di nascita", DT);
|
||||
add_field(16,215,254,40, "Comune o stato di nascita", AN);
|
||||
add_field(17,255,256, 2, "Provincia di nascita", AN);
|
||||
|
||||
add_field(21,264,279,16, "Codice fiscale intermediario", CF);
|
||||
add_field(22,280,284, 5, "Numero iscrizione C.A.F.", NU);
|
||||
add_field(23,285,285, 1, "Impegno alla trasmissione", NU, "1");
|
||||
add_field(24,286,293, 8, "Data dell'impegno", DT);
|
||||
add_field(18,257,260, 4, "Anno di riferimento", NU);
|
||||
add_field(19,261,261, 1, "Comunicazione società incorp.", AN, "0", OBBLIG);
|
||||
add_field(20,262,265, 4, "Progressivo invio telmatico", NU, "1");
|
||||
add_field(21,266,269, 4, "Numero totale invii telematici", NU, "1");
|
||||
|
||||
add_field(25,294,1797,1504, "Filler", AN);
|
||||
add_field(26,1798,1798,1,"Carattere di controllo", AN, "A", OBBLIG);
|
||||
add_field(27,1799,1800,2,"Caratteri di fine riga", AN, "\r\n");
|
||||
add_field(22,270,285,16, "Codice fiscale intermediario", CF);
|
||||
add_field(23,286,290, 5, "Numero iscrizione C.A.F.", NU);
|
||||
add_field(24,291,291, 1, "Impegno alla trasmissione", NU, "1");
|
||||
add_field(25,292,299, 8, "Data dell'impegno", DT);
|
||||
|
||||
add_field(26,300,1797,1498, "Filler", AN);
|
||||
add_field(27,1798,1798,1,"Carattere di controllo", AN, "A", OBBLIG);
|
||||
add_field(28,1799,1800,2,"Caratteri di fine riga", AN, "\r\n");
|
||||
} else
|
||||
if (_tipo == 1)
|
||||
{
|
||||
add_field( 2, 2,17,16, "Codice fiscale", CF, "", OBBLIG);
|
||||
add_field( 3,18,25, 8, "Data dell'operazione", DT);
|
||||
add_field( 4,26,26, 1, "Modalità di pagamento", NU, "3", OBBLIG);
|
||||
add_field( 5,27,35, 9, "Importo dovuto", NU);
|
||||
add_field( 6,36,36, 1, "Natura operazione", NU, "1", OBBLIG);
|
||||
add_field( 7,37,37, 1, "Tipologia dell'operazione", NU, "1", OBBLIG);
|
||||
add_field( 8,38,46, 9, "Importo totale operazione", NU);
|
||||
|
||||
add_field( 9,47,1797,1751, "Filler", AN);
|
||||
add_field(10,1798,1798,1,"Carattere di controllo", AN, "A", OBBLIG);
|
||||
add_field(11,1799,1800,2,"Caratteri di fine riga", AN, "\r\n");
|
||||
add_field(2, 2,17,16, "Codice fiscale", CF, "", OBBLIG);
|
||||
add_field(3,18,25, 8, "Data dell'operazione", DT);
|
||||
add_field(4,26,26, 1, "Modalità di pagamento", NU, "3", OBBLIG);
|
||||
add_field(5,27,35, 9, "Importo dovuto", NU);
|
||||
add_field(6,36,1797,1762, "Filler", AN);
|
||||
add_field(7,1798,1798,1,"Carattere di controllo", AN, "A", OBBLIG);
|
||||
add_field(8,1799,1800,2,"Caratteri di fine riga", AN, "\r\n");
|
||||
} else
|
||||
if (_tipo == 2)
|
||||
{
|
||||
add_field( 2, 2,12,11, "Partita IVA", PI, "", OBBLIG);
|
||||
add_field( 3,13,20, 8, "Data dell'operazione", DT);
|
||||
add_field( 4,21,21, 1, "Modalità di pagamento", NU, "3", OBBLIG);
|
||||
add_field( 5,22,30, 9, "Importo dovuto", NU);
|
||||
add_field( 6,31,39, 9, "Imposta", NU);
|
||||
add_field( 6,40,40, 1, "Natura operazione", NU, "1", OBBLIG);
|
||||
add_field( 7,41,41, 1, "Tipologia dell'operazione", NU, "1", OBBLIG);
|
||||
add_field( 8,42,50, 9, "Importo totale operazione", NU);
|
||||
add_field( 9,51,59, 9, "Imposta totale operazione", NU);
|
||||
add_field( 2, 2,12,11, "Partita IVA", PI, "", OBBLIG);
|
||||
add_field( 3,13,20, 8, "Data dell'operazione", DT);
|
||||
add_field( 4,21,35,15, "Numero della fattura", AN);
|
||||
add_field( 5,36,36, 1, "Modalità di pagamento", NU, "1", OBBLIG);
|
||||
add_field( 6,37,45, 9, "Importo dovuto", NU);
|
||||
add_field( 7,46,54, 9, "Imposta", NU);
|
||||
add_field( 8,55,55, 1, "Tipologia dell'operazione", NU, "1", OBBLIG);
|
||||
|
||||
add_field(10,60,1797,1738, "Filler", AN);
|
||||
add_field(11,1798,1798,1,"Carattere di controllo", AN, "A", OBBLIG);
|
||||
add_field(12,1799,1800,2,"Caratteri di fine riga", AN, "\r\n");
|
||||
add_field( 9,56,1797,1742, "Filler", AN);
|
||||
add_field(10,1798,1798,1,"Carattere di controllo", AN, "A", OBBLIG);
|
||||
add_field(11,1799,1800,2,"Caratteri di fine riga", AN, "\r\n");
|
||||
} else
|
||||
if (_tipo == 3)
|
||||
{
|
||||
@ -446,63 +443,64 @@ void TDati_rilevanti_trc::create_fields(int tipo, TAS400_recordset& recset)
|
||||
add_field( 5, 54, 93,40, "Comune o stato estero di nascita", AN);
|
||||
add_field( 6, 94, 95, 2, "Provincia di nascita", AN);
|
||||
add_field( 7, 96, 98, 3, "Stato estero del domicilio", AN);
|
||||
|
||||
add_field( 8, 99,158,60, "Ragione sociale", AN);
|
||||
add_field( 9,159,198,40, "Città estera della sede legale", AN);
|
||||
add_field(10,199,201, 3, "Stato estero della sede legale", AN);
|
||||
add_field(11,202,241,40, "Indirizzo estero della sede legale", AN);
|
||||
add_field(12,242,249, 8, "Data dell'operazione", DT);
|
||||
add_field(13,250,250, 1, "Modalità di pagamento", NU, "3", OBBLIG);
|
||||
add_field(14,251,259, 9, "Importo dovuto", NU);
|
||||
add_field(15,260,268, 9, "Imposta", NU);
|
||||
add_field(16,269,269, 1, "Natura operazione", NU, "1", OBBLIG);
|
||||
add_field(17,270,270, 1, "Tipologia dell'operazione", NU, "1", OBBLIG);
|
||||
add_field(18,271,279, 9, "Importo totale operazione", NU);
|
||||
add_field(19,280,288, 9, "Imposta totale operazione", NU);
|
||||
|
||||
add_field(20,289,1797,1509, "Filler", AN);
|
||||
add_field(21,1798,1798,1,"Carattere di controllo", AN, "A", OBBLIG);
|
||||
add_field(22,1799,1800,2,"Caratteri di fine riga", AN, "\r\n");
|
||||
add_field(12,242,249, 8, "Data dell'operazione", DT);
|
||||
add_field(13,250,264,15, "Numero della fattura", AN);
|
||||
add_field(14,265,265, 1, "Modalità di pagamento", NU, "1", OBBLIG);
|
||||
add_field(15,266,274, 9, "Importo dovuto", NU);
|
||||
add_field(16,275,283, 9, "Imposta", NU);
|
||||
add_field(17,284,284, 1, "Tipologia dell'operazione", NU, "1", OBBLIG);
|
||||
|
||||
add_field(18,285,1797,1513, "Filler", AN);
|
||||
add_field(19,1798,1798,1,"Carattere di controllo", AN, "A", OBBLIG);
|
||||
add_field(20,1799,1800,2,"Caratteri di fine riga", AN, "\r\n");
|
||||
} else
|
||||
if (_tipo == 4)
|
||||
{
|
||||
add_field( 2, 2,12,11, "Partita IVA", PI);
|
||||
add_field( 3,13,20, 8, "Data dell'operazione", DT, "", OBBLIG);
|
||||
add_field( 4,21,30,10, "Numero della Nota di Variazione", AN, "", OBBLIG);
|
||||
add_field( 5,31,39, 9, "Imponibile Nota di Variazione", NU);
|
||||
add_field( 6,40,48, 9, "Imposta Nota di Variazione", NU);
|
||||
add_field( 7,49,56, 8, "Data della Fattura da rettificare", DT, "", OBBLIG);
|
||||
add_field( 8,57,66,10, "Numero della Fattura da rettificare", AN, "", OBBLIG);
|
||||
add_field( 9,67,75, 9, "Imponibile Fattura da rettificare", NU);
|
||||
add_field(10,76,84, 9, "Imposta Fattura da rettificare", NU);
|
||||
add_field( 3,13,28,16, "Codice Fiscale", CF);
|
||||
add_field( 4,29,36, 8, "Data dell'operazione", DT, "", OBBLIG);
|
||||
add_field( 5,37,51,10, "Numero della Nota di Variazione", AN, "", OBBLIG);
|
||||
add_field( 6,52,60, 9, "Imponibile Nota di Variazione", NU);
|
||||
add_field( 7,61,69, 9, "Imposta Nota di Variazione", NU);
|
||||
add_field( 8,70,77, 8, "Data della Fattura da rettificare", DT, "", OBBLIG);
|
||||
add_field( 9,78,92,15, "Numero della Fattura da rettificare", AN, "", OBBLIG);
|
||||
add_field(10,93,93, 9, "Variazione imponib. (Debito/Credito)",AN);
|
||||
add_field(11,94,94, 9, "Variazione imposta (Debito/Credito)", AN);
|
||||
|
||||
add_field(11,85,1797,1713, "Filler", AN);
|
||||
add_field(11,95,1797,1703, "Filler", AN);
|
||||
add_field(12,1798,1798,1,"Carattere di controllo", AN, "A", OBBLIG);
|
||||
add_field(13,1799,1800,2,"Caratteri di fine riga", AN, "\r\n");
|
||||
} else
|
||||
if (_tipo == 5)
|
||||
{
|
||||
add_field( 2, 2, 25,24, "Cognome", AN);
|
||||
add_field( 3, 26, 45,20, "Nome", AN);
|
||||
add_field( 4, 46, 53, 8, "Data di nascita", DT);
|
||||
add_field( 5, 54, 93,40, "Comune o stato estero di nascita", AN);
|
||||
add_field( 6, 94, 95, 2, "Provincia di nascita", AN);
|
||||
add_field( 7, 96, 98, 3, "Stato estero del domicilio", AN);
|
||||
add_field( 8, 99,158,60, "Ragione sociale", AN);
|
||||
add_field( 9,159,198,40, "Città estera della sede legale", AN);
|
||||
add_field(10,199,201, 3, "Stato estero della sede legale", AN);
|
||||
add_field(11,202,241,40, "Indirizzo estero della sede legale", AN);
|
||||
add_field(12,242,249, 8, "Data dell'operazione", DT, "", OBBLIG);
|
||||
add_field(13,250,259,10, "Numero della Nota di Variazione", AN, "", OBBLIG);
|
||||
add_field(14,260,268, 9, "Imponibile Nota di Variazione", NU);
|
||||
add_field(15,269,277, 9, "Imposta Nota di Variazione", NU);
|
||||
add_field(16,278,285, 8, "Data della Fattura da rettificare", DT, "", OBBLIG);
|
||||
add_field(17,286,295,10, "Numero della Fattura da rettificare",AN, "", OBBLIG);
|
||||
add_field(18,296,304, 9, "Imponibile Fattura da rettificare", NU);
|
||||
add_field(19,305,313, 9, "Imposta Fattura da rettificare", NU);
|
||||
add_field( 2, 2, 25,24, "Cognome", AN);
|
||||
add_field( 3, 26, 45,20, "Nome", AN);
|
||||
add_field( 4, 46, 53, 8, "Data di nascita", DT);
|
||||
add_field( 5, 54, 93,40, "Comune o stato estero di nascita", AN);
|
||||
add_field( 6, 94, 95, 2, "Provincia di nascita", AN);
|
||||
add_field( 7, 96, 98, 3, "Stato estero del domicilio", AN);
|
||||
add_field( 8, 99,158,60, "Ragione sociale", AN);
|
||||
add_field( 9,159,198,40, "Città estera della sede legale", AN);
|
||||
add_field(10,199,201, 3, "Stato estero della sede legale", AN);
|
||||
add_field(11,202,241,40, "Indirizzo estero della sede legale", AN);
|
||||
add_field(12,242,249, 8, "Data dell'operazione", DT, "", OBBLIG);
|
||||
add_field(13,250,264,15, "Numero della Nota di Variazione", AN, "", OBBLIG);
|
||||
add_field(14,265,273, 9, "Imponibile Nota di Variazione", NU);
|
||||
add_field(15,274,282, 9, "Imposta Nota di Variazione", NU);
|
||||
add_field(16,283,290, 8, "Data della Fattura da rettificare", DT, "", OBBLIG);
|
||||
add_field(17,291,305,15, "Numero della Fattura da rettificare", AN, "", OBBLIG);
|
||||
add_field(18,306,306, 9, "Variazione imponib. (Debito/Credito)",AN);
|
||||
add_field(19,307,307, 9, "Variazione imposta (Debito/Credito)", AN);
|
||||
|
||||
add_field(20,314,1797,1484, "Filler", AN);
|
||||
add_field(21,1798,1798,1,"Carattere di controllo", AN, "A", OBBLIG);
|
||||
add_field(22,1799,1800,2,"Caratteri di fine riga", AN, "\r\n");
|
||||
add_field(20,308,1797,1490, "Filler", AN);
|
||||
add_field(21,1798,1798,1,"Carattere di controllo", AN, "A", OBBLIG);
|
||||
add_field(22,1799,1800,2,"Caratteri di fine riga", AN, "\r\n");
|
||||
}
|
||||
|
||||
_recset = NULL;
|
||||
@ -544,10 +542,15 @@ bool TDati_rilevanti_set::set_field(const TAS400_column_info& fi, const TVariant
|
||||
row().overwrite(str, fi._pos);
|
||||
return true;
|
||||
} else
|
||||
// Salva gli importi in formato 000001234 (non sappiamo ancora gestire i negativi)
|
||||
// Salva gli importi in formato 000001234 (non possono essere negativi)
|
||||
if (fi._type == NU && fi._width == 9)
|
||||
{
|
||||
const char* str = var.as_real().string(9, 0, '0');
|
||||
TString16 str = var.as_string();
|
||||
CHECKS(str[0] != '-', "Importo negativo non ammesso:", (const char*)str);
|
||||
// Tiene la sola parte intera e riempie di zeri
|
||||
const int dot = str.find('.');
|
||||
if (dot >= 0) str.cut(dot);
|
||||
str.right_just(fi._width, '0');
|
||||
row().overwrite(str, fi._pos);
|
||||
return true;
|
||||
}
|
||||
@ -686,7 +689,6 @@ protected:
|
||||
TExclusion_mode segnala_movimento(const TRectype& mov, TExclusion_mode motivo);
|
||||
bool is_nota_variazione(const TRectype& mov) const;
|
||||
real importo_limite(int anno) const;
|
||||
bool imponibile_imposta(long numreg, real& imponibile, real& imposta) const;
|
||||
void elabora_note(const TArray& note, TFast_isamfile& falleg, long& nprog);
|
||||
|
||||
public:
|
||||
@ -696,7 +698,7 @@ public:
|
||||
bool azzera_alleg(bool manual, TRecnotype first) const;
|
||||
TExclusion_mode elabora_movimento(const TRectype& mov, TFast_isamfile& falleg, TRecnotype& progr);
|
||||
bool salva_allegato(const TRectype& mov, TFast_isamfile& falleg, TRecnotype& progr,
|
||||
const real& corrispettivo, const real& imposta, int natope, int tipope);
|
||||
const real& corrispettivo, const real& imposta, int tipope);
|
||||
TExclusion_mode validate_clifo(const TRectype& mov);
|
||||
TExclusion_mode validate_mov(const TRectype& mov);
|
||||
|
||||
@ -814,15 +816,12 @@ bool TDati_rilevanti_msk::is_nota_variazione(const TRectype& mov) const
|
||||
}
|
||||
|
||||
bool TDati_rilevanti_msk::salva_allegato(const TRectype& mov, TFast_isamfile& falleg, TRecnotype& progr,
|
||||
const real& importo, const real& imposta, int natope, int tipope)
|
||||
const real& importo, const real& imposta, int tipope)
|
||||
{
|
||||
bool update_existing_row = false;
|
||||
const int anno = mov.get_int(MOV_ANNOIVA);
|
||||
const long numreg_mov = mov.get_long(MOV_NUMREG);
|
||||
|
||||
if (numreg_mov == 42297)
|
||||
int cazzone = 1;
|
||||
|
||||
long num_fatt = 0; // Numero di registrazione rettificabile
|
||||
long num_rett = 0; // Numero di registrazione rettificata
|
||||
|
||||
@ -835,8 +834,8 @@ bool TDati_rilevanti_msk::salva_allegato(const TRectype& mov, TFast_isamfile& fa
|
||||
if (contratto.full()) // Gestione contratti
|
||||
{
|
||||
TString80 key;
|
||||
key.format("%c%06ld_%s_%d%d", mov.get_char(MOV_TIPO), mov.get_long(MOV_CODCF),
|
||||
(const char*)contratto, natope, tipope);
|
||||
key.format("%c%06ld_%s_%d", mov.get_char(MOV_TIPO), mov.get_long(MOV_CODCF),
|
||||
(const char*)contratto, tipope);
|
||||
real* first_progr = (real*)_contratti.objptr(key);
|
||||
if (first_progr == NULL) // Primo movimento del contratto
|
||||
{
|
||||
@ -880,52 +879,46 @@ bool TDati_rilevanti_msk::salva_allegato(const TRectype& mov, TFast_isamfile& fa
|
||||
const TRectype& riga = partita.row(nriga);
|
||||
const int tipomov = riga.get_int(PART_TIPOMOV);
|
||||
const long nreg_part = riga.get_long(PART_NREG);
|
||||
if (tipomov == 1 && nreg_part > 0)
|
||||
if (tipomov == 1 && nreg_part > 0) // Fattura
|
||||
{
|
||||
num_fatt = nreg_part;
|
||||
TString query;
|
||||
query << "USE ALLEG KEY 3\n"
|
||||
<< "FROM NUMREG=" << num_fatt << '\n'
|
||||
<< "TO NUMREG=" << num_fatt;
|
||||
TISAM_recordset recset(query);
|
||||
bool found = false;
|
||||
if (recset.items() > 1)
|
||||
{
|
||||
for (bool ok = recset.move_first(); ok; ok = recset.move_next())
|
||||
{
|
||||
const int no = recset.get(ALL_NATOPE).as_int();
|
||||
const int to = recset.get(ALL_TIPOPE).as_int();
|
||||
if (no == natope && to == tipope)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
found = recset.move_first();
|
||||
|
||||
if (found)
|
||||
TLocalisamfile recset(LF_ALLEG);
|
||||
recset.setkey(3);
|
||||
recset.put(ALL_NUMREG, num_fatt);
|
||||
if (recset.read(_isgteq) == NOERR && recset.get_long(ALL_NUMREG) == num_fatt)
|
||||
{
|
||||
const TDate data_fatt = riga.get(PART_DATAREG);
|
||||
const int anno_fatt = data_fatt.year();
|
||||
num_rett = num_fatt; // Memorizzo comunque il numero fattura da rettificare
|
||||
|
||||
if (num_rett == 42297)
|
||||
int cazzone = 2;
|
||||
|
||||
if (anno_fatt == anno) // Se sono dello stesso anno vario la fattura e non registro la nota di variazione
|
||||
{
|
||||
update_existing_row = true;
|
||||
alleg = recset.cursor()->curr();
|
||||
} else
|
||||
if (anno_fatt < 2010)
|
||||
alleg = recset.curr();
|
||||
}
|
||||
else
|
||||
{
|
||||
num_rett = 0;
|
||||
_why = em_data_limite; // Non pertinente
|
||||
if (anno_fatt < 2010 || anno_fatt > anno)
|
||||
{
|
||||
num_rett = 0;
|
||||
_why = em_data_limite; // Non pertinente
|
||||
}
|
||||
else
|
||||
{
|
||||
// Variazione di fattura non rilevante
|
||||
if (_why == em_incluso && abs(importo) < importo_limite(anno))
|
||||
_why = em_importo_limite;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Variazione di fattura non rilevante
|
||||
if (_why == em_incluso && abs(importo) < importo_limite(anno))
|
||||
_why = em_importo_limite;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -964,7 +957,7 @@ bool TDati_rilevanti_msk::salva_allegato(const TRectype& mov, TFast_isamfile& fa
|
||||
|
||||
int modpag = mov.get_int(MOV_MODPAG);
|
||||
if (modpag <= 0)
|
||||
modpag = contratto.full() ? 1 : 3;
|
||||
modpag = contratto.full() ? 2 : 1;
|
||||
alleg.put(ALL_MODPAG, modpag);
|
||||
|
||||
int err = 0;
|
||||
@ -995,7 +988,6 @@ bool TDati_rilevanti_msk::salva_allegato(const TRectype& mov, TFast_isamfile& fa
|
||||
alleg.put(ALL_CODCF, codcf);
|
||||
alleg.put(ALL_OCFPI, mov.get(MOV_OCFPI));
|
||||
alleg.put(ALL_NUMREG, numreg_mov);
|
||||
alleg.put(ALL_NATOPE, natope);
|
||||
alleg.put(ALL_TIPOPE, tipope);
|
||||
alleg.put(ALL_IMPORTO, importo);
|
||||
alleg.put(ALL_IMPOSTA, imposta);
|
||||
@ -1003,12 +995,13 @@ bool TDati_rilevanti_msk::salva_allegato(const TRectype& mov, TFast_isamfile& fa
|
||||
if (contratto.full())
|
||||
{
|
||||
alleg.put(ALL_CONTRATTO, contratto);
|
||||
|
||||
const TContratto cont(tipocf, codcf, contratto);
|
||||
real importotot, impostatot;
|
||||
cont.totale_annuale(anno, importotot, impostatot);
|
||||
alleg.put(ALL_IMPORTOTOT, importotot);
|
||||
alleg.put(ALL_IMPOSTATOT, impostatot);
|
||||
if (_why == em_incluso)
|
||||
{
|
||||
TContratto cc(tipocf, codcf, contratto);
|
||||
real netto, iva;
|
||||
if (cc.totale_annuale(anno, netto, iva) && netto < importo_limite(anno))
|
||||
_why = em_importo_limite; // Contratto inutile :-)
|
||||
}
|
||||
} else
|
||||
if (num_rett > 0)
|
||||
{
|
||||
@ -1034,10 +1027,6 @@ bool TDati_rilevanti_msk::salva_allegato(const TRectype& mov, TFast_isamfile& fa
|
||||
return err == NOERR;
|
||||
}
|
||||
|
||||
// Struttura di comodo per memorizzare importi da sommare prima di spedire
|
||||
struct TCorrimp : public TObject
|
||||
{ real _corrispettivo, _imposta; };
|
||||
|
||||
real TDati_rilevanti_msk::importo_limite(int anno) const
|
||||
{ return anno <= 2010 ? 25000 : 3000; }
|
||||
|
||||
@ -1049,13 +1038,15 @@ TExclusion_mode TDati_rilevanti_msk::elabora_movimento(const TRectype& mov, TFas
|
||||
const TString4 tipodoc = mov.get(MOV_TIPODOC);
|
||||
const TDate datareg = mov.get_date(MOV_DATAREG);
|
||||
const int anno = datareg.year();
|
||||
|
||||
#ifdef DBG
|
||||
if (mov.get_long(MOV_NUMREG) == 2673)
|
||||
int cazzone = 1;
|
||||
#endif
|
||||
|
||||
const TString& keytok = mov.get(MOV_NUMREG);
|
||||
TRecord_array righe_iva(keytok, LF_RMOVIVA);
|
||||
|
||||
// Corrispettivi ed imposte raggruppate per tipologia imponibile [1..4] e tipologia movimento [1..4]
|
||||
TAssoc_array importi;
|
||||
|
||||
real tot_imponibile, tot_imposta;
|
||||
|
||||
//calcolo di imponibile ed imposta di tutte le righe iva del movimento
|
||||
@ -1086,45 +1077,20 @@ TExclusion_mode TDati_rilevanti_msk::elabora_movimento(const TRectype& mov, TFas
|
||||
if (natura_operazione == 4 && rmi_imposta.is_zero()) // se l'imposta non è specificata sullo scontrino ...
|
||||
rmi_imposta = ci.scorpora(rmi_imponibile); // ... scorporo il lordo
|
||||
|
||||
// Determina se la riga sia di servizi o merce.
|
||||
bool srv = ci.get_bool("B5"); // Flag apposito sul codice IVA
|
||||
if (!srv)
|
||||
{
|
||||
const TBill bill(rmi);
|
||||
const TRectype& pcon = cache().get(LF_PCON, bill.string());
|
||||
srv = pcon.get_bool(PCN_SERVIZI); // Flag apposito sul sottoconto
|
||||
}
|
||||
// Cessione o acquisto di beni (1 o 3) o servizi (2 o 4)
|
||||
const int tipope = (tipocf == 'C' ? 1 : 3) + (srv ? 1 : 0);
|
||||
|
||||
const char key[3] = { natura_operazione+'0', tipope+'0', '\0' };
|
||||
TCorrimp* imp = (TCorrimp*)importi.objptr(key);
|
||||
if (imp == NULL)
|
||||
{
|
||||
imp = new TCorrimp;
|
||||
importi.add(key, imp);
|
||||
}
|
||||
imp->_corrispettivo += rmi_imponibile;
|
||||
imp->_imposta += rmi_imposta;
|
||||
|
||||
tot_imponibile += rmi_imponibile;
|
||||
tot_imposta += rmi_imposta;
|
||||
}
|
||||
|
||||
if (mov.get(MOV_CONTRATTO).blank() && tot_imponibile > ZERO)
|
||||
if (mov.get(MOV_CONTRATTO).blank() && tot_imponibile >= ZERO)
|
||||
{
|
||||
// Considera solo registrazioni con importo rilevante
|
||||
if (tot_imponibile < importo_limite(anno))
|
||||
segnala_movimento(mov, em_importo_limite);
|
||||
}
|
||||
|
||||
FOR_EACH_ASSOC_OBJECT(importi, obj, key, itm)
|
||||
{
|
||||
const TCorrimp& corrimp = *(const TCorrimp*)itm;
|
||||
salva_allegato(mov, falleg, progr,
|
||||
corrimp._corrispettivo, corrimp._imposta,
|
||||
key[0]-'0', key[1]-'0');
|
||||
}
|
||||
// Cessione o acquisto di beni o servizi (1 o 2)
|
||||
const int tipope = tipocf == 'C' ? 1 : 2;
|
||||
salva_allegato(mov, falleg, progr, tot_imponibile, tot_imposta, tipope);
|
||||
|
||||
return _why;
|
||||
}
|
||||
@ -1287,21 +1253,6 @@ bool TDati_rilevanti_msk::elabora_alleg()
|
||||
return prog > 1;
|
||||
}
|
||||
|
||||
// Calcola il totale degli imponibili e delle imposte di un movimento IVA
|
||||
bool TDati_rilevanti_msk::imponibile_imposta(long numreg, real& imponibile, real& imposta) const
|
||||
{
|
||||
TString8 key; key << numreg;
|
||||
TRecord_array righe_iva(key, LF_RMOVIVA);
|
||||
imponibile = imposta = ZERO;
|
||||
for (int r = righe_iva.rows(); r > 0; r--)
|
||||
{
|
||||
const TRectype& ri = righe_iva.row(r);
|
||||
imponibile += ri.get_real(RMI_IMPONIBILE);
|
||||
imposta += ri.get_real(RMI_IMPOSTA);
|
||||
}
|
||||
return !imponibile.is_zero();
|
||||
}
|
||||
|
||||
bool TDati_rilevanti_msk::send_nc(const TISAM_recordset& alleg, TDati_rilevanti_set& operaz)
|
||||
{
|
||||
const long num_rett = alleg.get(ALL_NUMRETT).as_int();
|
||||
@ -1325,13 +1276,22 @@ bool TDati_rilevanti_msk::send_nc(const TISAM_recordset& alleg, TDati_rilevanti_
|
||||
|
||||
const TAnagrafica anag(alleg.cursor()->curr());
|
||||
|
||||
const real importo = alleg.get(ALL_IMPORTO).as_real();
|
||||
const real imposta = alleg.get(ALL_IMPOSTA).as_real();
|
||||
const TString& paiv = anag.partita_IVA();
|
||||
|
||||
real imp_fatt, iva_fatt;
|
||||
imponibile_imposta(num_rett, imp_fatt, iva_fatt);
|
||||
real imponibile = alleg.get(ALL_IMPORTO).as_real();
|
||||
real imposta = alleg.get(ALL_IMPOSTA).as_real();
|
||||
|
||||
const char tipocf = rec_fatt.get_char(MOV_TIPO);
|
||||
char segno_imponibile = tipocf == 'C' ? 'D' : 'C'; // Normalmente sono negative e quindi a debito del dichiarante
|
||||
char segno_imposta = segno_imponibile;
|
||||
|
||||
if (imponibile > ZERO)
|
||||
segno_imponibile = segno_imponibile == 'D' ? 'C' : 'D';
|
||||
else
|
||||
imponibile = -imponibile;
|
||||
if (imposta > ZERO)
|
||||
segno_imposta = segno_imposta == 'D' ? 'C' : 'D';
|
||||
else
|
||||
imposta = -imposta;
|
||||
|
||||
if (anag.stato_estero() > 0)
|
||||
{
|
||||
operaz.new_rec("5"); // Note di variazione a soggetti non residenti
|
||||
@ -1352,26 +1312,30 @@ bool TDati_rilevanti_msk::send_nc(const TISAM_recordset& alleg, TDati_rilevanti_
|
||||
operaz.set(11, EMPTY_STRING); // TBI? Indirizzo estero
|
||||
}
|
||||
operaz.set(12, alleg.get(ALL_DATAREG));
|
||||
operaz.set(13, rec_nota.get(MOV_NUMDOC).left(10));
|
||||
operaz.set(14, importo);
|
||||
operaz.set(13, rec_nota.get(MOV_NUMDOC).left(15));
|
||||
operaz.set(14, imponibile);
|
||||
operaz.set(15, imposta);
|
||||
operaz.set(16, rec_fatt.get_date(MOV_DATAREG));
|
||||
operaz.set(17, rec_fatt.get(MOV_NUMDOC).left(10));
|
||||
operaz.set(18, imp_fatt);
|
||||
operaz.set(19, iva_fatt);
|
||||
operaz.set(17, rec_fatt.get(MOV_NUMDOC).left(15));
|
||||
operaz.set(18, segno_imponibile);
|
||||
operaz.set(19, segno_imposta);
|
||||
}
|
||||
else
|
||||
{
|
||||
operaz.new_rec("4"); // Note di variazione a soggetti residenti - titolari di partita IVA
|
||||
operaz.set(2, paiv);
|
||||
operaz.set(3, alleg.get(ALL_DATAREG));
|
||||
operaz.set(4, rec_nota.get(MOV_NUMDOC).left(10));
|
||||
operaz.set(5, alleg.get(ALL_IMPORTO));
|
||||
operaz.set(6, alleg.get(ALL_IMPOSTA));
|
||||
operaz.set(7, rec_fatt.get_date(MOV_DATAREG));
|
||||
operaz.set(8, rec_fatt.get(MOV_NUMDOC).left(10));
|
||||
operaz.set(9, imp_fatt);
|
||||
operaz.set(10,iva_fatt);
|
||||
operaz.new_rec("4"); // Note di variazione a soggetti residenti
|
||||
if (anag.partita_IVA().full())
|
||||
operaz.set(2, anag.partita_IVA());
|
||||
else
|
||||
operaz.set(3, anag.codice_fiscale());
|
||||
|
||||
operaz.set(4, alleg.get(ALL_DATAREG));
|
||||
operaz.set(5, rec_nota.get(MOV_NUMDOC).left(15));
|
||||
operaz.set(6, imponibile);
|
||||
operaz.set(7, imposta);
|
||||
operaz.set(8, rec_fatt.get_date(MOV_DATAREG));
|
||||
operaz.set(9, rec_fatt.get(MOV_NUMDOC).left(15));
|
||||
operaz.set(10, segno_imponibile);
|
||||
operaz.set(11, segno_imposta);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -1379,32 +1343,27 @@ bool TDati_rilevanti_msk::send_nc(const TISAM_recordset& alleg, TDati_rilevanti_
|
||||
|
||||
bool TDati_rilevanti_msk::send_fatt(const TISAM_recordset& alleg, TDati_rilevanti_set& operaz)
|
||||
{
|
||||
if (!_send_all)
|
||||
{
|
||||
const int escluso = alleg.get(ALL_IGNORA).as_int();
|
||||
if (escluso > 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
const TAnagrafica anag(alleg.cursor()->curr());
|
||||
|
||||
const real importo = alleg.get(ALL_IMPORTO).as_real();
|
||||
const real imposta = alleg.get(ALL_IMPOSTA).as_real();
|
||||
const real importo_tot = alleg.get(ALL_IMPORTOTOT).as_real();
|
||||
const real imposta_tot = alleg.get(ALL_IMPOSTATOT).as_real();
|
||||
const TString& paiv = anag.partita_IVA();
|
||||
|
||||
if (!_send_all)
|
||||
|
||||
TLocalisamfile mov(LF_MOV);
|
||||
const long numreg = alleg.get(ALL_NUMREG).as_int();
|
||||
mov.put(MOV_NUMREG, numreg);
|
||||
if (mov.read() != NOERR)
|
||||
{
|
||||
bool send = false;
|
||||
const int anno = alleg.get(ALL_ANNO).as_int();
|
||||
if (!anag.stato_estero() && paiv.blank())
|
||||
{
|
||||
// Se l'importo dello scontrino o l'importo del contratto superano la soglia ...
|
||||
const real limit = 3600;
|
||||
send = anno > 2010 && ((importo+imposta) >= limit || (importo_tot+imposta_tot) >= limit);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Se l'importo della fattura o l'importo del contratto superano la soglia ...
|
||||
const real limit = importo_limite(anno);
|
||||
send = importo >= limit || importo_tot >= limit;
|
||||
}
|
||||
if (!send)
|
||||
return false;
|
||||
CHECKD(false, "Registrazione fantasma ", numreg);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (anag.stato_estero() > 0)
|
||||
@ -1427,13 +1386,11 @@ bool TDati_rilevanti_msk::send_fatt(const TISAM_recordset& alleg, TDati_rilevant
|
||||
operaz.set(11, EMPTY_STRING); // TBI? Indirizzo estero
|
||||
}
|
||||
operaz.set(12, alleg.get(ALL_DATAREG).as_date());
|
||||
operaz.set(13, alleg.get(ALL_MODPAG).as_int());
|
||||
operaz.set(14, importo);
|
||||
operaz.set(15, imposta);
|
||||
operaz.set(16, alleg.get(ALL_NATOPE).as_int());
|
||||
operaz.set(13, mov.get(MOV_NUMDOC));
|
||||
operaz.set(14, alleg.get(ALL_MODPAG).as_int());
|
||||
operaz.set(15, importo);
|
||||
operaz.set(16, imposta);
|
||||
operaz.set(17, alleg.get(ALL_TIPOPE).as_int());
|
||||
operaz.set(18, importo_tot);
|
||||
operaz.set(19, imposta_tot);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1444,22 +1401,17 @@ bool TDati_rilevanti_msk::send_fatt(const TISAM_recordset& alleg, TDati_rilevant
|
||||
operaz.set(3, alleg.get(ALL_DATAREG).as_date());
|
||||
operaz.set(4, alleg.get(ALL_MODPAG).as_int());
|
||||
operaz.set(5, real(importo+imposta));
|
||||
operaz.set(6, alleg.get(ALL_NATOPE).as_int());
|
||||
operaz.set(7, alleg.get(ALL_TIPOPE).as_int());
|
||||
operaz.set(8, real(importo_tot+imposta_tot));
|
||||
}
|
||||
else
|
||||
{
|
||||
operaz.new_rec("2"); // Operazioni con soggetti residenti - titolari di partita IVA
|
||||
operaz.set(2, paiv);
|
||||
operaz.set(3, alleg.get(ALL_DATAREG).as_date());
|
||||
operaz.set(4, alleg.get(ALL_MODPAG).as_int());
|
||||
operaz.set(5, alleg.get(ALL_IMPORTO).as_real());
|
||||
operaz.set(6, alleg.get(ALL_IMPOSTA).as_real());
|
||||
operaz.set(7, alleg.get(ALL_NATOPE).as_int());
|
||||
operaz.set(4, mov.get(MOV_NUMDOC));
|
||||
operaz.set(5, alleg.get(ALL_MODPAG).as_int());
|
||||
operaz.set(6, alleg.get(ALL_IMPORTO).as_real());
|
||||
operaz.set(7, alleg.get(ALL_IMPOSTA).as_real());
|
||||
operaz.set(8, alleg.get(ALL_TIPOPE).as_int());
|
||||
operaz.set(9, importo_tot);
|
||||
operaz.set(10,imposta_tot);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -1735,7 +1687,6 @@ bool TDati_rilevanti_msk::on_field_event(TOperable_field& o, TField_event e, lon
|
||||
row.add(nuovo_progr(), s.cid2index(A_RIGA));
|
||||
row.add(TDate(TODAY), s.cid2index(A_DATAREG));
|
||||
row.add(3, s.cid2index(A_MODPAG));
|
||||
row.add(1, s.cid2index(A_NATOPE));
|
||||
row.add(1, s.cid2index(A_TIPOPE));
|
||||
} else
|
||||
if (e == se_query_del)
|
||||
@ -1764,17 +1715,6 @@ bool TDati_rilevanti_msk::on_field_event(TOperable_field& o, TField_event e, lon
|
||||
m.set(A_COFI, anag.codice_fiscale());
|
||||
}
|
||||
break;
|
||||
case A_CONTRATTO:
|
||||
if (e == fe_modify || (e == fe_init && !o.empty()))
|
||||
{
|
||||
TMask& m = o.mask();
|
||||
const TContratto cont(m.get(A_TIPOCF)[0], m.get_long(A_CODCF), m.get(A_CONTRATTO));
|
||||
real importo, imposta;
|
||||
cont.totale_annuale(get_int(F_ANNO), importo, imposta);
|
||||
m.set(A_IMPORTOTOT, importo);
|
||||
m.set(A_IMPOSTATOT, imposta);
|
||||
}
|
||||
break;
|
||||
case DLG_USER:
|
||||
if (e == fe_button)
|
||||
{
|
||||
|
13
fe/fe0100a.h
13
fe/fe0100a.h
@ -25,13 +25,10 @@
|
||||
#define A_MODPAG 109
|
||||
#define A_IMPORTO 110
|
||||
#define A_IMPOSTA 111
|
||||
#define A_NATOPE 112
|
||||
#define A_TIPOPE 113
|
||||
#define A_CONTRATTO 114
|
||||
#define A_IMPORTOTOT 115
|
||||
#define A_IMPOSTATOT 116
|
||||
#define A_NUMRETT 117
|
||||
#define A_PAIV 118
|
||||
#define A_COFI 119
|
||||
#define A_TIPOPE 112
|
||||
#define A_CONTRATTO 113
|
||||
#define A_NUMRETT 114
|
||||
#define A_PAIV 115
|
||||
#define A_COFI 116
|
||||
|
||||
#define A_OCCAS 155
|
||||
|
@ -144,11 +144,8 @@ BEGIN
|
||||
ITEM "Mod.\nPag.@4"
|
||||
ITEM "Importo\ndovuto@12"
|
||||
ITEM "Imposta@12"
|
||||
ITEM "Nat.\nOper.@4"
|
||||
ITEM "Tipo.\nOper.@4"
|
||||
ITEM "Contratto@18"
|
||||
ITEM "Importo Tot.\nOperazione@12"
|
||||
ITEM "Imposta Tot.\nOperazione@12"
|
||||
ITEM "N. Reg.\nrettif.@7"
|
||||
ITEM "Partita IVA@15"
|
||||
ITEM "Codice Fiscale@17"
|
||||
@ -312,24 +309,11 @@ BEGIN
|
||||
FIELD MODPAG
|
||||
END
|
||||
|
||||
LIST A_NATOPE 1 35
|
||||
BEGIN
|
||||
PROMPT 1 7 "Natura operazione "
|
||||
ITEM "1|1 - Imponibile"
|
||||
ITEM "2|2 - Non imponibile"
|
||||
ITEM "3|3 - Esente"
|
||||
ITEM "4|4 - Imponibile con IVA non esposta"
|
||||
ITEM "5|5 - Imponibile con IVA a margine"
|
||||
FIELD NATOPE
|
||||
END
|
||||
|
||||
LIST A_TIPOPE 1 30
|
||||
LIST A_TIPOPE 1 40
|
||||
BEGIN
|
||||
PROMPT 1 8 "Tipologia operazione "
|
||||
ITEM "1|1 - Cessione di beni"
|
||||
ITEM "2|2 - Prestazione di servizi"
|
||||
ITEM "3|3 - Acquisto di beni"
|
||||
ITEM "4|4 - Acquisto di servizi"
|
||||
ITEM "1|1-Cessione e/o prestazione"
|
||||
ITEM "2|2-Acquisto e/o prestazione ricevuta"
|
||||
FIELD TIPOPE
|
||||
END
|
||||
|
||||
@ -358,20 +342,6 @@ BEGIN
|
||||
ADD RUN fe0 -1 &CON
|
||||
CHEKCTYPE NORMAL
|
||||
FIELD CONTRATTO
|
||||
MESSAGE EMPTY DISABLE,A_IMPORTOTOT|DISABLE,A_IMPOSTATOT
|
||||
MESSAGE ENABLE,A_IMPORTOTOT|ENABLE,A_IMPOSTATOT
|
||||
END
|
||||
|
||||
CURRENCY A_IMPORTOTOT 12
|
||||
BEGIN
|
||||
PROMPT 1 11 "Totale "
|
||||
FIELD IMPORTOTOT
|
||||
END
|
||||
|
||||
CURRENCY A_IMPOSTATOT 12
|
||||
BEGIN
|
||||
PROMPT 42 11 "Imposte "
|
||||
FIELD IMPOSTATOT
|
||||
END
|
||||
|
||||
NUMBER A_NUMRETT 7
|
||||
|
Loading…
x
Reference in New Issue
Block a user