Patch level : 12.0 784
Files correlati : ve0.exe ve1.exe ve5.exe ve6.exe Commento : Rifatto il metodo per determinare il numero di partita nella contabilizzazione fatture e nella generazione effetti, ora dovrebbero essere omogenei cioè : Nel casosia una fattura di acquisto o una nota di credito viene considerato prima il documento di riferimento, se compilato. Poi vengono utilizzati il numero di documento, il protocollo IVA o il mese a seconda dei flag sul saldaconto.
This commit is contained in:
parent
a2e56d2fae
commit
1d44f525ff
@ -534,7 +534,9 @@ static TBill _spin_billa, _spin_billv,
|
|||||||
static TBill _co_cliente, // conto clifo per movimento d'anticipo
|
static TBill _co_cliente, // conto clifo per movimento d'anticipo
|
||||||
_co_controp; // conto di contropartita per il movimetno d'anticipo
|
_co_controp; // conto di contropartita per il movimetno d'anticipo
|
||||||
|
|
||||||
static bool _nump_cfg; // se true prende il numero rif. partita dal numero protocollo
|
static bool _numpart_pro; // se true prende il numero rif. partita dal numero protocollo
|
||||||
|
static bool _numpart_mon; // se true prende il numero rif. partita dal mese
|
||||||
|
static char _part_type; // tipi di numero partita "D" codcumento, "P" protocollo IVA, "M" Mese
|
||||||
static bool _sc_enabled; // se true il saldaconto di ditta è abilitato
|
static bool _sc_enabled; // se true il saldaconto di ditta è abilitato
|
||||||
static bool _in_enabled; // se true l'intra è abilitato
|
static bool _in_enabled; // se true l'intra è abilitato
|
||||||
static TToken_string* _search_seq = NULL;
|
static TToken_string* _search_seq = NULL;
|
||||||
@ -855,7 +857,12 @@ bool TContabilizzazione::load_parameters()
|
|||||||
|
|
||||||
_sc_enabled = conf.get_bool("GesSal","cg");
|
_sc_enabled = conf.get_bool("GesSal","cg");
|
||||||
_in_enabled = dongle().active(INAUT);
|
_in_enabled = dongle().active(INAUT);
|
||||||
_nump_cfg = conf.get_bool("RifPro","cg");
|
_numpart_pro = conf.get_bool("RifPro", "cg");
|
||||||
|
_numpart_mon = conf.get_bool("RifMonth", "cg");
|
||||||
|
_part_type = 'D';
|
||||||
|
if (_numpart_pro) _part_type = 'P';
|
||||||
|
else
|
||||||
|
if (_numpart_mon) _part_type = 'M';
|
||||||
|
|
||||||
int gr,co;
|
int gr,co;
|
||||||
long so;
|
long so;
|
||||||
@ -2691,64 +2698,68 @@ error_type TContabilizzazione::write_scadenze(TDocumento& doc, bool recontabiliz
|
|||||||
pa.rewrite();
|
pa.rewrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
int anno = head.get_int(MOV_ANNOIVA);
|
// int anno = head.get_int(MOV_ANNOIVA);
|
||||||
TString8 numpart; // Max. 7 chars
|
int anno = 0;
|
||||||
if (_nump_cfg)
|
TString8 numpart; // Max. 7 chars
|
||||||
|
|
||||||
|
if (doc.get(DOC_TIPOCF) == "F" || is_nc)
|
||||||
{
|
{
|
||||||
numpart = head.get(MOV_PROTIVA);
|
anno = doc.get_int(DOC_ANNORIF);
|
||||||
if (is_nc)
|
numpart = doc.get(DOC_NUMDOCRIF);
|
||||||
{
|
|
||||||
int annorif = doc.get_int("ANNORIF");
|
|
||||||
if (annorif <= 0)
|
|
||||||
{
|
|
||||||
const TDate ddr = doc.get_date(DOC_DATADOCRIF);
|
|
||||||
annorif = ddr.year();
|
|
||||||
if (annorif <= 0)
|
|
||||||
annorif = anno;
|
|
||||||
}
|
|
||||||
TString4 codnumrif = doc.get("CODNUMRIF");
|
|
||||||
if (codnumrif.blank())
|
|
||||||
codnumrif = doc.get(DOC_CODNUM);
|
|
||||||
|
|
||||||
const TString8 numdocrif = doc.get(DOC_NUMDOCRIF);
|
if (numpart.full())
|
||||||
|
|
||||||
if (numdocrif.full())
|
|
||||||
{
|
|
||||||
TToken_string keydoc;
|
|
||||||
keydoc.add(doc.get(DOC_PROVV));
|
|
||||||
keydoc.add(annorif);
|
|
||||||
keydoc.add(codnumrif);
|
|
||||||
keydoc.add(numdocrif);
|
|
||||||
const long numreg = atol(cache().get(LF_DOC, keydoc, DOC_NUMREG));
|
|
||||||
if (numreg > 0)
|
|
||||||
{
|
|
||||||
TPartite_array pa; pa.add_numreg(numreg);
|
|
||||||
const TPartita* game = pa.first();
|
|
||||||
if (game != NULL)
|
|
||||||
{
|
|
||||||
anno = game->anno();
|
|
||||||
numpart = game->numero();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
numpart = doc.get(DOC_NUMDOCRIF);
|
TString4 codnum = doc.get(DOC_CODNUMRIF);
|
||||||
if (_caus->iva() == iva_vendite && !is_nc)
|
TToken_string keydoc;
|
||||||
numpart.cut(0);
|
|
||||||
|
|
||||||
if (numpart.blank())
|
if (codnum.blank())
|
||||||
numpart = head.get(MOV_NUMDOC);
|
codnum = doc.get(DOC_CODNUM);
|
||||||
else
|
if (anno <= 0)
|
||||||
|
{
|
||||||
|
const TDate ddr = doc.get_date(DOC_DATADOCRIF);
|
||||||
|
|
||||||
|
anno = ddr.year();
|
||||||
|
}
|
||||||
|
keydoc.add(doc.get(DOC_PROVV));
|
||||||
|
keydoc.add(anno);
|
||||||
|
keydoc.add(codnum);
|
||||||
|
keydoc.add(numpart);
|
||||||
|
|
||||||
|
const long numreg = atol(cache().get(LF_DOC, keydoc, DOC_NUMREG));
|
||||||
|
|
||||||
|
if (numreg > 0)
|
||||||
|
{
|
||||||
|
TPartite_array pa; pa.add_numreg(numreg);
|
||||||
|
const TPartita* game = pa.first();
|
||||||
|
|
||||||
|
if (game != NULL)
|
||||||
{
|
{
|
||||||
const TDate ddr = doc.get_date(DOC_DATADOCRIF);
|
anno = game->anno();
|
||||||
if (ddr.ok())
|
numpart = game->numero();
|
||||||
anno = ddr.year();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (anno <= 0 || numpart.blank())
|
||||||
|
{
|
||||||
|
switch (_part_type)
|
||||||
|
{
|
||||||
|
case 'P':
|
||||||
|
anno = head.get_int(MOV_ANNOES);
|
||||||
|
numpart = head.get(MOV_PROTIVA);
|
||||||
|
break;
|
||||||
|
case 'M':
|
||||||
|
anno = doc.get_int(DOC_ANNO);
|
||||||
|
numpart = format("%02d", doc.get_date(DOC_DATADOC).month());
|
||||||
|
break;
|
||||||
|
case 'D':
|
||||||
|
default:
|
||||||
|
anno = doc.get_int(DOC_ANNO);
|
||||||
|
numpart = doc.get(DOC_NDOC);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TPartita* newgame = NULL;
|
TPartita* newgame = NULL;
|
||||||
if (anno > 0 && numpart.full())
|
if (anno > 0 && numpart.full())
|
||||||
{
|
{
|
||||||
|
@ -359,13 +359,15 @@ long TGenerazione_effetti::group_bills(TAssoc_array& group_array, bool interatti
|
|||||||
const real change = doc.cambio();
|
const real change = doc.cambio();
|
||||||
const TDate datafatt = doc.get_date(DOC_DATADOC);
|
const TDate datafatt = doc.get_date(DOC_DATADOC);
|
||||||
const bool is_nota_credito = doc.is_nota_credito();
|
const bool is_nota_credito = doc.is_nota_credito();
|
||||||
long numdocrif = doc.get_long(DOC_NUMDOCRIF);
|
TString8 numdocrif = doc.get(DOC_NUMDOCRIF);
|
||||||
int annodocrif = doc.get_date(DOC_DATADOCRIF).year();
|
long lnumdocrif = doc.get_long(DOC_NUMDOCRIF);
|
||||||
if (numdocrif > 0L && doc.get_char(DOC_TIPOCF) == 'C' && !doc.tipo().nota_credito())
|
int annodocrif = doc.get_date(DOC_DATADOCRIF).year();
|
||||||
{
|
|
||||||
annodocrif = 0;
|
if (numdocrif.full() && doc.get_char(DOC_TIPOCF) == 'C' && !doc.tipo().nota_credito())
|
||||||
numdocrif = 0L;
|
{
|
||||||
}
|
annodocrif = 0;
|
||||||
|
numdocrif = 0L;
|
||||||
|
}
|
||||||
|
|
||||||
// Qui il controllo sul residuo da pagare per il documento corrente non va effettuato,
|
// Qui il controllo sul residuo da pagare per il documento corrente non va effettuato,
|
||||||
// proprio perchè si sta effettuando un raggruppamento di effetti; eventuali documenti
|
// proprio perchè si sta effettuando un raggruppamento di effetti; eventuali documenti
|
||||||
@ -442,7 +444,7 @@ long TGenerazione_effetti::group_bills(TAssoc_array& group_array, bool interatti
|
|||||||
{
|
{
|
||||||
const int annoeff = effetto.row_r(r).get_int(REFF_ANNODOC);
|
const int annoeff = effetto.row_r(r).get_int(REFF_ANNODOC);
|
||||||
const long codeff = effetto.row_r(r).get_long(REFF_NFATT);
|
const long codeff = effetto.row_r(r).get_long(REFF_NFATT);
|
||||||
if (annoeff == annodocrif && codeff == numdocrif)
|
if (annoeff == annodocrif && codeff == lnumdocrif)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (r <= rows) // Se l'ha trovata ...
|
if (r <= rows) // Se l'ha trovata ...
|
||||||
@ -502,14 +504,88 @@ long TGenerazione_effetti::group_bills(TAssoc_array& group_array, bool interatti
|
|||||||
riga.put(REFF_NFATT,numdoc);
|
riga.put(REFF_NFATT,numdoc);
|
||||||
riga.put(REFF_IMPFATT,totale_fatt.get_num());
|
riga.put(REFF_IMPFATT,totale_fatt.get_num());
|
||||||
riga.put(REFF_IMPORTO,imprata);
|
riga.put(REFF_IMPORTO,imprata);
|
||||||
riga.put(REFF_ANNO, annodocrif);
|
|
||||||
|
TString8 numpart; // Max. 7 chars
|
||||||
|
int anno = 0;
|
||||||
|
const bool is_nota_credito = doc.tipo().nota_credito();
|
||||||
|
const bool numpart_pro = ini_get_bool(CONFIG_DITTA, "cg", "RifPro");
|
||||||
|
const bool numpart_mon = ini_get_bool(CONFIG_DITTA, "cg", "RifMonth");
|
||||||
|
char part_type = 'D';
|
||||||
|
|
||||||
const TString4 npart_type = ini_get_string(CONFIG_DITTA, "cg", "RifPro");
|
if (numpart_pro)
|
||||||
|
part_type = 'P';
|
||||||
|
else
|
||||||
|
if (numpart_mon)
|
||||||
|
part_type = 'M';
|
||||||
|
|
||||||
if (npart_type == "M" && effetto.get(EFF_TIPOCF) == "C")
|
if (doc.get(DOC_TIPOCF) == "F" || is_nota_credito)
|
||||||
riga.put(REFF_NUMPART, format("%02d", datafatt.month()));
|
{
|
||||||
else
|
anno = doc.get_int(DOC_ANNORIF);
|
||||||
riga.put(REFF_NUMPART, numdocrif);
|
numpart = doc.get(DOC_NUMDOCRIF); // Max. 7 chars
|
||||||
|
|
||||||
|
if (numpart.full())
|
||||||
|
{
|
||||||
|
TString4 codnum = doc.get(DOC_CODNUMRIF);
|
||||||
|
TToken_string keydoc;
|
||||||
|
|
||||||
|
if (codnum.blank())
|
||||||
|
codnum = doc.get(DOC_CODNUM);
|
||||||
|
if (anno <= 0)
|
||||||
|
{
|
||||||
|
const TDate ddr = doc.get_date(DOC_DATADOCRIF);
|
||||||
|
|
||||||
|
anno = ddr.year();
|
||||||
|
}
|
||||||
|
keydoc.add(doc.get(DOC_PROVV));
|
||||||
|
keydoc.add(anno);
|
||||||
|
keydoc.add(codnum);
|
||||||
|
keydoc.add(numpart);
|
||||||
|
|
||||||
|
const long numreg = atol(cache().get(LF_DOC, keydoc, DOC_NUMREG));
|
||||||
|
|
||||||
|
if (numreg > 0)
|
||||||
|
{
|
||||||
|
TPartite_array pa; pa.add_numreg(numreg);
|
||||||
|
const TPartita* game = pa.first();
|
||||||
|
|
||||||
|
if (game != NULL)
|
||||||
|
{
|
||||||
|
anno = game->anno();
|
||||||
|
numpart = game->numero();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (anno <= 0 || numpart.blank())
|
||||||
|
{
|
||||||
|
switch (part_type)
|
||||||
|
{
|
||||||
|
case 'P':
|
||||||
|
{
|
||||||
|
const TRectype & mov = cache().get(LF_MOV, doc.get_long(DOC_NUMREG));
|
||||||
|
|
||||||
|
anno = mov.get_int(MOV_ANNOES);
|
||||||
|
numpart = mov.get(MOV_PROTIVA);
|
||||||
|
if (numpart.blank())
|
||||||
|
{
|
||||||
|
anno = doc.get_int(DOC_ANNO);
|
||||||
|
numpart = doc.get(DOC_NDOC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'M':
|
||||||
|
anno = doc.get_int(DOC_ANNO);
|
||||||
|
numpart = format("%02d", doc.get_date(DOC_DATADOC).month());
|
||||||
|
break;
|
||||||
|
case 'D':
|
||||||
|
default:
|
||||||
|
anno = doc.get_int(DOC_ANNO);
|
||||||
|
numpart = doc.get(DOC_NDOC);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
riga.put(REFF_ANNO, anno);
|
||||||
|
riga.put(REFF_NUMPART, numpart);
|
||||||
if (valuta)
|
if (valuta)
|
||||||
{
|
{
|
||||||
riga.put(REFF_IMPFATTVAL,totale_fatt.get_num());
|
riga.put(REFF_IMPFATTVAL,totale_fatt.get_num());
|
||||||
@ -696,11 +772,12 @@ void TGenerazione_effetti::generate_bill(TDocumento& doc, bool interattivo) // b
|
|||||||
effetto.put(EFF_CODABI,codabi);
|
effetto.put(EFF_CODABI,codabi);
|
||||||
effetto.put(EFF_CODCAB,codcab);
|
effetto.put(EFF_CODCAB,codcab);
|
||||||
effetto.put(EFF_IBAN,iban);
|
effetto.put(EFF_IBAN,iban);
|
||||||
effetto.put(EFF_CUP,doc.get(DOC_CUP));
|
effetto.put(EFF_CUP,doc.get(DOC_CUP));
|
||||||
effetto.put(EFF_CIG,doc.get(DOC_CIG));
|
effetto.put(EFF_CIG,doc.get(DOC_CIG));
|
||||||
effetto.put(EFF_CONTSEP,doc.get(DOC_CONTSEP));
|
effetto.put(EFF_CONTSEP,doc.get(DOC_CONTSEP));
|
||||||
effetto.put(EFF_EFFCOMP,TRUE);
|
effetto.put(EFF_EFFCOMP,TRUE);
|
||||||
if (i == numrate - 1) effetto.put(EFF_ULTRATA,TRUE);
|
if (i == numrate - 1)
|
||||||
|
effetto.put(EFF_ULTRATA,true);
|
||||||
// Put sulla riga dell'effetto
|
// Put sulla riga dell'effetto
|
||||||
reffetto.put(REFF_NPROGTR,nprog);
|
reffetto.put(REFF_NPROGTR,nprog);
|
||||||
reffetto.put(REFF_NRIGATR,1);
|
reffetto.put(REFF_NRIGATR,1);
|
||||||
@ -710,26 +787,88 @@ void TGenerazione_effetti::generate_bill(TDocumento& doc, bool interattivo) // b
|
|||||||
reffetto.put(REFF_ANNODOC,anno);
|
reffetto.put(REFF_ANNODOC,anno);
|
||||||
reffetto.put(REFF_CODNUM,codnum);
|
reffetto.put(REFF_CODNUM,codnum);
|
||||||
reffetto.put(REFF_NFATT,nfatt);
|
reffetto.put(REFF_NFATT,nfatt);
|
||||||
if (doc.get_char(DOC_TIPOCF) == 'F' || doc.tipo().nota_credito())
|
|
||||||
|
TString8 numpart; // Max. 7 chars
|
||||||
|
int anno = 0;
|
||||||
|
const bool is_nota_credito = doc.tipo().nota_credito();
|
||||||
|
const bool numpart_pro = ini_get_bool(CONFIG_DITTA, "cg", "RifPro");
|
||||||
|
const bool numpart_mon = ini_get_bool(CONFIG_DITTA, "cg", "RifMonth");
|
||||||
|
char part_type = 'D';
|
||||||
|
|
||||||
|
if (numpart_pro)
|
||||||
|
part_type = 'P';
|
||||||
|
else
|
||||||
|
if (numpart_mon)
|
||||||
|
part_type = 'M';
|
||||||
|
|
||||||
|
if (doc.get(DOC_TIPOCF) == "F" || is_nota_credito)
|
||||||
{
|
{
|
||||||
reffetto.put(REFF_ANNO, doc.get_date(DOC_DATADOCRIF).year());
|
anno = doc.get_int(DOC_ANNORIF);
|
||||||
reffetto.put(REFF_NUMPART, doc.get(DOC_NUMDOCRIF));
|
numpart = doc.get(DOC_NUMDOCRIF); // Max. 7 chars
|
||||||
|
|
||||||
|
if (numpart.full())
|
||||||
|
{
|
||||||
|
TString4 codnum = doc.get(DOC_CODNUMRIF);
|
||||||
|
TToken_string keydoc;
|
||||||
|
|
||||||
|
if (codnum.blank())
|
||||||
|
codnum = doc.get(DOC_CODNUM);
|
||||||
|
if (anno <= 0)
|
||||||
|
{
|
||||||
|
const TDate ddr = doc.get_date(DOC_DATADOCRIF);
|
||||||
|
|
||||||
|
anno = ddr.year();
|
||||||
|
}
|
||||||
|
keydoc.add(doc.get(DOC_PROVV));
|
||||||
|
keydoc.add(anno);
|
||||||
|
keydoc.add(codnum);
|
||||||
|
keydoc.add(numpart);
|
||||||
|
|
||||||
|
const long numreg = atol(cache().get(LF_DOC, keydoc, DOC_NUMREG));
|
||||||
|
|
||||||
|
if (numreg > 0)
|
||||||
|
{
|
||||||
|
TPartite_array pa; pa.add_numreg(numreg);
|
||||||
|
const TPartita* game = pa.first();
|
||||||
|
|
||||||
|
if (game != NULL)
|
||||||
|
{
|
||||||
|
anno = game->anno();
|
||||||
|
numpart = game->numero();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
if (anno <= 0 || numpart.blank())
|
||||||
{
|
{
|
||||||
const TString4 npart_type = ini_get_string(CONFIG_DITTA, "cg", "RifPro");
|
switch (part_type)
|
||||||
|
{
|
||||||
if (npart_type == "M" && effetto.get(EFF_TIPOCF) == "C")
|
case 'P':
|
||||||
{
|
{
|
||||||
reffetto.put(REFF_ANNO, datafatt.year());
|
const TRectype & mov = cache().get(LF_MOV, doc.get_long(DOC_NUMREG));
|
||||||
reffetto.put(REFF_NUMPART, format("%02d", datafatt.month()));
|
|
||||||
}
|
anno = mov.get_int(MOV_ANNOES);
|
||||||
else
|
numpart = mov.get(MOV_PROTIVA);
|
||||||
{
|
if (numpart.blank())
|
||||||
reffetto.put(REFF_ANNO, doc.get_date(DOC_DATADOCRIF).year());
|
{
|
||||||
reffetto.put(REFF_NUMPART, doc.get(DOC_NUMDOCRIF));
|
anno = doc.get_int(DOC_ANNO);
|
||||||
}
|
numpart = doc.get(DOC_NDOC);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'M':
|
||||||
|
anno = doc.get_int(DOC_ANNO);
|
||||||
|
numpart = format("%02d", doc.get_date(DOC_DATADOC).month());
|
||||||
|
break;
|
||||||
|
case 'D':
|
||||||
|
default:
|
||||||
|
anno = doc.get_int(DOC_ANNO);
|
||||||
|
numpart = doc.get(DOC_NDOC);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reffetto.put(REFF_ANNO, anno);
|
||||||
|
reffetto.put(REFF_NUMPART, numpart);
|
||||||
importo = pag.importo_rata(i,FALSE);
|
importo = pag.importo_rata(i,FALSE);
|
||||||
effetto.put(EFF_IMPORTO,importo);
|
effetto.put(EFF_IMPORTO,importo);
|
||||||
reffetto.put(REFF_IMPFATT,totale_fatt.get_num());
|
reffetto.put(REFF_IMPFATT,totale_fatt.get_num());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user