From 848151dff5ea386bc97a5b77c5687eba30d4e6fb Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 24 Feb 2015 08:26:33 +0000 Subject: [PATCH] Aggiunta prima gestione di base dello split payment git-svn-id: svn://10.65.10.50/branches/R_10_00@23036 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg0200.cpp | 14 +- cg/cg0200.h | 8 + cg/cg0200a.uml | 96 ++++-- cg/cg0400.cpp | 11 +- cg/cg2100.cpp | 22 +- cg/cg2100p.uml | 21 ++ cg/cg2102.cpp | 60 +++- cg/cg2102.h | 2 + cg/cg2104.cpp | 50 +-- cg/cg21rata.uml | 30 +- cg/cg21sld.uml | 2 +- cg/cg4300.cpp | 2 +- cg/cg4301.cpp | 175 ++++------ cg/cg4303.cpp | 13 +- cg/cg4304.cpp | 71 ++-- cg/cg4400.cpp | 160 +++++---- cg/cg4400.h | 10 +- cg/cg5500d.uml | 2 +- cg/cg5700.cpp | 39 +-- cg/cg6600.cpp | 38 ++- cg/cg6700.cpp | 13 +- cg/cglib01.cpp | 9 +- cg/cglib03.cpp | 881 ++++++++++++++++++++++++++---------------------- cg/cglib03.h | 2 + cg/cgpagame.cpp | 2 +- cg/f17.dir | 2 +- cg/f17.trr | 3 +- cg/f20.dir | 2 +- cg/f20.trr | 3 +- 29 files changed, 943 insertions(+), 800 deletions(-) diff --git a/cg/cg0200.cpp b/cg/cg0200.cpp index 1a8e2108b..0e63552b1 100755 --- a/cg/cg0200.cpp +++ b/cg/cg0200.cpp @@ -82,9 +82,8 @@ protected: public: virtual bool get_next_key(TToken_string& key); // @cmember Disabilita la verifica del modulo : essendo una anagrafica, va sempre abilitata - virtual bool check_autorization() const - {return false;} - virtual TRelation* get_relation() const {return (TRelation*)_rel;} + virtual bool check_autorization() const { return false; } + virtual TRelation* get_relation() const { return (TRelation*)_rel; } }; inline TClifo_application& app() { return (TClifo_application&)main_app(); } @@ -517,8 +516,8 @@ HIDDEN bool alleg_handler(TMask_field& f, KEY key) { if (f.to_check(key, true)) { - TMask& m = f.mask(); const int tipoall = atoi(f.get()); + TMask& m = f.mask(); if (key == K_ENTER) { @@ -545,6 +544,7 @@ HIDDEN bool alleg_handler(TMask_field& f, KEY key) } if (tipoall == 2) m.set(F_OCCASIONALE, "X"); + m.show(F_SPLITPAY, (tipoall == 4 || tipoall == 7) && m.get(F_TIPOCF)=="C"); m.field(F_COFI).set_dirty(true); m.field(F_PAIV).set_dirty(true); } @@ -633,8 +633,8 @@ HIDDEN bool contrlav_handler(TMask_field& f, KEY key) void TClifo_application::on_config_change() { TConfig cnf(CONFIG_DITTA); - _gesven = cnf.get_bool("GesVen") || !_has_cg; - _gessal = cnf.get_bool("GesSal") || !_has_cg; + _gesven = !_has_cg || (cnf.get_bool("GesVen") || main_app().has_module(PAAUT)); + _gessal = !_has_cg || cnf.get_bool("GesSal"); _lbcn = cnf.get_bool("GsLbCn"); _liscatven = cnf.get_bool("GESLISCV", "ve"); _geslv = _gesven && main_app().has_module(LVAUT); @@ -678,7 +678,7 @@ void TClifo_application::init_insert_mode(TMask& m) { init_query_mode(m); m.enable_page(4, _gesven); - if(_gesven) + if (_gesven) { m.enable_page(10, _geslv); if (_geslv) diff --git a/cg/cg0200.h b/cg/cg0200.h index c79031e14..2314ab882 100755 --- a/cg/cg0200.h +++ b/cg/cg0200.h @@ -158,6 +158,13 @@ #define F_PADESTIN 263 #define F_PARIFAMM 264 +#define F_PRODACC 271 +#define F_PRODALL 272 +#define F_PRODCAR 273 +#define F_PRODPLA 274 +#define F_PRODLEG 275 +#define F_PRODVET 276 + #define DLG_RIC 300 #define DLG_CST 301 #define F_RAGSOCA 302 @@ -174,6 +181,7 @@ #define F_ENTE 313 #define F_DESENTE 314 #define F_INDENTE 315 +#define F_SPLITPAY 316 #define F_TPIMBALLO 401 #define F_DIMENSIONE 402 diff --git a/cg/cg0200a.uml b/cg/cg0200a.uml index 3c21ff432..fea7f56b4 100755 --- a/cg/cg0200a.uml +++ b/cg/cg0200a.uml @@ -299,7 +299,7 @@ BEGIN ITEM "1|Non valido per allegato IVA" ITEM "2|Occasionale" ITEM "3|Documenti riepilogativi" - ITEM "4|Codice fiscale gia' inserito" + ITEM "4|Codice fiscale già inserito" ITEM "5|Estero CEE" ITEM "6|Privato" ITEM "7|Ente pubblico" @@ -351,6 +351,12 @@ BEGIN CHECKTYPE NORMAL END +BOOLEAN F_SPLITPAY +BEGIN + PROMPT 2 15 "Ente soggetto a 'SCISSIONE DEI PAGAMENTI' ai sensi art. 17-ter D.P.R. 633/72" + FIELD SPLITPAY +END + BOOLEAN F_OCCASIONALE BEGIN PROMPT 2 16 "Occasionale " @@ -1419,87 +1425,128 @@ BEGIN MESSAGE TRUE ENABLE,8@|CLEAR,F_CONAIASS END -DATE F_DATAECONAI -BEGIN - PROMPT 2 12 "Data fine esenz.CONAI " - FIELD LF_CFVEN->DATAECONAI - GROUP 8 - MESSAGE TRUE ENABLE,8@|CLEAR,F_CONAIASS -END - BOOLEAN F_CONAIASS BEGIN - PROMPT 43 12 "Stampa contributo CONAI assolto" + PROMPT 30 11 "Stampa 'Contributo CONAI assolto'" FIELD LF_CFVEN->CONAIASS MESSAGE FALSE ENABLE,F_ADDCONAI MESSAGE TRUE CLEAR,F_ADDCONAI END -GROUPBOX DLG_NULL 76 4 +DATE F_DATAECONAI +BEGIN + PROMPT 2 12 "Data fine esenzione " + FIELD LF_CFVEN->DATAECONAI + GROUP 8 + MESSAGE TRUE ENABLE,8@|CLEAR,F_CONAIASS +END + +GROUPBOX DLG_NULL 38 5 BEGIN PROMPT 1 13 "@bEsenzioni CONAI" END NUMBER F_ESACC 6 2 BEGIN - PROMPT 2 14 "Acciaio " + PROMPT 2 14 "Acciaio " FIELD LF_CFVEN->ESACC GROUP 8 END NUMBER F_ESALL 6 2 BEGIN - PROMPT 30 14 "Alluminio " + PROMPT 20 14 "Alluminio " FIELD LF_CFVEN->ESALL GROUP 8 END NUMBER F_ESCAR 6 2 BEGIN - PROMPT 50 14 "Carta " + PROMPT 2 15 "Carta " FIELD LF_CFVEN->ESCAR GROUP 8 END NUMBER F_ESPLA 6 2 BEGIN - PROMPT 2 15 "Plastica " + PROMPT 20 15 "Plastica " FIELD LF_CFVEN->ESPLA GROUP 8 END NUMBER F_ESLEG 6 2 BEGIN - PROMPT 30 15 "Legno " + PROMPT 2 16 "Legno " FIELD LF_CFVEN->ESLEG GROUP 8 END NUMBER F_ESVET 6 2 BEGIN - PROMPT 50 15 "Vetro " + PROMPT 20 16 "Vetro " FIELD LF_CFVEN->ESVET GROUP 8 END +GROUPBOX DLG_NULL 35 5 +BEGIN + PROMPT 42 13 "@bProduttore CONAI" +END + +BOOLEAN F_PRODACC +BEGIN + PROMPT 43 14 "Acciao" + FIELD LF_CFVEN->PRODCONAI[1,1] +END + +BOOLEAN F_PRODALL +BEGIN + PROMPT 62 14 "Alluminio" + FIELD LF_CFVEN->PRODCONAI[2,2] +END + +BOOLEAN F_PRODCAR +BEGIN + PROMPT 43 15 "Carta" + FIELD LF_CFVEN->PRODCONAI[3,3] +END + +BOOLEAN F_PRODPLA +BEGIN + PROMPT 62 15 "Plastica" + FIELD LF_CFVEN->PRODCONAI[4,4] +END + +BOOLEAN F_PRODLEG +BEGIN + PROMPT 43 16 "Legno" + FIELD LF_CFVEN->PRODCONAI[5,5] +END + +BOOLEAN F_PRODVET +BEGIN + PROMPT 62 16 "Vetro" + FIELD LF_CFVEN->PRODCONAI[6,6] +END + GROUPBOX DLG_NULL 76 3 BEGIN - PROMPT 1 17 "@bFatture Elettroniche P.A." + PROMPT 1 18 "@bFattura elettronica Pubblica Amministrazione" MODULES PA END STRING F_PADESTIN 6 BEGIN - PROMPT 2 18 "Destinatario " + PROMPT 2 19 "Destinatario " FLAGS "U" MODULES PA - HELP "Codice dell'ufficio dell'amministrazione destinatario della fattura" + HELP "Codice dell'ufficio dell'amministrazione destinatario della fattura elettronica" FIELD LF_CFVEN->PADESTIN END STRING F_PARIFAMM 20 BEGIN - PROMPT 27 18 "Riferimento amministrazione " + PROMPT 27 19 "Riferimento amministrazione " FLAGS "U" MODULES PA HELP "Codice del cedente presso l'amministrazione" @@ -2132,6 +2179,7 @@ GROUPBOX DLG_NULL 78 14 BEGIN PROMPT 0 4 "@bLavanderie" GROUP G_LV + MODULE LV END LISTBOX F_TPIMBALLO 10 @@ -2141,16 +2189,18 @@ BEGIN ITEM "C|Carrello" FIELD 41@->S0 //LVAUT = 41 GROUP G_LV + MODULE LV END LISTBOX F_DIMENSIONE 2 BEGIN - PROMPT 26 5 "Dimensione " + PROMPT 30 5 "Dimensione " ITEM "XS|XS" ITEM "M|M" ITEM "XL|XL" FIELD 41@->S2 //LVAUT = 41 GROUP G_LV + MODULE LV END LISTBOX F_RIEMPIMENTO 24 @@ -2160,6 +2210,7 @@ BEGIN ITEM "P|Proporzionale" FIELD 41@->S1 GROUP G_LV + MODULE LV END BOOLEAN F_ARTSEP @@ -2167,6 +2218,7 @@ BEGIN PROMPT 1 7 "Articoli separati" FIELD 41@->B0 //LVAUT = 41 GROUP G_LV + MODULE LV END ENDPAGE diff --git a/cg/cg0400.cpp b/cg/cg0400.cpp index 70c78420b..3b9cc6679 100755 --- a/cg/cg0400.cpp +++ b/cg/cg0400.cpp @@ -226,17 +226,10 @@ const char* TProgressivi_iva::desc_iva(const TString& cod) if (cod == "{AF") return TR("Artt.17c3/74c1"); - else if (cod == "{VA7") + if (cod == "{VA7") return TR("Art.40c5/6/8 a.i."); - else - { - TString16 codtab; codtab.format("%-4s", (const char*)cod); - const TRectype & iva = cache().get("%IVA", codtab); - - return iva.get("S0"); - } - return ""; + return cache().get("%IVA", cod, "S0"); } char TProgressivi_iva::frequenza_versamenti(long ditta, int anno) diff --git a/cg/cg2100.cpp b/cg/cg2100.cpp index ea33a7294..8aaaf06c6 100755 --- a/cg/cg2100.cpp +++ b/cg/cg2100.cpp @@ -1852,8 +1852,10 @@ void TPrimanota_application::ini2mask(TConfig& ini, TMask& msk, bool query) } else { - int i; - + _as400 = false; + if (ini.set_paragraph("24,1")) + _as400 = !ini.exist(RMV_ROWTYPE) && ini.get_int(RMV_NUMRIG) == 1; + if (msk.id2pos(F_ANNORIF) > 0) set_not_empty(msk, F_ANNORIF, ini, PART_ANNO); if (msk.id2pos(F_NUMRIF) > 0) @@ -1864,10 +1866,11 @@ void TPrimanota_application::ini2mask(TConfig& ini, TMask& msk, bool query) msk.set(F_SOLAIVA, ini.get("SOLAIVA")); if (msk.id2pos(F_CODIVA) >= 0) msk.set(F_CODIVA, ini.get("CODIVA")); + add_cgs_tot(msk); - + TSheet_field& is = ivas(); - for (i = 0; ini.set_paragraph(format("%d,%d", LF_RMOVIVA, i+1)); i++) + for (int i = 0; ini.set_paragraph(format("%d,%d", LF_RMOVIVA, i+1)); i++) { TToken_string& riga = is.row(i); @@ -1896,12 +1899,14 @@ void TPrimanota_application::ini2mask(TConfig& ini, TMask& msk, bool query) } TSheet_field& cg = cgs(); - for (i = 0; ini.set_paragraph(format("%d,%d", LF_RMOV, i+1)); i++) + for (int i = 0; ini.set_paragraph(format("%d,%d", LF_RMOV, i+1)); i++) { char tipo = ini.get_char(RMV_ROWTYPE); - if (tipo == '\0') tipo = ' '; + if (tipo < ' ') tipo = ' '; TBill conto; ini2bill(ini, conto, false); + if (_as400 && conto.tipo() <= ' ') + conto.find(); int numrig = ini.get_int(RMV_NUMRIG)-1; if (numrig != i) // Controllo se ho un numero riga valido @@ -1926,7 +1931,7 @@ void TPrimanota_application::ini2mask(TConfig& ini, TMask& msk, bool query) TToken_string& riga = cg.row(numrig); - if (numrig < 0 || !(cg.cell_disabled(numrig, 0) && cg.cell_disabled(numrig, 1))) + if (numrig < 0 || _as400 || !(cg.cell_disabled(numrig, 0) && cg.cell_disabled(numrig, 1))) { TString4 sez = ini.get(RMV_SEZIONE); sez.strip("\""); if (sez == "A" || sez == "D") @@ -1973,7 +1978,7 @@ void TPrimanota_application::ini2mask(TConfig& ini, TMask& msk, bool query) const int start_items = pag.items(); msk.reset(FS_RECALC); // Disabilita ricalcolo automatico - for (i = 0; ini.set_paragraph(format("%d,%d", LF_SCADENZE, i+1)); i++) + for (int i = 0; ini.set_paragraph(format("%d,%d", LF_SCADENZE, i+1)); i++) { TToken_string& row = pag.row(i); if (i >= start_items) @@ -1986,6 +1991,7 @@ void TPrimanota_application::ini2mask(TConfig& ini, TMask& msk, bool query) // pag_notify(pag, i, K_ENTER); } + int i; for (i = 0; i < pag.items(); i++) { TToken_string& row = pag.row(i); diff --git a/cg/cg2100p.uml b/cg/cg2100p.uml index a48945716..2d74fee2b 100755 --- a/cg/cg2100p.uml +++ b/cg/cg2100p.uml @@ -147,6 +147,7 @@ BEGIN ITEM "Tipo" ITEM "Riga pag." ITEM "Blocc." + ITEM "Motivazione@50" FLAGS "D" END @@ -295,6 +296,26 @@ END BOOLEAN 114 BEGIN PROMPT 1 8 "Pagamenti bloccati" + MESSAGE FALSE CLEAR,115|CLEAR,116 + MESSAGE TRUE ENABLE,115 +END + +STRING 115 6 +BEGIN + PROMPT 1 9 "Motivo " + USE %MBP + INPUT CODTAB 115 + DISPLAY "Codice" + DISPLAY "Descrizione@50" + OUTPUT 115 CODTAB + OUTPUT 116 S0 + FLAGS "D" +END + +STRING 116 50 +BEGIN + PROMPT 17 9 "" + FLAGS "D" END BUTTON DLG_CANCEL 12 2 diff --git a/cg/cg2102.cpp b/cg/cg2102.cpp index 3dccd2515..6db3018ef 100755 --- a/cg/cg2102.cpp +++ b/cg/cg2102.cpp @@ -1411,9 +1411,9 @@ void TPrimanota_application::ivas_pack() { TToken_string& r = rows.row(i); const real imponibile(r.get(0)); - if (imponibile != ZERO) continue; + if (!imponibile.is_zero()) continue; const real imposta(r.get(3)); - if (imposta != ZERO) continue; + if (!imposta.is_zero()) continue; rows.destroy(i, false); } @@ -1553,15 +1553,14 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k) if (i.is_zero()) deliva = oldposiva[d]; } - - + TBill conto(row, 6); int newpos = bill2pos(conto, 'I'); // Riga in cui andra' l'imponibile TImporto newimp = a.real2imp(imponibile, 'I'); newimp.normalize(); - // Aggiorna conto sulla riga contabile + // Aggiorna conto sulla riga contabile if (newpos < 0) { TString saved_descr; @@ -1581,7 +1580,6 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k) } } else - { const bool empty = a.add_cgs_imp(newpos, newimp); if (empty) // Se la riga si e' azzerata ... @@ -2681,11 +2679,24 @@ void TPrimanota_application::add_cgs_tot(TMask& m) } } - if (!_as400) + if (_as400) + { + if (riga_totale >= 0) // Dare e Avere potrebbero essere disabilitati + { + TToken_string& r = ss.row(riga_totale); + if (row_type(r) == 'T') + { + r.rtrim(2); + ss.enable_cell(riga_totale, 0); + ss.enable_cell(riga_totale, 1); + } + } + } + else { // Creazione/Aggiornamento riga totale const real tot(m.get(F_TOTALE)); - TString descr; + TString80 descr; if (riga_totale >= 0) descr = cgs().row(riga_totale).get(8); if (descr.blank()) @@ -2973,6 +2984,25 @@ static void force_iva_det_bill() cgs.force_update(); } +bool TPrimanota_application::is_split_payment() const +{ + bool yes = false; + const TMask& m = curr_mask(); + if (clifo() == 'C' && m.get_int(F_ANNOIVA) >= 2015) + { + const TRectype& cliente = cache().get_rec(LF_CLIFO, "C", m.get(F_CLIENTE)); + if (cliente.get_bool(CLI_SPLITPAY)) + { + TRelation rel(LF_MOV); + rel.add(LF_PARTITE, "NREG==NUMREG", 2); + m.autosave(rel); + yes = ::is_split_payment(rel.curr()); // Controlla reverse charge e ritenute + } + } + + return yes; +} + // Handler of the F_LIQDIFF // Certified 99% bool TPrimanota_application::liqdiff_handler(TMask_field& f, KEY key) @@ -2980,10 +3010,12 @@ bool TPrimanota_application::liqdiff_handler(TMask_field& f, KEY key) if (key == K_SPACE && f.mask().is_running()) force_iva_det_bill(); - if (key == K_ENTER) + if (key == K_ENTER && f.get().full()) { - if (f.get().full() && f.mask().get_bool(F_IVAXCASSA)) - return f.error_box(TR("Non è ammesso selezionare IVA per cassa e liquidazione differita")); + if (f.mask().get_bool(F_IVAXCASSA)) + return f.error_box(TR("Non è ammessa l'IVA per cassa a liquidazione differita")); + if (app().is_split_payment()) + return f.error_box(TR("Non è ammessa la liquidazione differita con split payment")); } return true; @@ -2996,10 +3028,10 @@ bool TPrimanota_application::ivaxcassa_handler(TMask_field& f, KEY key) if (key == K_SPACE && f.mask().is_running()) force_iva_det_bill(); - if (key == K_ENTER) + if (key == K_ENTER && f.get().full()) { - if (f.get().full() && f.mask().get_bool(F_LIQDIFF)) - return f.error_box(TR("Non è ammesso selezionare IVA per cassa e liquidazione differita")); + if (app().is_split_payment()) + return f.error_box(TR("Non è ammesso l'IVA per cassa con split payment")); } return true; diff --git a/cg/cg2102.h b/cg/cg2102.h index bafe8612e..02aa9c4be 100755 --- a/cg/cg2102.h +++ b/cg/cg2102.h @@ -213,6 +213,8 @@ protected: bool is_fattura() const { return is_saldaconto() && causale().tipomov() == 1; } bool is_nota_credito() const { return is_saldaconto() && causale().tipomov() == 2; } bool is_pagamento() const { return is_saldaconto() && causale().tipomov() >= 3; } + bool is_split_payment() const; + bool activate_numrif(TMask& m, bool set_pag); void fill_sheet(TMask& m) const; diff --git a/cg/cg2104.cpp b/cg/cg2104.cpp index 30563ac27..65ebd088d 100755 --- a/cg/cg2104.cpp +++ b/cg/cg2104.cpp @@ -68,30 +68,30 @@ bool TPrimanota_application::pag_notify(TSheet_field& ps, int r, KEY k) // qui viene il bello, si fa per dire if (news != ts.get(0)) // modificata data scadenza - mod = m_scad = TRUE; + mod = m_scad = true; if (real(newp) != real(ts.get(3))) // modificata percentuale - mod = m_perc = TRUE; + mod = m_perc = true; if (real(newl) != real(ts.get(1))) // modificato importo lire { // se si modifica la percentuale nessun importo viene cagato if ((recalc && !m_perc) || (!recalc)) - mod = m_impl = TRUE; + mod = m_impl = true; } if (in_valuta && real(newv) != real(ts.get(2))) { // se si modifica la percentuale nessun importo viene cagato if ((recalc && !m_perc) || (!recalc)) - mod = m_impv = TRUE; + mod = m_impv = true; } if (newt != ts.get(4)) // modificato tipo pagamento - mod = m_tipo = m_ulc = TRUE; + mod = m_tipo = m_ulc = true; if (newu != ts.get(5)) // modificata ulteriore classificazione - mod = m_ulc = TRUE; + mod = m_ulc = true; else if (m_tipo) { // forza reset di ulc se si e' modificato il tipo rata - m_ulc = TRUE; + m_ulc = true; newu = ""; } @@ -230,9 +230,9 @@ bool TPrimanota_application::pag_sheet_handler(TMask_field& f, KEY key) word err = pag.validate(); if (m.edit_mode()) err &= ~(P_RSUM | P_TOTNCLIT | P_TOTNCVAL ); // Ignora totale importi e rate - if ((err && P_ZEROLIT) && yesno_box("Almeno una rata ha importo zero in lire si desidera continuare ? ")) + if ((err && P_ZEROLIT) && yesno_box(TR("Almeno una rata ha importo nullo in Euro si desidera continuare?"))) err &= ~P_ZEROLIT; - if ((err && P_ZEROVAL) && yesno_box("Almeno una rata ha importo in valuta zero si desidera continuare ? ")) + if ((err && P_ZEROVAL) && yesno_box(TR("Almeno una rata ha importo nullo in valuta si desidera continuare?"))) err &= ~P_ZEROVAL; if (err != P_OK) { @@ -260,8 +260,8 @@ bool TPrimanota_application::pag_sheet_handler(TMask_field& f, KEY key) const TString is = curr.string(TRUE); curr.set_num(tot); const TString ts = curr.string(TRUE); - ok = yesno_box(FR("Il totale delle rate e' %s mentre\n" - "il totale del documento e' %s.\n" + ok = yesno_box(FR("Il totale delle rate è %s mentre\n" + "il totale del documento è %s.\n" "Si desidera registrare ugualmente?"), (const char*)is, (const char*)ts); } @@ -285,8 +285,8 @@ bool TPrimanota_application::pag_sheet_handler(TMask_field& f, KEY key) const TRectype & rec = cache().get("%VAL", TCurrency::get_firm_val()); const char * name = (const char *) rec.get("S0"); - ok = yesno_box(FR("Il totale in %s delle rate e' %s mentre\n" - "il totale del documento e' %s.\n" + ok = yesno_box(FR("Il totale in %s delle rate è %s mentre\n" + "il totale del documento è %s.\n" "Si desidera registrare ugualmente?"), name, (const char*)is, (const char*)ts); } @@ -328,7 +328,7 @@ bool TPrimanota_application::codpag_handler(TMask_field& f, KEY key) { if (set_scad && f.empty()) { - ok = f.error_box(TR("Il codice di pagamento e' obbligatorio!")); + ok = f.error_box(TR("Il codice di pagamento è obbligatorio!")); // Nella maschera iva cerco di reperirlo dal cliente if (m.id2pos(F_CLIENTE) > 0) @@ -367,7 +367,7 @@ bool TPrimanota_application::annorif_handler(TMask_field& f, KEY key) { const TString& anno = m.get(F_DATADOC).right(4); f.set(anno); - ok = error_box(TR("L'anno di riferimento partita e' obbligatorio!")); + ok = error_box(TR("L'anno di riferimento partita è obbligatorio!")); } } return ok; @@ -404,7 +404,7 @@ bool TPrimanota_application::numrif_handler(TMask_field& f, KEY key) f.set(m.get(a._npart_is_prot ? F_PROTIVA : F_NUMDOC)); key = K_TAB; // Forza la successiva activate_numrif - ok = f.error_box(TR("Il numero di riferimento partita e' obbligatorio!")); + ok = f.error_box(TR("Il numero di riferimento partita è obbligatorio!")); } if (key == K_TAB && a.is_fattura()) @@ -561,8 +561,8 @@ bool TPrimanota_application::recalc_handler(TMask_field& f, KEY key) if (pag.in_valuta()) yak |= (pag.tval_rata(0) != pag.importo_da_non_dividere(TRUE)); if (yak) { - if (yesno_box(TR("L'importo della prima rata e' stato modificato. " - "Con il ricalcolo automatico esso non sara' piu'" + if (yesno_box(TR("L'importo della prima rata è stato modificato. " + "Con il ricalcolo automatico esso non sarà più" " modificabile. Si desidera " "riportare le rate alle condizioni iniziali?"))) { @@ -571,8 +571,8 @@ bool TPrimanota_application::recalc_handler(TMask_field& f, KEY key) a.reset_pagamento(); a.set_scadenze(m); } - else warning_box(FR("Il tipo prima rata e' stato modificato in \"%s\" per " - "poter mantenere la rateazione scelta e la possibilita' di " + else warning_box(FR("Il tipo prima rata è stato modificato in \"%s\" per " + "poter mantenere la rateazione scelta e la possibilità di " "ricalcolo automatico"), pag.desc_tpr()); } @@ -609,7 +609,7 @@ bool TPrimanota_application::nrate_handler(TMask_field& f, KEY key) app().set_banche(m); app().pag_rows() = ps.rows_array(); } - TString8 r; r.format("%d", pag.n_rate()); + TString4 r; r.format("%d", pag.n_rate()); f.set(r); } return TRUE; @@ -802,10 +802,10 @@ bool TPrimanota_application::read_scadenze(TMask& m) const TDate datadoc = testa.get_date(MOV_DATADOC); const int npart = part.prima_fattura(nreg); - if (npart <= 0) // Non esiste una riga per questo movimento + if (npart <= 0) // Non esiste una riga per questo movimento { partite().destroy(); - return FALSE; // Non dovrebbe succedere mai, in quanto gia' beccato sopra! + return false; // Non dovrebbe succedere mai, in quanto gia' beccato sopra! } // Determino il codice pagamento dalla riga di fattura @@ -1139,7 +1139,7 @@ bool TPrimanota_application::showpartite_handler(TMask_field& f, KEY k) { TString msg(128); const TCurrency curr(speso.valore()); - msg.format(FR("L'importo sul saldaconto della riga %d e' %s"), (riga+1), (const char*)curr.string(TRUE)); + msg.format(FR("L'importo sul saldaconto della riga %d è %s"), (riga+1), (const char*)curr.string(TRUE)); if (!speso.is_zero()) msg << (speso.sezione() == 'A' ? TR(" Avere") : TR(" Dare")); return f.error_box(msg); @@ -1297,7 +1297,7 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa if (old_ap != ' ') // Se c'era un abbuono ... { const int riga_abb = type2pos(old_ap); - CHECK(riga_abb >= 0, "Chiss'e' fregato gli abbuoni?"); + CHECK(riga_abb >= 0, "Chiss'è fregato gli abbuoni?"); const bool empty = add_cgs_imp(riga_abb, old_abbuono); if (empty && new_ap != old_ap) sheet.destroy(riga_abb); diff --git a/cg/cg21rata.uml b/cg/cg21rata.uml index 74e4de88d..cc462a310 100755 --- a/cg/cg21rata.uml +++ b/cg/cg21rata.uml @@ -1,4 +1,4 @@ -PAGE "Rata pagamento" -1 -1 50 15 +PAGE "Rata pagamento" -1 -1 51 15 DATE 101 BEGIN @@ -147,20 +147,29 @@ BEGIN PROMPT 1 11 "Note:" END -BOOLEAN 114 -BEGIN - PROMPT 12 11 "Non cancellabile" - FLAGS "D" +STRING 112 50 47 +BEGIN + PROMPT 1 12 "" END BOOLEAN 113 BEGIN - PROMPT 38 11 "Bloccata" + PROMPT 12 11 "Bloccata" END -STRING 112 50 47 +BOOLEAN 114 +BEGIN + PROMPT 1 -1 "Non cancellabile" + FLAGS "D" +END + +ENDPAGE + +TOOLBAR "" 0 0 0 2 + +BUTTON DLG_OK 10 2 BEGIN - PROMPT 1 12 "" + PROMPT -33 -1 "" END BUTTON DLG_DELREC 10 2 @@ -175,11 +184,6 @@ BEGIN PROMPT -23 -1 "" END -BUTTON DLG_OK 10 2 -BEGIN - PROMPT -33 -1 "" -END - ENDPAGE ENDMASK diff --git a/cg/cg21sld.uml b/cg/cg21sld.uml index 081ab5d98..b0c2cc392 100755 --- a/cg/cg21sld.uml +++ b/cg/cg21sld.uml @@ -40,7 +40,7 @@ BEGIN ITEM "1|Differenziate" MESSAGE DISABLE,FS_NRATE ITEM "2|Uguali (obbligate dalla 2a)" MESSAGE ENABLE,FS_NRATE ITEM "3|Uguali dall'ultima modificata" MESSAGE DISABLE,FS_NRATE - ITEM "4|Uguali finche' possibile" MESSAGE DISABLE,FS_NRATE + ITEM "4|Uguali finché possibile" MESSAGE DISABLE,FS_NRATE END STRING FS_NAMEPAG 50 29 diff --git a/cg/cg4300.cpp b/cg/cg4300.cpp index 5fe387dc6..4263e5979 100755 --- a/cg/cg4300.cpp +++ b/cg/cg4300.cpp @@ -850,7 +850,7 @@ void TLiquidazione_app::build_ditte_sheet(wht what) const char vers = d->get_char(2); const bool agr = d->get_char(3) == 'X'; - bool unselectable = vers == '?' || (_year > "1997" && _month < 13 && agr); + const bool unselectable = (vers == '?') || (_month < 13 && agr); if ((what == mnt && vers == 'T') || (what == trimestre && vers == 'M')) continue; diff --git a/cg/cg4301.cpp b/cg/cg4301.cpp index a849c5867..01c36bd2b 100755 --- a/cg/cg4301.cpp +++ b/cg/cg4301.cpp @@ -563,38 +563,7 @@ void TLiquidazione_app::zero_att(int month, const char* codatt) zero_diff(month,codatt); } -/* -static bool ivadiff_chiusa_old(const TRectype& mov, const TDate& fine) -{ - const long numreg = mov.get_long(MOV_NUMREG); - - TString query; - query << "USE IVADIFF" - << "\nSELECT BETWEEN(DATAREGP,0," << fine.date2ansi() << ")" - << "\nFROM NUMREG=" << numreg - << "\nTO NUMREG=" << numreg; - TISAM_recordset id(query); - const TRectype& rid = id.cursor()->curr(); - - bool some_pag = false; // Ci sono pagamenti? - TImporto tot; - for (bool ok = id.move_first(); ok; ok = id.move_next()) - { - const char sez = rid.get_char("SEZIONE"); - const real imp = rid.get(RMI_IMPOSTA); - if (!imp.is_zero()) - { - if (rid.get_int(MOV_TIPOMOV) > 1) - some_pag = true; - tot += TImporto(sez, imp); - } - } - const bool chiusa = some_pag && tot.valore() < 0.01; - return chiusa; -} -*/ - -static bool ivadiff_chiusa_new(const TRectype& mov, const TDate& fine) +bool TLiquidazione_app::ivadiff_chiusa(const TRectype& mov, const TDate& fine) const { bool chiusa = false; const long numreg = mov.get_long(MOV_NUMREG); @@ -625,14 +594,6 @@ static bool ivadiff_chiusa_new(const TRectype& mov, const TDate& fine) return chiusa; } -bool TLiquidazione_app::ivadiff_chiusa(const TRectype& mov, const TDate& fine) const -{ - bool cnew = ivadiff_chiusa_new(mov, fine); - //bool cold = ivadiff_chiusa_old(mov, fine); - // CHECK(cold == cnew, "Cazzo"); - return cnew; -} - // Fattura più vecchia di un anno a ente NON pubblico bool TLiquidazione_app::sarebbe_da_pagare(const TRectype& mov, const TDate& fine) const { @@ -665,24 +626,32 @@ bool TLiquidazione_app::sarebbe_da_pagare(const TRectype& mov, const TDate& fine TString8 key; key.format("%c|%ld", mov.get_char(MOV_TIPO), mov.get_long(MOV_CODCF)); const TRectype& clifo = cache().get(LF_CLIFO, key); - const int alleg = clifo.get_int(CLI_ALLEG); + int alleg = clifo.get_int(CLI_ALLEG); if (alleg == 7 || alleg == 8) // Ente pubblico e amministrazione controllata ... return false; // ... possono aspettare le calende greche if (mov.get_bool(MOV_IVAXCASSA)) { + if (alleg == 6) // privato? + { + TString16 paiv, cofi; + if (clifo.get_bool(CLI_OCCAS)) + { + const TRectype& occas = cache().get(LF_OCCAS, mov.get(MOV_OCFPI)); + paiv = occas.get(OCC_PAIV); + cofi = occas.get(OCC_COFI); + } + else + { + paiv = clifo.get(CLI_PAIV); + cofi = clifo.get(CLI_COFI); + } + if (paiv.full()) + alleg = 0; // Falso allarme: NON è un privato avendo partita IVA + } if (alleg == 5 || alleg == 6 || alleg == 9) // Privati, import ed export non hanno IVA per cassa return true; - - TString16 paiv = clifo.get(CLI_PAIV); - if (paiv.empty() && clifo.get_bool(CLI_OCCAS)) - { - const TRectype& occas = cache().get(LF_OCCAS, mov.get(MOV_OCFPI)); - paiv = occas.get(OCC_PAIV); - } - if (paiv.blank()) - return true; // In assenza di Partita IVA non c'è IVA per cassa } if (ivadiff_chiusa(mov, fine)) @@ -824,9 +793,8 @@ static bool is_autofattura_articolo_17(const TRectype& mov) // Dal 24-02-2014 controlliamo meglio if (af) { - TString8 key; - key << mov.get(MOV_TIPO) << '|' << mov.get(MOV_CODCF); - const int tp = atoi(cache().get(LF_CLIFO, key, CLI_ALLEG)); + const TRectype& clifo = cache().get_rec(LF_CLIFO, mov.get(MOV_TIPO), mov.get(MOV_CODCF)); + const int tp = clifo.get_int(CLI_ALLEG); af = tp == 5 || tp == 9; // cliente estero CEE o non CEE } @@ -1010,7 +978,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) if (_isviaggio) f74 = TDate(1, 1, year_int-1); - if (year_int < 1998 || _recalc_regis) // Vecchia selezione o calcolo progressivi per stampa registri bollati + if (_recalc_regis) // Vecchia selezione priam del 1998 o calcolo progressivi per stampa registri bollati { t.set_month(month == 13 ? 12 : month); t.set_year(year_int); @@ -1079,7 +1047,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) } #ifndef NDEBUG - if (_mov->get_long(MOV_NUMREG) == 15985) + if (_mov->get_long(MOV_CODCF) == 940) int cazzone = 1; #endif @@ -1095,11 +1063,16 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) const bool cau_intra = rcs.get_bool(CAU_INTRACOM); const bool cau_valintra = rcs.get_bool(CAU_VALINTRA); + // Gestione SPLIT PAYMENT dal 01-01-2015: movimenti a enti pubblici senza ritenuta e senza reverse charge + if (tipomov == vendita && (tm == tm_fattura || tm == tm_nota_credito) && + !cau_intra && date.year() >= 2015 && is_split_payment(_mov->curr())) + continue; // Ignora movimento di split payment + // Inizio gestione IVA differita const bool iva_diff = _mov->get_bool(MOV_LIQDIFF); - const bool iva_cass = !iva_diff && _mov->get_bool(MOV_IVAXCASSA) && tm > 0; + const bool iva_cass = !iva_diff && !_isviaggio && tm > tm_nessuno && _mov->get_bool(MOV_IVAXCASSA) && is_IVAxCassa(_mov->curr()); const bool movdiff = (iva_diff || iva_cass) && !_recalc_regis; // Aggiunto test su ricalcolo da registri 13-12-2012 - bool dok = is_date_ok(date, month, liqmonth, year_int); + bool dok = is_date_ok(date, month, liqmonth, year_int); TPartite_array arrpart; // Partite interessate TPointer_array pagscatt; // Righe di pagsca interessate @@ -1124,7 +1097,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) const TPartita* p = arrpart.first(); const int row = p ? p->mov2rig(numreg, 0) : 0; game_found = row > 0; - if (game_found && !id_chiusa) // 25-02-2014 sostituito inizio al posto di fine + if (game_found && !id_chiusa) { const TRiga_partite& rp = p->riga(row); TImporto pg, nc; @@ -1317,7 +1290,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) const bool intra = _rmoviva->get_bool(RMI_INTRA); // autofatture art. 17 per non residenti, con trattamento speciale in liquidazione annuale - const bool autodafe = is_autofattura_articolo_17(_mov->curr()); + const bool autodafe = (tipodoc == "AF") && is_autofattura_articolo_17(_mov->curr()); // vendite art. 40 c. 5/6/8 acq.intra., con trattamento // speciale in liquidazione annuale (VA7 in stampa) const bool art40 = (tipodoc != "AF" && tipoiva != "NS" && !rcs.get_bool("AUTOFATT") && rcs.get_bool("VALINTRA") && !intra); @@ -1464,9 +1437,6 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) meseliq += 3-resto; } idcurr.put("MESELIQ", meseliq); - - if (pagtmp.sezione() != sezpag) - int cazzone = 2; idcurr.put("SEZIONE", pagtmp.sezione()); if (ultimo) { @@ -1564,15 +1534,11 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) ) continue; - /* - * Riga imponibile > 9 = ritenute; non si - * considerano (Scudler 1994) - */ + /* Riga imponibile > 9 = ritenute; non si considerano (Scudler 1994) */ // Filling dell'array per IVA11 if (_is_interactive && month == 13) - iva11_set_arr_phase_1(trueatt); - + iva11_set_arr_phase_1(trueatt); // Cumula l'ammontare delle operazioni attive/passive // per la dichiarazione annuale dati iva e quadro VT @@ -1593,8 +1559,8 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) { if (clifo.get_bool(CLI_OCCAS)) { - const TString80 key_occ(_mov->get(MOV_OCFPI)); - const TRectype & occas = cache().get(LF_OCCAS, key_occ); + const TString& key_occ = _mov->get(MOV_OCFPI); + const TRectype& occas = cache().get(LF_OCCAS, key_occ); key = occas.get(OCC_STATO); key << "|" << occas.get(OCC_COM); @@ -1623,9 +1589,10 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) } const TString& iva_vpn = _iva->get(tipomov == vendita ? "S10" : "S11"); - if (iva_vpn.full()) + + // Aggiunto "&& is_detraibile" al test altrimenti somma due volte imponibile_orig (22/01/2015) + if (iva_vpn.full() && _mov->get(MOV_ANNOIVA) == _year && is_detraibile) { - if (_mov->get(MOV_ANNOIVA) == _year) switch (tipomov) { case vendita: // CD1 - 1 2 3 4 @@ -2512,10 +2479,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) } } - /* rediito_ - * calcola il lercio prorata - * solo se liq. periodica - */ + /* calcola il lercio prorata solo se liq. periodica */ real prorata, prorata_precedente1, prorata_precedente2; real percentuale1, percentuale2; if (month != 13) @@ -2544,7 +2508,11 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) // Prorata per l'anno corrente + quelli eventuali dello scorso anno e quelli che sono oltre 3 anni fa... // E quelli che non hanno la % prorata settata in tabella real aaa = acquisti_iva; - aaa -= ammort_det_iva; // Scarta gli acquisti di beni ammortizzabili (4-9-2014) + + // E'una questione molto dibattuta il fatti di escludere i beni ammortizzabili o no: + // Nella versione precedente (10.0) non venivano esclusi, poi dal 4-9-2014 sono stati esclusi ed infine nuovamente ignorati dal 17-2-2015 + // aaa -= ammort_det_iva; // Scarta gli acquisti di beni ammortizzabili + if (percentuale1 != INVALID_PRORATA && percentuale1 != INVALID_PRORATA_ASSERT) aaa -= rr1 ? *rr1 : ZERO; if (percentuale2 != INVALID_PRORATA && percentuale2 != INVALID_PRORATA_ASSERT) @@ -3833,7 +3801,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts) continue; real vf1 = _pla->get_real("R14"); - real vf2(_pla->get("S1")); + real vf2 = _pla->get("S1"); real iaq = _pla->get_real("R11"); // IVA acquisti real ppg = _pla->get_real("R12"); // pro-rata pagato @@ -3853,23 +3821,16 @@ void TLiquidazione_app::write_liq(int month, const char* codatts) real prorata = 0.0; real conguaglio = 0.0; real topay = 0.0; - real ris = vol_aff_t; // gia' esclusi: NS, B3, cess. amm + const real ris = vol_aff_t; // gia' esclusi: NS, B3, cess. amm - // calcola nuovo prorata per ogni attivita' (miste: 1+2) - if (year_int > 1997) // Calcolo dal 1998 in poi + // calcola nuovo prorata dal 1998 per ogni attivita' (miste: 1+2) + const real rsa = ris - (es_c1a-es_c1a_am) - (es_c3-es_c3_am); + const real rsn = rsa - es_c1; + if (!rsa.is_zero()) { - const real rsa = ris - (es_c1a-es_c1a_am) - (es_c3-es_c3_am); - const real rsn = rsa - es_c1; - if (!rsa.is_zero()) - prorata = CENTO - (rsn * CENTO / rsa); // Percentuale di indetraibilita: reciproco della percentuale di detraibilita' + prorata = CENTO - (rsn * CENTO / rsa); // Percentuale di indetraibilita: reciproco della percentuale di detraibilita' + prorata.round(0); } - else - { - if (!ris.is_zero()) - prorata = es_c1 * CENTO / ris; - } - - prorata.round(0); // calcolo conguaglio -- se positivo e' a debito if (prorata > ZERO) @@ -3932,23 +3893,17 @@ void TLiquidazione_app::write_liq(int month, const char* codatts) // comprende anche il conguaglio prorata risultato += tot_cong; - if (atoi(_year) <= 1997) + + // Nuovo prorata dal 1998, congloba il conguaglio pro-rata nell'IVA ammessa in detrazione + if (tot_cong.sign() > 0) { - if (tot_cong.sign() > 0) res_debt += tot_cong; - if (tot_cong.sign() < 0) res_cred -= tot_cong; + iva_acq -= tot_cong; + res_cred -= tot_cong; } - else // Nuovo prorata dal 1998, congloba il conguaglio pro-rata nell'IVA ammessa in detrazione + else { - if (tot_cong.sign() > 0) - { - iva_acq -= tot_cong; - res_cred -= tot_cong; - } - else - { - iva_acq += abs(tot_cong); - res_cred += abs(tot_cong); - } + iva_acq += abs(tot_cong); + res_cred += abs(tot_cong); } look_lim(month+deltam,TRUE); @@ -4084,13 +4039,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts) _lam->put("R3", debt_precd); if (!_recalc_only && _recalc != never) - { - _lim->put("B0","X"); - // Dal 1998 questo flag vale solo per i progressivi dei registri IVA, visto che sono separati - // pertanto il suo settaggio andra' fatto solo in fase di ricalcolo (_recalc_only) - if (atoi(_year) < 1998) - _lim->put("B1","X"); - } + _lim->put("B0","X"); if (_recalc_only) _lim->put("B1", "X"); diff --git a/cg/cg4303.cpp b/cg/cg4303.cpp index 44b952ea0..bebc916d3 100755 --- a/cg/cg4303.cpp +++ b/cg/cg4303.cpp @@ -41,25 +41,21 @@ void TLiquidazione_app::zero_plafond (int month, const char* codatt) { if (_recalc != needed) { - describe_error(TR("Progressivi plafond non ricalcolati per " - "i mesi precedenti: possibili errori"), + describe_error(TR("Progressivi plafond non ricalcolati per i mesi precedenti: possibili errori"), codatt); is_ok = FALSE; } else { if (!update_att(previous_month(month),codatt, FALSE)) - describe_error(TR("Progressivi plafond non ricalcolati per " - "i mesi precedenti: possibili errori"), + describe_error(TR("Progressivi plafond non ricalcolati per i mesi precedenti: possibili errori"), codatt); look_ppa(previous_month(month),codatt,jj); } } if (is_ok) // Se il record prec. esiste allora esegue i calcoli; In caso contrario diventa un errore sistematico - r = _ppa_r->get_real("R2") - - _ppa_r->get_real("R0") - - _ppa_r->get_real("R1"); + r = _ppa_r->get_real("R2") - _ppa_r->get_real("R0") - _ppa_r->get_real("R1"); _ppa->readat(rn); } @@ -637,6 +633,9 @@ void TLiquidazione_app::zero_diff(int month, const char* codatt) return; TFast_isamfile fid(LF_IVADIFF); + if (fid.status() != NOERR) + return; + TString query; query << "USE IVADIFF KEY 2"; // Key 2 = ANNOLIQ+MESELIQ+... query << "\nFROM ANNOLIQ=" << _year; diff --git a/cg/cg4304.cpp b/cg/cg4304.cpp index 1a25af71f..af4cc0287 100755 --- a/cg/cg4304.cpp +++ b/cg/cg4304.cpp @@ -942,7 +942,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool } } // fine while (codatt) - if (!describe_pis && (art40.sign() > 0 || art40_iva.sign() > 0)) + if (!describe_pis && (art40 > ZERO || art40_iva > ZERO)) { _DescrItem* ads = new _DescrItem(PIM_ROW); ads->_s0 = ref; @@ -953,7 +953,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool _descr_arr.insert(ads, totpos++); } - if (!describe_pis && (autodafe.sign() > 0 || autodafe_iva.sign() > 0)) + if (!describe_pis && (autodafe > ZERO || autodafe_iva > ZERO)) { _DescrItem* ads = new _DescrItem(PIM_ROW); ads->_s0 = ref; @@ -1004,7 +1004,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool // aggiunge dati ptm _DescrItem* t = new _DescrItem(MISC_LIQ); - t->_f2 = atoi(_year) > 1997 ? describe_pis : TRUE; //isfirst; // per il form feed o meno alla fine + t->_f2 = describe_pis; //isfirst; // per il form feed o meno alla fine if (!describe_pis) { @@ -1051,8 +1051,12 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool t->_r14 += _plm->get_real("R15"); t->_r15 = _plm->get_real("R16"); // percentuale prorata 2 anni addietro } - t->_r11 += _plm->get_real("R2") - _plm->get_real("R14") - _plm->get_real("R15"); // pro-rata indetraibile sui doc. acq. anno attuale - // in caso di liq. annuale prende il totale (tutto R2) + + // pro-rata indetraibile sui doc. acq. anno attuale + // in caso di liq. annuale prende il totale (tutto R2) + t->_r11 += _plm->get_real("R2"); + t->_r11 -= _plm->get_real("R14") + _plm->get_real("R15"); + ad1 = real(ttm.get(1)); ad2 = real(ttm.get(2)); ad1 += _pom->get_real("R11"); @@ -2227,44 +2231,35 @@ void TLiquidazione_app::set_pumpam(const _DescrItem& d) { printed = TRUE; - if (yy > 1997) // prorata 1998 + real prc(dp.get(0)); + real rprc = CENTO - prc; + TString ss(rprc.string()); + + set_row(row++, FR("%% PRO-RATA (%s%%) ed IVA non detraibile (%s%%)@69g%r"), + (const char*) ss, (const char*)prc.string(), &(d._r11)); + yy-=2; + if (d._r13 != INVALID_PRORATA && d._r12 != ZERO) { - real prc(dp.get(0)); - real rprc = CENTO - prc; - TString ss(rprc.string()); - - set_row(row++, FR("%% PRO-RATA (%s%%) ed IVA non detraibile (%s%%)@69g%r"), - (const char*) ss, (const char*)prc.string(), &(d._r11)); - yy-=2; - if (d._r13 != INVALID_PRORATA && d._r12 != ZERO) - { - rprc = CENTO - d._r13; - ss = rprc.string(); - set_row(row++, FR("%% PRO-RATA %d (%s%%) ed IVA non detraibile (%s%%)@69g%r"), - yy, (const char*) ss, (const char*)d._r13.string(), &(d._r12)); - } - else - if (!_isfinal && d._r13 == INVALID_PRORATA_ASSERT) - set_row(row++, FR("Impossibile reperire la %% PRO-RATA relativa all'anno %d."), yy); - - yy--; - if (d._r15 != INVALID_PRORATA && d._r14 != ZERO) - { - rprc = CENTO - d._r15; - ss = rprc.string(); - set_row(row++, FR("%% PRO-RATA %d (%s%%) ed IVA non detraibile (%s%%)@69g%r"), - yy, (const char*) ss, (const char*)d._r15.string(), &(d._r14)); - } - else - if (!_isfinal && d._r15 == INVALID_PRORATA_ASSERT) - set_row(row++, FR("Impossibile reperire la %% PRO-RATA relativa all'anno %d."), yy); + rprc = CENTO - d._r13; + ss = rprc.string(); + set_row(row++, FR("%% PRO-RATA %d (%s%%) ed IVA non detraibile (%s%%)@69g%r"), + yy, (const char*) ss, (const char*)d._r13.string(), &(d._r12)); } else + if (!_isfinal && d._r13 == INVALID_PRORATA_ASSERT) + set_row(row++, FR("Impossibile reperire la %% PRO-RATA relativa all'anno %d."), yy); + + yy--; + if (d._r15 != INVALID_PRORATA && d._r14 != ZERO) { - real prc(dp.get(0)); - set_row(row++, FR("%% PRO-RATA ed IVA non detraibile (%s%%)@69g%r"), - (const char*)prc.string(), &(d._r11)); + rprc = CENTO - d._r15; + ss = rprc.string(); + set_row(row++, FR("%% PRO-RATA %d (%s%%) ed IVA non detraibile (%s%%)@69g%r"), + yy, (const char*) ss, (const char*)d._r15.string(), &(d._r14)); } + else + if (!_isfinal && d._r15 == INVALID_PRORATA_ASSERT) + set_row(row++, FR("Impossibile reperire la %% PRO-RATA relativa all'anno %d."), yy); } // items vari per dichiarazione annuale diff --git a/cg/cg4400.cpp b/cg/cg4400.cpp index c59a04779..119e31cb9 100755 --- a/cg/cg4400.cpp +++ b/cg/cg4400.cpp @@ -683,43 +683,39 @@ bool TStampa_registri_app::mask_cod (TMask_field& f, KEY k) return true; } -bool TStampa_registri_app::mask_data (TMask_field& f, KEY k) +bool TStampa_registri_app::mask_data(TMask_field& f, KEY k) { if (k == K_TAB && f.mask().is_running()) { - const int anno = f.mask().get_int(ANNO); - TDate data(f.get()); - if (data.ok()) - if (data.year() != anno) - { - f.warning_box(TR("L'anno delle date limite deve essere uguale all'anno iva specificato")); - return false; - } - if (f.dlg() == A_DATA) - if (data.ok()) - { - if ( data.day() == 31 && data.month() == 12 ) - f.mask().show (TIPO_RIEPILOGATIVO); - else f.mask().hide (TIPO_RIEPILOGATIVO); - } + const TDate data(f.get()); + if (data.ok()) + { + TMask& m = f.mask(); + const int anno = m.get_int(ANNO); + if (data.year() != anno) + return f.warning_box(FR("L'anno delle date limite deve essere %d"), anno); + if (f.dlg() == A_DATA) + m.show (TIPO_RIEPILOGATIVO, data.day() == 31 && data.month() == 12); + } } return true; } -bool TStampa_registri_app::year_handler(TMask_field& f, KEY key) +bool TStampa_registri_app::year_freq_handler(TMask_field& f, KEY key) { if (key == K_TAB && f.focusdirty()) - { - app().set_year(atoi(f.get())); - const int freq = f.mask().get_int(F_FREQUENZA); - app().build_ditte_sheet(freq); + { + TMask& m = f.mask(); + app().set_year(m.get_int(ANNO)); + const int freq = m.get_int(F_FREQUENZA); + app().build_ditte_sheet(freq); + app().set_choice_limits(m); } return true; } void TStampa_registri_app::build_ditte_sheet(int flags) { - TWait_cursor hourglass; if (_nomiditte.empty()) build_nomiditte(); @@ -733,9 +729,10 @@ void TStampa_registri_app::build_ditte_sheet(int flags) // build sheet _ditte->destroy(); _ditte->enable_row(-1); + long good_one = -1; for (int i = 0; i < _nomiditte.items(); i++) { - TToken_string d = (const TToken_string&)_nomiditte[i]; + TToken_string d = _nomiditte.row(i); const char vers = d.get_char(2); if ((flags == 0x1 && vers != 'M') || (flags == 0x2 && vers != 'T')) continue; @@ -748,9 +745,15 @@ void TStampa_registri_app::build_ditte_sheet(int flags) { const long ditta = d.get_long(1); if (sel[ditta]) - _ditte->check(i); + _ditte->check(pos); // Ripristino eventuale selezione precedente + if (good_one == -1) + good_one = pos; else + if (good_one >= 0) + good_one = -2; } - } + } + if (good_one >= 0 && !_ditte->one_checked()) + _ditte->check(good_one); } // --------- handlers per selezione ditte @@ -767,16 +770,15 @@ bool TStampa_registri_app::to_ditt_handler(TMask_field& f, KEY key) sh->disable(DLG_USER); if (sh->run() == K_ENTER) { - app().select_firm_range(m.get_long(DA_CODICE),sh->row(sh->selected()).get_long(1)); - app().set_choice_limits(m); + m.set(A_CODICE, sh->row(sh->selected()).get_long(1)); + key = K_TAB; } sh->enable(DLG_USER); } if (key == K_TAB && f.focusdirty()) { - const long l = app().select_firm_range(m.get_long(DA_CODICE), m.get_long(A_CODICE)); + app().select_firm_range(m.get_long(DA_CODICE), m.get_long(A_CODICE)); app().set_choice_limits(m); - m.set(F_SELECT, l); } return true; } @@ -793,34 +795,30 @@ bool TStampa_registri_app::fr_ditt_handler(TMask_field& f, KEY key) sh->disable(DLG_USER); if (sh->run() == K_ENTER) { - app().select_firm_range(sh->row(sh->selected()).get_long(1), m.get_long(A_CODICE)); - app().set_choice_limits(m); + m.set(DA_CODICE, sh->row(sh->selected()).get_long(1)); + key = K_TAB; } sh->enable(DLG_USER); - } - else if (key == K_TAB && f.focusdirty()) + } + if (key == K_TAB && f.focusdirty()) { - const long l = app().select_firm_range(m.get_long(DA_CODICE), m.get_long(A_CODICE)); + app().select_firm_range(m.get_long(DA_CODICE), m.get_long(A_CODICE)); app().set_choice_limits(m); - m.set(F_SELECT, l); } return true; } void TStampa_registri_app::set_choice_limits(TMask& m) { - long first = -1l, last = -1l; - for (int i = 0; i < _ditte->items(); i++) + long first = 0, last = 0; + FOR_EACH_CHECKED_ROW(*_ditte, i, riga) { - if (_ditte->checked(i)) - { - const long dit = _ditte->row(i).get_long(1); - if (first < 0) first = dit; - if (last < dit) last = dit; - } + const long dit = riga->get_long(1); + if (first <= 0) first = dit; + if (last < dit) last = dit; } - if (first > 0) m.set(DA_CODICE, first); - if (last > 0) m.set(A_CODICE, last); + m.set(DA_CODICE, first); + m.set(A_CODICE, last); m.set(F_SELECT, _ditte->checked()); if (m.is_running() && first > 0) app().set_firm(first); @@ -848,7 +846,7 @@ long TStampa_registri_app::select_firm_range(long from, long to) return _ditte->checked(); } -void TStampa_registri_app::build_nomiditte(TProgind* pnd) +void TStampa_registri_app::build_nomiditte() { _nomiditte.destroy(); @@ -870,28 +868,32 @@ void TStampa_registri_app::build_nomiditte(TProgind* pnd) d->add(freq); _nomiditte.add(d); } - _n_ditte = _nomiditte.items(); } bool TStampa_registri_app::set_ditte(TMask& m) { - m.field(TIPO_STAMPA).set("1"); - m.field(DA_DATA).set(""); - m.field(A_DATA).set(""); - m.field(CODICE_LIBRO_PROVA).set(""); + m.set(TIPO_STAMPA, 1); + m.reset(DA_DATA); + m.reset(A_DATA); + m.reset(CODICE_LIBRO_PROVA); - KEY tasto; - do + KEY tasto = K_SPACE; + while (tasto != K_ENTER && tasto != K_QUIT) { tasto = m.run(); if (tasto == DLG_SELECT) { _ditte->enable_check(); - // seleziona e aggiungi alle gia' selezionate + // seleziona e aggiungi alle già selezionate if (_ditte->run() == K_ENTER) + { + const long sel = _ditte->selected(); + if (sel >= 0 && _ditte->row_enabled(sel) && !_ditte->checked(sel)) + _ditte->check(sel); set_choice_limits(m); + } } - } while (tasto != K_ENTER && tasto != K_QUIT); + } return tasto == K_ENTER; } @@ -908,13 +910,12 @@ bool TStampa_registri_app::user_create() _cur = new TSorted_cursor(_rel, "DATAREG|PROTIVA|NUMREG","", 2); _ditte = new TArray_sheet(-1, 4, -4, -4, TR("Selezione Ditte"), HR("@1|Cod.@5R|Ragione Sociale@50|Vers.")); - _n_ditte = 0l; __firm = TApplication::get_firm(); - TDate oggi(TODAY); - _annoes = oggi.year(); - + const TDate oggi(TODAY); + _annoes = oggi.year(); // Anno per frequenza IVA ditte build_ditte_sheet(0x3); + add_cursor(_cur); add_file(LF_MOV); add_file(LF_RMOVIVA); @@ -1286,6 +1287,7 @@ int TStampa_registri_app::stampa_prospetto(int rr, bool print_prec) riga << TR("; 4=liquidazione differita"); if (has_module(ICAUT)) riga << TR("; 5=IVA per cassa"); + riga << TR("; 6=Scissione pagamenti art.17 ter"); set_row(rr++, riga); _stampa = _st_tot_fin; @@ -2054,7 +2056,7 @@ bool TStampa_registri_app::print_IVAxCassa(int da_month, int a_month) riga.put(id.get("MOV.NUMDOC").as_string(), 24); riga.put(format("%6ld", id.get("CLIFO.CODCF").as_int()), 31); riga.put(clifo.get(), 38); - riga.put(tipodiff == 2 ? "5" : "4", 66); // 4 = Differita; 5 = x Cassa + riga.put(tipodiff == 2 ? "5" : "4", 66); // 4 = Differita; 5 = x Cassa; riga.put(id.get("MOV.TIPODOC").as_string(), 68); print_real(riga, importo, 70); print_real(riga, imponibile, 85); @@ -2302,8 +2304,10 @@ bool TStampa_registri_app::preprocess_page(int file, int counter) TString4 codval = mov.get(MOV_CODVALI); real corrval = mov.get_real(MOV_CORRVALUTA); const bool autof = caus.get_bool(CAU_AUTOFATT); - const bool liqdiff = mov.get_bool(MOV_LIQDIFF); - const bool IVAxcassa= !liqdiff && mov.get_bool(MOV_IVAXCASSA); + + const bool splitpay = tipocf == 'C' && is_split_payment(mov.curr()); + const bool liqdiff = !splitpay && mov.get_bool(MOV_LIQDIFF); + const bool IVAxcassa= !splitpay && !liqdiff && mov.get_bool(MOV_IVAXCASSA); TString80 descrcau = caus.get(CAU_DESCR); @@ -2532,15 +2536,22 @@ bool TStampa_registri_app::preprocess_page(int file, int counter) { _auto_intraf = true; tipo_op = "3"; - } - else if (intra) - tipo_op = "1"; - else if (autof) - tipo_op = "2"; - else if (liqdiff) - tipo_op = "4"; - else if (IVAxcassa) - tipo_op = "5"; + } else + if (intra) + tipo_op = "1"; else + if (autof) + tipo_op = "2"; else + if (splitpay) + { + tipo_op = "6"; + } + else + { + if (liqdiff) + tipo_op = "4"; else + if (IVAxcassa) + tipo_op = "5"; + } set_row(_r, "@66g%s", (const char*)tipo_op); @@ -3353,7 +3364,8 @@ bool TStampa_registri_app::setta_mask(long i) if (_u_data.ok()) mb.set(U_DATA, _u_data.string()); KEY tasto = mb.run(); - if (tasto != K_ENTER) return false; + if (tasto != K_ENTER) + return false; //MI3213 _pagine_stampate = mb.get_long(U_PAGINA); _numini = _pagine_stampate; @@ -3612,8 +3624,8 @@ bool TStampa_registri_app::set_print(int n) m.set_handler (F_ANNULLA, mask_azzera); m.set_handler (A_CODICE, to_ditt_handler); m.set_handler (DA_CODICE, fr_ditt_handler); - m.set_handler (ANNO, year_handler); - m.set_handler (F_FREQUENZA, year_handler); + m.set_handler (ANNO, year_freq_handler); + m.set_handler (F_FREQUENZA, year_freq_handler); m.set(DA_CODICE, get_firm()); m.set(A_CODICE, get_firm(), 0x3); diff --git a/cg/cg4400.h b/cg/cg4400.h index 148187cf2..b1f895ec5 100755 --- a/cg/cg4400.h +++ b/cg/cg4400.h @@ -41,7 +41,7 @@ class TStampa_registri_app : public TPrintapp TTipodoc_array _doc_array; TRiga_array _tot_iva_array, _tot_prec_iva_array; TArray_sheet *_ditte; - TArray _nomiditte; + TString_array _nomiditte; tiporeg _tipo_reg; bool _st_liq[13]; bool _test; @@ -54,7 +54,7 @@ class TStampa_registri_app : public TPrintapp char _frequiva, _tipo_riepilogativo, _freq_riepilogo; TDate _data_da, _data_a, _data_stampa, _dataregp, _dataregs, _datareg; TDate _u_data; - long _n_ditte, _u_stampata, _primast, __firm, _uprotivap, _ditta; + long _u_stampata, _primast, __firm, _uprotivap, _ditta; long _numini, _pagine_stampate; int _fino_a_mese, _cod_un_loc; int _annoes, _r, _stampa_width, _mese_ultima_liq, _mese_credito; @@ -84,7 +84,7 @@ protected: static bool mask_mese (TMask_field&, KEY); static bool mask_fino_a_mese (TMask_field&, KEY); static bool mask_azzera (TMask_field&, KEY); - static bool year_handler (TMask_field&, KEY); + static bool year_freq_handler(TMask_field&, KEY); public: @@ -148,8 +148,8 @@ public: bool some_IVAxCassa(int da_month, int a_month) const; // C'e' IVA per cassa o differita da stampare? bool print_IVAxCassa(int da_month, int a_month); - void build_nomiditte(TProgind* pnd = NULL); - void set_year(int y) { _annoes = y; } + void build_nomiditte(); + void set_year(int y) { if (_annoes != y) { _annoes = y; build_nomiditte(); } } void clear_stliq(); virtual bool preprocess_print(int, int); virtual bool user_create(); diff --git a/cg/cg5500d.uml b/cg/cg5500d.uml index 6afc1f403..37404e554 100755 --- a/cg/cg5500d.uml +++ b/cg/cg5500d.uml @@ -60,7 +60,7 @@ BEGIN ITEM "13|Annuale" END -BROWSEFILE F_VISFLQ -3 -1 +BROWSEFILE F_VISFLQ -3 12 BEGIN PROMPT 0 4 "" END diff --git a/cg/cg5700.cpp b/cg/cg5700.cpp index 71db98106..0c272b2d5 100755 --- a/cg/cg5700.cpp +++ b/cg/cg5700.cpp @@ -211,25 +211,22 @@ public: TDich_periodica_iva_form::TDich_periodica_iva_form(int anno) : TForm("cg5700a") { - if (anno > 2000) + TPrint_section& b = section('B', odd_page); + TString p; + for (int i = b.fields()-1; i > 0; i--) { - TPrint_section& b = section('B', odd_page); - TString p; - for (int i = b.fields()-1; i > 0; i--) - { - TForm_item& f = b.field(i); - p = f.prompt(); - if (change_prompt(p, anno)) - f.set_prompt(p); - } + TForm_item& f = b.field(i); + p = f.prompt(); + if (change_prompt(p, anno)) + f.set_prompt(p); } } class TDich_periodica_iva_mask : public TAutomask { TDich_periodica_selfirm_mask * _sf; - bool _dirty_versament, // Sporco versamento... - _is_euro; // importi in euro + bool _dirty_versament; // Sporco versamento... + protected: void read_iva_data(); real imposta_diff(int tipo) const; @@ -286,13 +283,8 @@ real TDich_periodica_iva_mask::imposta_diff(int tipo) const void TDich_periodica_iva_mask::read_iva_data() { - - TString16 key; - - key.format("%4d13", _sf->get_year()); - - - const TRectype & lim = cache().get("LIM", key); + TString8 key; key.format("%4d13", _sf->get_year()); + const TRectype& lim = cache().get("LIM", key); if (lim.get_bool("B0")) { @@ -319,19 +311,16 @@ void TDich_periodica_iva_mask::read_iva_data() real cd3_4 = ZERO; TRelation relpum("PUM"); - TRectype & pum = relpum.curr(); - + TRectype& pum = relpum.curr(); key.format("%04d",_sf->get_year()); - pum.put("CODTAB", key); TCursor cur(&relpum, "", 1, &pum, &pum); - const TRecnotype items = cur.items(); + const TRecnotype items = cur.items(); cur.freeze(); for (cur = 0L; cur.pos() < items; ++cur) { - const TString& codtab = pum.get("CODTAB"); - + const TString& codtab = pum.get("CODTAB"); const TString& annoiva = codtab.left(4); if (annoiva != key) break; diff --git a/cg/cg6600.cpp b/cg/cg6600.cpp index 9909f9a7d..f230bc10c 100755 --- a/cg/cg6600.cpp +++ b/cg/cg6600.cpp @@ -79,7 +79,7 @@ public: void ricevi_movPN(const TString& key, char sigla); void scrivi_righePN(long numreg); void ricevi_movIVA(const TString& key, char sigla); - void scrivi_righeIVA(long numreg); + bool scrivi_righeIVA(long numreg); void ricevi_movSC(TString& key,char sigla); long esiste_numreg(long nreg); void num_protocollo(); @@ -1217,24 +1217,36 @@ bool TRic_tab::occasionali(TString& ocfpi) return err == NOERR; } -void TRic_tab::scrivi_righeIVA(long numreg) +bool TRic_tab::scrivi_righeIVA(long numreg) { - _triva->setkey(1); - _triva->zero(); - _triva->put(RMI_NUMREG, numreg); - - for (_triva->read(); !_triva->eof(); _triva->next()) + if (_triva) { - if (_triva->get_long(RMI_NUMREG) != numreg) - break; - _triva->put(RMI_NUMREG, _nuovareg); - _rmoviva->curr() = _triva->curr(); - _rmoviva->write(); + _triva->setkey(1); + _triva->zero(); + _triva->put(RMI_NUMREG, numreg); + + for (_triva->read(); !_triva->eof(); _triva->next()) + { + if (_triva->get_long(RMI_NUMREG) != numreg) + break; + _triva->put(RMI_NUMREG, _nuovareg); + _rmoviva->curr() = _triva->curr(); + _rmoviva->write(); + } } + else + return cantread_box(_tmpriva); + return true; } void TRic_tab::ricevi_movIVA(const TString& key, char uselab) -{ +{ + if (_triva == NULL) + { + cantread_box(_tmpriva); + return; + } + const char flag = _tras_file.flg_agg(uselab); _tmov->setkey(1); diff --git a/cg/cg6700.cpp b/cg/cg6700.cpp index f2f330a5c..3f818917b 100755 --- a/cg/cg6700.cpp +++ b/cg/cg6700.cpp @@ -670,8 +670,6 @@ bool TRic_ListaMov::controlla_mov() bool TRic_ListaMov::errori_partita(int g, int c, long s) { TLocalisamfile pconti (LF_PCON); - pconti.setkey(1); - pconti.zero(); pconti.put(PCN_GRUPPO, g); pconti.put(PCN_CONTO, c); pconti.put(PCN_SOTTOCONTO, 0L); @@ -681,8 +679,6 @@ bool TRic_ListaMov::errori_partita(int g, int c, long s) if (tipo == 'C' || tipo == 'F') { TLocalisamfile clifo (LF_CLIFO); - clifo.setkey(1); - clifo.zero(); clifo.put(CLI_TIPOCF, tipo); clifo.put(CLI_CODCF, s); if (clifo.read() != NOERR) @@ -690,7 +686,6 @@ bool TRic_ListaMov::errori_partita(int g, int c, long s) } else { - pconti.zero(); pconti.put(PCN_GRUPPO, g); pconti.put(PCN_CONTO, c); pconti.put(PCN_SOTTOCONTO, s); @@ -698,7 +693,8 @@ bool TRic_ListaMov::errori_partita(int g, int c, long s) return FALSE; } } - else return FALSE; + else + return FALSE; return TRUE; } @@ -842,8 +838,7 @@ void TRic_ListaMov::stampa_errori_rmov(int riga) } } - if ( (_importo != ZERO && _sezione == '\0') || - (_sezione != 'D' && _sezione != 'A' && _sezione != '\0') ) + if (!_importo.is_zero() && _sezione != 'D' && _sezione != 'A') { _errore_grave = TRUE; set_row(++riga, FR("@8g*** Segnale dare/avere non valido")); @@ -861,7 +856,7 @@ void TRic_ListaMov::stampa_errori_rmov(int riga) set_row(++riga, FR("@8g--- Sottoconto contropartita non valido o non presente in archivio")); } - if (!_mov_sez && _importo == ZERO) + if (!_mov_sez && _importo.is_zero()) set_row(++riga, FR("@8g--- Importo riga uguale a zero")); } diff --git a/cg/cglib01.cpp b/cg/cglib01.cpp index 8bc7ea241..5024fafd1 100755 --- a/cg/cglib01.cpp +++ b/cg/cglib01.cpp @@ -558,10 +558,9 @@ real TRegistro::prorata(int annodoc) void TRegistro::set_prorata(int annodoc, const real& pro) { const int annoiva = year(); - if (annodoc <= 1900) annodoc = annoiva; // Test per anno documento non specificato - const int annopro = annoiva >= 1998 && annodoc < annoiva ? annodoc+1 : annoiva; - - TString16 chiave; chiave << annopro; + if (annodoc <= 2000) annodoc = annoiva; // Test per anno documento non specificato + const int annopro = annodoc < annoiva ? annodoc+1 : annoiva; + TString4 chiave; chiave << annopro; _prorata.add(chiave, pro, TRUE); } @@ -934,7 +933,7 @@ bool TBill::find() { TString16 key; key.format("%c|%ld", _tipo, _sottoconto); - const TRectype & clifo = cache().get(LF_CLIFO, key); + const TRectype& clifo = cache().get(LF_CLIFO, key); ok = !clifo.empty(); if (ok) { diff --git a/cg/cglib03.cpp b/cg/cglib03.cpp index 2378b43c9..c2572e152 100755 --- a/cg/cglib03.cpp +++ b/cg/cglib03.cpp @@ -1,405 +1,476 @@ -#include "cg2103.h" -#include "cglib03.h" - -#include -#include -#include - -#include -#include - -static int codind2tipodet(const TString & codind, real& perc) -{ - int tipodet = 0; - perc = ZERO; - if (codind.full()) - { - const TRectype& rec = cache().get("%DET", codind); - if (rec.empty()) - { - if (strchr("139", codind[0]) != NULL) // Clausola di salvaguardia - { - tipodet = codind[0]-'0'; - perc = CENTO; - } - } - else - { - tipodet = rec.get_int("I0"); - if (tipodet > 0) - perc = rec.get_real("R0"); - } - } - return tipodet; -} - -real indetraibile_al(const TString& codind, const TCausale& caus, int /*annodoc*/, int & tipodet,const bool is_liq) -{ - real perc; - - switch (caus.iva()) - { - case iva_acquisti: - case nessuna_iva: - case iva_errata: -#ifdef PRORATA100 - if (!is_liq && caus.reg().prorata100(annodoc)) // Se prorata = 100% e' indetraibile - { - perc = CENTO; - tipodet = 9; - } - else -#endif - tipodet = codind2tipodet(codind, perc); - break; - default: - tipodet = 0; // Vendite sempre detraibili - break; - } - - return perc; -} - -int analizza_IVA(const real& imptot, const real& ivatot, const real perc_ind, - const bool corrispettivo, const bool iva_ind_al_costo, const TString& codiva, - real& imp_det, real& iva_det, real& imp_ind, real& iva_ind) -{ - int flag = 0; - - if (perc_ind <= ZERO) - { - flag = 1; - imp_det = imptot; - iva_det = ivatot; - if (corrispettivo && iva_det.is_zero()) - { - const TCodiceIVA iva(codiva); - iva_det = iva.scorpora(imp_det); - } - imp_ind = iva_ind = ZERO; - } - else - { - if (perc_ind >= CENTO) - { - flag = 2; - imp_ind = imptot; - iva_ind = ivatot; - imp_det = iva_det = ZERO; - } - else - { - flag = 3; - const int decimali = TCurrency::get_firm_dec(); - imp_ind = imptot * perc_ind / CENTO; imp_ind.round(decimali); - imp_det = imptot - imp_ind; - - const TCodiceIVA iva(codiva); - iva_ind = iva.imposta(imp_ind, decimali); - iva_det = ivatot - iva_ind; - } - if (iva_ind_al_costo && !iva_ind.is_zero()) - { - imp_ind += iva_ind; - iva_ind = ZERO; - } - } - - return flag; -} - -bool gestione_IVAxCassa(const TDate& data, long firm) -{ - int anno = data.year(); - if (anno <= 0) - anno = TDate(TODAY).year(); - bool yes = anno >= 2012 && dongle().active(ICAUT) && dongle().active(SCAUT); - if (yes) - { - if (firm <= 0) - firm = prefix().get_codditta(); - TString16 codtab; - codtab.format("%05ld%04d", firm, anno); - const TRectype& lia = cache().get("%LIA", codtab); - yes = lia.get_bool("B5"); - if (yes) - { - TDate dal = lia.get("D0"); if (dal.year() != anno) dal = TDate( 1, 1,anno); - TDate al = lia.get("D1"); if (al.year() != anno) al = TDate(31,12,anno); - yes = data >= dal && data <= al; - } - } - return yes; -} - -// Anticamente TIPODET conteneva in tipo di indetraibilita, -// ora invece trattasi di un codice di indetraibilità -// associato ad un motivo ed una percentuale di indetraibilita' -int get_tipodet_from_rmi(const TRectype& rmi, const TRectype& mov,real& percind, const bool is_liq) -{ - const int annodoc = mov.get_date(MOV_DATAREG).year(); - const TCausale caus(mov.get(MOV_CODCAUS), annodoc); - - int tipodet = 0; - percind = indetraibile_al(rmi.get(RMI_TIPODET), caus, annodoc, tipodet, is_liq); - - return tipodet; -} - -/////////////////////////////////// -// classe TInteressi_IVA_table // -// per la lettura versamenti e // -// e interessi IVA dalla tabella // -/////////////////////////////////// - -TInteressi_IVA_table::TInteressi_IVA_table() : TTable("%VER") -{ -} - -TInteressi_IVA_table::~TInteressi_IVA_table() -{ -} - -int TInteressi_IVA_table::read(int anno, int mese) -{ - TString8 k; k.format("%04d%02d",anno,mese); - zero(); put("CODTAB",k); - if (TTable::read(_isgteq) == NOERR) - { - const TString& cod = TTable::get("CODTAB"); - if (cod > k && prev() != NOERR) - zero(); - } - else - if (last() != NOERR) - zero(); - return status(); -} - -real TInteressi_IVA_table::get(int what) -{ - TString4 fieldname; - fieldname.format("R%d", what); - return get_real(fieldname); -} - -/////////////////////////////////////////////// -// TRigaiva_array -// Tabella per il calcolo degli imponibili Iva -/////////////////////////////////////////////// - -const TString& TRigaiva::descr_det() const -{ - TString& rig = get_tmp_string(); - switch (_tipodet) - { - case 1 : rig = TR("Indetraib. su op.es."); break; - case 3 : rig = TR("Passaggi interni"); break; - case 9 : rig = TR("Indetraibile art.19"); break; - default: rig = TR("Detraibile"); break; - } - return rig; -} - -bool TRigaiva_array::add_riga(const real& imponibile, const real& imposta, - const real& imponibilep, const real& impostap, - const char* codiva, int tipodet, int tipocr, - bool intra, int tipoatt) -{ - int i; - for (i = items()-1; i >= 0; i--) - { - TRigaiva& r = riga(i); - if (r._codiva==codiva && r._tipodet==tipodet && r._tipocr==tipocr && r._tipoatt==tipoatt) - { - r._imponibile += imponibile; - r._imposta += imposta; - r._imponibilep += imponibilep; - r._impostap += impostap; - break; - } - } - if (i < 0) - { - TRigaiva* r = new TRigaiva(imponibile,imposta,imponibilep,impostap,codiva,tipodet,tipocr,intra,tipoatt); - add(r); - } - return i >= 0; -} - -bool TRigaiva_array::add_riga(const TRectype& iva) -{ - const real impo = iva.get_real(RMI_IMPONIBILE); - const real impos = iva.get_real(RMI_IMPOSTA); - bool ok = !impo.is_zero() || !impos.is_zero(); - if (ok) - { - real percind; - const TString& codind = iva.get(RMI_TIPODET); - const int tipodet = codind2tipodet(codind, percind); - const TString4 codiva = iva.get(RMI_CODIVA); - const int tipocr = iva.get_int (RMI_TIPOCR); - const bool intra = iva.get_bool(RMI_INTRA); - const int tipoatt = iva.get_int (RMI_TIPOATT); - - if (percind > ZERO && percind < CENTO) - { - const int dec = TCurrency::get_firm_dec(); - real impo_ind = impo * percind / CENTO; impo_ind.round(dec); - const real impo_det = impo - impo_ind; - - const TCodiceIVA iva(codiva); - - real impos_ind = iva.imposta(impo_ind, dec); - const real impos_det = impos - impos_ind; - - ok = add_riga(impo_det,impos_det,ZERO,ZERO,codiva,0,tipocr,intra,tipoatt); - ok &= add_riga(impo_ind,impos_ind,ZERO,ZERO,codiva,tipodet,tipocr,intra,tipoatt); - } - else - { - ok = add_riga(impo,impos,ZERO,ZERO,codiva,tipodet,tipocr,intra,tipoatt); - } - } - return ok; -} - -/////////////////////////////////////////////// -// TRiga_array -/////////////////////////////////////////////// - -bool TRiga_array::add_riga(const real& imponibile, const real& imposta, const real& implordo, - const real& imponibilep, const real& impostap, const real& implordop, - const char* codiva) -{ - bool found = false; - for (int i = 0; i < items(); i++) - { - TRiga& r = riga(i); - if (r._codiva==codiva) - { - found = true; - r._imponibile += imponibile; - r._imposta += imposta; - r._implordo += implordo; - r._imponibilep += imponibilep; - r._impostap += impostap; - r._implordop += implordop; - break; - } - } - if (!found) - { - TRiga* r = new TRiga(imponibile,imposta,implordo,imponibilep,impostap,implordop,codiva); - add(r); - } - return found; -} - -/////////////////////////////////////////////// -// TDociva_array -/////////////////////////////////////////////// - -bool TDociva_array::add_riga(const char* _descrdociva, const real& _importo,const int _natdoc) -{ - bool found = false; - for (int i = 0; i < items(); i++) - { - TDociva& r = riga(i); - if (r._descrdoc==_descrdociva) - { - found = true; - if ((r._ndoc == 1)||(r._ndoc == 2)||(r._ndoc == 9))//||(r._ndoc == 4)) - r._totdociva += _importo; - } - } - if (!found) - { - if ((_natdoc == 1)||(_natdoc == 2)||(_natdoc == 9))//||(_natdoc == 4)) - { - TDociva* r = new TDociva(_descrdociva,_importo,_natdoc); - add(r); - } - } - return found; -} - -bool TTipodoc_array::add_riga(const char* tipodoc, const char* descrdoc, const real& totdoc) -{ - bool found = false; - for (int i = 0; i < items(); i++) - { - TTipodoc& r = (TTipodoc&)(*this)[i]; - if (r._tipodoc==tipodoc) - { - found = true; - r._totdoc += totdoc; - } - } - if (!found) - { - TTipodoc* r = new TTipodoc(tipodoc,descrdoc,totdoc); - add(r); - } - return found; -} - -/////////////////////////////////////////////////////////// -// Arrotondamenti iva -/////////////////////////////////////////////////////////// - -TRound_mode TIva_round::_def_mode = rm_unknown; -int TIva_round::_def_decimals = 0; - -void TIva_round::set_default_mode(TRound_mode m, int d) -{ - _def_mode = _mode = m; - _def_decimals = _decimals = d; -} - -void TIva_round::set_mode(TRound_mode m, int d) -{ - _mode = m; - _decimals = d; -} - -void TIva_round::set_default_iva_mode(int year, bool declaration, long ditta) -{ - if (year < 1990) - year = TDate(TODAY).year(); - - if (year >= 2002 && is_euro_value(NULL)) - { - if (ditta <= 0) - ditta = prefix().get_codditta(); - TString16 key; key.format("%05ld%04d", ditta, year); - const TRectype& lia = cache().get("%LIA", key); - const int dec = lia.get_int(declaration ? "I2" : "I1"); - set_default_mode(rm_round, dec); - } - else - set_default_mode(rm_millelire, -3); -} - -void TIva_round::round(real& n) const -{ - CHECK(_mode != rm_unknown, "Non è stato impostato il metodo di arrotondamento"); - switch (_mode) - { - case rm_ceil: - n.ceil(_decimals); - break; - case rm_millelire: - n -= 0.0001; // Le 500 lire vanno arrontondate per difetto - default: - n.round(_decimals); - break; - } -} - -TIva_round::TIva_round() -{ - _mode = _def_mode; - _decimals = _def_decimals; -} - +#include "cg2103.h" +#include "cglib03.h" + +#include +#include +#include + +#include +#include +#include +#include +#include + +static int codind2tipodet(const TString & codind, real& perc) +{ + int tipodet = 0; + perc = ZERO; + if (codind.full()) + { + const TRectype& rec = cache().get("%DET", codind); + if (rec.empty()) + { + if (strchr("139", codind[0]) != NULL) // Clausola di salvaguardia + { + tipodet = codind[0]-'0'; + perc = CENTO; + } + } + else + { + tipodet = rec.get_int("I0"); + if (tipodet > 0) + perc = rec.get_real("R0"); + } + } + return tipodet; +} + +real indetraibile_al(const TString& codind, const TCausale& caus, int /*annodoc*/, int & tipodet,const bool is_liq) +{ + real perc; + + switch (caus.iva()) + { + case iva_acquisti: + case nessuna_iva: + case iva_errata: +#ifdef PRORATA100 + if (!is_liq && caus.reg().prorata100(annodoc)) // Se prorata = 100% e' indetraibile + { + perc = CENTO; + tipodet = 9; + } + else +#endif + tipodet = codind2tipodet(codind, perc); + break; + default: + tipodet = 0; // Vendite sempre detraibili + break; + } + + return perc; +} + +int analizza_IVA(const real& imptot, const real& ivatot, const real perc_ind, + const bool corrispettivo, const bool iva_ind_al_costo, const TString& codiva, + real& imp_det, real& iva_det, real& imp_ind, real& iva_ind) +{ + int flag = 0; + + if (perc_ind <= ZERO) + { + flag = 1; + imp_det = imptot; + iva_det = ivatot; + if (corrispettivo && iva_det.is_zero()) + { + const TCodiceIVA iva(codiva); + iva_det = iva.scorpora(imp_det); + } + imp_ind = iva_ind = ZERO; + } + else + { + if (perc_ind >= CENTO) + { + flag = 2; + imp_ind = imptot; + iva_ind = ivatot; + imp_det = iva_det = ZERO; + } + else + { + flag = 3; + const int decimali = TCurrency::get_firm_dec(); + imp_ind = imptot * perc_ind / CENTO; imp_ind.round(decimali); + imp_det = imptot - imp_ind; + + const TCodiceIVA iva(codiva); + iva_ind = iva.imposta(imp_ind, decimali); + iva_det = ivatot - iva_ind; + } + if (iva_ind_al_costo && !iva_ind.is_zero()) + { + imp_ind += iva_ind; + iva_ind = ZERO; + } + } + + return flag; +} + +bool gestione_IVAxCassa(const TDate& data_mov, long firm) +{ + const TDate data = data_mov.ok() ? data_mov : TDate(TODAY); + const int anno = data.year(); + bool yes = anno >= 2012 && dongle().active(ICAUT) && dongle().active(SCAUT); + if (yes) + { + if (firm <= 0) + firm = prefix().get_codditta(); + TString16 codtab; + codtab.format("%05ld%04d", firm, anno); + const TRectype& lia = cache().get("%LIA", codtab); + yes = lia.get_bool("B5"); + if (yes) + { + TDate dal = lia.get("D0"); if (dal.year() != anno) dal = TDate( 1, 1, anno); + TDate al = lia.get("D1"); if (al.year() != anno) al = TDate(31,12, anno); + yes = data >= dal && data <= al; + } + } + return yes; +} + +bool is_split_payment(const TRectype& mov) +{ + if (mov.get_char(MOV_TIPO) == 'C' && mov.get_int(MOV_ANNOIVA) >= 2015 && mov.get_real(MOV_RITFIS).is_zero()) + { + const TRectype& clifo = cache().get_rec(LF_CLIFO, "C", mov.get(MOV_CODCF)); + if (clifo.get_bool(CLI_SPLITPAY)) // Ente pubblico con split payment + { + const TRectype& rcs = cache().get(LF_CAUSALI, mov.get(MOV_CODCAUS)); + const int rsi = rcs.get_int(CAU_REGSPIVA); // Regime speciale IVA + if (rsi != 13 && rsi != 50 && rsi != 51) // No reverse charge! + return true; + } + } + return false; +} + +bool is_IVAxCassa(const TRectype& mov) +{ + if (mov.get_bool(MOV_LIQDIFF) || !mov.get_bool(MOV_IVAXCASSA) || mov.get_char(MOV_TIPO) < 'C') + return false; + + tipo_movimento tm = (tipo_movimento)mov.get_int(MOV_TIPOMOV); + if (tm == tm_nessuno) + { + const TString& tipodoc = mov.get(MOV_TIPODOC); + if (tipodoc == "FV" || tipodoc == "FA") + tm = tm_fattura; else + if (tipodoc == "NC") + tm = tm_nota_credito; + } + if (tm != tm_fattura && tm != tm_nota_credito) + return false; + + const TRectype& clifo = cache().get_rec(LF_CLIFO, mov.get(MOV_TIPO), mov.get(MOV_CODCF)); + int alleg = clifo.get_int(CLI_ALLEG); + if (alleg == 6) // privato? + { + TString16 paiv, cofi; + if (clifo.get_bool(CLI_OCCAS)) + { + const TRectype& occas = cache().get(LF_OCCAS, mov.get(MOV_OCFPI)); + paiv = occas.get(OCC_PAIV); + cofi = occas.get(OCC_COFI); + } + else + { + paiv = clifo.get(CLI_PAIV); + cofi = clifo.get(CLI_COFI); + } + if (paiv.full()) + alleg = 0; // Falso allarme: NON è un privato avendo partita IVA + } + if (alleg == 7 || (clifo.get_bool(CLI_SPLITPAY) && is_split_payment(mov))) + { + return false; + } + else + { + if (alleg == 5 || alleg == 6 || alleg == 9) // Niente IVA per cassa a privati o fallimentari + return false; + } + + const TDate data_reg = mov.get(MOV_DATAREG); + const TDate data_doc = mov.get(MOV_DATADOC); + const TDate data_rif = data_doc.ok() && data_doc < data_reg ? data_doc : data_reg; + return gestione_IVAxCassa(data_rif); +} + + +// Anticamente TIPODET conteneva in tipo di indetraibilita, +// ora invece trattasi di un codice di indetraibilità +// associato ad un motivo ed una percentuale di indetraibilita' +int get_tipodet_from_rmi(const TRectype& rmi, const TRectype& mov,real& percind, const bool is_liq) +{ + const int annodoc = mov.get_date(MOV_DATAREG).year(); + const TCausale caus(mov.get(MOV_CODCAUS), annodoc); + + int tipodet = 0; + percind = indetraibile_al(rmi.get(RMI_TIPODET), caus, annodoc, tipodet, is_liq); + + return tipodet; +} + +/////////////////////////////////// +// classe TInteressi_IVA_table // +// per la lettura versamenti e // +// e interessi IVA dalla tabella // +/////////////////////////////////// + +TInteressi_IVA_table::TInteressi_IVA_table() : TTable("%VER") +{ +} + +TInteressi_IVA_table::~TInteressi_IVA_table() +{ +} + +int TInteressi_IVA_table::read(int anno, int mese) +{ + TString8 k; k.format("%04d%02d",anno,mese); + zero(); put("CODTAB",k); + if (TTable::read(_isgteq) == NOERR) + { + const TString& cod = TTable::get("CODTAB"); + if (cod > k && prev() != NOERR) + zero(); + } + else + if (last() != NOERR) + zero(); + return status(); +} + +real TInteressi_IVA_table::get(int what) +{ + TString4 fieldname; + fieldname.format("R%d", what); + return get_real(fieldname); +} + +/////////////////////////////////////////////// +// TRigaiva_array +// Tabella per il calcolo degli imponibili Iva +/////////////////////////////////////////////// + +const TString& TRigaiva::descr_det() const +{ + TString& rig = get_tmp_string(); + switch (_tipodet) + { + case 1 : rig = TR("Indetraib. su op.es."); break; + case 3 : rig = TR("Passaggi interni"); break; + case 9 : rig = TR("Indetraibile art.19"); break; + default: rig = TR("Detraibile"); break; + } + return rig; +} + +bool TRigaiva_array::add_riga(const real& imponibile, const real& imposta, + const real& imponibilep, const real& impostap, + const char* codiva, int tipodet, int tipocr, + bool intra, int tipoatt) +{ + int i; + for (i = items()-1; i >= 0; i--) + { + TRigaiva& r = riga(i); + if (r._codiva==codiva && r._tipodet==tipodet && r._tipocr==tipocr && r._tipoatt==tipoatt) + { + r._imponibile += imponibile; + r._imposta += imposta; + r._imponibilep += imponibilep; + r._impostap += impostap; + break; + } + } + if (i < 0) + { + TRigaiva* r = new TRigaiva(imponibile,imposta,imponibilep,impostap,codiva,tipodet,tipocr,intra,tipoatt); + add(r); + } + return i >= 0; +} + +bool TRigaiva_array::add_riga(const TRectype& iva) +{ + const real impo = iva.get_real(RMI_IMPONIBILE); + const real impos = iva.get_real(RMI_IMPOSTA); + bool ok = !impo.is_zero() || !impos.is_zero(); + if (ok) + { + real percind; + const TString& codind = iva.get(RMI_TIPODET); + const int tipodet = codind2tipodet(codind, percind); + const TString4 codiva = iva.get(RMI_CODIVA); + const int tipocr = iva.get_int (RMI_TIPOCR); + const bool intra = iva.get_bool(RMI_INTRA); + const int tipoatt = iva.get_int (RMI_TIPOATT); + + if (percind > ZERO && percind < CENTO) + { + const int dec = TCurrency::get_firm_dec(); + real impo_ind = impo * percind / CENTO; impo_ind.round(dec); + const real impo_det = impo - impo_ind; + + const TCodiceIVA iva(codiva); + + real impos_ind = iva.imposta(impo_ind, dec); + const real impos_det = impos - impos_ind; + + ok = add_riga(impo_det,impos_det,ZERO,ZERO,codiva,0,tipocr,intra,tipoatt); + ok &= add_riga(impo_ind,impos_ind,ZERO,ZERO,codiva,tipodet,tipocr,intra,tipoatt); + } + else + { + ok = add_riga(impo,impos,ZERO,ZERO,codiva,tipodet,tipocr,intra,tipoatt); + } + } + return ok; +} + +/////////////////////////////////////////////// +// TRiga_array +/////////////////////////////////////////////// + +bool TRiga_array::add_riga(const real& imponibile, const real& imposta, const real& implordo, + const real& imponibilep, const real& impostap, const real& implordop, + const char* codiva) +{ + bool found = false; + for (int i = 0; i < items(); i++) + { + TRiga& r = riga(i); + if (r._codiva==codiva) + { + found = true; + r._imponibile += imponibile; + r._imposta += imposta; + r._implordo += implordo; + r._imponibilep += imponibilep; + r._impostap += impostap; + r._implordop += implordop; + break; + } + } + if (!found) + { + TRiga* r = new TRiga(imponibile,imposta,implordo,imponibilep,impostap,implordop,codiva); + add(r); + } + return found; +} + +/////////////////////////////////////////////// +// TDociva_array +/////////////////////////////////////////////// + +bool TDociva_array::add_riga(const char* _descrdociva, const real& _importo,const int _natdoc) +{ + bool found = false; + for (int i = 0; i < items(); i++) + { + TDociva& r = riga(i); + if (r._descrdoc==_descrdociva) + { + found = true; + if ((r._ndoc == 1)||(r._ndoc == 2)||(r._ndoc == 9))//||(r._ndoc == 4)) + r._totdociva += _importo; + } + } + if (!found) + { + if ((_natdoc == 1)||(_natdoc == 2)||(_natdoc == 9))//||(_natdoc == 4)) + { + TDociva* r = new TDociva(_descrdociva,_importo,_natdoc); + add(r); + } + } + return found; +} + +bool TTipodoc_array::add_riga(const char* tipodoc, const char* descrdoc, const real& totdoc) +{ + bool found = false; + for (int i = 0; i < items(); i++) + { + TTipodoc& r = (TTipodoc&)(*this)[i]; + if (r._tipodoc==tipodoc) + { + found = true; + r._totdoc += totdoc; + } + } + if (!found) + { + TTipodoc* r = new TTipodoc(tipodoc,descrdoc,totdoc); + add(r); + } + return found; +} + +/////////////////////////////////////////////////////////// +// Arrotondamenti iva +/////////////////////////////////////////////////////////// + +TRound_mode TIva_round::_def_mode = rm_unknown; +int TIva_round::_def_decimals = 0; + +void TIva_round::set_default_mode(TRound_mode m, int d) +{ + _def_mode = _mode = m; + _def_decimals = _decimals = d; +} + +void TIva_round::set_mode(TRound_mode m, int d) +{ + _mode = m; + _decimals = d; +} + +void TIva_round::set_default_iva_mode(int year, bool declaration, long ditta) +{ + if (year < 1990) + year = TDate(TODAY).year(); + + if (year >= 2002 && is_euro_value(NULL)) + { + if (ditta <= 0) + ditta = prefix().get_codditta(); + TString16 key; key.format("%05ld%04d", ditta, year); + const TRectype& lia = cache().get("%LIA", key); + const int dec = lia.get_int(declaration ? "I2" : "I1"); + set_default_mode(rm_round, dec); + } + else + set_default_mode(rm_millelire, -3); +} + +void TIva_round::round(real& n) const +{ + CHECK(_mode != rm_unknown, "Non è stato impostato il metodo di arrotondamento"); + switch (_mode) + { + case rm_ceil: + n.ceil(_decimals); + break; + case rm_millelire: + n -= 0.0001; // Le 500 lire vanno arrontondate per difetto + default: + n.round(_decimals); + break; + } +} + +TIva_round::TIva_round() +{ + _mode = _def_mode; + _decimals = _def_decimals; +} + diff --git a/cg/cglib03.h b/cg/cglib03.h index dd1bf93cc..f0081da72 100755 --- a/cg/cglib03.h +++ b/cg/cglib03.h @@ -158,5 +158,7 @@ int analizza_IVA(const real& imptot, const real& ivatot, const real perc_ind, int get_tipodet_from_rmi(const TRectype& rmi, const TRectype& mv, real& percind, const bool is_liq = false); bool gestione_IVAxCassa(const TDate& data, long firm = 0); +bool is_split_payment(const TRectype& mov); +bool is_IVAxCassa(const TRectype& mov); #endif diff --git a/cg/cgpagame.cpp b/cg/cgpagame.cpp index eb7dc502e..18bcfd790 100755 --- a/cg/cgpagame.cpp +++ b/cg/cgpagame.cpp @@ -1908,7 +1908,7 @@ void TPagamento::adjust_refused_scad() CHECK(_tipocf == 'C' || _tipocf == 'F', "Bad tipocf in pagament"); - TString16 codice; + TString8 codice; codice << _tipocf << '|' << _codcf; const TRectype& clifo = cache().get(LF_CFVEN, codice); diff --git a/cg/f17.dir b/cg/f17.dir index 8d6f02e34..e01e9f80c 100755 --- a/cg/f17.dir +++ b/cg/f17.dir @@ -1,3 +1,3 @@ 17 0 -$cfven|0|0|496|0|Clienti/Fornitori per vendite||| +$cfven|0|0|502|0|Clienti/Fornitori per vendite||| diff --git a/cg/f17.trr b/cg/f17.trr index 971488527..32973ae0f 100755 --- a/cg/f17.trr +++ b/cg/f17.trr @@ -1,5 +1,5 @@ 17 -81 +82 TIPOCF|1|1|0|Tipo liente, ornitore CODCF|3|6|0|Codice CODINDDOC|2|3|0|Codice indirizzo documenti @@ -81,5 +81,6 @@ RIFDOC|8|1|0|Riferimenti sui documenti IMPMINFAT|4|18|3|Importo minimo Fatture PADESTIN|1|6|0|Codice ufficio amministrazione PARIFAMM|1|20|0|Codice riferimento amministrativo +PRODCONAI|1|6|0|Produttore CONAI[6]: acc,all,car,pla,leg,vet 1 TIPOCF+CODCF| diff --git a/cg/f20.dir b/cg/f20.dir index a378e73de..ec65c5d8b 100755 --- a/cg/f20.dir +++ b/cg/f20.dir @@ -1,3 +1,3 @@ 20 0 -$clifo|0|0|742|0|Clienti/Fornitori||| +$clifo|0|0|743|0|Clienti/Fornitori||| diff --git a/cg/f20.trr b/cg/f20.trr index 5477f43b8..05bf4ccd5 100755 --- a/cg/f20.trr +++ b/cg/f20.trr @@ -1,5 +1,5 @@ 20 -60 +61 TIPOCF|1|1|0|Tipo liente ornitore CODCF|3|6|0|Codice RAGSOC|1|50|0|Ragione sociale @@ -60,6 +60,7 @@ CODCFASS|3|6|0|Codice cliente (fornitori) o fornitore (clienti) associato CODCFFATT|3|6|0|Codice cliente (fornitore) cui fatturare DIPPUBB|8|1|0|Dipendente Pubblico ENTE|1|4|0|Codice ente pubblico di appartenenza (Dipendente Pubblico) +SPLITPAY|8|1|0|Ente pubblico soggetto a split payment 6 TIPOCF+CODCF| TIPOCF+UPPER(RAGSOC)|X