diff --git a/cd/test/cg1138.txt b/cd/test/cg1138.txt new file mode 100644 index 000000000..1a77815d8 --- /dev/null +++ b/cd/test/cg1138.txt @@ -0,0 +1,4 @@ +cg4.exe + +Corretta imputazione quadro VT ora viene usato il comune dell'unità locale +corretto calcolo imponibile nel caso di fatture pagate nel periodo in acluni casi aggiungieva l'imonibile 2 volte diff --git a/cd/test/cg1138a.ini b/cd/test/cg1138a.ini new file mode 100644 index 000000000..90986909b --- /dev/null +++ b/cd/test/cg1138a.ini @@ -0,0 +1,98 @@ +[Main] +Demo=0 + +[cg4] +File(84) = cg4.exe|X +Patch = 1138 +Versione = 21511200 + +[cg99] +Kill(0) = bastdpn.msk|x +Kill(1) = batbins.msk|x +Kill(2) = batbvet.msk|x +Kill(3) = bastcve.msk|x +Kill(4) = batbver.msk|x +Kill(5) = bastnot.rep|x +Kill(6) = batbcfi.msk|x +Kill(7) = batbtra.msk|x +Kill(8) = batbscc.msk|x +Kill(9) = bastcfi.msk|x +Kill(10) = bastdpn.rep|x +Kill(11) = bastpdb.rep|x +Kill(12) = bastzon.rep|x +Kill(13) = batbind.msk|x +Kill(14) = bastzon.msk|x +Kill(15) = batbdel.msk|x +Kill(16) = batbleg.msk|x +Kill(17) = bastleg.msk|x +Kill(18) = bastscc.rep|x +Kill(19) = bastesc.rep|x +Kill(20) = bastcco.msk|x +Kill(21) = cgtbcon.msk|x +Kill(22) = cg2fppro.msk|x +Kill(23) = bastreg.rep|x +Kill(24) = bastcam.rep|x +Kill(25) = bastcam.msk|x +Kill(26) = bastivd.rep|x +Kill(27) = batbndo.msk|x +Kill(28) = bastvet.rep|x +Kill(29) = bastndo.msk|x +Kill(30) = batbcve.msk|x +Kill(31) = bastivd.msk|x +Kill(32) = bastarb.msk|x +Kill(33) = bastmsp.msk|x +Kill(34) = batbntb.msk|x +Kill(35) = bastscc.msk|x +Kill(36) = bastver.msk|x +Kill(37) = batbesc.msk|x +Kill(38) = bastleg.rep|x +Kill(39) = bastver.rep|x +Kill(40) = batbtit.msk|x +Kill(41) = batbmsp.msk|x +Kill(42) = batblia.msk|x +Kill(43) = bastntb.rep|x +Kill(44) = batbcam.msk|x +Kill(45) = bastcco.rep|x +Kill(46) = batbcco.msk|x +Kill(47) = bastnot.msk|x +Kill(48) = batbinl.msk|x +Kill(49) = bastarb.rep|x +Kill(50) = batbivd.msk|x +Kill(51) = bastntb.msk|x +Kill(52) = bastreg.msk|x +Kill(53) = batblia.msk|x +Kill(54) = bastpor.msk|x +Kill(55) = bastvet.msk|x +Kill(56) = bastcfi.rep|x +Kill(57) = bastpor.rep|x +Kill(58) = bastpdb.msk|x +Kill(59) = bastesc.msk|x +Kill(60) = batbdpn.msk|x +Kill(61) = batblbu.msk|x +Kill(62) = bastcve.rep|x +Kill(63) = bastndo.rep|x +Kill(64) = batbpdb.msk|x +Kill(65) = batbzon.msk|x +Kill(66) = batbnot.msk|x +Kill(67) = batbarb.msk|x +Kill(68) = batbpor.msk|x +Kill(69) = bastmsp.rep|x +Kill(70) = batbreg.msk|x + +[cg] +Data = 21-04-2022 +Descrizione = Contabilita' Generale +Dischi = 1 +Edit_19 = cg0 -0 +Edit_20 = cg0 -1 +Edit_26 = cg0 -4 +Edit_5 = cg0 -5 +Moduli = ba +OEM = +Patch = 1138 +PostProcess = bainst -0 CG +PreProcess = +Prezzo(1) = +Prezzo(2) = +Versione = 21511200 + diff --git a/cd/test/cg1138a1.zip b/cd/test/cg1138a1.zip new file mode 100644 index 000000000..2cdf3dce9 Binary files /dev/null and b/cd/test/cg1138a1.zip differ diff --git a/cd/test/ve1138.txt b/cd/test/ve1138.txt new file mode 100644 index 000000000..310181c96 --- /dev/null +++ b/cd/test/ve1138.txt @@ -0,0 +1,4 @@ +ve4300a.msk +ve4.exe + +Corretto bug "Controllo IBAN da documenti". mancava la maschera diff --git a/cd/test/ve1138a.ini b/cd/test/ve1138a.ini new file mode 100644 index 000000000..a87660e51 --- /dev/null +++ b/cd/test/ve1138a.ini @@ -0,0 +1,130 @@ +[Main] +Demo=0 + +[ve4] +File(281) = ve4300a.msk|X +File(282) = ve4.exe|X +Patch = 1138 +Versione = 21511200 + +[ve99] +Kill(0) = batbcld.msk|x +Kill(1) = bastspp.rep|x +Kill(2) = batbspp.msk|x +Kill(3) = bastgmc.rep|x +Kill(4) = bastfca.msk|x +Kill(5) = bastrfc.msk|x +Kill(6) = batbabe.msk|x +Kill(7) = basttip.msk|x +Kill(8) = batbfrm.msk|x +Kill(9) = efstbnp.msk|x +Kill(10) = batbrfc.msk|x +Kill(11) = bastprs.msk|x +Kill(12) = ve7200a.frm|x +Kill(13) = bastimb.msk|x +Kill(14) = bastcaa.msk|x +Kill(15) = batbums.msk|x +Kill(16) = bastfrr.rep|x +Kill(17) = bastasf.msk|x +Kill(18) = ve7400a.msk|x +Kill(19) = batbgca.msk|x +Kill(20) = ve7200a.msk|x +Kill(21) = basttri.msk|x +Kill(22) = batbgmc.msk|x +Kill(23) = bastnum.msk|x +Kill(24) = basteld.rep|x +Kill(25) = bastfrd.msk|x +Kill(26) = ve7701a.ini|x +Kill(27) = batbfrr.msk|x +Kill(28) = bastcaa.rep|x +Kill(29) = batbtag.msk|x +Kill(30) = bastbnp.msk|x +Kill(31) = bastfrm.msk|x +Kill(32) = bastrfc.rep|x +Kill(33) = batbmre.msk|x +Kill(34) = batbfid.msk|x +Kill(35) = batbgsa.msk|x +Kill(36) = ve7300a.frm|x +Kill(37) = batbspt.msk|x +Kill(38) = batbpro.msk|x +Kill(39) = ve7400a.ini|x +Kill(40) = ve7400conf.ini|x +Kill(41) = batbnum.msk|x +Kill(42) = batbprs.msk|x +Kill(43) = bastctr.rep|x +Kill(44) = batbtri.msk|x +Kill(45) = bastrfa.msk|x +Kill(46) = bastnum.rep|x +Kill(47) = batbfsa.msk|x +Kill(48) = bastgca.rep|x +Kill(49) = ve7700a.msk|x +Kill(50) = batbrfa.msk|x +Kill(51) = batbgcg.msk|x +Kill(52) = batbprv.msk|x +Kill(53) = bastfrr.msk|x +Kill(54) = bastcau.msk|x +Kill(55) = batbcau.msk|x +Kill(56) = bastubi.msk|x +Kill(57) = bastgmc.msk|x +Kill(58) = bastubi.rep|x +Kill(59) = batbstd.msk|x +Kill(60) = batbtip.msk|x +Kill(61) = bastgcg.msk|x +Kill(62) = bastimb.rep|x +Kill(63) = basttag.msk|x +Kill(64) = basteld.msk|x +Kill(65) = batbbnp.msk|x +Kill(66) = bastums.rep|x +Kill(67) = bastctr.msk|x +Kill(68) = bastcau.rep|x +Kill(69) = batbasf.msk|x +Kill(70) = batbubi.msk|x +Kill(71) = bastasf.rep|x +Kill(72) = basttri.rep|x +Kill(73) = bastcra.msk|x +Kill(74) = bastgca.msk|x +Kill(75) = bastfrd.rep|x +Kill(76) = batbctr.msk|x +Kill(77) = basttag.rep|x +Kill(78) = batbfrd.msk|x +Kill(79) = ve7500a.msk|x +Kill(80) = bastabe.rep|x +Kill(81) = ve7600a.msk|x +Kill(82) = efstbnp.rep|x +Kill(83) = bastabe.msk|x +Kill(84) = ve7.exe|x +Kill(85) = bastprs.rep|x +Kill(86) = basttip.rep|x +Kill(87) = bastfca.rep|x +Kill(88) = baststd.msk|x +Kill(89) = ve7100a.msk|x +Kill(90) = bastrfa.rep|x +Kill(91) = bastgcg.rep|x +Kill(92) = baststd.rep|x +Kill(93) = bastspp.msk|x +Kill(94) = batbcaa.msk|x +Kill(95) = batbeld.msk|x +Kill(96) = bastcra.rep|x +Kill(97) = batbfca.msk|x +Kill(98) = batbacr.msk|x +Kill(99) = batbimb.msk|x +Kill(100) = bastfrm.rep|x +Kill(101) = eftbbnp.msk|x +Kill(102) = bastbnp.rep|x +Kill(103) = bastums.msk|x +Kill(104) = batbcra.msk|x +Kill(105) = ve7300a.msk|x + +[ve] +Data = 26-04-2022 +Descrizione = Vendite +Dischi = 1 +Moduli = ba,cg0, cg9,pr9,mg9,sv9,in9,ef9 +OEM = +Patch = 1138 +PostProcess = bainst -0 VE +PreProcess = +Prezzo(1) = +Prezzo(2) = +Versione = 21511200 + diff --git a/cd/test/ve1138a1.zip b/cd/test/ve1138a1.zip new file mode 100644 index 000000000..1a6e51c29 Binary files /dev/null and b/cd/test/ve1138a1.zip differ diff --git a/src/cg/cg4301.cpp b/src/cg/cg4301.cpp index 828a1984e..eda004d48 100755 --- a/src/cg/cg4301.cpp +++ b/src/cg/cg4301.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -35,19 +36,21 @@ #ifdef DBG #define _BREAK(func, par, values) func(par, values); -#define BREAK_DBG _BREAK(check_nreg, __nreg, __values) -#define LOAD_VAL load_values() +#define BREAK_NREG _BREAK(check_nreg, __nreg, __nregs) +#define BREAK_CODIVA(codiva) _BREAK(check_codiva, codiva, __codivas) +#define LOAD_VAL(sel) load_values(sel) -const char * load_values() +const char * load_values(int selector) { TFilename dbgname; TFilename filename("dbg"); + const char * names[] = { "NReg", "CodIVA"}; filename << main_app().name(); dbgname.currdir(); dbgname.add(filename); dbgname.ext("ini"); - return ini_get_string(dbgname, "Main", "Values"); + return ini_get_string(dbgname, "Main", names[selector]); } bool check_nreg(TToken_string &nreg, TToken_string &values) @@ -61,8 +64,20 @@ bool check_nreg(TToken_string &nreg, TToken_string &values) } return false; } + +bool check_codiva(const TString4 &codiva, TToken_string &values) +{ + + FOR_EACH_TOKEN(values, val) + { + if (codiva == val) + return true; + } + return false; +} #else -#define BREAK_DBG +#define BREAK_NREG +#define BREAK_CODIVA #endif bool TLiquidazione_app::recalc_all() @@ -338,7 +353,7 @@ bool TLiquidazione_app::update_firm(int month, bool recalc) TString8 cattiv(codatt); cattiv << tipoatt; - const bool waspla = look_pla(cattiv); // perchè sta cosa ) , has_single_activity); + const bool waspla = look_pla(cattiv, has_single_activity); if (!waspla) break; // Non calcolare attività inesistenti 29-11-2012 @@ -1148,10 +1163,11 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & TDate date = _mov->get(MOV_DATAREG); #ifdef DBG TToken_string __nreg = _mov->get(MOV_NUMREG); - TToken_string __values = LOAD_VAL; + TToken_string __nregs = LOAD_VAL(0); + TToken_string __codivas = LOAD_VAL(1); #endif - BREAK_DBG; + BREAK_NREG; const int liqmonth = _mov->get_int(MOV_MESELIQ); const TString4 reg = _mov->get("REG"); const bool isreg = look_reg(reg); @@ -1199,7 +1215,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & TPartite_array arrpart; // Partite interessate TPointer_array pagscatt; // Righe di pagsca interessate - BREAK_DBG; + BREAK_NREG; if (fattrit) dok = (atoi(_year) == datadoc.year()) && _month == 13; @@ -1221,7 +1237,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & bool game_found = false; TImporto residuo; - BREAK_DBG; + BREAK_NREG; if (has_sc) { arrpart.add_numreg(numreg); @@ -1253,13 +1269,10 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & bool regular_month = orizzonte >= date; bool first_month = regular_month && date > inizio + 1L; - BREAK_DBG; -#ifdef DBG - if (rp.get_long(PART_NREG) == 100616) - int i = 1; -#endif + BREAK_NREG; flag_pg_nc = rp.calcola_pagato_periodo(first_month ? botime : inizio + 1L, orizzonte, pg_per, nc_per, &pagscatt) && regular_month; - residuo += pg_per; + if (IMPORTO_NON_ZERO(residuo)) + residuo += pg_per; if (pagscatt.items() >= 2) { // Fondo tra loro le righe generate dallo stesso pagamento @@ -1304,7 +1317,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & if (ps == obj) { found = true; - BREAK_DBG; + BREAK_NREG; } } if (!found) @@ -1367,7 +1380,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & datainc = data_end_cassa; #ifdef DBG else - BREAK_DBG; + BREAK_NREG; #endif _mov->put(MOV_DATAINC, datainc); if (datainc < date) @@ -1450,10 +1463,10 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & real nin_iva = ZERO; // imposta non incassati const TString4 codiva = _rmoviva->get(RMI_CODIVA); - TCodiceIVA civa(codiva); + const TCodiceIVA& civa = cached_codIVA(codiva); #ifdef DBG - BREAK_DBG; + BREAK_NREG; if (tipomov == vendite) int i = 1; if (!bIsMovDiff && (civa.percentuale() == 20)) @@ -1466,17 +1479,16 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & continue; } - look_iva(codiva); // da eliminare esso per evitare un problema di non lettura _iva ve eliminato - const TString4 tipoiva = _iva->get("S1"); - const TString4 tipoes_v = _iva->get("S2"); - const TString4 tipoes_a = _iva->get("S9"); - const int tipoagr = _iva->get_int("I4"); // 2/9/2015 was S4 - const int tipoag = _iva->get_int("S5"); - const int tipopla = _iva->get_int("S3"); - int isrimbinfr = _iva->get_bool("B3"); // vale per calcolo rimborso se ES o NI - const real perciva = _iva->get_real("R0") / CENTO; - int ivarimb = !_iva->get_bool("B4"); // non escluso calcolo rimb. per al. media - const bool den_prorata = _iva->get_bool("B7"); // denominatore prorata nel caso di calcolo pro rata con numeratore e denominatore + const TString4 tipoiva = civa.tipo(); + const TString4 tipoes_v = civa.IVA11_vendite(); + const TString4 tipoes_a = civa.IVA11_acquisti(); + const int tipoagr = civa.tipo_IVA_agricola(); // 2/9/2015 was S4 + const int tipoag = civa.tipo_agenzie_viaggio(); + const int tipopla = civa.tipo_plafond(); + int isrimbinfr = civa.codice_rimborso_infrannuale(); // vale per calcolo rimborso se ES o NI + const real perciva = civa.moltiplicatore_percentuale(); + int ivarimb = !civa.escluso_dal_rimborso(); // non escluso calcolo rimb. per al. media + const bool den_prorata = civa.tipo_IVA_agricola(); // denominatore prorata nel caso di calcolo pro rata con numeratore e denominatore const TString4 tipocr_s = _rmoviva->get(RMI_TIPOCR); const int tipocr = atoi(tipocr_s); @@ -1528,7 +1540,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & const TCli_for & clifo = cached_clifor(LF_MOV, _mov->curr()); const int tp = clifo.alleg(); - BREAK_DBG; + BREAK_NREG; if ((soloiva && (caus_reg.objptr(codcaus) != NULL || tp < 1)) && sosp_imp != vol_affari) @@ -1551,15 +1563,17 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & real diff_ivar = (is_detr_diff == 0) ? impos_det : impos_ind; real diff_totr = diff_impr + diff_ivar; + if (diff_totr == ZERO) continue; + BREAK_CODIVA(codiva); TDate datafat = _mov->get_date(MOV_DATAREG); long numreg = _rmoviva->get_long(RMI_NUMREG); sezfat = tipomov == vendita ? 'D' : 'A'; - if (is_detr_diff == 1 || civa.tipo() == "NS") + if (is_detr_diff == 1 || civa.iva_non_soggetta()) continue; if (bIsMovDiff && tm == tm_fattura) { @@ -1567,7 +1581,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & int mesereg = liqmonth == 0 ? datareg.month() : liqmonth; bool ok = is_month_ok(mesereg, month) && (atoi(_year) == datareg.year()); - BREAK_DBG; + BREAK_NREG; if (ok) { datafat = datareg; @@ -1876,28 +1890,28 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & if (tipoiva.empty() && codcf != 0) { - TString8 key; key.format("%c|%ld", _mov->get_char(MOV_TIPO), codcf); + TToken_string 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); - } - + key.cut(0); + key.add(get_firm()); + + int unloc = _reg->get_int("I7"); + + if (unloc == 0) + unloc = 1; + key.add(unloc); + + const TRectype & runloc = cache().get(LF_UNLOC, key); + + key.format("|%s", (const char *)runloc.get(ULC_COMULC)); + const TRectype& comune = cache().get(LF_COMUNI, key); + codreg = comune.get_int(COM_CODREG) + 1; } @@ -1918,7 +1932,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & bool bMovDiffToAdd = true; #ifdef DBG - BREAK_DBG; + BREAK_NREG; if (!bIsMovDiff && (civa.percentuale() == 20)) real p = imposta_orig / imponibile_orig * CENTO; #endif @@ -2221,8 +2235,10 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & if (_pcon_1_r->get_int(PCN_INDBIL) == 4) if (_cur->is_first_match(-AGR_PCON2)) // Esiste il sottoconto ? { - if (look_iva(_pcon_2_r->get(PCN_IVACOMP))) - ivacomp = _iva->get("CODTAB"); // Ecco il codice IVA di compensazione + const TCodiceIVA & civa = cached_codIVA(_pcon_2_r->get(PCN_IVACOMP)); + + if (civa.ok()) + ivacomp = civa.codice(); // Ecco il codice IVA di compensazione } look_pia(month, codatt, codiva, ivacomp, true); // Crea il record in tabella se non esiste real pia_imp = _pia->get_real("R0") + agr_imp; // Aggiorna... @@ -2687,7 +2703,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & if (diff_imp > ZERO) int i = 1; tab->curr().add("R30", diff_imp); - tab->curr().add("R31", diff_iva); + tab->curr().add("R31", diff_iva); tab->curr().add("R32", incdiff_imp); tab->curr().add("R33", incdiff_iva); fdiff_imp_acq += diff_imp; @@ -2727,11 +2743,10 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & if (_pim->get_bool("B4")) { // ricalcola l'imposta a partire dal codice IVA - look_iva(*_pim_codiva); - real old_iva = _pim->get_real("R1"); - real perc = _iva->get_real("R0"); + const TCodiceIVA & civa = cached_codIVA(*_pim_codiva); + const real old_iva = _pim->get_real("R1"); + real new_iva = _pim->get_real("R0") * civa.moltiplicatore_percentuale(); - real new_iva = _pim->get_real("R0") * perc / CENTO; round_al_centesimo(new_iva); if (new_iva != old_iva) @@ -2759,10 +2774,9 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & if (_pia->get_bool("B0")) { // calcola l'imposta a partire dal codice IVA di compensazione - look_iva(*_pia_codcom); - real perc = _iva->get_real("R0"); - - real iva = _pia->get_real("R0") * perc / CENTO; + const TCodiceIVA & civa = cached_codIVA(*_pia_codcom); + real iva = _pia->get_real("R0") * civa.moltiplicatore_percentuale(); + round_al_centesimo(iva); agr_detIA += iva; _pia->put("R1",iva); @@ -2994,12 +3008,14 @@ void TLiquidazione_app::iva11_set_arr_phase_1(const TString& codatt) if (is_split_payment(_mov->curr())) imposta = ZERO; - const TString4 codiva = _iva->get("CODTAB"); - const TString4 tipoiva = _iva->get("S1"); - const real ali = _iva->get_real("R0"); - const TString4 tipoes_v = _iva->get("S2"); - const TString4 tipoes_a = _iva->get("S9"); - const int tipoagr = _iva->get_int("I4"); // 2/9/2015 was S4 + + const TCodiceIVA & civa = cached_codIVA(_rmoviva->get(RMI_CODIVA)); + const TString4 codiva = civa.codice(); + const TString4 tipoiva = civa.tipo(); + const real ali = civa.percentuale(); + const TString4 tipoes_v = civa.IVA11_vendite(); + const TString4 tipoes_a = civa.IVA11_acquisti(); + const int tipoagr = civa.tipo_IVA_agricola(); // 2/9/2015 was S4 const TRectype& rcs = _cur->curr(LF_CAUSALI); const bool autofattura = rcs.get_bool("AUTOFATT"); const bool valintra = rcs.get_bool("VALINTRA"); @@ -3379,14 +3395,17 @@ void TLiquidazione_app::iva11_set_arr_phase_2(const TString& codatt) // Must consider current activity too... codiva = *_pim_codiva; reg = *_pim_codreg; - look_iva(codiva); look_reg(reg); // posiziona la tabella registri e quella IVA - tiva = _iva->get("S1"); // tipo IVA - tpla = _iva->get("S3"); // tipo gestione plafond - tagr = _iva->get_int("I4"); // tipo gestione regime agricolo 2/9/2015 was S4 - tvia = _iva->get("S5"); // tipo gestione ag. viaggio - v11 = _iva->get("S2"); // n.ro riga vendite per mod. IVA11 - a11 = _iva->get("S9"); // n.ro riga acquisti per mod. IVA11 - aliq = _iva->get_real("R0"); // aliquota + + const TCodiceIVA & civa = cached_codIVA(codiva); + + look_reg(reg); // posiziona la tabella registri e quella IVA + tiva = civa.tipo(); // tipo IVA + tpla = civa.tipo_plafond(); // tipo gestione plafond + tagr = civa.tipo_IVA_agricola(); // tipo gestione regime agricolo 2/9/2015 was S4 + tvia = civa.tipo_agenzie_viaggio(); // tipo gestione ag. viaggio + v11 = civa.IVA11_vendite(); // n.ro riga vendite per mod. IVA11 + a11 = civa.IVA11_acquisti(); // n.ro riga acquisti per mod. IVA11 + aliq = civa.percentuale(); // aliquota treg = (tiporeg)_reg->get_long("I0"); const bool is_vendita = treg == vendita; const bool is_acquisto = treg == acquisto; @@ -3484,7 +3503,7 @@ void TLiquidazione_app::iva11_set_arr_phase_2(const TString& codatt) _CorrItem& ca = (_CorrItem&) corr_ann[codiva]; ca._totale += lor; if (!is_present) - ca._aliquota = _iva->get_real("R0"); // Se e' nuovo setta l'aliquota + ca._aliquota = civa.percentuale(); // Se e' nuovo setta l'aliquota } tt = _pim->get("S0"); @@ -4541,8 +4560,10 @@ void TLiquidazione_app::recalc_annual(const char* att, bool & first) const int tipocr = atoi(*_pim_tipocr); codiva = *_pim_codiva; reg = *_pim_codreg; - look_iva(codiva); look_reg(reg); - tiva = _iva->get("S1"); + const TCodiceIVA & civa = cached_codIVA(codiva); + + look_reg(reg); + tiva = civa.tipo(); const TRegistro & reg = cached_registro(_reg->curr()); const tipo_sospensione simp = reg.sospensione(); @@ -4573,7 +4594,7 @@ void TLiquidazione_app::recalc_annual(const char* att, bool & first) _CorrItem& ca = (_CorrItem&)corr_ann[codiva]; ca._totale += _pim->get_real("R3"); if (!is_key) // se non c'e' lo aggiunge - ca._aliquota = _iva->get_real("R0") / CENTO; // Se è nuovo setta l'aliquota + ca._aliquota = civa.moltiplicatore_percentuale(); // Se è nuovo setta l'aliquota } if (tipoatt == 1) volaff1 += imp_ifs; diff --git a/src/include/mask.cpp b/src/include/mask.cpp index 75dd52c34..649561696 100755 --- a/src/include/mask.cpp +++ b/src/include/mask.cpp @@ -1194,6 +1194,7 @@ int TMask::win2page(WINDOW w) const TMask_field* TMask::parse_field(TScanner& scanner) { const TString& k = scanner.key(); + if (k == "BO") return new TBoolean_field(this); if (k == "BR") return new TBrowsefile_field(this); if (k == "BU") return new TButton_field(this); diff --git a/src/include/mov.h b/src/include/mov.h index 266340987..4f18392b6 100755 --- a/src/include/mov.h +++ b/src/include/mov.h @@ -61,7 +61,6 @@ #define MOV_KEYFPPRO "KEYFPPRO" #define MOV_MOVCOLL "MOVCOLL" #define MOV_ELABF9 "ELABF9" - #define MOV_IDDOCSDI "IDDOCSDI" #define MOV_DATADOCSDI "DATADOCSDI" diff --git a/src/include/relation.cpp b/src/include/relation.cpp index bbb6213d9..01e57fc8b 100755 --- a/src/include/relation.cpp +++ b/src/include/relation.cpp @@ -1423,7 +1423,6 @@ TRecnotype TCursor::update() _lastrec = eod; _index_firm = prefix().get_codditta(); _lastkrec = DB_changed(handle); - return _totrec; } diff --git a/src/include/tabapp.cpp b/src/include/tabapp.cpp index 19c1be32a..5b45a511e 100755 --- a/src/include/tabapp.cpp +++ b/src/include/tabapp.cpp @@ -108,6 +108,8 @@ bool TTable_application::user_create() return false; _tabname = argv(2); + if (_tabname == "ÊU") + _tabname = "%CAU"; _tabname.upper(); _rel = new TRelation(_tabname); diff --git a/src/include/tsdb.cpp b/src/include/tsdb.cpp index 76cd1df5f..bf95a2c6b 100644 --- a/src/include/tsdb.cpp +++ b/src/include/tsdb.cpp @@ -26,28 +26,35 @@ const real SSimple_query::sq_get_real(const char * field) return app; } -TString SSimple_query::sq_get(const char* field, bool rtrim) +const TString & SSimple_query::sq_get(const char* field, const bool rtrim) { - TString fld = _rec.get(field); + TString & fld = get_tmp_string(1024); + + fld = _rec.get(field); if (rtrim) fld.rtrim(); return fld; } -TString SSimple_query::sq_get(const string& field, const bool rtrim) +const TString & SSimple_query::sq_get(const string& field, const bool rtrim) { return sq_get(field.c_str(), rtrim); } -TString SSimple_query::sq_get(TString& field, bool rtrim) +const TString & SSimple_query::sq_get(TString& field, const bool rtrim) { - return sq_get(static_cast(field), rtrim); + return sq_get((const char *)field, rtrim); } -TString SSimple_query::sq_get(unsigned int column, bool rtrim) +const TString & SSimple_query::sq_get(unsigned int column, const bool rtrim) { - return _rec.get(column); + TString & val = get_tmp_string(1024); + + val << _rec.get(column); + if (rtrim) + val.rtrim(); + return val; } unsigned SSimple_query::sq_get_num_fields() const @@ -55,9 +62,12 @@ unsigned SSimple_query::sq_get_num_fields() const return _rec.get_num_fields(); } -TString SSimple_query::sq_get_name_field(const unsigned column) const +const TString & SSimple_query::sq_get_name_field(const unsigned column) const { - return _rec.get_name_field(column); + TString & name = get_tmp_string(); + + name = _rec.get_name_field(column); + return name; } int SSimple_query::sq_get_width_field(const unsigned column) const @@ -75,6 +85,8 @@ TFieldtypes SSimple_query::sq_get_type_field(const unsigned column) const return _boolfld; if (type == "dtShort") return _intfld; + if (type == "dtLong") + return _longfld; if (type == "dtULong") return _longfld; if (type == "dtDouble") diff --git a/src/include/tsdb.h b/src/include/tsdb.h index 4a92a47ba..8fc0196aa 100644 --- a/src/include/tsdb.h +++ b/src/include/tsdb.h @@ -40,29 +40,22 @@ #ifndef __STRINGS_H #include -#endif // !__STRINGS_H - +#endif // #ifndef __DATE_H #include -#endif // !__DATE_H +#endif // #ifndef __REAL_H #include -#endif // !__REAL_H +#endif // -#define CHIAVE_ID_ "_ID_" #include "recset.h" /******************************************************************************** - * SSimpleQuery (Sirio Simple Query) * + * SSimpleQuery (Sirio Simple Query) * * "Wrapper" di TXvt_recordset, implementa OGNI funzione in modo tale da * * poterlo sostituire brutalmente in qualsiasi momento così da non aver * - * problemi come durante il passaggio da ISAM a SQL (spero). * - * Se ti stai domandando perchè non è stata usata l'ereditarietà (magari con * - * un bel ": private TXvt_recordset" così da bloccare il tutto) è per bloccare * - * qualsiasi riferimento a questa classe in eventuali reimplementazioni future. * - * Preferisco scrivere un po' di codice ridondante adesso che andare a fare * - * salti mortali dopo * + * problemi come durante il passaggio da ISAM a SQL (spero). che cazzata da riscrivere * ********************************************************************************/ class SSimple_query { @@ -160,19 +153,19 @@ public: /**< Ritorna il valore nel campo (field) in formato (SADateTime), Campo non gestisce le ore */ //SADateTime sqGetDateTime(const char* field) { get_short(field); } /**< Ritorna il valore nel campo (field) passato come (const char *) in formato (const char *) */ - TString sq_get(const char* field, bool rtrim = true); + const TString & sq_get(const char* field, bool rtrim = true); /**< Ritorna il valore nel campo (field) passato come (string) in formato (const char *) */ - TString sq_get(const string& field, bool rtrim = true); + const TString & sq_get(const string& field, bool rtrim = true); /**< Ritorna il valore nel campo (field) passato come (TString) in formato (const char *) */ - TString sq_get(TString& field, bool rtrim = true); + const TString & sq_get(TString& field, bool rtrim = true); /**< Ritorna il valore della colonna numero (column) passato come (unsigned int) */ - TString sq_get(unsigned int column, bool rtrim = true); + const TString & sq_get(unsigned int column, bool rtrim = true); /**< Ritorna il valore nel campo (field) in formato (char) */ const char sq_get_char(const char* field) { return _rec.get_char(field); } /**< Ritorna il numero di campi dopo l'ultimo comando di esecuzione effettuato; se il risultato esiste */ unsigned int sq_get_num_fields() const; - /**< Ritorna il nome del campo numero (column) in formato (TString= */ - TString sq_get_name_field(unsigned column) const; + /**< Ritorna il nome del campo numero (column) in formato (TString) = */ + const TString & sq_get_name_field(unsigned column) const; /**< Ritorna la grandezza del campo numero (column) */ int sq_get_width_field(unsigned column) const; /**< Ritorna il tipo del campo numero (column) in formato (TFieldtypes) */ @@ -198,12 +191,12 @@ public: void defrost() { _rec.defrost(); } /**< Costruttore, non inizializza nulla, da caricare successivamente */ - SSimple_query() = default; + SSimple_query() {}; /**< Costruttore, Accetta in ingresso dei parametri per la connessione, volendo è anche possibile impostare una query ed eseguirla. Attenzione! Non risponde se la query ha avuto un esito positivo o negativo! */ SSimple_query(const char* db, const char* user, const char* pass, const TT_driver tipo_db, const char * query = "", const bool ex = false, const bool freezed = false) : _rec(db, user, pass, tipo_db, query, ex, freezed) {} //SSimpleQuery(const TString& db, const TString& user, const TString& pass, TT_driver tipoDb, const char * query = "", const bool ex = false, const bool freezed = false) : _rec(db, user, pass, tipoDb, query, ex, freezed) {} /**< Distruttore */ - virtual ~SSimple_query() = default; + virtual ~SSimple_query() {}; }; #endif \ No newline at end of file diff --git a/src/include/winsock.h b/src/include/winsock.h index 8b94a04cc..5894f661d 100755 --- a/src/include/winsock.h +++ b/src/include/winsock.h @@ -490,6 +490,7 @@ struct linger { /* * Windows Sockets definitions of regular Microsoft C error constants */ +#ifndef WSAEINTR #define WSAEINTR (WSABASEERR+4) #define WSAEBADF (WSABASEERR+9) #define WSAEACCES (WSABASEERR+13) @@ -497,6 +498,7 @@ struct linger { #define WSAEINVAL (WSABASEERR+22) #define WSAEMFILE (WSABASEERR+24) + /* * Windows Sockets definitions of regular Berkeley error constants */ @@ -581,6 +583,7 @@ struct linger { /* * Windows Sockets errors redefined as regular Berkeley error constants */ + #define EWOULDBLOCK WSAEWOULDBLOCK #define EINPROGRESS WSAEINPROGRESS #define EALREADY WSAEALREADY @@ -618,6 +621,7 @@ struct linger { #define EDQUOT WSAEDQUOT #define ESTALE WSAESTALE #define EREMOTE WSAEREMOTE +#endif /* Socket function prototypes */