From 1159b1d0920b0ebcf41fc3db25e492c2a17fd98f Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 23 Feb 2012 16:50:46 +0000 Subject: [PATCH] Patch level : 10.0 Files correlati : cg2.exe Ricompilazione Demo : [ ] Commento : Abilitate ricerche per codice alternativo git-svn-id: svn://10.65.10.50/branches/R_10_00@22584 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg2102.cpp | 5 -- cg/cg2105.cpp | 80 +++++-------------------- cg/cg5100a.h | 4 +- cg/cg5100a.uml | 35 +++++++---- cg/cgpagame.h | 2 +- cg/cgsalda3.cpp | 2 +- cg/cgsaldac.cpp | 156 +++++++++++++++++++++++++++++------------------- cg/cgsaldac.h | 3 + 8 files changed, 140 insertions(+), 147 deletions(-) diff --git a/cg/cg2102.cpp b/cg/cg2102.cpp index 48f2fa818..e9492dbfb 100755 --- a/cg/cg2102.cpp +++ b/cg/cg2102.cpp @@ -2967,11 +2967,6 @@ void TPrimanota_application::gioca_cambi(int force) if ( (force == 0x4 || cambio.is_zero()) && !(totale.is_zero() || totval.is_zero()) ) { real new_cambio = totale / totval; - exchange_type dummy_contro_euro; - const real& fc = TCurrency::get_firm_change(dummy_contro_euro); - if (fc > ZERO) - new_cambio *= fc; - new_cambio.round(6); if (new_cambio != cambio) m.set(SK_CAMBIO, new_cambio, true); diff --git a/cg/cg2105.cpp b/cg/cg2105.cpp index 737a51615..d0637891f 100755 --- a/cg/cg2105.cpp +++ b/cg/cg2105.cpp @@ -8,6 +8,7 @@ #include "cg2102.h" // Applicazione di prima nota #endif +#include "cg2105.h" #include "cg2107.h" #include // Colori righe @@ -99,49 +100,6 @@ public: // Maschera pagamenti /////////////////////////////////////////////////////////// -class TPay_mask : public TMask -{ - TDate _datadoc, _datarat; - real _da_pagare, _pagabile; - const TGame_mask* _parent; - - tipo_movimento _tipomov; - - bool _assigned; - bool _can_solder; - bool _swap_ritsoc; - -protected: - static bool importo_handler(TMask_field& f, KEY k); - static bool importolire_handler(TMask_field& f, KEY k); - static bool saldo_handler(TMask_field& f, KEY k); - static bool datapag_handler(TMask_field& f, KEY k); - static bool conto_handler(TMask_field& f, KEY k); - static bool descr_handler(TMask_field& f, KEY k); - void gioca_cambi(int force = 0x0); - -#ifdef __EXTRA__ - static bool datareg_handler(TMask_field& f, KEY k); - static bool datadoc_handler(TMask_field& f, KEY k); - static bool numdoc_handler(TMask_field& f, KEY k); - static bool sezione_handler(TMask_field& f, KEY k); -#endif - -public: - void set_pag(const TRectype& oldpag, const TRiga_scadenze& scad, const TImporto& importo); - void get_pag(TRectype& oldpag, TRectype& somma) const; - - bool assigned() const { return _assigned; } - bool unassigned() const { return !_assigned; } - tipo_movimento tipo() const { return _tipomov; } - - void attiva_valuta(bool on); - - void init(const TGame_mask* parent, int mode); - TPay_mask(const TGame_mask* parent, int mode); - virtual ~TPay_mask(); -}; - #ifdef __EXTRA__ const char* const PAYMASK = "sc0100b"; #else @@ -150,7 +108,10 @@ const char* const PAYMASK = "cg2100s"; void TPay_mask::init(const TGame_mask* parent, int mod) { +#ifndef __EXTRA__ _parent = parent; +#endif + set_mode(mod); enable(DLG_DELREC, edit_mode()); @@ -576,30 +537,18 @@ bool TPay_mask::conto_handler(TMask_field& f, KEY k) // Maschera gestione nuovo pagamento / fattura /////////////////////////////////////////////////////////// -class TNew_mask : public TMask -{ - bool _allow_fatt; - -protected: - static bool tipomov_handler(TMask_field& f, KEY k); - -public: - void init(char tipocf, bool fatt, bool edit); - - TNew_mask(char tipocf, bool fatt, bool edit); - virtual ~TNew_mask() {} -}; - -bool TNew_mask::tipomov_handler(TMask_field& f, KEY k) +bool TNew_mask::on_field_event(TOperable_field& f, TField_event e, long jolly) { - if (k == K_ENTER) + switch (f.dlg()) { - TNew_mask& m = (TNew_mask&)f.mask(); - if (!m._allow_fatt && f.get() == "1") - return f.error_box(TR("Non e' possibile utilizzare una fattura come pagamento")); + case P_NUOVO: + if (e == fe_close && !_allow_fatt && f.get() == "1") + return error_box(TR("Non e' possibile utilizzare una fattura come pagamento")); + break; + default: + break; } - - return TRUE; + return true; } void TNew_mask::init(char tipocf, bool fatt, bool edit) @@ -608,7 +557,6 @@ void TNew_mask::init(char tipocf, bool fatt, bool edit) TMask_field& tipomov = field(P_NUOVO); #ifdef __EXTRA__ - tipomov.set_handler(tipomov_handler); tipomov.enable(); tipomov.set(_allow_fatt ? "1" : "3"); if (!_allow_fatt) @@ -633,7 +581,7 @@ void TNew_mask::init(char tipocf, bool fatt, bool edit) } TNew_mask::TNew_mask(char tipocf, bool fatt, bool edit) - : TMask("cg2100n") + : TAutomask("cg2100n") { init(tipocf, fatt, edit); } diff --git a/cg/cg5100a.h b/cg/cg5100a.h index a7f4442f2..ebb5089fa 100755 --- a/cg/cg5100a.h +++ b/cg/cg5100a.h @@ -17,6 +17,8 @@ #define FLD_NUM_EC 117 #define FLD_LAST_EC 118 #define FLD_DATSAL 119 +#define CHK_EASYSAL 120 +#define CHK_DIFFCAM 121 #define FLD_CSBICHS 217 #define FLD_CSBICHG 218 @@ -42,6 +44,7 @@ #define FLD_CSAUCPS 238 #define FLD_CSAUCPG 239 #define FLD_CSAUCPC 240 +#define FLD_DCSAUCP 241 #define LST_RRFRAM 338 #define CHK_RRMECO 339 @@ -66,7 +69,6 @@ #define CHK_DTCFPG 358 #define CHK_RIFPRO 359 #define CHK_LIQDIF 360 -#define FLD_DCSAUCP 361 #define FLD_RATEI_G 371 #define FLD_RATEI_C 372 diff --git a/cg/cg5100a.uml b/cg/cg5100a.uml index 95a99a006..73a8d5660 100755 --- a/cg/cg5100a.uml +++ b/cg/cg5100a.uml @@ -88,7 +88,7 @@ BEGIN GROUP GROUP_CONTABILITA END -GROUPBOX DLG_NULL 76 7 +GROUPBOX DLG_NULL 76 8 BEGIN PROMPT 2 12 "@bParametri saldaconto" END @@ -98,10 +98,10 @@ BEGIN PROMPT 4 13 "Gestione saldaconto " MESSAGE TRUE ENABLE,CHK_GESVAL|ENABLE,CHK_NRCLIDX|ENABLE,CHK_NRFORDX MESSAGE TRUE ENABLE,CHK_DTCFPG|ENABLE,CHK_RIFPRO|ENABLE,FLD_CODLIN - MESSAGE TRUE ENABLE,FLD_NUM_EC|ENABLE,FLD_LAST_EC + MESSAGE TRUE ENABLE,FLD_NUM_EC|ENABLE,FLD_LAST_EC|ENABLE,CHK_EASYSAL MESSAGE FALSE DISABLE,CHK_GESVAL|DISABLE,CHK_NRCLIDX|DISABLE,CHK_NRFORDX MESSAGE FALSE DISABLE,CHK_DTCFPG|DISABLE,CHK_RIFPRO|DISABLE,FLD_CODLIN - MESSAGE FALSE DISABLE,FLD_NUM_EC|DISABLE,FLD_LAST_EC + MESSAGE FALSE DISABLE,FLD_NUM_EC|DISABLE,FLD_LAST_EC|CLEAR,CHK_EASYSAL FIELD GesSal GROUP GROUP_SALDACONTO END @@ -121,9 +121,24 @@ BEGIN GROUP GROUP_SALDACONTO END +BOOLEAN CHK_EASYSAL +BEGIN + PROMPT 35 14 "Saldaconto semplificato " + FIELD EasySal + GROUP GROUP_SALDACONTO +END + +BOOLEAN CHK_DIFFCAM +BEGIN + PROMPT 4 15 "Rilevazione differenze cambi su pagamenti parziali" + HELP "Indicare se si desidera calcolare le eventuali differenze cambi anche sui pagamenti non a saldo" + FIELD DiffCamAlways + GROUP GROUP_SALDACONTO +END + BOOLEAN CHK_NRCLIDX BEGIN - PROMPT 4 15 "N. Rif. allineato a destra per clienti" + PROMPT 4 16 "N. Rif. allineato a destra per clienti" HELP "Indicare se allineare a destra il num. di rif. delle partite nel saldaconto" FIELD NrCliDx GROUP GROUP_SALDACONTO @@ -131,7 +146,7 @@ END BOOLEAN CHK_NRFORDX BEGIN - PROMPT 48 15 "e per fornitori" + PROMPT 48 16 "e per fornitori" HELP "Indicare se allineare a destra il num. di rif. delle partite nel saldaconto" FIELD NrForDx GROUP GROUP_SALDACONTO @@ -139,7 +154,7 @@ END BOOLEAN CHK_RIFPRO BEGIN - PROMPT 4 16 "Riferimento partita con numero protocollo" + PROMPT 4 17 "Riferimento partita con numero protocollo" HELP "Indicare se si desidera il numero protocollo IVA anziche' il numero documento come riferimento partita" FIELD RifPro GROUP GROUP_SALDACONTO @@ -147,7 +162,7 @@ END STRING FLD_CODLIN 1 BEGIN - PROMPT 50 16 "Codice lingua " + PROMPT 50 17 "Codice lingua " HELP "Lingua di riferimento per rendiconti contabili" FIELD CodLin USE %LNG @@ -161,7 +176,7 @@ END LIST FLD_NUM_EC 1 10 BEGIN - PROMPT 4 17 "Numerazione estratti conto " + PROMPT 4 18 "Numerazione estratti conto " ITEM " |Nessuna" MESSAGE HIDE,FLD_LAST_EC ITEM "G|Globale" MESSAGE SHOW,FLD_LAST_EC ITEM "A|Anagrafica" MESSAGE HIDE,FLD_LAST_EC @@ -171,14 +186,14 @@ END NUMBER FLD_LAST_EC 6 BEGIN - PROMPT 50 17 "Ultimo E.C. " + PROMPT 50 18 "Ultimo E.C. " FIELD LastEC GROUP GROUP_SALDACONTO END BOOLEAN CHK_DTCFPG BEGIN - PROMPT 4 18 "Dettaglio riga C/F sui pagamenti" + PROMPT 4 19 "Dettaglio riga C/F sui pagamenti" HELP "Indicare se si desidera il dettaglio riga clienti/fornitori in gestione pagamenti" FIELD DtCfPg GROUP GROUP_SALDACONTO diff --git a/cg/cgpagame.h b/cg/cgpagame.h index 8635d3503..c1a8407ed 100755 --- a/cg/cgpagame.h +++ b/cg/cgpagame.h @@ -227,7 +227,7 @@ public: { set_total(ib.get_num(), im.get_num(), sp.get_num());} void set_total_valuta(const TCurrency& ib, const TCurrency& im, const TCurrency& sp, const TCurrency& ibl, const TCurrency& iml, const TCurrency& spl) - { set_total_valuta(ib.get_num(), im.get_num(), sp.get_num(), ib.get_base_change(), + { set_total_valuta(ib.get_num(), im.get_num(), sp.get_num(), ib.get_change(), ibl.get_num(), iml.get_num(), spl.get_num(), ib.get_value());} // istanzia uno sheet field come diobue comanda diff --git a/cg/cgsalda3.cpp b/cg/cgsalda3.cpp index 1934b874d..fb1053007 100755 --- a/cg/cgsalda3.cpp +++ b/cg/cgsalda3.cpp @@ -486,7 +486,7 @@ void TSolder_tree::set_var_real(TVariant& var, const real& imp, bool in_value) c if (in_value) cur.change_to_firm_val(); else - cur.change_value(_codval, _cambio, _exchange_contro); + cur.change_value(_codval, _cambio); } var = cur.string(true); } diff --git a/cg/cgsaldac.cpp b/cg/cgsaldac.cpp index 99911d0b1..15f63985b 100755 --- a/cg/cgsaldac.cpp +++ b/cg/cgsaldac.cpp @@ -4,6 +4,7 @@ #include #include "cgsaldac.h" +#include "cg2103.h" #include #include @@ -123,7 +124,7 @@ TValuta::TValuta() : _cod(""), _dat(TODAY), _cam(ZERO) void TValuta::adjust() { - const TCurrency this_cur(ZERO, _cod, _cam, _exchange_contro); + const TCurrency this_cur(ZERO, _cod, _cam); if (this_cur.is_firm_value()) { _cod.cut(0); @@ -158,16 +159,12 @@ void TValuta::put(TRectype& rec) const rec.put("CODVAL", _cod); rec.put("DATACAM", _dat); rec.put("CAMBIO", _cam); - if (rec.exist("CONTROEURO")) - rec.put("CONTROEURO", "X"); } else { rec.zero("CODVAL"); rec.zero("DATACAM"); rec.zero("CAMBIO"); - if (rec.exist("CONTROEURO")) - rec.zero("CONTROEURO"); } } @@ -205,20 +202,20 @@ void TValuta::set(const TValuta& v) real TValuta::eur2val(const real& lit) const { TCurrency cur(lit); - cur.change_value(_cod, _cam, _exchange_contro); + cur.change_value(_cod, _cam); return cur.get_num(); } real TValuta::val2eur(const real& val) const { - TCurrency cur(val, _cod, _cam, _exchange_contro); + TCurrency cur(val, _cod, _cam); cur.change_to_firm_val(); return cur.get_num(); } void TValuta::val2eur(real& val) const { - TCurrency cur(val, _cod, _cam, _exchange_contro); + TCurrency cur(val, _cod, _cam); cur.change_to_firm_val(); val = cur.get_num(); } @@ -226,7 +223,7 @@ void TValuta::val2eur(real& val) const void TValuta::eur2val(real& lit) const { TCurrency cur(lit); - cur.change_value(_cod, _cam, _exchange_contro); + cur.change_value(_cod, _cam); lit = cur.get_num(); } @@ -285,7 +282,7 @@ const TString& TRiga_scadenze::codice_valuta() const // Controlla se la rata e' stata completamente pagata bool TRiga_scadenze::chiusa(bool update) const { - bool chiusa; + bool chiusa = false; if (update) { TImporto imp(importo(true)); @@ -469,16 +466,31 @@ TImporto TRiga_scadenze::calcola_differenza_cambio(int p, bool update) TImporto diffcam; TRectype& pag = row(p); - if (pag.get_char(PAGSCA_ACCSAL) == 'S' && in_valuta()) + const bool a_saldo = pag.get_char(PAGSCA_ACCSAL) == 'S'; + if (in_valuta() && (a_saldo || partita().rileva_sempre_differenze_cambi())) { - const char sez = partita().riga(p).sezione(); - + const char sez = partita().riga(p).sezione(); if (update) { - diffcam = importo(false); - pag.zero(PAGSCA_DIFFCAM); - diffcam += importo_pagato(false); // Conta anche gli abbuoni e le altre diffcam - diffcam.swap_section(); + const int dec = TCurrency::get_firm_dec(); + // Normalmente le differenze cambio si rilevano solo a saldo ... + if (a_saldo) + { + diffcam = importo(false); // Importo della scadenza in in euro + pag.zero(PAGSCA_DIFFCAM); // Azzera temporaneamente la DIFFCAM del pagamento corrente + diffcam += importo_pagato(false); // Conta anche gli abbuoni e le altre diffcam + diffcam.swap_section(); + } + else // ... ma non alla Pharmatex + { + const TImporto e = importo(false); // Importo della scadenza in euro + const TImporto v = importo(true); // Importo della scadenza in valuta + const real pg = pag.get_real(PAGSCA_IMPORTO); + real rt = e.valore() * pag.get_real(PAGSCA_IMPORTOVAL) / v.valore(); + rt.round(dec); + diffcam.set(e.sezione(), rt-pg); + } + diffcam.normalize(sez); pag.put(PAGSCA_DIFFCAM, diffcam.valore()); } @@ -521,7 +533,7 @@ TImporto TRiga_scadenze::esposto_al(bool valuta, const TDate & al, const TDate & datapag = data; if (datapag <= al) { - const int tp = pag.get_int(PART_TIPOPAG); + const tipo_pagamento tp = pag.tipo_pag(); if (tp >= tp_tratta && tp <= tp_rid) { @@ -543,7 +555,7 @@ TImporto TRiga_scadenze::esposto_al(bool valuta, const TDate & al, const TDate & return esposto; } -TImporto TRiga_scadenze::esposto(bool valuta, const TDate & data_scad, const TDate & data_rischio, bool & sbf) const +TImporto TRiga_scadenze::esposto(bool valuta, const TDate& data_scad, const TDate& data_rischio, bool& sbf) const { TImporto esposto; const bool rischio = data_scad != data_rischio; @@ -554,7 +566,7 @@ TImporto TRiga_scadenze::esposto(bool valuta, const TDate & data_scad, const TDa for (int p = first(); p <= lasts; p = succ(p)) { const TRiga_partite & pag = riga().partita().riga(p); - const int tp = pag.get_int(PART_TIPOPAG); + const tipo_pagamento tp = pag.tipo_pag(); if (tp >= tp_tratta && tp <= tp_rid) { @@ -583,7 +595,6 @@ bool TRiga_scadenze::modifica_pagamento(const TRectype& new_pag, const TValuta& char& new_ap, TImporto& new_abb, TImporto& new_diffcam, bool update) { - const bool in_val = in_valuta(); const int nrigp = new_pag.get_int(PAGSCA_NRIGP); const TRectype old_pag(row(nrigp)); TRiga_partite& sum = partita().riga(nrigp); @@ -591,20 +602,17 @@ bool TRiga_scadenze::modifica_pagamento(const TRectype& new_pag, const TValuta& TImporto old_abbuono; old_ap = calcola_abbuono(nrigp, old_abbuono, false); // Vecchio abbuono in valuta old_abb = old_abbuono; // Vecchio abbuono in lire - if (in_val) + if (in_valuta()) { const TString4 codval = sum.codice_valuta(); - exchange_type et = _exchange_undefined; - if (sum.TRectype::exist(PART_CONTROEURO)) - et = sum.get_bool(PART_CONTROEURO) ? _exchange_contro : _exchange_base; - TCurrency cur(old_abb.valore(), codval, sum.get_real(PART_CAMBIO), et); + TCurrency cur(old_abb.valore(), codval, sum.get_real(PART_CAMBIO)); cur.change_to_firm_val(); old_abb.valore() = cur.get_num(); } old_diffcam = calcola_differenza_cambio(nrigp, false); - if (in_val && valuta.in_valuta()) + if (in_valuta() && !valuta.in_euro()) valuta.put(sum); row(nrigp) = new_pag; @@ -612,14 +620,11 @@ bool TRiga_scadenze::modifica_pagamento(const TRectype& new_pag, const TValuta& TImporto new_abbuono; new_ap = calcola_abbuono(nrigp, new_abbuono, update); // Calcolo abbuono in valuta - new_abb = new_abbuono; // Calcola nuovo abbuono in lire - if (in_valuta()) + new_abb = new_abbuono; // Calcola nuovo abbuono in euro + if (in_valuta() && !new_abb.is_zero()) { const TString4 codval = sum.codice_valuta(); - exchange_type et = _exchange_undefined; - if (((TRectype&)sum).exist(PART_CONTROEURO)) - et = sum.get_bool(PART_CONTROEURO) ? _exchange_contro : _exchange_base; - TCurrency cur(new_abb.valore(), codval, sum.get_real(PART_CAMBIO), et); + TCurrency cur(new_abb.valore(), codval, sum.get_real(PART_CAMBIO)); cur.change_to_firm_val(); new_abb.valore() = cur.get_num(); } @@ -649,8 +654,9 @@ bool TRiga_scadenze::modifica_pagamento(const TRectype& new_pag, const TValuta& bool TRiga_scadenze::esistono_abbuoni_diffcam() const { +/* Prima dellla Pharmatex le differenze cambi potevano aversi solo con pagamenti a saldo bool ad = false; - for (int p = last(); p > 0; p = pred(p)) + for (int p = last(); p > 0 && !ad; p = pred(p)) { const TRectype& pag = row(p); if (pag.get_char(PAGSCA_ACCSAL) == 'S') @@ -664,6 +670,14 @@ bool TRiga_scadenze::esistono_abbuoni_diffcam() const } } return ad; +*/ + for (int p = last(); p > 0; p = pred(p)) + { + const TRectype& pag = row(p); + if (!pag.get_real(PAGSCA_ABBUONI).is_zero() || !pag.get_real(PAGSCA_DIFFCAM).is_zero()) + return true; + } + return false; } @@ -755,10 +769,16 @@ tipo_movimento TRiga_partite::tipo() const return tm; } +tipo_pagamento TRiga_partite::tipo_pag() const +{ + const tipo_pagamento tp = (tipo_pagamento)get_int(PART_TIPOPAG); + return tp; +} + // Calcola il segno delle ritenute sociali in base alla causale char TRiga_partite::sezione_ritsoc() const { - TString16 key; key << get(PART_CODCAUS) << "|14"; // Riga ritenute sociali + TString16 key; key << get(PART_CODCAUS) << '|' << RIGA_PAG_RITSOC; // Riga ritenute sociali const char sez_cau = cache().get(LF_RCAUSALI, key, RCA_SEZIONE)[0]; const char sez_rit = sez_cau > ' ' ? (sez_cau == 'D' ? 'A' : 'D') : sezione(); return sez_rit; @@ -850,8 +870,7 @@ bool TRiga_partite::update(const TImporto& vec, const TImporto& nuo, // Certified 99% int TRiga_partite::ultima_rata_con_abbuoni_diffcam() const { - int s; - + int s = 0; for (s = rate(); s > 0; s--) { const TRiga_scadenze& scad = rata(s); @@ -870,7 +889,7 @@ const TString& TRiga_partite::codice_valuta() const // Determina se una riga e' in valuta in base al codice valuta bool TRiga_partite::in_valuta() const { - return codice_valuta().not_empty(); + return !is_firm_value(codice_valuta()); } // Calcola l'importo in lire o in valuta su di una riga di partita @@ -902,9 +921,11 @@ TImporto TRiga_partite::importo(bool valuta, int mode) const } else // Desidero gli abbuoni in lire { - if (in_euro && (mode & 0x8)) + if (in_euro && (mode & 0x8)) // Ritenute Fiscali e/o sociali { + // Ritenute Fiscali i.valore() += get_real(PART_RITENUTE); + // Ritenute Sociali if (sezione() == sezione_ritsoc()) i.valore() += get_real(PART_RITSOC); else @@ -928,6 +949,7 @@ TImporto TRiga_partite::importo(bool valuta, int mode) const { const TImporto diffcam(get_char(PART_SEZDIFCAM), get_real(PART_DIFFCAM)); i += diffcam; + i.valore().round(TCurrency::get_firm_dec()); } } } @@ -970,7 +992,7 @@ TImporto TRiga_partite::esposto(bool valuta, const TDate & data_scad, const TDat if (p != nrigp) { const TRiga_partite & prow = partita().riga(p); - const int tp = prow.get_int(PART_TIPOPAG); + const tipo_pagamento tp = prow.tipo_pag(); if (tp >= tp_tratta && tp <= tp_rid) { @@ -1041,6 +1063,7 @@ TImporto TRiga_partite::calcola_pagato_al(bool valuta,const TDate& al, const TDa char TPartita::_cli_align = ' '; char TPartita::_for_align = ' '; +bool TPartita::_diffcam_always = false; TPartita::TPartita(const TBill& clifo, int anno, const char* num) : _part(LF_PARTITE, PART_NRIGA), _unassigned(LF_PAGSCA, PAGSCA_NRIGP), _align(' ') @@ -1085,6 +1108,9 @@ void TPartita::carica_allineamento() TConfig cd(CONFIG_DITTA, "cg"); _cli_align = cd.get_bool("NrCliDx") ? 'R' : 'L'; _for_align = cd.get_bool("NrForDx") ? 'R' : 'L'; + + // Nel nuovo saldaconto si possono rilevare le differenze cambi su pagamenti non a saldo + _diffcam_always = cd.get_bool("EasySal") && cd.get_bool("DiffCamAlways"); } char TPartita::allineamento_richiesto(char tipocf) @@ -1103,6 +1129,12 @@ char TPartita::allineamento_richiesto(char tipocf) return all; } +bool TPartita::rileva_sempre_differenze_cambi() +{ + if (_cli_align <= ' ' || _for_align <= ' ') // Carica il flag insieme agli allineamnti + carica_allineamento(); + return _diffcam_always; +} // Ritorna l'allineamento corrente del numero partita // L = Sinistra, R = Destra, ' ' = indeterminato @@ -1322,13 +1354,8 @@ bool TPartita::write(bool re) const const char req_align = allineamento_richiesto(conto().tipo()); if (cur_align > ' ' && cur_align != req_align) { - if (yesno_box("La partita %d '%s' non rispetta l'allineamento " - "specificato nei parametri ditta: si desidera correggerlo?", - anno(), (const char*)numero())) - { - // Riallinea tutti i numeri partita nelle righe. rate e pagamenti - ((TPartita*)this)->allinea(req_align); - } + // Riallinea tutti i numeri partita nelle righe. rate e pagamenti + ((TPartita*)this)->allinea(req_align); } } @@ -1360,12 +1387,15 @@ bool TPartita::write(bool re) const { part.put(PART_GRUPPO, conto().gruppo()); part.put(PART_CONTO, conto().conto()); - } - part.put(PART_SOTTOCONTO, conto().sottoconto()); + part.put(PART_SOTTOCONTO, conto().sottoconto()); + } + else + part.put(PART_SOTTOCONTO, conto().codclifo()); + part.put(PART_ANNO, anno()); part.put(PART_NUMPART, num); - TRectype comp(part.curr()); + const TRectype comp(part.curr()); if (part.read(_isgteq) == NOERR && part.curr().compare_key(comp, 1 ,1) == 0) { @@ -1438,7 +1468,7 @@ TRiga_scadenze& TPartita::rata(int nriga, int nrata) const bool TPartita::rata_chiusa(int nriga, int nrata) const { bool pag = false; - if (nriga != UNASSIGNED) + if (nriga > 0 && nriga < UNASSIGNED && nrata > 0 && nrata < UNASSIGNED) { const TRiga_scadenze& r = rata(nriga, nrata); pag = r.chiusa(); @@ -1458,7 +1488,7 @@ bool TPartita::esistono_abbuoni_diffcam(long nreg) const const TString& TPartita::codice_valuta() const { const int ultima = last(); - return ultima > 0 ? riga(ultima).codice_valuta() : (const TString &) EMPTY_STRING; + return ultima > 0 ? riga(ultima).codice_valuta() : (const TString&)EMPTY_STRING; } bool TPartita::in_valuta() const @@ -1469,7 +1499,7 @@ bool TPartita::in_valuta() const TRectype& TPartita::pagamento(int nriga, int nrata, int nrigp) { - if (nriga == UNASSIGNED) + if (nriga == UNASSIGNED || nrata == UNASSIGNED) return _unassigned.row(nrigp, true); TRiga_scadenze& r = rata(nriga, nrata); return r.row(nrigp); @@ -1530,6 +1560,8 @@ TImporto TPartita::importo_speso(long nreg, int numrig, bool valuta, int mode) c if (nreg == row.get_long(PART_NREG) && numrig == row.get_int(PART_NUMRIG)) imp += row.importo(valuta, mode); } + if (!valuta || !in_valuta()) + imp.valore().round(TCurrency::get_firm_dec()); return imp; } @@ -1672,12 +1704,12 @@ void TPartita::calcola_saldo(TImporto& saldo, TImporto& doc, TImporto& pag, TImp TImporto TPartita::calcola_saldo(bool valuta) const { TImporto saldo; - for (int r = last(); r > 0; r = pred(r)) { const TRiga_partite& row = riga(r); saldo += row.importo(valuta); } + saldo.normalize(); // Aggiunto il 26/10/2010 nella 11.0 ed il 13/1/2012 nella 10.0 return saldo; } @@ -1695,7 +1727,7 @@ TImporto TPartita::calcola_pagato_al(bool valuta,const TDate& al, const TDate & pagato += row.importo(valuta); if (!row.is_fattura()) { - const int tipopag = row.get_int(PART_TIPOPAG); + const tipo_pagamento tipopag = row.tipo_pag(); if (tipopag >= tp_tratta && tipopag <= tp_rid) { @@ -1722,7 +1754,7 @@ TImporto TPartita::calcola_saldo_al(bool valuta,const TDate& al, const TDate & d saldo += row.importo(valuta); if (!row.is_fattura()) { - const int tipopag = row.get_int(PART_TIPOPAG); + const tipo_pagamento tipopag = row.tipo_pag(); if (tipopag >= tp_tratta && tipopag <= tp_rid) { @@ -1782,11 +1814,8 @@ real TPartita::calcola_scaduto_al(bool valuta,const TDate& al) const scaduto.normalize(sezione); if (scaduto.valore() > 0) return scaduto.valore(); - else - return ZERO; } - else - return ZERO; + return ZERO; } // Calcola il totale dei pagamenti non assegnati (eventualmente in valuta) @@ -1803,7 +1832,6 @@ TImporto TPartita::importo_pagato_unassigned(bool val, int mode) const const TRectype& pag = _unassigned.row(p); // Riga pagamento const TRiga_partite& sum = riga(pag.get_int(PAGSCA_NRIGP)); // Riga partite const char sez = sum.sezione(); - // const int tipo = sum.get_int(PART_TIPOPAG); if (mode & 0x1) totale += TImporto(sez, pag.get_real(imp_field)); @@ -2105,11 +2133,11 @@ int TPartita::tipopag2causale(int tipo) const const TString& TPartite_array::key(const TBill& clifo, int anno, const char* num) { if (clifo.tipo() > ' ') - _key.format("%c%3d%3d%6ld%4d%*s", clifo.tipo(), 0, 0, clifo.sottoconto(), + _key.format("%c%3d%3d%6ld%4d%*s", clifo.tipo(), 0, 0, clifo.codclifo(), anno, TPartita::NUMLEN, num); else _key.format("%c%3d%3d%6ld%4d%*s", - clifo.tipo(), clifo.gruppo(), clifo.conto(), clifo.sottoconto(), + ' ', clifo.gruppo(), clifo.conto(), clifo.sottoconto(), anno, TPartita::NUMLEN, num); return _key; } @@ -2239,6 +2267,8 @@ TImporto TPartite_array::importo_speso(long nreg, int numrig, bool valuta, int m for (TPartita* game = first(); game; game = next()) imp += game->importo_speso(nreg, numrig, valuta, mode); imp.normalize(); + if (!valuta) + imp.valore().round(TCurrency::get_firm_dec()); return imp; } diff --git a/cg/cgsaldac.h b/cg/cgsaldac.h index 5c2cc19cb..31acea03a 100755 --- a/cg/cgsaldac.h +++ b/cg/cgsaldac.h @@ -182,6 +182,7 @@ public: TRiga_scadenze& new_row(int r = 0); tipo_movimento tipo() const; + tipo_pagamento tipo_pag() const; bool is_fattura() const { return tipo() == tm_fattura; } bool is_nota_credito() const { return tipo() == tm_nota_credito; } int ultima_ratapagata() const; @@ -222,6 +223,7 @@ class TPartita : public TSortable char _align; // current _num alignment static char _cli_align, _for_align; // default _num alignment + static bool _diffcam_always; protected: char allineamento_iniziale() const { return _align; } @@ -305,6 +307,7 @@ public: static void carica_allineamento(); static char allineamento_richiesto(char tipocf); static int read_saldo(TRectype& riga, TImporto& saldo, TImporto& doc, TImporto& pag, TImporto& imp); + static bool rileva_sempre_differenze_cambi(); int tipopag2causale(int tipo) const;