Minima gestione split payment

git-svn-id: svn://10.65.10.50/branches/R_10_00@23041 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2015-02-24 08:34:37 +00:00
parent ed57567c20
commit 83bb071f66

View File

@ -48,11 +48,14 @@ class TFatturazione_lav_app: public TSkeleton_application
protected:
virtual void main_loop();
virtual bool create();
public:
void genera_bolle_nolo(TAssoc_array& cliela, TFatturazione_lavanderie& elab, int& numdocgen, real& totimp, real& imposta, real& totdoc, real& spese);
bool controlli_preliminari();
bool copy_file(const TFilename& src, const TFilename& dst) const;
bool copy_tree(const char* src_study, const char* dst_study) const;
void log(const char* msg, int sev = 0);
};
TFatturazione_lav_app & app() { return (TFatturazione_lav_app &) main_app();}
@ -528,25 +531,30 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
bool rifbol = contr.get_bool(LVCONDV_RIFBOL);
const int alleg = doc.clifor().get_int(CLI_ALLEG);
const bool liqdiff = alleg == 7 && doc.clifor().vendite().get_bool(CFV_FATTSOSP);
const bool splitpay = alleg == 7 && doc.clifor().get_bool(CLI_SPLITPAY);
real consvconv;
real impvconv;
TAssoc_array nolo_computed;
doc.zero(DOC_LIQDIFF);
doc.zero(DOC_IVAXCASSA);
if (liqdiff)
if (!splitpay)
{
doc.put(DOC_LIQDIFF, "X");
}
else
{
if ((alleg < 5 || alleg == 7) && doc.clifor().get(CLI_PAIV).full() &&
gestione_IVAxCassa(doc.get_date(DOC_DATADOC)))
const bool liqdiff = alleg == 7 && doc.clifor().vendite().get_bool(CFV_FATTSOSP);
if (liqdiff)
{
doc.put(DOC_IVAXCASSA, "X");
doc.put(DOC_LIQDIFF, "X");
}
else
{
if ((alleg < 5 || alleg == 7) && doc.clifor().get(CLI_PAIV).full() &&
gestione_IVAxCassa(doc.get_date(DOC_DATADOC)))
{
doc.put(DOC_IVAXCASSA, "X");
}
}
}
if (doc.physical_rows() > 0 && doc[1].is_descrizione())
{
if (elcons)
@ -1531,6 +1539,10 @@ TRiga_documento& TFatturazione_lavanderie::find_or_create_row(TDocumento& doc_ou
row.zero(RDOC_CODMAGC);
row.put("LVTYPE", lavtype);
r = row.get_int(RDOC_NRIGA);
TString msg; msg.format(FR("Creazione riga %d in fattura %d/%s/%ld"),
r, doc_out.anno(), (const char*)doc_out.numerazione(), doc_out.numero());
app().log(msg, -1);
}
if (fatt_02())
{
@ -1609,7 +1621,7 @@ void TFatturazione_lavanderie::create_row(TDocumento& doc_out, const TRiga_docum
}
//se è una causale di ritirato e se sto ritirando una quantità di merce diversa da zero, allora:
if (cau.is_ritiro() && !qta1.is_zero())
if (!qta1.is_zero() && cau.is_ritiro())
{
//leggo la casuale di magazzino associata al ritiro e il suo segno sul consegnato mese
const TCausale_magazzino& rit = cau.causale_ritiro();
@ -1628,7 +1640,7 @@ void TFatturazione_lavanderie::create_row(TDocumento& doc_out, const TRiga_docum
}
//se è una causale di consegnato e se sto consegnando una quantità di merce diversa da zero, allora:
if (cau.is_consegna() && !qta.is_zero())
if (!qta.is_zero() && cau.is_consegna())
{
//leggo la casuale di magazzino associata al ritiro e i suoi segni sul consegnato mese,
//sulla dotazione temporanea e sulla dotazione iniziale
@ -1725,6 +1737,15 @@ TFatturazione_msk::TFatturazione_msk():TAutomask("lv2500a")
//// TFatturazione_lav_app ////
/////////////////////////////////////
void TFatturazione_lav_app::log(const char* msg, int sev)
{
#ifdef NDEBUG
if (sev >= 0) // No debug messages in release build
#endif
if (_log) _log->log(sev, msg);
}
//GENERA_BOLLE_NOLO: metodo che genera le fatture di solo nolo per quei clienti a cui non è stato consegnato niente
void TFatturazione_lav_app::genera_bolle_nolo(TAssoc_array& cliela, TFatturazione_lavanderie& elab, int& numdocgen, real& totimp, real& imposta, real& totdoc, real& spese)
{
@ -1747,7 +1768,7 @@ void TFatturazione_lav_app::genera_bolle_nolo(TAssoc_array& cliela, TFatturazion
TLista_documenti doc_in;
TLista_documenti doc_out;
TProgress_indicator pi(contr.items(), TR("Elaborazione Nolo", true);
TProgress_monitor pi(contr.items(), TR("Elaborazione Nolo"), true);
for(bool ok = contr.move_first(); ok; ok = contr.move_next())
{
if (!pi.add_status())
@ -2025,14 +2046,14 @@ bool TFatturazione_lav_app::copy_tree(const char* src_study, const char* dst_stu
TFilename mask(src_study); mask.add("*.");
SLIST dlist = xvt_fsys_list_files(DIR_TYPE, mask, TRUE);
xvt_fsys_restore_dir();
TProgind pd(xvt_slist_count(dlist), TR("Copia cartelle"), true, true);
TProgress_monitor pd(xvt_slist_count(dlist), TR("Copia cartelle"), true);
TString msg; // Messaggio di progresso
bool go_on = true;
for (SLIST_ELT d = xvt_slist_get_first(dlist); d && go_on; d = xvt_slist_get_next(dlist, d))
{
if (!pd.addstatus(1))
if (!pd.add_status())
{
go_on = false;
break;
@ -2041,7 +2062,7 @@ bool TFatturazione_lav_app::copy_tree(const char* src_study, const char* dst_stu
const TFilename dir = xvt_slist_get(dlist, d, NULL);
TString name = dir.name(); name.lower();
if (name == "cesp") // Ignora la vetusta cartella Cespiti in FoxPro
if (name.compare("cesp", -1, true) == 0) // Ignora la vetusta cartella Cespiti in FoxPro
continue;
msg.cut(0) << TR("Copia di ") << name;
@ -2050,12 +2071,12 @@ bool TFatturazione_lav_app::copy_tree(const char* src_study, const char* dst_stu
mask = dir; mask.add("*.*");
TString_array files; list_files(mask, files);
TProgind pi(files.items(), "Copia file", true, true);
TProgress_monitor pi(files.items(), "Copia file", true);
TFilename dst;
FOR_EACH_ARRAY_ROW(files, i, f)
{
if (!pi.addstatus(1))
if (!pi.add_status())
{
go_on = false;
break;
@ -2078,6 +2099,13 @@ bool TFatturazione_lav_app::copy_tree(const char* src_study, const char* dst_stu
return go_on;
}
bool TFatturazione_lav_app::create()
{
//instanzio i localisamfile che mi servono
open_files(LF_TABCOM, LF_TAB, LF_CLIFO, LF_DOC, LF_RIGHEDOC, LF_LVCONDV, LF_LVRCONDV, 0);
return TSkeleton_application::create();
}
void TFatturazione_lav_app::main_loop()
{
@ -2099,17 +2127,11 @@ void TFatturazione_lav_app::main_loop()
_msk = new TFatturazione_msk();
_msk->show(F_SAVEDATA, lv_is_02_active());
//instanzio i localisamfile che mi servono
TLocalisamfile doc(LF_DOC);
TLocalisamfile rdoc(LF_RIGHEDOC);
while (_msk->run()!= K_QUIT)
{
_solototali = _msk->get_bool(F_SOLOTOTALI);
const int annoes = _msk->get_date(F_DATAFAT).year();
if (!controlli_preliminari())
{
TString str;
@ -2118,13 +2140,12 @@ void TFatturazione_lav_app::main_loop()
warning_box(str);
return;
}
_log = new TLog_report("Fatturazione");
_log = new TLog_report(TR("Fatturazione"));
if (_msk->get_bool(F_SAVEDATA))
{
TFilename src = firm2dir(-1);
TFilename dst = ini_get_string(CONFIG_DITTA, "lv", "Backup");
copy_tree(src, dst);
}
//leggo i dati di primo interesse
@ -2143,7 +2164,6 @@ void TFatturazione_lav_app::main_loop()
if (!dal.ok())
{
dal.set_day(1);
dal.set_month(1);
dal.set_year(year);
}
@ -2194,7 +2214,7 @@ void TFatturazione_lav_app::main_loop()
long last_clifo = 0;
int numdocgen = 0;
int numdocscart = 0;
bool space = true;
real totimp;
real imposta;
real totdoc;
@ -2244,7 +2264,7 @@ void TFatturazione_lav_app::main_loop()
key.format("C|%ld", lastcli);
TString str;
str << "Cli. " << lastcli << ' ' << cache().get(LF_CLIFO, key, CLI_RICALT) << TR(" non ha generato la fattura pur avendo bolle");
_log->log(0, str);
log(str);
numdocscart++;
}
@ -2268,7 +2288,6 @@ void TFatturazione_lav_app::main_loop()
docsin.destroy(-1);
}
lastcli = clifo;
space = true;
}
//preparo la chiave e recupero da CFVEN i dati di quel cliente
@ -2300,12 +2319,9 @@ void TFatturazione_lav_app::main_loop()
else
if (!_solototali && elab.is_document_compatible(docrec) && docrec.get(DOC_STATO) < stato_min)
{
if (space)
//_log->log(0, "");
space = false;
TString msg;
msg << "Cli. " << clifo << ' ' << clirec.get(CLI_RICALT) << " Bolla n. " << docrec.get(DOC_NDOC) << " del " << docrec.get(DOC_DATADOC) << " in stato " << docrec.get(DOC_STATO);
_log->log(0, msg);
log(msg);
}
//se ho passato tutti e due i test, allora:
@ -2318,7 +2334,7 @@ void TFatturazione_lav_app::main_loop()
{
TString msg;
msg << TR("Non ci sono contratti in essere per il cliente ") << clifo << " " << clirec.get(CLI_RICALT) << TR(" in data ") << datafat.string();
_log->log(0, msg);
log(msg);
}
const int contrper = contr.get_int(LVCONDV_PERFAT);
@ -2415,14 +2431,10 @@ void TFatturazione_lav_app::main_loop()
}
if (doc_updated)
{
if (space)
//_log->log(0, "");
space = false;
TString msg(" Cli.");
msg << clifo << " " << clirec.get(CLI_RICALT) << "Bolla " << docrec.get(DOC_CODNUM) << ' ' << docrec.get(DOC_TIPODOC)
<< ' ' << docrec.get(DOC_NDOC) << " del " << docrec.get(DOC_DATADOC) << " aggiornata la testata ";
_log->log(0, msg);
log(msg);
}
}
for (int r = 1; !_solototali && r <= doc->physical_rows(); r++)
@ -2437,10 +2449,6 @@ void TFatturazione_lav_app::main_loop()
//estraggo il record corrispondente su LF_CLIFOGIAC
const TRecmag_lavanderie& rec = art.find_rec(annoes);
if (space)
//_log->log(0, "");
space = false;
TString str;
str << "Cli." << clifo << ' ' << clirec.get(CLI_RICALT) << " Bolla " << docrec.get(DOC_CODNUM) << ' ' << docrec.get(DOC_TIPODOC)
<< ' ' << docrec.get(DOC_NDOC) << " del " << docrec.get(DOC_DATADOC) << " art." << codart << " - ";
@ -2449,13 +2457,13 @@ void TFatturazione_lav_app::main_loop()
{
TString msg;
msg << str << " Dot.odier.negativa";
_log->log(0, msg);
log(msg);
}
if (rec.get_real("DOTIN") < ZERO)
{
TString msg;
msg << str << " Dot.iniz.negativa";
_log->log(0, msg);
log(msg);
}
bool prezzo_nullo = false;
@ -2480,7 +2488,7 @@ void TFatturazione_lav_app::main_loop()
msg << "sul contratto";
else
msg << "sulla bolla";
_log->log(0, msg);
log(msg);
}
}
}
@ -2521,13 +2529,9 @@ void TFatturazione_lav_app::main_loop()
else
if (!_solototali)
{
if (space)
//_log->log(0, "");
space = false;
TString str;
TToken_string key;
key.add('C');
key.add(lastcli);
str << "Cli." << lastcli << ' ' << cache().get(LF_CLIFO, key, CLI_RICALT) << " non ha generato la fattura pur avendo bolle";
@ -2573,7 +2577,8 @@ void TFatturazione_lav_app::main_loop()
str.format(" %5d", numdocscart);
_log->log(0, str);
_log->print_or_preview();
delete _log;
delete _log; _log = NULL;
}
}