From c9502129628947dd19774dcd6a19d7bfdd900414 Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 15 Apr 2016 08:14:40 +0000 Subject: [PATCH] git-svn-id: svn://10.65.10.50/branches/R_10_00@23187 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg2103.cpp | 23 +++-- cg/cg2103.h | 1 + cg/cg3200.cpp | 38 +++---- cg/cg3200a.uml | 2 - cg/cg3600.cpp | 20 +++- cg/cg3600b.uml | 20 ++-- cg/cg3600s.uml | 141 +++++++++++++++++++++++++ cg/cg3601.cpp | 134 ++++++++++++++++++++++++ cg/cg3601.h | 1 + cg/cg4301.cpp | 276 +++++++++++++++++++++++++------------------------ cg/cg5700.cpp | 19 ++-- cg/cglib01.cpp | 14 +-- 12 files changed, 487 insertions(+), 202 deletions(-) create mode 100644 cg/cg3600s.uml create mode 100644 cg/cg3601.cpp create mode 100644 cg/cg3601.h diff --git a/cg/cg2103.cpp b/cg/cg2103.cpp index 78f4d4811..db0219107 100755 --- a/cg/cg2103.cpp +++ b/cg/cg2103.cpp @@ -1,5 +1,6 @@ #include "cg2103.h" +#include #include #include #include @@ -77,18 +78,20 @@ TBill& TCausale::bill(int num, TBill& conto) const return conto; } +const char* TCausale::cod_desc_agg(int num) const +{ + const TRectype* rec = row(num); + if (rec) + return rec->get(RCA_CODDESC); + return ""; // ho problemi con ? : +} + const char* TCausale::desc_agg(int num) const { - const char* deag = ""; - - const TRectype* rec = row(num); - if (rec != NULL) - { - const TString& cod = rec->get(RCA_CODDESC); - deag = cache().get("%DPN", cod, "S0"); - } - - return deag; + const char* cod = cod_desc_agg(num); + if (cod && *cod) + return cache().get("%DPN", cod, "S0"); + return ""; // ho problemi con ? : } const char* TCausale::descrizione() const diff --git a/cg/cg2103.h b/cg/cg2103.h index ee3a073a2..6df045fa7 100755 --- a/cg/cg2103.h +++ b/cg/cg2103.h @@ -27,6 +27,7 @@ public: const char* codice() const; const char* descrizione() const; + const char* cod_desc_agg(int num) const; const char* desc_agg(int num) const; bool data_doc() const; diff --git a/cg/cg3200.cpp b/cg/cg3200.cpp index 0c184e0e9..d30c64ed3 100755 --- a/cg/cg3200.cpp +++ b/cg/cg3200.cpp @@ -33,28 +33,27 @@ public: const TString& TMastrini_record::get_str(const char* fieldname) const { - if (strcmp(fieldname, RMV_DESCR) == 0) + if (xvt_str_same(fieldname, RMV_DESCR)) { const int g = atoi(TRectype::get_str(RMV_GRUPPO)); const int c = atoi(TRectype::get_str(RMV_CONTO)); const long s = atol(TRectype::get_str(RMV_SOTTOCONTO)); ((TBill&)_bill).set(g, c, s); - const TString& descr = _bill.descrizione(); - return descr; + return _bill.descrizione(); } return TRectype::get_str(fieldname); } int TMastrini_record::length(const char* fieldname) const { - if (strcmp(fieldname, RMV_DESCR) == 0) + if (xvt_str_same(fieldname, RMV_DESCR)) return 50; return TRectype::length(fieldname); } TFieldtypes TMastrini_record::type(const char* fieldname) const { - if (strcmp(fieldname, RMV_DESCR) == 0) + if (xvt_str_same(fieldname, RMV_DESCR)) return _alfafld; return TRectype::type(fieldname); } @@ -277,8 +276,7 @@ bool TMastrini_application::sottoc_handler_ini(TMask_field& f, KEY key) char tipo = id == F_SOTTOCINI_CLIENTE ? 'C' : 'F'; if (sottoconto != 0) { - TString16 key; - key.format("%c|%ld", tipo, sottoconto); + TString8 key; key.format("%c|%ld", tipo, sottoconto); const TRectype & clifo = cache().get(LF_CLIFO, key); if (clifo.empty()) return f.warning_box(TR("Anagrafica inesistente")); @@ -533,10 +531,7 @@ bool TMastrini_application::memorizza_handler(TMask_field& f, KEY k) bool TMastrini_application::scelte_notify(TSheet_field& s, int r, KEY k) { - bool ok = TRUE; - if (k == K_INS) - ok = FALSE; - return ok; + return k != K_INS; } int TMastrini_application::date2esc(const TDate& d) @@ -2124,10 +2119,8 @@ print_action TMastrini_application::postprocess_print(int file, int counter) if (file == LF_SALDI) { reset_print(); -// stampa_totali_commessa(); print_one(file); - - _msk->reset(-9); + //_msk->reset(-9); // commentato 25-03-2015 } return NEXT_PAGE; @@ -2240,7 +2233,7 @@ bool TMastrini_application::set_print(int m) KEY tasto = K_ENTER; while (tasto == K_ENTER) { - _puoi_stampare = TRUE; + _puoi_stampare = true; // Controlla se esistono impostazioni di stampa in coda if (sheet2mask()) { @@ -2269,7 +2262,7 @@ bool TMastrini_application::set_print(int m) else _real_picture = "####.###.###.###"; set_real_picture(_real_picture); - set_magic_currency(TRUE); + set_magic_currency(true); _codice_ditta = get_firm(); _annomsk = _msk->get_int(F_ANNO); @@ -2286,7 +2279,7 @@ bool TMastrini_application::set_print(int m) _stampa_cont = !_msk->get_bool(F_NOT_STAMPA_CONT); _stampanum = _msk->get_int(F_STAMPANUM); _stampa_mov_prov = _msk->get_bool(F_STAMPAMOVPROV); - _selez_mastrini = _msk->get_int(F_SELEZ_STAMPA); + _selez_mastrini = _msk->get_int(F_SELEZ_STAMPA); _numcarat = _msk->get_int(F_NUMCARAT); _stampa_saldo_des = _numcarat==2 ? _msk->get_int(F_SALDO_DES) : 0; @@ -3590,9 +3583,6 @@ const char* TMastrini_application::descrizione_classe(char sezione, char lettera const char* TMastrini_application::descrizione_gruppo() { -// TString16 key; -// key.format("%d", _gruppo); -// return cache().get(LF_PCON, key, PCN_DESCR); return cache().get(LF_PCON, _gruppo, PCN_DESCR); } @@ -3600,17 +3590,13 @@ const char* TMastrini_application::descrizione_gruppo() const char* TMastrini_application::descrizione_conto() { - TString8 key; - key.format("%d|%d", _gruppo, _conto); - + TString8 key; key.format("%d|%d", _gruppo, _conto); return cache().get(LF_PCON, key, PCN_DESCR); } const char* TMastrini_application::descrizione_sottoconto() { - TString16 key; - key.format("%d|%d|%ld", _gruppo, _conto, _sottoc); - + TString16 key; key.format("%d|%d|%ld", _gruppo, _conto, _sottoc); return cache().get(LF_PCON, key, PCN_DESCR); } diff --git a/cg/cg3200a.uml b/cg/cg3200a.uml index 1f523d7df..8183ffae3 100755 --- a/cg/cg3200a.uml +++ b/cg/cg3200a.uml @@ -511,8 +511,6 @@ BEGIN MODULE NP END - - BUTTON F_MEMORIZZA 18 2 BEGIN PROMPT -11 -1 "~Memorizza scelte" diff --git a/cg/cg3600.cpp b/cg/cg3600.cpp index 8fdc6db8f..7314c578c 100755 --- a/cg/cg3600.cpp +++ b/cg/cg3600.cpp @@ -3,6 +3,7 @@ #include "cg3.h" #include "cglib02.h" #include "cg3600.h" +#include "cg3601.h" #include #include @@ -2273,8 +2274,9 @@ protected: // TMask static bool link_handler(TMask_field& f, KEY k); static bool new_handler(TMask_field& f, KEY k); - static bool edit_handler(TMask_field& f, KEY k); + //static bool edit_handler(TMask_field& f, KEY k); static bool export_handler(TMask_field& f, KEY k); + static bool saldac_handler(TMask_field& f, KEY k); public: TMastrini_grid& grid() { CHECK(_grid, "What's grid?"); return *_grid; } @@ -2289,8 +2291,9 @@ TGrid_mask::TGrid_mask() read_mask("cg3600b", 0, 0); set_handler(DLG_LINK, link_handler); set_handler(DLG_NEWREC, new_handler); - set_handler(DLG_EDIT, edit_handler); + //set_handler(DLG_EDIT, edit_handler); set_handler(DLG_EXPORT, export_handler); + set_handler(DLG_USER, saldac_handler); // implemented in cg3601.cpp const bool show_cms = main_app().has_module(CMAUT) || main_app().has_module(CAAUT); if (!show_cms) @@ -2336,6 +2339,7 @@ bool TGrid_mask::new_handler(TMask_field& f, KEY k) return true; } +/* Useless bool TGrid_mask::edit_handler(TMask_field& f, KEY k) { bool ok = true; @@ -2352,7 +2356,7 @@ bool TGrid_mask::edit_handler(TMask_field& f, KEY k) ok = export_handler(f, k); // Se non parte Excel salvo altrove } return ok; -} +}*/ bool TGrid_mask::export_handler(TMask_field& f, KEY k) { @@ -2372,6 +2376,16 @@ bool TGrid_mask::export_handler(TMask_field& f, KEY k) } return ok; } + +bool TGrid_mask::saldac_handler(TMask_field& f, KEY k) +{ + if (k == K_SPACE) + { + TBill zio; zio.get(f.mask(), F_GRUPPO, F_CONTO, F_SOTTOCONTO); + popup_games(zio); + } + return true; +} bool TGrid_mask::on_key(KEY k) { diff --git a/cg/cg3600b.uml b/cg/cg3600b.uml index e6f6ec9b4..aa4d3f58e 100755 --- a/cg/cg3600b.uml +++ b/cg/cg3600b.uml @@ -14,16 +14,10 @@ BEGIN PICTURE TOOL_NEWREC END -BUTTON DLG_EDIT 10 2 -BEGIN - PROMPT 3 1 "E~xcel" - PICTURE TOOL_EXCEL -END - BUTTON DLG_EXPORT 10 2 BEGIN PROMPT 4 1 "~Esporta" - PICTURE TOOL_EXPORT + PICTURE TOOL_EXCEL END BUTTON DLG_CANCEL 10 2 @@ -61,22 +55,28 @@ END NUMBER F_ESERCIZIO 4 BEGIN - PROMPT 1 1 "Cod. esercizio " + PROMPT 1 1 "Esercizio " FLAGS "D" END DATE F_DADATA BEGIN - PROMPT 25 1 "Dalla data " + PROMPT 21 1 "Dal " FLAGS "D" END DATE F_ADATA BEGIN - PROMPT 54 1 "Alla data " + PROMPT 38 1 "Al " FLAGS "D" END +BUTTON DLG_USER 10 +BEGIN + PROMPT 64 1 "Partite" + MODULE sc +END + SPREADSHEET F_MASTRINI 0 -6 BEGIN PROMPT 1 2 "Mastrini" diff --git a/cg/cg3600s.uml b/cg/cg3600s.uml new file mode 100644 index 000000000..c6faeb58c --- /dev/null +++ b/cg/cg3600s.uml @@ -0,0 +1,141 @@ +#include "../sc/sc0200b.h" + +TOOLBAR "" 0 0 0 2 +#include +ENDPAGE + +PAGE "Partite" 0 0 0 0 + +LIST F_TIPO 1 10 +BEGIN + PROMPT 1 0 "Tipo conto " + ITEM "C|Cliente" + MESSAGE HIDE,1@|SHOW,2@|HIDE,3@ + ITEM "F|Fornitore" + MESSAGE HIDE,1@|HIDE,2@|SHOW,3@ + ITEM "|Conto" + MESSAGE SHOW,1@|HIDE,2@|HIDE,3@ + FLAGS "DG" +END + +NUMBER F_GRUPPO 3 +BEGIN + PROMPT 27 0 "Gruppo " + FLAGS "D" +END + +NUMBER F_CONTO 3 +BEGIN + PROMPT 41 0 "Conto " + FLAGS "D" +END + +NUMBER F_SOTTOCONTO 6 +BEGIN + PROMPT 54 0 "Sottoconto " + USE LF_PCON SELECT SOTTOCONTO!="" + INPUT GRUPPO F_GRUPPO + INPUT CONTO F_CONTO + INPUT SOTTOCONTO F_SOTTOCONTO + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Sottoconto" SOTTOCONTO + DISPLAY "Descrizione@50" DESCR + OUTPUT F_GRUPPO GRUPPO + OUTPUT F_CONTO CONTO + OUTPUT F_SOTTOCONTO SOTTOCONTO + OUTPUT F_DESCR DESCR + GROUP 1 + CHECKTYPE REQUIRED + FLAGS "D" +END + +NUMBER F_CLIENTE 6 +BEGIN + PROMPT 54 0 "Cliente " + USE LF_CLIFO + INPUT TIPOCF "C" + INPUT CODCF F_CLIENTE + DISPLAY "Cliente" CODCF + DISPLAY "Descrizione@50" RAGSOC + OUTPUT F_CLIENTE CODCF + OUTPUT F_DESCRCLI RAGSOC + ADD RUN cg0 -1 C + GROUP 2 + CHECKTYPE REQUIRED + FLAGS "D" +END + +NUMBER F_FORNITORE 6 +BEGIN + PROMPT 54 0 "Fornitore " + USE LF_CLIFO + INPUT TIPOCF "F" + INPUT CODCF F_FORNITORE + DISPLAY "Fornitore" CODCF + DISPLAY "Descrizione@50" RAGSOC + OUTPUT F_FORNITORE CODCF + OUTPUT F_DESCRFOR RAGSOC + ADD RUN cg0 -1 F + GROUP 3 + CHECKTYPE REQUIRED + FLAGS "D" +END + +STRING F_DESCR 50 58 +BEGIN + PROMPT 1 1 "Descrizione " + GROUP 1 + FLAGS "D" +END + +STRING F_DESCRCLI 50 58 +BEGIN + PROMPT 1 1 "Descrizione " + GROUP 2 + FLAGS "D" +END + +STRING F_DESCRFOR 50 58 +BEGIN + PROMPT 1 1 "Descrizione " + GROUP 3 + FLAGS "D" +END + +RADIOBUTTON F_TUTTE 1 38 +BEGIN + PROMPT 1 2 "Mostra partite" + ITEM "1|Aperte" + ITEM "2|Chiuse" + ITEM "3|Tutte" + FLAGS "Z" +END + +STRING F_CODVAL 4 +BEGIN + PROMPT 60 3 "Valuta " + USE %VAL + INPUT CODTAB F_CODVAL + DISPLAY "Codice" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT F_CODVAL CODTAB + CHECKTYPE NORMAL +END + +TLIST F_PARTITE -3 -1 +BEGIN + PROMPT 0 5 "" + DISPLAY "Partita@35" DESCR + DISPLAY "Docum.@8" NUMDOC + DISPLAY "Data@10R" DATADOC + DISPLAY "Dare@15R" DARE + DISPLAY "Avere@15R" AVERE + DISPLAY "Abbuoni@15R" ABBUONI + DISPLAY "Diff. Cambio@15R" DIFFCAM + DISPLAY "Ritenute fiscali@15R" RITENUTE + DISPLAY "Ritenute sociali@15R" RITSOC + DISPLAY "P.N.@7R" NREG +END + +ENDMASK diff --git a/cg/cg3601.cpp b/cg/cg3601.cpp new file mode 100644 index 000000000..d2ebde180 --- /dev/null +++ b/cg/cg3601.cpp @@ -0,0 +1,134 @@ +#include +#include +#include + +#include "cgsalda3.h" +#include "cg3601.h" + +#include "../sc/sc0200b.h" + +class TPartitario : public TAutomask +{ + TPartite_array _games; + TSolder_tree _tree; + long _numreg; + +protected: + bool on_field_event(TOperable_field& o, TField_event e, long jolly); + +public: + TPartitario(const TBill& bill); +}; + +bool TPartitario::on_field_event(TOperable_field& o, TField_event e, long jolly) +{ + switch (o.dlg()) + { + case F_TUTTE: + if (e == fe_init || e == fe_modify) + { + TBill bill; + const char tipo = get(F_TIPO)[0]; + const short dlg = tipo == 'C' ? F_CLIENTE : (tipo == 'F' ? F_FORNITORE : F_SOTTOCONTO); + bill.get(*this, F_GRUPPO, F_CONTO, dlg, F_TIPO, dlg+1); + const TString& codval = get(F_CODVAL); + const real cambio = UNO; + const TSolder_tree_flags flags = (TSolder_tree_flags)atoi(o.get()); + _tree.set_root(_games, bill, 0, 0, codval, cambio, flags); + tfield(F_PARTITE).set_tree(&_tree); + _numreg = 0L; + disable(DLG_EDIT); + } + break; + case DLG_USER: + if (e == fe_button) + { + TWait_cursor hourglass; + if (_tree.expanded()) + _tree.shrink_all(); + else + _tree.expand_all(); + tfield(F_PARTITE).win().force_update(); + } + break; + case F_PARTITE: + if (e == fe_modify || e == fe_button) + { + _numreg = 0L; + + TTree_field& tree = tfield(F_PARTITE); + tree.goto_selected(); + TToken_string node; _tree.curr_id(node); + int level = node.items(); + if (level >= 2) + { + TPartita& game = *_tree.partita(); + + const int nriga = node.get_int(1); + const int nrata = node.get_int(); + int nrigp = node.get_int(); + if (nrigp <= 0 && nriga == TPartita::UNASSIGNED) + nrigp = game.unassigned().first_row(); + + long numreg = 0; + if (nrigp > 0 && game.esiste(nrigp)) + { + const TRiga_partite& rigp = game.riga(nrigp); + _numreg = rigp.get_long(PART_NREG); + } else + if (nriga > 0 && nriga < TPartita::UNASSIGNED && game.esiste(nriga)) + { + TRiga_partite& riga = game.riga(nriga); + _numreg = riga.get_long(PART_NREG); + } + } + enable(DLG_EDIT, _numreg > 0L); + } + if (e == fe_button && _numreg > 0) + { + TRectype mov(LF_MOV); + mov.put("NUMREG", _numreg); + mov.edit(); + } + break; + case DLG_EDIT: + if (e == fe_button && _numreg > 0) + { + TRectype mov(LF_MOV); + mov.put("NUMREG", _numreg); + mov.edit(); + } + break; + default: + break; + } + return true; +} + +TPartitario::TPartitario(const TBill& bill) : TAutomask("sc0200b") +{ + WINDOW tb = toolbar(); + xvt_toolbar_remove_control(tb, DLG_NEWREC); + xvt_toolbar_remove_control(tb, DLG_EDIT); + + const real cambio = UNO; + const TSolder_tree_flags flags = sct_all_games; + switch (bill.tipo()) + { + case 'C': bill.set(*this, F_GRUPPO, F_CONTO, F_CLIENTE); break; + case 'F': bill.set(*this, F_GRUPPO, F_CONTO, F_FORNITORE); break; + default : bill.set(*this, F_GRUPPO, F_CONTO, F_SOTTOCONTO); break; + } +} + +bool popup_games(const TBill& bill) +{ + TBill conto = bill; + bool go = conto.find(); + if (go) + { + TPartitario part(conto); + go = part.run() == K_ENTER; + } + return go; +} \ No newline at end of file diff --git a/cg/cg3601.h b/cg/cg3601.h new file mode 100644 index 000000000..aee2daeaa --- /dev/null +++ b/cg/cg3601.h @@ -0,0 +1 @@ +bool popup_games(const TBill& zio); \ No newline at end of file diff --git a/cg/cg4301.cpp b/cg/cg4301.cpp index 2dacb0797..a3d9b32b5 100755 --- a/cg/cg4301.cpp +++ b/cg/cg4301.cpp @@ -751,6 +751,7 @@ static bool partita_chiusa_al(const TPartita& p, const TDate& d) return c; } + static void LOG_IVA_DIFF(const TRectype& id) { #ifndef NDEBUG @@ -851,7 +852,6 @@ static void LOG_PIM_DIFF(const TRectype& pim) #endif } - static bool is_autofattura_articolo_17(const TRectype& mov) { // E' giusto prendere il tipo documento dal movimento senza fidarsi della causale? si. @@ -901,6 +901,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) real esenti_b14 = ZERO; real vendite_rev = ZERO; // Vendire in reverse charge (da escludere in prorata) + /* Comunicazione dati iva annuale dal 2016 calcolata in cg5 // Comunicazione dati iva annuale (dal 2003) real cessioni_cd1_1 = ZERO; // Totale operazioni attive real cessioni_cd1_2 = ZERO; // non imponibili @@ -917,7 +918,8 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) real rottami_cd3_3 = ZERO; // imponibile acquisto rottami real rottami_cd3_4 = ZERO; // imposta acquisto rottami real cessioni_cd1_1s = ZERO; // Totale operazioni attive in split payment - + */ + real esni_rimb = ZERO; // ci sommo tutti esenti e ni validi per rimborso real corr_CEE = ZERO; real corr_noCEE = ZERO; @@ -1140,8 +1142,8 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) if (tipomov == vendita && (tm == tm_fattura || tm == tm_nota_credito) && !cau_intra && date.year() >= 2015 && is_split_payment(_mov->curr())) { - // *** aggiunto il 27-01-2016 *** - // In tredicesima devo compilare anche CD1_1 + /* Dal 2016 calcoliamo comunicazione annuale in cg5 + // aggiunto il 27-01-2016: in tredicesima devo compilare anche CD1_1 if (month == 13 && date.year() == year_int) { do // scansione semplificata delle righe IVA @@ -1161,6 +1163,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) } } while (_cur->next_match(LF_RMOVIVA)); } + */ continue; // Ignora movimento di split payment } @@ -1633,6 +1636,138 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) impon_det, impos_det, impon_ind, impos_ind); } + + // Filling dell'array per IVA11 + if (_is_interactive && month == 13) + iva11_set_arr_phase_1(trueatt); + + + // Cumula l'ammontare delle operazioni attive/passive + // per la dichiarazione annuale dati iva e quadro VT + if (month == 13 && !fattrit) + { + + if (tipomov == vendita) + { + const long codcf = _mov->get_long(MOV_CODCF); + + if (tipoiva.empty() && codcf != 0) + { + TString8 key; key.format("%c|%ld", _mov->get_char(MOV_TIPO), codcf); + const TRectype& clifo = cache().get(LF_CLIFO, key); + int codreg = 0; // codice regione x privati 22 == partite iva 0 == senza codice + const int tipoalleg = clifo.get_int(CLI_ALLEG); + + if (tipoalleg == 6) // privato + { + if (clifo.get_bool(CLI_OCCAS)) + { + 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); + } + else + { + key = clifo.get(CLI_STATOCF); + key << "|" << clifo.get(CLI_COMCF); + } + + const TRectype& comune = cache().get(LF_COMUNI, key); + codreg = comune.get_int(COM_CODREG) + 1; + } + + if (bIsMovDiff) + { + vt_imponibile[codreg] += incdiff_imp; + vt_imposta[codreg] += incdiff_iva; + } + else + { + vt_imponibile[codreg] += imponibile_orig; + vt_imposta[codreg] += imposta_orig; + } + } + } + + /* Calcoli sprecati: dal 2016 calcolimao la comuncazione annuale direttamente in cg5 + const TString& iva_vpn = _iva->get(tipomov == vendita ? "S10" : "S11"); + + // Aggiunto "&& is_detraibile==0" al test altrimenti somma due volte imponibile_orig (22/01/2015) + if (!bIsMovDiff && iva_vpn.full() && _mov->get_int(MOV_ANNOIVA) == year_int && is_detraibile == 0) + { + switch (tipomov) + { + case vendita: // CD1 - 1 2 3 4 + { + // bool is_valid = !corrisp && tipodoc != "AF" && (cau_intra || !cau_valintra) && + // sosp_imp != normale && sosp_imp != liquidazione; + bool is_valid = tipodoc != "AF" && sosp_imp != normale && sosp_imp != liquidazione; + if (is_valid) + { + cessioni_cd1_1 += imponibile_orig; + if (iva_vpn.starts_with("CD1")) + { + if (tipocr == 4) + cessioni_cd1_5 += imponibile_orig; + } + if (!cau_intra) + { + if (iva_vpn == "CD12") + cessioni_cd1_2 += imponibile_orig; else + if (iva_vpn == "CD13") + cessioni_cd1_3 += imponibile_orig; + } + else + { + if (iva_vpn == "CD14") + cessioni_cd1_4 += imponibile_orig; + } + } + + } + break; + case acquisto: // CD2 - 1 2 3 4 + { + acquisti_cd2_1 += imponibile_orig; + if (iva_vpn.starts_with("CD2")) + { + if (tipocr == 2 || tipocr == 3 || tipocr == 8) + acquisti_cd2_5 += imponibile_orig; + } + if (!cau_intra) + { + if (iva_vpn == "CD22") + acquisti_cd2_2 += imponibile_orig; + else + if (iva_vpn == "CD23") + acquisti_cd2_3 += imponibile_orig; + } + else + { + if (iva_vpn == "CD24") + acquisti_cd2_4 += imponibile_orig; + } + if (iva_vpn == "CD31") + { + oroargento_cd3_1 += imponibile_orig; + oroargento_cd3_2 += imposta_orig; + } + if (iva_vpn == "CD33") + { + rottami_cd3_3 += imponibile_orig; + rottami_cd3_4 += imposta_orig; + } + } + break; + default: + break; + } + } + */ + } + for (int is_detraibile = 0; is_detraibile < 2; is_detraibile++) { const int tipodet = is_detraibile ? 0 : tipoind; @@ -1653,132 +1788,6 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) /* 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); - - // Cumula l'ammontare delle operazioni attive/passive - // per la dichiarazione annuale dati iva e quadro VT - if (month == 13 && !fattrit) - { - if (tipomov == vendita) - { - const long codcf = _mov->get_long(MOV_CODCF); - - if (tipoiva.empty() && codcf != 0) - { - TString8 key; key.format("%c|%ld", _mov->get_char(MOV_TIPO), codcf); - const TRectype& clifo = cache().get(LF_CLIFO, key); - int codreg = 0; // codice regione x privati 22 == partite iva 0 == senza codice - const int tipoalleg = clifo.get_int(CLI_ALLEG); - - if (tipoalleg == 6) // privato - { - if (clifo.get_bool(CLI_OCCAS)) - { - 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); - } - else - { - key = clifo.get(CLI_STATOCF); - key << "|" << clifo.get(CLI_COMCF); - } - - const TRectype& comune = cache().get(LF_COMUNI, key); - codreg = comune.get_int(COM_CODREG) + 1; - } - - if (bIsMovDiff) - { - vt_imponibile[codreg] += incdiff_imp; - vt_imposta[codreg] += incdiff_iva; - } - else - { - vt_imponibile[codreg] += imponibile; - vt_imposta[codreg] += imposta; - } - } - } - - const TString& iva_vpn = _iva->get(tipomov == vendita ? "S10" : "S11"); - - // Aggiunto "&& is_detraibile==0" al test altrimenti somma due volte imponibile_orig (22/01/2015) - if (!bIsMovDiff && iva_vpn.full() && _mov->get_int(MOV_ANNOIVA) == year_int && is_detraibile == 0) - { - switch (tipomov) - { - case vendita: // CD1 - 1 2 3 4 - { - // bool is_valid = !corrisp && tipodoc != "AF" && (cau_intra || !cau_valintra) && - // sosp_imp != normale && sosp_imp != liquidazione; - bool is_valid = tipodoc != "AF" && sosp_imp != normale && sosp_imp != liquidazione; - if (is_valid) - { - cessioni_cd1_1 += imponibile_orig; - if (iva_vpn.starts_with("CD1")) - { - if (tipocr == 4) - cessioni_cd1_5 += imponibile_orig; - } - if (!cau_intra) - { - if (iva_vpn == "CD12") - cessioni_cd1_2 += imponibile_orig; else - if (iva_vpn == "CD13") - cessioni_cd1_3 += imponibile_orig; - } - else - { - if (iva_vpn == "CD14") - cessioni_cd1_4 += imponibile_orig; - } - } - - } - break; - case acquisto: // CD2 - 1 2 3 4 - { - acquisti_cd2_1 += imponibile_orig; - if (iva_vpn.starts_with("CD2")) - { - if (tipocr == 2 || tipocr == 3 || tipocr == 8) - acquisti_cd2_5 += imponibile_orig; - } - if (!cau_intra) - { - if (iva_vpn == "CD22") - acquisti_cd2_2 += imponibile_orig; - else - if (iva_vpn == "CD23") - acquisti_cd2_3 += imponibile_orig; - } - else - { - if (iva_vpn == "CD24") - acquisti_cd2_4 += imponibile_orig; - } - if (iva_vpn == "CD31") - { - oroargento_cd3_1 += imponibile_orig; - oroargento_cd3_2 += imposta_orig; - } - if (iva_vpn == "CD33") - { - rottami_cd3_3 += imponibile_orig; - rottami_cd3_4 += imposta_orig; - } - } - break; - default: - break; - } - } - } if (noninc) // non incassati: non devono entrare in nessun altro calcolo { @@ -2484,8 +2493,6 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) const real oldv = tab->get("R29"); const real newv = oldv + incdiff_iva; const long numreg = _mov->get_long(MOV_NUMREG); - if (numreg == 23260) - int cazzone = 1; __trace("%s %s\t%s\t%s\t%7ld\t%s\t+\t%s\t=\t%s", tab->name(), (const char*)tab->curr().get("CODTAB"), (const char*)reg, (const char*)tipocr_s, numreg, oldv.stringa(12, 2), incdiff_iva.stringa(12, 2), newv.stringa(12, 2)); } @@ -2748,6 +2755,8 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) _pum->put("S5", esenti_c1a_bam); _pum->put("R7", esenti_b14); _pum->put("R12", esni_rimb); + + /* Dal 2016 calcoliamo comunicazione annuale in cg5 _pum->put("R14", cessioni_cd1_1); _pum->put("R15", cessioni_cd1_2); _pum->put("R16", cessioni_cd1_3); @@ -2764,7 +2773,8 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) _pum->put("R27", cessioni_cd1_5); _pum->put("R28", vendite_rev); // Vendite in reverse charge da escludere da prorata _pum->put("R29", cessioni_cd1_1s); // cessioni in split - + */ + _pam->put("R0", acquisti); _pam->put("R1", vendite); _pam->put("R6", assp_imp); diff --git a/cg/cg5700.cpp b/cg/cg5700.cpp index a294e571a..9a9547122 100755 --- a/cg/cg5700.cpp +++ b/cg/cg5700.cpp @@ -248,7 +248,7 @@ protected: void read_iva_data(); real imposta_diff(int tipo) const; void calc_cd_new(int anno, Tcd& s) const; - void calc_cd_old(int anno, Tcd& s) const; + //void calc_cd_old(int anno, Tcd& s) const; public: void set_prospect(); @@ -283,17 +283,12 @@ real TDich_periodica_iva_mask::imposta_diff(int tipo) const real imposta; const int anno = _sf->get_year(); - const TDate data_da(1,1,anno); - const TDate data_a(31,12,anno); - TString query; - query << "USE IVADIFF SELECT (BETWEEN(DATAREGP,#DAL,#AL))&&(STR(" - << "(MOV.TOTDOC>0)&&(TIPOMOV>2)&&(MESELIQ<13)&&(TIPOIVA=" << tipo << ')' - << "))"; - query << "\nJOIN MOV INTO NUMREG==NUMREG"; + query << "USE IVADIFF KEY 2" + << "\nSELECT (TIPOMOV>2)&&(MESELIQ<13)&&(TIPOIVA=" << tipo << ')' + << "\nFROM ANNOLIQ=" << anno + << "\nTO ANNOLIQ=" << anno; TISAM_recordset id(query); - id.set_var("#DAL", data_da); - id.set_var("#AL", data_a); TProgress_monitor pi(id.items(), TR("Calcolo IVA differita")); for (bool ok = id.move_first(); ok; ok = id.move_next()) @@ -465,6 +460,7 @@ void TDich_periodica_iva_mask::calc_cd_new(int anno, Tcd& s) const } } +/* void TDich_periodica_iva_mask::calc_cd_old(int anno, Tcd& s) const { s.Reset(); @@ -505,6 +501,7 @@ void TDich_periodica_iva_mask::calc_cd_old(int anno, Tcd& s) const } } } +*/ void TDich_periodica_iva_mask::read_iva_data() { @@ -518,7 +515,7 @@ void TDich_periodica_iva_mask::read_iva_data() TString descrizione(120); descrizione << lim.get("S0") << lim.get("S1"); const bool exclude_sign = descrizione.find("$$") >= 0 || descrizione.find(">>") >= 0; - Tcd cd_old; calc_cd_old(anno, cd_old); + //Tcd cd_old; calc_cd_old(anno, cd_old); Tcd cd_new; calc_cd_new(anno, cd_new); real cd1_1 = cd_new.cd1_1; cd1_1.round(); diff --git a/cg/cglib01.cpp b/cg/cglib01.cpp index 0039e0d73..9184faa17 100755 --- a/cg/cglib01.cpp +++ b/cg/cglib01.cpp @@ -597,7 +597,11 @@ bool TLibro_giornale::read(int y) if (y <= 0) { TEsercizi_contabili esc; - y = esc[esc.last()].inizio().year(); + const int lastes = esc.last(); + if (lastes > 0) + y = esc[lastes].inizio().year(); + else + y = TDate(TODAY).year(); } TString4 anno; anno.format("%04d", y); @@ -693,7 +697,6 @@ real TCodiceIVA::scorpora(real& lordo, int ndec, const char* codval) const real TCodiceIVA::lordo(const real& imponibile, int ndec, const char* codval) const { return imponibile + imposta(imponibile, ndec, codval); } - /////////////////////////////////////////////////////////// // TBill /////////////////////////////////////////////////////////// @@ -760,7 +763,6 @@ const TBill& TBill::copy(const TBill& bill) return *this; } - // Certified 100% const TBill& TBill::set(int g, int c, long s, char t, const char* d, int r) { @@ -886,7 +888,7 @@ void TBill::get(const TMask& m, short g, short c, short s, short t, short d) { const int gr = m.get_int(g); const int co = m.get_int(c); - const long so = m.get_long(s); + const long so = s > 0 ? m.get_long(s) : 0L; char ti = ' '; if (t) ti = m.get(t)[0]; @@ -896,7 +898,6 @@ void TBill::get(const TMask& m, short g, short c, short s, short t, short d) set(gr, co, so, ti, de); } - // Certified 100% bool TBill::ok() const { @@ -922,7 +923,6 @@ int TBill::compare(const TSortable& s) const return res; } - // Certified 95% bool TBill::find() { @@ -962,7 +962,7 @@ bool TBill::find() if (tipoa == 'F') // Se persona fisica allora aggiusta la ragione sociale { TString nome(descrizione().mid(30)); - if (nome.not_empty()) + if (nome.full()) { _descrizione->cut(30); _descrizione->trim(); nome.trim();