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
This commit is contained in:
guy 2012-02-23 16:50:46 +00:00
parent 9ded4cbee0
commit 1159b1d092
8 changed files with 140 additions and 147 deletions

View File

@ -2967,11 +2967,6 @@ void TPrimanota_application::gioca_cambi(int force)
if ( (force == 0x4 || cambio.is_zero()) && !(totale.is_zero() || totval.is_zero()) ) if ( (force == 0x4 || cambio.is_zero()) && !(totale.is_zero() || totval.is_zero()) )
{ {
real new_cambio = totale / totval; 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); new_cambio.round(6);
if (new_cambio != cambio) if (new_cambio != cambio)
m.set(SK_CAMBIO, new_cambio, true); m.set(SK_CAMBIO, new_cambio, true);

View File

@ -8,6 +8,7 @@
#include "cg2102.h" // Applicazione di prima nota #include "cg2102.h" // Applicazione di prima nota
#endif #endif
#include "cg2105.h"
#include "cg2107.h" #include "cg2107.h"
#include <colors.h> // Colori righe #include <colors.h> // Colori righe
@ -99,49 +100,6 @@ public:
// Maschera pagamenti // 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__ #ifdef __EXTRA__
const char* const PAYMASK = "sc0100b"; const char* const PAYMASK = "sc0100b";
#else #else
@ -150,7 +108,10 @@ const char* const PAYMASK = "cg2100s";
void TPay_mask::init(const TGame_mask* parent, int mod) void TPay_mask::init(const TGame_mask* parent, int mod)
{ {
#ifndef __EXTRA__
_parent = parent; _parent = parent;
#endif
set_mode(mod); set_mode(mod);
enable(DLG_DELREC, edit_mode()); enable(DLG_DELREC, edit_mode());
@ -576,30 +537,18 @@ bool TPay_mask::conto_handler(TMask_field& f, KEY k)
// Maschera gestione nuovo pagamento / fattura // Maschera gestione nuovo pagamento / fattura
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
class TNew_mask : public TMask bool TNew_mask::on_field_event(TOperable_field& f, TField_event e, long jolly)
{ {
bool _allow_fatt; switch (f.dlg())
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)
{
if (k == K_ENTER)
{ {
TNew_mask& m = (TNew_mask&)f.mask(); case P_NUOVO:
if (!m._allow_fatt && f.get() == "1") if (e == fe_close && !_allow_fatt && f.get() == "1")
return f.error_box(TR("Non e' possibile utilizzare una fattura come pagamento")); 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) 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); TMask_field& tipomov = field(P_NUOVO);
#ifdef __EXTRA__ #ifdef __EXTRA__
tipomov.set_handler(tipomov_handler);
tipomov.enable(); tipomov.enable();
tipomov.set(_allow_fatt ? "1" : "3"); tipomov.set(_allow_fatt ? "1" : "3");
if (!_allow_fatt) 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) TNew_mask::TNew_mask(char tipocf, bool fatt, bool edit)
: TMask("cg2100n") : TAutomask("cg2100n")
{ {
init(tipocf, fatt, edit); init(tipocf, fatt, edit);
} }

View File

@ -17,6 +17,8 @@
#define FLD_NUM_EC 117 #define FLD_NUM_EC 117
#define FLD_LAST_EC 118 #define FLD_LAST_EC 118
#define FLD_DATSAL 119 #define FLD_DATSAL 119
#define CHK_EASYSAL 120
#define CHK_DIFFCAM 121
#define FLD_CSBICHS 217 #define FLD_CSBICHS 217
#define FLD_CSBICHG 218 #define FLD_CSBICHG 218
@ -42,6 +44,7 @@
#define FLD_CSAUCPS 238 #define FLD_CSAUCPS 238
#define FLD_CSAUCPG 239 #define FLD_CSAUCPG 239
#define FLD_CSAUCPC 240 #define FLD_CSAUCPC 240
#define FLD_DCSAUCP 241
#define LST_RRFRAM 338 #define LST_RRFRAM 338
#define CHK_RRMECO 339 #define CHK_RRMECO 339
@ -66,7 +69,6 @@
#define CHK_DTCFPG 358 #define CHK_DTCFPG 358
#define CHK_RIFPRO 359 #define CHK_RIFPRO 359
#define CHK_LIQDIF 360 #define CHK_LIQDIF 360
#define FLD_DCSAUCP 361
#define FLD_RATEI_G 371 #define FLD_RATEI_G 371
#define FLD_RATEI_C 372 #define FLD_RATEI_C 372

View File

@ -88,7 +88,7 @@ BEGIN
GROUP GROUP_CONTABILITA GROUP GROUP_CONTABILITA
END END
GROUPBOX DLG_NULL 76 7 GROUPBOX DLG_NULL 76 8
BEGIN BEGIN
PROMPT 2 12 "@bParametri saldaconto" PROMPT 2 12 "@bParametri saldaconto"
END END
@ -98,10 +98,10 @@ BEGIN
PROMPT 4 13 "Gestione saldaconto " PROMPT 4 13 "Gestione saldaconto "
MESSAGE TRUE ENABLE,CHK_GESVAL|ENABLE,CHK_NRCLIDX|ENABLE,CHK_NRFORDX 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,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_GESVAL|DISABLE,CHK_NRCLIDX|DISABLE,CHK_NRFORDX
MESSAGE FALSE DISABLE,CHK_DTCFPG|DISABLE,CHK_RIFPRO|DISABLE,FLD_CODLIN 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 FIELD GesSal
GROUP GROUP_SALDACONTO GROUP GROUP_SALDACONTO
END END
@ -121,9 +121,24 @@ BEGIN
GROUP GROUP_SALDACONTO GROUP GROUP_SALDACONTO
END 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 BOOLEAN CHK_NRCLIDX
BEGIN 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" HELP "Indicare se allineare a destra il num. di rif. delle partite nel saldaconto"
FIELD NrCliDx FIELD NrCliDx
GROUP GROUP_SALDACONTO GROUP GROUP_SALDACONTO
@ -131,7 +146,7 @@ END
BOOLEAN CHK_NRFORDX BOOLEAN CHK_NRFORDX
BEGIN 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" HELP "Indicare se allineare a destra il num. di rif. delle partite nel saldaconto"
FIELD NrForDx FIELD NrForDx
GROUP GROUP_SALDACONTO GROUP GROUP_SALDACONTO
@ -139,7 +154,7 @@ END
BOOLEAN CHK_RIFPRO BOOLEAN CHK_RIFPRO
BEGIN 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" HELP "Indicare se si desidera il numero protocollo IVA anziche' il numero documento come riferimento partita"
FIELD RifPro FIELD RifPro
GROUP GROUP_SALDACONTO GROUP GROUP_SALDACONTO
@ -147,7 +162,7 @@ END
STRING FLD_CODLIN 1 STRING FLD_CODLIN 1
BEGIN BEGIN
PROMPT 50 16 "Codice lingua " PROMPT 50 17 "Codice lingua "
HELP "Lingua di riferimento per rendiconti contabili" HELP "Lingua di riferimento per rendiconti contabili"
FIELD CodLin FIELD CodLin
USE %LNG USE %LNG
@ -161,7 +176,7 @@ END
LIST FLD_NUM_EC 1 10 LIST FLD_NUM_EC 1 10
BEGIN BEGIN
PROMPT 4 17 "Numerazione estratti conto " PROMPT 4 18 "Numerazione estratti conto "
ITEM " |Nessuna" MESSAGE HIDE,FLD_LAST_EC ITEM " |Nessuna" MESSAGE HIDE,FLD_LAST_EC
ITEM "G|Globale" MESSAGE SHOW,FLD_LAST_EC ITEM "G|Globale" MESSAGE SHOW,FLD_LAST_EC
ITEM "A|Anagrafica" MESSAGE HIDE,FLD_LAST_EC ITEM "A|Anagrafica" MESSAGE HIDE,FLD_LAST_EC
@ -171,14 +186,14 @@ END
NUMBER FLD_LAST_EC 6 NUMBER FLD_LAST_EC 6
BEGIN BEGIN
PROMPT 50 17 "Ultimo E.C. " PROMPT 50 18 "Ultimo E.C. "
FIELD LastEC FIELD LastEC
GROUP GROUP_SALDACONTO GROUP GROUP_SALDACONTO
END END
BOOLEAN CHK_DTCFPG BOOLEAN CHK_DTCFPG
BEGIN 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" HELP "Indicare se si desidera il dettaglio riga clienti/fornitori in gestione pagamenti"
FIELD DtCfPg FIELD DtCfPg
GROUP GROUP_SALDACONTO GROUP GROUP_SALDACONTO

View File

@ -227,7 +227,7 @@ public:
{ set_total(ib.get_num(), im.get_num(), sp.get_num());} { set_total(ib.get_num(), im.get_num(), sp.get_num());}
void set_total_valuta(const TCurrency& ib, const TCurrency& im, const TCurrency& sp, void set_total_valuta(const TCurrency& ib, const TCurrency& im, const TCurrency& sp,
const TCurrency& ibl, const TCurrency& iml, const TCurrency& spl) 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());} ibl.get_num(), iml.get_num(), spl.get_num(), ib.get_value());}
// istanzia uno sheet field come diobue comanda // istanzia uno sheet field come diobue comanda

View File

@ -486,7 +486,7 @@ void TSolder_tree::set_var_real(TVariant& var, const real& imp, bool in_value) c
if (in_value) if (in_value)
cur.change_to_firm_val(); cur.change_to_firm_val();
else else
cur.change_value(_codval, _cambio, _exchange_contro); cur.change_value(_codval, _cambio);
} }
var = cur.string(true); var = cur.string(true);
} }

