diff --git a/lv/lv2500.cpp b/lv/lv2500.cpp index 8eef185a9..5b4144884 100755 --- a/lv/lv2500.cpp +++ b/lv/lv2500.cpp @@ -574,23 +574,26 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do //di partenza, poi costruisco la descrizione in base alla periodicità di fatturazione, //metto la qta uguale alla dotazione che ho appena letto //e prendo il prezzo nolo dalla riga contratto - TRiga_documento& nolorow = doc.insert_row(++i, "01"); - doc.copy_data(nolorow, rout); - TString80 descr("Nolo"); - const int contrper = contr.get_int(LVCONDV_PERFAT); + if (dot != ZERO) + { + TRiga_documento& nolorow = doc.insert_row(++i, "01"); + doc.copy_data(nolorow, rout); + TString80 descr("Nolo"); + const int contrper = contr.get_int(LVCONDV_PERFAT); - switch (contrper) - { - case 0: descr << " per il giorno"; break; - case 1: descr << " per la settimana"; break; - case 2: descr << " per la quindicina"; break; - case 3: descr << " per il mese"; break; - default: break; - } - nolorow.put(RDOC_DESCR,descr); + switch (contrper) + { + case 0: descr << " per il giorno"; break; + case 1: descr << " per la settimana"; break; + case 2: descr << " per la quindicina"; break; + case 3: descr << " per il mese"; break; + default: break; + } + nolorow.put(RDOC_DESCR,descr); - nolorow.put(RDOC_QTA, dot); - nolorow.put(RDOC_PREZZO, rcont.get_real(LVRCONDV_PREZNOL)); + nolorow.put(RDOC_QTA, dot); + nolorow.put(RDOC_PREZZO, rcont.get_real(LVRCONDV_PREZNOL)); + } } break; case 3: //forfait = CICLAGGIO @@ -974,7 +977,7 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do if (!riga.is_descrizione()) to_delete = (riga.imponibile() == ZERO && riga.get_real(RDOC_QTA) == ZERO); } - if (to_delete) + if (to_delete || doc.totale_doc() == ZERO) doc_out.destroy(id); } for (int id = doc_out.items() - 1; id >= 0 ; id--) @@ -1316,13 +1319,108 @@ void TFatturazione_lav_app::genera_bolle_nolo(TAssoc_array& cliela, TFatturazion doc.put(DOC_STATO, stato); doc.put(DOC_TIPOCF, 'C'); - doc.put(DOC_CODCF, contr.get(LVCONDV_CODCF).as_int()); - TLaundry_contract contratto(contr.cursor()->curr()); const long codcf = contratto.get_long(LVCONDV_CODCF); const int codcont = contratto.get_int(LVCONDV_CODCONT); + doc.put(DOC_CODCF, codcf); + TToken_string key("C"); + key.add(codcf); + + const TRectype& clifo = cache().get(LF_CLIFO, key); + const TString4 codpag = clifo.get(CLI_CODPAG); + const long codabi = clifo.get_long(CLI_CODABI); + const long codcab = clifo.get_long(CLI_CODCAB); + const TString80 iban = clifo.get(CLI_IBAN); + + //recupero i dati di interesse dal file CFVEN + const TRectype& cfven = cache().get(LF_CFVEN, key); + const long codabipr = cfven.get_long(CFV_CODABIPR); + const long codcabpr = cfven.get_long(CFV_CODCABPR); + const bool ragdoc = cfven.get_bool(CFV_RAGGDOC); + const TString8 codag1 = cfven.get(CFV_CODAG1); + const TString4 codmez = cfven.get(CFV_CODSPMEZZO); + const TString4 codporto = cfven.get(CFV_CODPORTO); + const TString4 codnote1 = cfven.get(CFV_CODNOTESP1); + const TString4 codnote2 = cfven.get(CFV_CODNOTESP2); + const TString4 codnote = cfven.get(CFV_CODNOTE); + const TString8 codvet1 = cfven.get(CFV_CODVETT1); + const TString8 codvet2 = cfven.get(CFV_CODVETT2); + const TString8 codvet3 = cfven.get(CFV_CODVETT3); + const real speseinc = cfven.get_real(CFV_PERCSPINC); + const TString4 catven = cfven.get(CFV_CATVEN); + const bool addbolli = cfven.get_bool(CFV_ADDBOLLI); + const TString8 codlist = cfven.get(CFV_CODLIST); + const TString4 codzona = cfven.get(CFV_CODZONA); + + //gestione sconto + TString sconto; + + const char tpgest = ini_get_string(CONFIG_DITTA, "ve", "GESSCO")[0]; + switch(tpgest) + { + case 'P': sconto = cfven.get(CFV_SCONTO); break; //Percentuale su anagrafica cliente + case 'T': sconto = cache().get("%SCC", cfven.get(CFV_CODSCC), "S1"); break; //Gestione tabella sconti + case 'A': //Gestione archivio sconti + { + TConfig ditta(CONFIG_DITTA, "ve"); + + TLocalisamfile sconti(LF_SCONTI); + sconti.put("TIPO", "I"); + + if(ditta.get_bool("SCOKEY", "ve", 1)) + sconti.put("CODCAT", cfven.get(CFV_CATVEN)); + + TString16 cod; + if(ditta.get_bool("SCOKEY", "ve", 2)) + cod.format("%-2s", (const char*)cfven.get(CFV_CODSCC)); + else + cod = " "; + + if(ditta.get_bool("SCOKEY", "ve", 3)) + { + TString8 tmp; + tmp.format("%-2s", (const char*)cfven.get(CFV_CODZONA)); + cod << tmp; + } + else + cod << " "; + + if(ditta.get_bool("SCOKEY", "ve", 4)) + cod << clifo.get(CLI_CODPAG); + + sconti.put("CODART", cod); + + if (sconti.read() == NOERR) + sconto = sconti.get("SCONTO"); + } + case 'N': //sconto non gestito + default: break; + } + + doc.put(DOC_CODPAG, codpag); + doc.put(DOC_CODABIA, codabi); + doc.put(DOC_CODCABA, codcab); + doc.put(DOC_IBAN, iban); + doc.put(DOC_CODABIP, codabipr); + doc.put(DOC_CODCABP, codcabpr); + doc.put(DOC_CODAGVIS, codag1); + doc.put(DOC_CODSPMEZZO, codmez); + doc.put(DOC_ZONA, codzona); + doc.put(DOC_CODPORTO, codporto); + doc.put(DOC_CODNOTESP1, codnote1); + doc.put(DOC_CODNOTESP2, codnote2); + doc.put(DOC_CODNOTE, codnote); + doc.put(DOC_CODVETT1, codvet1); + doc.put(DOC_CODVETT2, codvet2); + doc.put(DOC_CODVETT3, codvet3); + doc.put(DOC_CATVEN, catven); + doc.put(DOC_CODLIST, codlist); + doc.put(DOC_PERCSPINC, speseinc); + doc.put(DOC_ADDBOLLI, addbolli); + doc.put(DOC_SCONTOPERC, sconto); + TString str; str << "USE LVRCONDV\n" << "FROM CODCF=" << codcf << " CODCONT=" << codcont << "\n" @@ -1362,7 +1460,7 @@ void TFatturazione_lav_app::genera_bolle_nolo(TAssoc_array& cliela, TFatturazion if (ini_get_bool(CONFIG_DITTA, "lv", "RifTest")) elab.put("B15", true); //forzo la descrizione abbreviata - if (doc.rows() > 0) + if (doc.physical_rows() > 0) { elab.elabora(doc_in, doc_out, _msk->get_date(F_DATAFAT)); int err = doc_out.write();