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@17600 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
c92d53d164
commit
faf072a109
@ -334,7 +334,7 @@ int TScoperto_form::print_bolla(const TRectype& dochead, TArray* fatt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
quant = riga.qtaresidua();
|
quant = riga.qtaresidua();
|
||||||
valore = riga.valore(FALSE, AUTO_DECIMALS);
|
valore = riga.valore(false, false, AUTO_DECIMALS);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -374,7 +374,7 @@ int TScoperto_form::print_bolla(const TRectype& dochead, TArray* fatt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
quant = riga.quantita();
|
quant = riga.quantita();
|
||||||
valore = riga.valore(TRUE, AUTO_DECIMALS);
|
valore = riga.valore(true, false, AUTO_DECIMALS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valore > ZERO) // Devo stampare la riga
|
if (valore > ZERO) // Devo stampare la riga
|
||||||
|
@ -54,7 +54,7 @@ void TDocumentoOrdine::scadord_recalc()
|
|||||||
if (!datacons.ok())
|
if (!datacons.ok())
|
||||||
datacons = testadoc.get_date(DOC_DATACONS);
|
datacons = testadoc.get_date(DOC_DATACONS);
|
||||||
TString4 codval = valuta();
|
TString4 codval = valuta();
|
||||||
real totimponibili = rigadoc.valore(FALSE, AUTO_DECIMALS);
|
real totimponibili = rigadoc.valore(false, false, AUTO_DECIMALS);
|
||||||
real totimposte = rigadoc.iva().imposta(totimponibili, AUTO_DECIMALS, codval);
|
real totimposte = rigadoc.iva().imposta(totimponibili, AUTO_DECIMALS, codval);
|
||||||
real totspese = ZERO;
|
real totspese = ZERO;
|
||||||
const bool is_in_valuta = in_valuta();
|
const bool is_in_valuta = in_valuta();
|
||||||
|
@ -550,7 +550,7 @@ public:
|
|||||||
real qtaresidua() const;
|
real qtaresidua() const;
|
||||||
real calc_conai_qta(int type) const;
|
real calc_conai_qta(int type) const;
|
||||||
|
|
||||||
real valore(bool totale, int ndec) const;
|
real valore(bool totale, bool lordo = false, int ndec = AUTO_DECIMALS) const;
|
||||||
const TString & codice_costo() const;
|
const TString & codice_costo() const;
|
||||||
const TString & codice_commessa() const;
|
const TString & codice_commessa() const;
|
||||||
const TString & fase_commessa() const;
|
const TString & fase_commessa() const;
|
||||||
@ -768,7 +768,7 @@ public:
|
|||||||
real spese() const;
|
real spese() const;
|
||||||
real ritenute(const char tipo = '\0', bool lordo = false, int ndec = AUTO_DECIMALS) const;
|
real ritenute(const char tipo = '\0', bool lordo = false, int ndec = AUTO_DECIMALS) const;
|
||||||
real provvigione(int ndec = AUTO_DECIMALS) const;
|
real provvigione(int ndec = AUTO_DECIMALS) const;
|
||||||
real valore(bool totale, int ndec = AUTO_DECIMALS) const;
|
real valore(bool totale, bool lordo = false, int ndec = AUTO_DECIMALS) const;
|
||||||
|
|
||||||
TPagamento & pagamento();
|
TPagamento & pagamento();
|
||||||
|
|
||||||
|
@ -745,7 +745,7 @@ bool TRiga_documento::is_evasa() const
|
|||||||
return qtaresidua().is_zero();
|
return qtaresidua().is_zero();
|
||||||
}
|
}
|
||||||
|
|
||||||
real TRiga_documento::valore(bool totale, int ndec) const
|
real TRiga_documento::valore(bool totale, bool lordo, int ndec) const
|
||||||
{
|
{
|
||||||
real val;
|
real val;
|
||||||
|
|
||||||
@ -762,13 +762,13 @@ real TRiga_documento::valore(bool totale, int ndec) const
|
|||||||
if (qta_is_price)
|
if (qta_is_price)
|
||||||
field_qta = RDOC_QTA;
|
field_qta = RDOC_QTA;
|
||||||
val = get_real(field_qta);
|
val = get_real(field_qta);
|
||||||
val *= prezzo(TRUE, FALSE, ALL_DECIMALS);
|
val *= prezzo(TRUE, lordo, ALL_DECIMALS);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
val = qtaresidua();
|
val = qtaresidua();
|
||||||
if (!qta_is_price)
|
if (!qta_is_price)
|
||||||
val *= prezzo(TRUE, FALSE, ALL_DECIMALS);
|
val *= prezzo(TRUE, lordo, ALL_DECIMALS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ndec == AUTO_DECIMALS)
|
if (ndec == AUTO_DECIMALS)
|
||||||
|
@ -2261,14 +2261,14 @@ real TDocumento::provvigione(int ndec) const
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
real TDocumento::valore(bool totale, int ndec) const
|
real TDocumento::valore(bool totale, bool lordo, int ndec) const
|
||||||
{
|
{
|
||||||
real val;
|
real val;
|
||||||
for (int i=rows(); i>0; i--)
|
for (int i=rows(); i>0; i--)
|
||||||
{
|
{
|
||||||
TRiga_documento &r = ((TRiga_documento &) ((TDocumento *)this)->row(i));
|
TRiga_documento &r = ((TRiga_documento &) ((TDocumento *)this)->row(i));
|
||||||
if (r.is_merce() || r.is_spese() || r.is_prestazione())
|
if (r.is_merce() || r.is_spese() || r.is_prestazione())
|
||||||
val += r.valore(totale, ndec);
|
val += r.valore(totale, lordo, ndec);
|
||||||
}
|
}
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
@ -733,7 +733,7 @@ void TExpr_documento::evaluate_user_func(int index, int nparms, TEval_stack & st
|
|||||||
real & r = stack.peek_real();
|
real & r = stack.peek_real();
|
||||||
|
|
||||||
if (_doc)
|
if (_doc)
|
||||||
r = _doc->valore(totale, ndec);
|
r = _doc->valore(totale, false, ndec);
|
||||||
else
|
else
|
||||||
r = ZERO;
|
r = ZERO;
|
||||||
}
|
}
|
||||||
|
@ -567,15 +567,12 @@ bool TContabilizzazione_analitica::elabora(TDocumento& doc, long numreg_cg, TVis
|
|||||||
const TRiga_documento& riga = doc[i];
|
const TRiga_documento& riga = doc[i];
|
||||||
bool pareggio = false;
|
bool pareggio = false;
|
||||||
|
|
||||||
// salto descrizioni, sconti e omaggi
|
|
||||||
// if (riga.is_descrizione() || riga.is_sconto() || riga.is_omaggio())
|
|
||||||
// salto descrizioni, e omaggi
|
// salto descrizioni, e omaggi
|
||||||
if (riga.is_descrizione() || riga.is_omaggio())
|
if (riga.is_descrizione() || riga.is_omaggio())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// salto valori nulli
|
// salto valori nulli
|
||||||
const real qta = riga.get(RDOC_QTA);
|
const real qta = riga.get(RDOC_QTA);
|
||||||
// const real valore = riga.valore(true, decimals);
|
|
||||||
real valore = riga.importo(true, false);
|
real valore = riga.importo(true, false);
|
||||||
|
|
||||||
if (valore.is_zero())
|
if (valore.is_zero())
|
||||||
|
@ -605,13 +605,12 @@ static TImporto get_importo(const TISAM_recordset& partite, const char* sezione,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void calcola_fido_da_saldaconto (const char tipocf, const long codcf, const TDate& datacalc, const int riskdays,
|
static real calcola_esposto_da_saldaconto (const char tipocf, const long codcf, const TDate& datacalc, const int riskdays)
|
||||||
real& saldo, real& saldo_sbf)
|
|
||||||
{
|
{
|
||||||
//estrae le partite aperte del clifo selezionato (no righe 9999) con data <= della data selezionata datacalc
|
//estrae le righe partita relative a pagamenti successivi alla data di rischio (e con tipopag >2,<7)
|
||||||
TString query;
|
TString query;
|
||||||
query << "USE PART\nSELECT ((NRIGA!=9999)&&(CHIUSA!=\"X\")&&(BETWEEN(DATAREG,0,#DATACALC)))\n";
|
query << "USE PART\nSELECT BETWEEN(DATAPAG,#DATASBF,0)&&BETWEEN(TIPOPAG,2,7)\n";
|
||||||
query << "FROM TIPOC=#TIPOCF GRUPPO=0 CONTO=0 SOTTOCONTO=#CODCF\n";
|
query << "FROM TIPOC=#TIPOCF GRUPPO=0 CONTO=0 SOTTOCONTO=#CODCF ANNO=#ANNO\n";
|
||||||
query << "TO TIPOC=#TIPOCF GRUPPO=0 CONTO=0 SOTTOCONTO=#CODCF";
|
query << "TO TIPOC=#TIPOCF GRUPPO=0 CONTO=0 SOTTOCONTO=#CODCF";
|
||||||
|
|
||||||
TISAM_recordset partite(query);
|
TISAM_recordset partite(query);
|
||||||
@ -620,13 +619,15 @@ static void calcola_fido_da_saldaconto (const char tipocf, const long codcf, con
|
|||||||
partite.set_var("#TIPOCF", TVariant(str_tipocf));
|
partite.set_var("#TIPOCF", TVariant(str_tipocf));
|
||||||
partite.set_var("#CODCFCF", codcf);
|
partite.set_var("#CODCFCF", codcf);
|
||||||
partite.set_var("#DATACALC", datacalc);
|
partite.set_var("#DATACALC", datacalc);
|
||||||
|
|
||||||
//importone somma degli importi delle righe del recordset
|
|
||||||
TImporto importone_saldo, importone_sbf;
|
|
||||||
|
|
||||||
//data considerante i giorni di rischio ammessi dall'utonto
|
//data considerante i giorni di rischio ammessi dall'utonto
|
||||||
TDate data_sbf = datacalc;
|
TDate data_sbf = datacalc;
|
||||||
data_sbf -= riskdays;
|
data_sbf -= riskdays;
|
||||||
|
partite.set_var("#DATASBF", data_sbf); //data salvo buon fine
|
||||||
|
partite.set_var("#ANNO", TVariant((long)data_sbf.year()));
|
||||||
|
|
||||||
|
|
||||||
|
//importone somma degli importi delle righe del recordset
|
||||||
|
TImporto importone_esposto;
|
||||||
|
|
||||||
for (bool ok = partite.move_first(); ok; ok = partite.move_next())
|
for (bool ok = partite.move_first(); ok; ok = partite.move_next())
|
||||||
{
|
{
|
||||||
@ -647,24 +648,21 @@ static void calcola_fido_da_saldaconto (const char tipocf, const long codcf, con
|
|||||||
TImporto importo_diff_cambio = get_importo(partite, PART_SEZDIFCAM, PART_DIFFCAM);
|
TImporto importo_diff_cambio = get_importo(partite, PART_SEZDIFCAM, PART_DIFFCAM);
|
||||||
importo_riga += importo_diff_cambio;
|
importo_riga += importo_diff_cambio;
|
||||||
}
|
}
|
||||||
//importo pagamento a rischio (solo pagamenti, mai fatture)
|
|
||||||
const bool is_sbf = partite.get(PART_DATAREG).as_date() >= data_sbf;
|
|
||||||
if (is_sbf)
|
|
||||||
importone_sbf += importo_riga;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//somma importi presenti sulla riga partita (fatture, pagamenti, insoluti, pagamenti insoluti)
|
//somma importi presenti sulla riga partita (fatture, pagamenti, insoluti, pagamenti insoluti)
|
||||||
importone_saldo += importo_riga;
|
importone_esposto += importo_riga;
|
||||||
|
|
||||||
}
|
}
|
||||||
//la normalizzazione del totale delle partite va fatta in base al fatto che si parli di 'C'liente o 'F'ornitore
|
//la normalizzazione del totale delle partite va fatta in base al fatto che si parli di 'C'liente o 'F'ornitore
|
||||||
const char sezione_finale = (tipocf == 'C') ? 'A' : 'D';
|
const char sezione_finale = (tipocf == 'C') ? 'A' : 'D';
|
||||||
importone_saldo.normalize(sezione_finale);
|
importone_esposto.normalize(sezione_finale);
|
||||||
importone_sbf.normalize(sezione_finale);
|
|
||||||
|
|
||||||
//primo valore in output
|
//valore in output
|
||||||
saldo += importone_saldo.valore();
|
real esposto;
|
||||||
saldo_sbf += importone_sbf.valore();
|
esposto += importone_esposto.valore();
|
||||||
|
|
||||||
|
return esposto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -708,8 +706,15 @@ static void calcola_fido_da_documenti(const char tipocf, const long codcf, const
|
|||||||
//adesso che ha i documenti che cercava..
|
//adesso che ha i documenti che cercava..
|
||||||
for (bool ok = documenti.move_first(); ok; ok = documenti.move_next())
|
for (bool ok = documenti.move_first(); ok; ok = documenti.move_next())
|
||||||
{
|
{
|
||||||
const real totdoc = documenti.get("G1:TOTDOC").as_real();
|
TDocumento doc(documenti.cursor()->curr());
|
||||||
|
//documento a residuo (tipo ordini)
|
||||||
|
if (residuo_fido)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else //documento normale (tipo fattura)
|
||||||
|
{
|
||||||
|
const real totdoc = doc.totale_doc();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -721,7 +726,7 @@ void calcola_fido_cliente (const char tipocf, const long codcf, const TDate& dat
|
|||||||
real& saldo, real& saldo_sbf)
|
real& saldo, real& saldo_sbf)
|
||||||
{
|
{
|
||||||
//PRIMA PARTE: controlla il saldaconto
|
//PRIMA PARTE: controlla il saldaconto
|
||||||
calcola_fido_da_saldaconto(tipocf, codcf, datacalc, riskdays, saldo, saldo_sbf);
|
real esposto = calcola_esposto_da_saldaconto(tipocf, codcf, datacalc, riskdays);
|
||||||
//SECONDA PARTE: controlla i documenti
|
//SECONDA PARTE: controlla i documenti
|
||||||
calcola_fido_da_documenti(tipocf, codcf, datacalc, riskdays, saldo, saldo_sbf);
|
calcola_fido_da_documenti(tipocf, codcf, datacalc, riskdays, saldo, saldo_sbf);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user