From faf072a1095323240c99fc5980e2b2ccae508820 Mon Sep 17 00:00:00 2001 From: luca Date: Wed, 12 Nov 2008 11:25:59 +0000 Subject: [PATCH] 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 --- ve/ve1200.cpp | 4 ++-- ve/ve7200.cpp | 2 +- ve/velib.h | 4 ++-- ve/velib02.cpp | 6 +++--- ve/velib03.cpp | 4 ++-- ve/velib03a.cpp | 2 +- ve/velib04f.cpp | 3 --- ve/velib07.cpp | 49 +++++++++++++++++++++++++++---------------------- 8 files changed, 38 insertions(+), 36 deletions(-) diff --git a/ve/ve1200.cpp b/ve/ve1200.cpp index 3fc75fd05..2f53f84ea 100755 --- a/ve/ve1200.cpp +++ b/ve/ve1200.cpp @@ -334,7 +334,7 @@ int TScoperto_form::print_bolla(const TRectype& dochead, TArray* fatt) } } quant = riga.qtaresidua(); - valore = riga.valore(FALSE, AUTO_DECIMALS); + valore = riga.valore(false, false, AUTO_DECIMALS); } else { @@ -374,7 +374,7 @@ int TScoperto_form::print_bolla(const TRectype& dochead, TArray* fatt) } } quant = riga.quantita(); - valore = riga.valore(TRUE, AUTO_DECIMALS); + valore = riga.valore(true, false, AUTO_DECIMALS); } if (valore > ZERO) // Devo stampare la riga diff --git a/ve/ve7200.cpp b/ve/ve7200.cpp index a0b80006d..3b6534768 100755 --- a/ve/ve7200.cpp +++ b/ve/ve7200.cpp @@ -54,7 +54,7 @@ void TDocumentoOrdine::scadord_recalc() if (!datacons.ok()) datacons = testadoc.get_date(DOC_DATACONS); 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 totspese = ZERO; const bool is_in_valuta = in_valuta(); diff --git a/ve/velib.h b/ve/velib.h index 68509dcc9..2dfe95849 100755 --- a/ve/velib.h +++ b/ve/velib.h @@ -550,7 +550,7 @@ public: real qtaresidua() 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_commessa() const; const TString & fase_commessa() const; @@ -768,7 +768,7 @@ public: real spese() const; real ritenute(const char tipo = '\0', bool lordo = false, 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(); diff --git a/ve/velib02.cpp b/ve/velib02.cpp index bb31c09b5..eb5477453 100755 --- a/ve/velib02.cpp +++ b/ve/velib02.cpp @@ -745,7 +745,7 @@ bool TRiga_documento::is_evasa() const 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; @@ -762,13 +762,13 @@ real TRiga_documento::valore(bool totale, int ndec) const if (qta_is_price) field_qta = RDOC_QTA; val = get_real(field_qta); - val *= prezzo(TRUE, FALSE, ALL_DECIMALS); + val *= prezzo(TRUE, lordo, ALL_DECIMALS); } else { val = qtaresidua(); if (!qta_is_price) - val *= prezzo(TRUE, FALSE, ALL_DECIMALS); + val *= prezzo(TRUE, lordo, ALL_DECIMALS); } if (ndec == AUTO_DECIMALS) diff --git a/ve/velib03.cpp b/ve/velib03.cpp index 6b12bb339..4a6415f86 100755 --- a/ve/velib03.cpp +++ b/ve/velib03.cpp @@ -2261,14 +2261,14 @@ real TDocumento::provvigione(int ndec) const return val; } -real TDocumento::valore(bool totale, int ndec) const +real TDocumento::valore(bool totale, bool lordo, int ndec) const { real val; for (int i=rows(); i>0; i--) { TRiga_documento &r = ((TRiga_documento &) ((TDocumento *)this)->row(i)); if (r.is_merce() || r.is_spese() || r.is_prestazione()) - val += r.valore(totale, ndec); + val += r.valore(totale, lordo, ndec); } return val; } diff --git a/ve/velib03a.cpp b/ve/velib03a.cpp index 137e884ac..3a31efe89 100755 --- a/ve/velib03a.cpp +++ b/ve/velib03a.cpp @@ -733,7 +733,7 @@ void TExpr_documento::evaluate_user_func(int index, int nparms, TEval_stack & st real & r = stack.peek_real(); if (_doc) - r = _doc->valore(totale, ndec); + r = _doc->valore(totale, false, ndec); else r = ZERO; } diff --git a/ve/velib04f.cpp b/ve/velib04f.cpp index adeb16dca..1c69e3c28 100755 --- a/ve/velib04f.cpp +++ b/ve/velib04f.cpp @@ -567,15 +567,12 @@ bool TContabilizzazione_analitica::elabora(TDocumento& doc, long numreg_cg, TVis const TRiga_documento& riga = doc[i]; bool pareggio = false; -// salto descrizioni, sconti e omaggi -// if (riga.is_descrizione() || riga.is_sconto() || riga.is_omaggio()) // salto descrizioni, e omaggi if (riga.is_descrizione() || riga.is_omaggio()) continue; // salto valori nulli const real qta = riga.get(RDOC_QTA); - // const real valore = riga.valore(true, decimals); real valore = riga.importo(true, false); if (valore.is_zero()) diff --git a/ve/velib07.cpp b/ve/velib07.cpp index 87fe113c0..53ea78045 100755 --- a/ve/velib07.cpp +++ b/ve/velib07.cpp @@ -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, - real& saldo, real& saldo_sbf) +static real calcola_esposto_da_saldaconto (const char tipocf, const long codcf, const TDate& datacalc, const int riskdays) { - //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; - query << "USE PART\nSELECT ((NRIGA!=9999)&&(CHIUSA!=\"X\")&&(BETWEEN(DATAREG,0,#DATACALC)))\n"; - query << "FROM TIPOC=#TIPOCF GRUPPO=0 CONTO=0 SOTTOCONTO=#CODCF\n"; + query << "USE PART\nSELECT BETWEEN(DATAPAG,#DATASBF,0)&&BETWEEN(TIPOPAG,2,7)\n"; + query << "FROM TIPOC=#TIPOCF GRUPPO=0 CONTO=0 SOTTOCONTO=#CODCF ANNO=#ANNO\n"; query << "TO TIPOC=#TIPOCF GRUPPO=0 CONTO=0 SOTTOCONTO=#CODCF"; 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("#CODCFCF", codcf); 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 TDate data_sbf = datacalc; 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()) { @@ -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); 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) - 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 const char sezione_finale = (tipocf == 'C') ? 'A' : 'D'; - importone_saldo.normalize(sezione_finale); - importone_sbf.normalize(sezione_finale); + importone_esposto.normalize(sezione_finale); - //primo valore in output - saldo += importone_saldo.valore(); - saldo_sbf += importone_sbf.valore(); + //valore in output + real esposto; + 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.. 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) { //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 calcola_fido_da_documenti(tipocf, codcf, datacalc, riskdays, saldo, saldo_sbf); } \ No newline at end of file