Patch level :10.0
Files correlati : Ricompilazione Demo : [ ] Commento :calcolo del fido in corso d'opera git-svn-id: svn://10.65.10.50/trunk@17613 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
7228488c31
commit
fe894014e1
@ -1,6 +1,9 @@
|
||||
#include "velib07.h"
|
||||
|
||||
#include <pconti.h>
|
||||
|
||||
#include "../cg/cgsaldac.h"
|
||||
#include "../cg/cglib02.h"
|
||||
#include "../db/dblib.h"
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -597,6 +600,65 @@ bool TDocument_report::execute_usr_word(unsigned int opcode, TVariant_stack& sta
|
||||
/////////////////////////////////////////
|
||||
// Metodi non appartenenti a classi
|
||||
/////////////////////////////////////////
|
||||
|
||||
//estrazioni mastri clienti e/o fornitori
|
||||
static const TString_array& mastro(char tipocf)
|
||||
{
|
||||
static TString_array m[2];
|
||||
const TString_array& a = m[tipocf == 'C' ? 0 : 1];
|
||||
|
||||
if (a.empty())
|
||||
{
|
||||
TISAM_recordset mastri("USE PCON SELECT (CONTO!=\"\")&&(SOTTOCONTO="")");
|
||||
for (bool ok = mastri.move_first(); ok; ok = mastri.move_next())
|
||||
{
|
||||
const int gruppo = mastri.get(PCN_GRUPPO).as_int();
|
||||
const int conto = mastri.get(PCN_CONTO).as_int();
|
||||
const int indbil = mastri.get(PCN_INDBIL).as_int();
|
||||
const char tipocf = mastri.get(PCN_TMCF).as_string()[0];
|
||||
TToken_string info;
|
||||
info.add(gruppo);
|
||||
info.add(conto);
|
||||
info.add(indbil);
|
||||
m[tipocf == 'C' ? 0 : 1].add(info);
|
||||
}
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
static real calcola_saldo_contabile(const char tipocf, const long codcf, const TDate& datacalc)
|
||||
{
|
||||
real saldone;
|
||||
|
||||
TEsercizi_contabili esc;
|
||||
TDate datainies, datafines;
|
||||
const int codes = esc.date2esc(datacalc);
|
||||
if (codes > 0)
|
||||
esc.code2range(codes, datainies, datafines);
|
||||
else
|
||||
{
|
||||
datainies = datacalc;
|
||||
datainies.set_day(1);
|
||||
datainies.set_month(1);
|
||||
}
|
||||
|
||||
const TString_array& a = mastro(tipocf);
|
||||
|
||||
//per tutti i mastri selezionati va a calcolare il saldo del cliente/fornitore in input
|
||||
FOR_EACH_ARRAY_ROW(a, i, row)
|
||||
{
|
||||
const int gruppo = row->get_int(0);
|
||||
const int conto = row->get_int(1);
|
||||
const int indbil = row->get_int(2);
|
||||
|
||||
TSaldo saldo;
|
||||
real saldo_periodo = saldo.saldo_periodo(gruppo, conto, codcf, datainies, datacalc, indbil, false);
|
||||
|
||||
saldone += saldo_periodo;
|
||||
}
|
||||
return saldone;
|
||||
}
|
||||
|
||||
static TImporto get_importo(const TISAM_recordset& partite, const char* sezione, const char* valore)
|
||||
{
|
||||
const char sez = partite.get(sezione).as_string()[0];
|
||||
@ -666,9 +728,9 @@ static real calcola_esposto_da_saldaconto (const char tipocf, const long codcf,
|
||||
}
|
||||
|
||||
|
||||
static void calcola_fido_da_documenti(const char tipocf, const long codcf, const TDate& datacalc, const int riskdays,
|
||||
real& saldo, real& saldo_sbf)
|
||||
static real calcola_fido_da_documenti(const char tipocf, const long codcf, const TDate& datacalc)
|
||||
{
|
||||
real totalone;
|
||||
TConfig config(CONFIG_DITTA, "ve");
|
||||
|
||||
//scansione delle righe FIDO_XX(j)=.. sul paragrafo di configurazione VE per avere i parametri di numerazione/tipo..
|
||||
@ -706,27 +768,43 @@ static void calcola_fido_da_documenti(const char tipocf, const long codcf, const
|
||||
//adesso che ha i documenti che cercava..
|
||||
for (bool ok = documenti.move_first(); ok; ok = documenti.move_next())
|
||||
{
|
||||
TDocumento doc(documenti.cursor()->curr());
|
||||
const TDocumento doc(documenti.cursor()->curr());
|
||||
//deve tener conto di eventuali docs in valuta
|
||||
TCurrency_documento totdoc(ZERO, doc);
|
||||
|
||||
//documento a residuo (tipo ordini)
|
||||
if (residuo_fido)
|
||||
{
|
||||
totdoc.set_num(doc.valore(false, true));
|
||||
}
|
||||
else //documento normale (tipo fattura)
|
||||
{
|
||||
const real totdoc = doc.totale_doc();
|
||||
totdoc.set_num(doc.totale_doc());
|
||||
}
|
||||
|
||||
totdoc.change_to_firm_val();
|
||||
|
||||
//le nac vanno con segno rovesciato
|
||||
if (doc.is_nota_credito())
|
||||
totdoc = -totdoc;
|
||||
|
||||
totalone += totdoc.get_num();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return totalone;
|
||||
}
|
||||
|
||||
|
||||
//metodo per il calcolo fido di un cliente ad una data definita
|
||||
void calcola_fido_cliente (const char tipocf, const long codcf, const TDate& datacalc, const int riskdays,
|
||||
real& saldo, real& saldo_sbf)
|
||||
real calcola_fido_cliente (const char tipocf, const long codcf, const TDate& datacalc, const int riskdays)
|
||||
{
|
||||
//PRIMA PARTE: controlla il saldaconto
|
||||
//PRIMA PARTE: controlla i movimenti
|
||||
real saldo_contabile = calcola_saldo_contabile(tipocf, codcf, datacalc);
|
||||
//SECONDA PARTE: controlla il saldaconto
|
||||
real esposto = calcola_esposto_da_saldaconto(tipocf, codcf, datacalc, riskdays);
|
||||
//SECONDA PARTE: controlla i documenti
|
||||
calcola_fido_da_documenti(tipocf, codcf, datacalc, riskdays, saldo, saldo_sbf);
|
||||
//TERZA PARTE: controlla i documenti
|
||||
real tot_documenti = calcola_fido_da_documenti(tipocf, codcf, datacalc);
|
||||
|
||||
return saldo_contabile + esposto + tot_documenti;
|
||||
}
|
@ -123,7 +123,7 @@ public:
|
||||
// Metodi non appartenenti a classi
|
||||
///////////////////////////////////////////////
|
||||
//metodo per il calcolo del fido cliente
|
||||
void calcola_fido_cliente (const char tipocf, const long codcf, const TDate& datacalc, const int riskdays,
|
||||
real calcola_fido_cliente (const char tipocf, const long codcf, const TDate& datacalc, const int riskdays,
|
||||
real& saldo, real& saldo_sbf);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user