View File

@ -4,6 +4,7 @@
#include <relation.h> #include <relation.h>
#include "cgsaldac.h" #include "cgsaldac.h"
#include "cg2103.h"
#include <mov.h> #include <mov.h>
#include <rmov.h> #include <rmov.h>
@ -123,7 +124,7 @@ TValuta::TValuta() : _cod(""), _dat(TODAY), _cam(ZERO)
void TValuta::adjust() 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()) if (this_cur.is_firm_value())
{ {
_cod.cut(0); _cod.cut(0);
@ -158,16 +159,12 @@ void TValuta::put(TRectype& rec) const
rec.put("CODVAL", _cod); rec.put("CODVAL", _cod);
rec.put("DATACAM", _dat); rec.put("DATACAM", _dat);
rec.put("CAMBIO", _cam); rec.put("CAMBIO", _cam);
if (rec.exist("CONTROEURO"))
rec.put("CONTROEURO", "X");
} }
else else
{ {
rec.zero("CODVAL"); rec.zero("CODVAL");
rec.zero("DATACAM"); rec.zero("DATACAM");
rec.zero("CAMBIO"); 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 real TValuta::eur2val(const real& lit) const
{ {
TCurrency cur(lit); TCurrency cur(lit);
cur.change_value(_cod, _cam, _exchange_contro); cur.change_value(_cod, _cam);
return cur.get_num(); return cur.get_num();
} }
real TValuta::val2eur(const real& val) const real TValuta::val2eur(const real& val) const
{ {
TCurrency cur(val, _cod, _cam, _exchange_contro); TCurrency cur(val, _cod, _cam);
cur.change_to_firm_val(); cur.change_to_firm_val();
return cur.get_num(); return cur.get_num();
} }
void TValuta::val2eur(real& val) const void TValuta::val2eur(real& val) const
{ {
TCurrency cur(val, _cod, _cam, _exchange_contro); TCurrency cur(val, _cod, _cam);
cur.change_to_firm_val(); cur.change_to_firm_val();
val = cur.get_num(); val = cur.get_num();
} }
@ -226,7 +223,7 @@ void TValuta::val2eur(real& val) const
void TValuta::eur2val(real& lit) const void TValuta::eur2val(real& lit) const
{ {
TCurrency cur(lit); TCurrency cur(lit);
cur.change_value(_cod, _cam, _exchange_contro); cur.change_value(_cod, _cam);
lit = cur.get_num(); lit = cur.get_num();
} }
@ -285,7 +282,7 @@ const TString& TRiga_scadenze::codice_valuta() const
// Controlla se la rata e' stata completamente pagata // Controlla se la rata e' stata completamente pagata
bool TRiga_scadenze::chiusa(bool update) const bool TRiga_scadenze::chiusa(bool update) const
{ {
bool chiusa; bool chiusa = false;
if (update) if (update)
{ {
TImporto imp(importo(true)); TImporto imp(importo(true));
@ -469,16 +466,31 @@ TImporto TRiga_scadenze::calcola_differenza_cambio(int p, bool update)
TImporto diffcam; TImporto diffcam;
TRectype& pag = row(p); 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) if (update)
{ {
diffcam = importo(false); const int dec = TCurrency::get_firm_dec();
pag.zero(PAGSCA_DIFFCAM); // 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 += importo_pagato(false); // Conta anche gli abbuoni e le altre diffcam
diffcam.swap_section(); 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); diffcam.normalize(sez);
pag.put(PAGSCA_DIFFCAM, diffcam.valore()); pag.put(PAGSCA_DIFFCAM, diffcam.valore());
} }
@ -521,7 +533,7 @@ TImporto TRiga_scadenze::esposto_al(bool valuta, const TDate & al, const TDate &
datapag = data; datapag = data;
if (datapag <= al) 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) 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; 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; TImporto esposto;
const bool rischio = data_scad != data_rischio; 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)) for (int p = first(); p <= lasts; p = succ(p))
{ {
const TRiga_partite & pag = riga().partita().riga(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) 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, char& new_ap, TImporto& new_abb, TImporto& new_diffcam,
bool update) bool update)
{ {
const bool in_val = in_valuta();
const int nrigp = new_pag.get_int(PAGSCA_NRIGP); const int nrigp = new_pag.get_int(PAGSCA_NRIGP);
const TRectype old_pag(row(nrigp)); const TRectype old_pag(row(nrigp));
TRiga_partite& sum = partita().riga(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; TImporto old_abbuono;
old_ap = calcola_abbuono(nrigp, old_abbuono, false); // Vecchio abbuono in valuta old_ap = calcola_abbuono(nrigp, old_abbuono, false); // Vecchio abbuono in valuta
old_abb = old_abbuono; // Vecchio abbuono in lire old_abb = old_abbuono; // Vecchio abbuono in lire
if (in_val) if (in_valuta())
{ {
const TString4 codval = sum.codice_valuta(); const TString4 codval = sum.codice_valuta();
exchange_type et = _exchange_undefined; TCurrency cur(old_abb.valore(), codval, sum.get_real(PART_CAMBIO));
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);
cur.change_to_firm_val(); cur.change_to_firm_val();
old_abb.valore() = cur.get_num(); old_abb.valore() = cur.get_num();
} }
old_diffcam = calcola_differenza_cambio(nrigp, false); old_diffcam = calcola_differenza_cambio(nrigp, false);
if (in_val && valuta.in_valuta()) if (in_valuta() && !valuta.in_euro())
valuta.put(sum); valuta.put(sum);
row(nrigp) = new_pag; row(nrigp) = new_pag;
@ -612,14 +620,11 @@ bool TRiga_scadenze::modifica_pagamento(const TRectype& new_pag, const TValuta&
TImporto new_abbuono; TImporto new_abbuono;
new_ap = calcola_abbuono(nrigp, new_abbuono, update); // Calcolo abbuono in valuta new_ap = calcola_abbuono(nrigp, new_abbuono, update); // Calcolo abbuono in valuta
new_abb = new_abbuono; // Calcola nuovo abbuono in lire new_abb = new_abbuono; // Calcola nuovo abbuono in euro
if (in_valuta()) if (in_valuta() && !new_abb.is_zero())
{ {
const TString4 codval = sum.codice_valuta(); const TString4 codval = sum.codice_valuta();
exchange_type et = _exchange_undefined; TCurrency cur(new_abb.valore(), codval, sum.get_real(PART_CAMBIO));
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);
cur.change_to_firm_val(); cur.change_to_firm_val();
new_abb.valore() = cur.get_num(); 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 bool TRiga_scadenze::esistono_abbuoni_diffcam() const
{ {
/* Prima dellla Pharmatex le differenze cambi potevano aversi solo con pagamenti a saldo
bool ad = false; 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); const TRectype& pag = row(p);
if (pag.get_char(PAGSCA_ACCSAL) == 'S') if (pag.get_char(PAGSCA_ACCSAL) == 'S')
@ -664,6 +670,14 @@ bool TRiga_scadenze::esistono_abbuoni_diffcam() const
} }
} }
return ad; 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; 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 // Calcola il segno delle ritenute sociali in base alla causale
char TRiga_partite::sezione_ritsoc() const 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_cau = cache().get(LF_RCAUSALI, key, RCA_SEZIONE)[0];
const char sez_rit = sez_cau > ' ' ? (sez_cau == 'D' ? 'A' : 'D') : sezione(); const char sez_rit = sez_cau > ' ' ? (sez_cau == 'D' ? 'A' : 'D') : sezione();
return sez_rit; return sez_rit;
@ -850,8 +870,7 @@ bool TRiga_partite::update(const TImporto& vec, const TImporto& nuo,
// Certified 99% // Certified 99%
int TRiga_partite::ultima_rata_con_abbuoni_diffcam() const int TRiga_partite::ultima_rata_con_abbuoni_diffcam() const
{ {
int s; int s = 0;
for (s = rate(); s > 0; s--) for (s = rate(); s > 0; s--)
{ {
const TRiga_scadenze& scad = rata(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 // Determina se una riga e' in valuta in base al codice valuta
bool TRiga_partite::in_valuta() const 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 // 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 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); i.valore() += get_real(PART_RITENUTE);
// Ritenute Sociali
if (sezione() == sezione_ritsoc()) if (sezione() == sezione_ritsoc())
i.valore() += get_real(PART_RITSOC); i.valore() += get_real(PART_RITSOC);
else 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)); const TImporto diffcam(get_char(PART_SEZDIFCAM), get_real(PART_DIFFCAM));
i += 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) if (p != nrigp)
{ {
const TRiga_partite & prow = partita().riga(p); 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) 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::_cli_align = ' ';
char TPartita::_for_align = ' '; char TPartita::_for_align = ' ';
bool TPartita::_diffcam_always = false;
TPartita::TPartita(const TBill& clifo, int anno, const char* num) TPartita::TPartita(const TBill& clifo, int anno, const char* num)
: _part(LF_PARTITE, PART_NRIGA), _unassigned(LF_PAGSCA, PAGSCA_NRIGP), _align(' ') : _part(LF_PARTITE, PART_NRIGA), _unassigned(LF_PAGSCA, PAGSCA_NRIGP), _align(' ')
@ -1085,6 +1108,9 @@ void TPartita::carica_allineamento()
TConfig cd(CONFIG_DITTA, "cg"); TConfig cd(CONFIG_DITTA, "cg");
_cli_align = cd.get_bool("NrCliDx") ? 'R' : 'L'; _cli_align = cd.get_bool("NrCliDx") ? 'R' : 'L';
_for_align = cd.get_bool("NrForDx") ? '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) char TPartita::allineamento_richiesto(char tipocf)
@ -1103,6 +1129,12 @@ char TPartita::allineamento_richiesto(char tipocf)
return all; 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 // Ritorna l'allineamento corrente del numero partita
// L = Sinistra, R = Destra, ' ' = indeterminato // L = Sinistra, R = Destra, ' ' = indeterminato
@ -1321,16 +1353,11 @@ bool TPartita::write(bool re) const
const char cur_align = allineamento_corrente(); const char cur_align = allineamento_corrente();
const char req_align = allineamento_richiesto(conto().tipo()); const char req_align = allineamento_richiesto(conto().tipo());
if (cur_align > ' ' && cur_align != req_align) 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 // Riallinea tutti i numeri partita nelle righe. rate e pagamenti
((TPartita*)this)->allinea(req_align); ((TPartita*)this)->allinea(req_align);
} }
} }
}
int err = _part.write(re); int err = _part.write(re);
if (err == NOERR) if (err == NOERR)
@ -1360,12 +1387,15 @@ bool TPartita::write(bool re) const
{ {
part.put(PART_GRUPPO, conto().gruppo()); part.put(PART_GRUPPO, conto().gruppo());
part.put(PART_CONTO, conto().conto()); 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_ANNO, anno());
part.put(PART_NUMPART, num); 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) 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 TPartita::rata_chiusa(int nriga, int nrata) const
{ {
bool pag = false; bool pag = false;
if (nriga != UNASSIGNED) if (nriga > 0 && nriga < UNASSIGNED && nrata > 0 && nrata < UNASSIGNED)
{ {
const TRiga_scadenze& r = rata(nriga, nrata); const TRiga_scadenze& r = rata(nriga, nrata);
pag = r.chiusa(); pag = r.chiusa();
@ -1458,7 +1488,7 @@ bool TPartita::esistono_abbuoni_diffcam(long nreg) const
const TString& TPartita::codice_valuta() const const TString& TPartita::codice_valuta() const
{ {
const int ultima = last(); 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 bool TPartita::in_valuta() const
@ -1469,7 +1499,7 @@ bool TPartita::in_valuta() const
TRectype& TPartita::pagamento(int nriga, int nrata, int nrigp) TRectype& TPartita::pagamento(int nriga, int nrata, int nrigp)
{ {
if (nriga == UNASSIGNED) if (nriga == UNASSIGNED || nrata == UNASSIGNED)
return _unassigned.row(nrigp, true); return _unassigned.row(nrigp, true);
TRiga_scadenze& r = rata(nriga, nrata); TRiga_scadenze& r = rata(nriga, nrata);
return r.row(nrigp); 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)) if (nreg == row.get_long(PART_NREG) && numrig == row.get_int(PART_NUMRIG))
imp += row.importo(valuta, mode); imp += row.importo(valuta, mode);
} }
if (!valuta || !in_valuta())
imp.valore().round(TCurrency::get_firm_dec());
return imp; 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 TPartita::calcola_saldo(bool valuta) const
{ {
TImporto saldo; TImporto saldo;
for (int r = last(); r > 0; r = pred(r)) for (int r = last(); r > 0; r = pred(r))
{ {
const TRiga_partite& row = riga(r); const TRiga_partite& row = riga(r);
saldo += row.importo(valuta); saldo += row.importo(valuta);
} }
saldo.normalize(); // Aggiunto il 26/10/2010 nella 11.0 ed il 13/1/2012 nella 10.0
return saldo; return saldo;
} }
@ -1695,7 +1727,7 @@ TImporto TPartita::calcola_pagato_al(bool valuta,const TDate& al, const TDate &
pagato += row.importo(valuta); pagato += row.importo(valuta);
if (!row.is_fattura()) 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) 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); saldo += row.importo(valuta);
if (!row.is_fattura()) 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) if (tipopag >= tp_tratta && tipopag <= tp_rid)
{ {
@ -1782,10 +1814,7 @@ real TPartita::calcola_scaduto_al(bool valuta,const TDate& al) const
scaduto.normalize(sezione); scaduto.normalize(sezione);
if (scaduto.valore() > 0) if (scaduto.valore() > 0)
return scaduto.valore(); return scaduto.valore();
else
return ZERO;
} }
else
return ZERO; return ZERO;
} }
@ -1803,7 +1832,6 @@ TImporto TPartita::importo_pagato_unassigned(bool val, int mode) const
const TRectype& pag = _unassigned.row(p); // Riga pagamento const TRectype& pag = _unassigned.row(p); // Riga pagamento
const TRiga_partite& sum = riga(pag.get_int(PAGSCA_NRIGP)); // Riga partite const TRiga_partite& sum = riga(pag.get_int(PAGSCA_NRIGP)); // Riga partite
const char sez = sum.sezione(); const char sez = sum.sezione();
// const int tipo = sum.get_int(PART_TIPOPAG);
if (mode & 0x1) if (mode & 0x1)
totale += TImporto(sez, pag.get_real(imp_field)); 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) const TString& TPartite_array::key(const TBill& clifo, int anno, const char* num)
{ {
if (clifo.tipo() > ' ') 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); anno, TPartita::NUMLEN, num);
else else
_key.format("%c%3d%3d%6ld%4d%*s", _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); anno, TPartita::NUMLEN, num);
return _key; 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()) for (TPartita* game = first(); game; game = next())
imp += game->importo_speso(nreg, numrig, valuta, mode); imp += game->importo_speso(nreg, numrig, valuta, mode);
imp.normalize(); imp.normalize();
if (!valuta)
imp.valore().round(TCurrency::get_firm_dec());
return imp; return imp;
} }

View File

@ -182,6 +182,7 @@ public:
TRiga_scadenze& new_row(int r = 0); TRiga_scadenze& new_row(int r = 0);
tipo_movimento tipo() const; tipo_movimento tipo() const;
tipo_pagamento tipo_pag() const;
bool is_fattura() const { return tipo() == tm_fattura; } bool is_fattura() const { return tipo() == tm_fattura; }
bool is_nota_credito() const { return tipo() == tm_nota_credito; } bool is_nota_credito() const { return tipo() == tm_nota_credito; }
int ultima_ratapagata() const; int ultima_ratapagata() const;
@ -222,6 +223,7 @@ class TPartita : public TSortable
char _align; // current _num alignment char _align; // current _num alignment
static char _cli_align, _for_align; // default _num alignment static char _cli_align, _for_align; // default _num alignment
static bool _diffcam_always;
protected: protected:
char allineamento_iniziale() const { return _align; } char allineamento_iniziale() const { return _align; }
@ -305,6 +307,7 @@ public:
static void carica_allineamento(); static void carica_allineamento();
static char allineamento_richiesto(char tipocf); static char allineamento_richiesto(char tipocf);
static int read_saldo(TRectype& riga, TImporto& saldo, TImporto& doc, TImporto& pag, TImporto& imp); 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; int tipopag2causale(int tipo) const;