diff --git a/lv/lv2400.cpp b/lv/lv2400.cpp index 65058bd70..9ec281558 100755 --- a/lv/lv2400.cpp +++ b/lv/lv2400.cpp @@ -181,13 +181,80 @@ bool TGenera_documenti_app::crea_documento(const TISAM_recordset& plan, TLog_rep key.add('C'); key.add(codcli); 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 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); //reupero la cuasale di magazzino di testata const TString16 causmag = cache().get("%TIP", tpdoc, "S9"); + //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 int codindsp = cfven.get_int(CFV_CODINDSP); + 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_CODSCC); 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; + } + //creo il documento corretto riempiendo i campi che già conosco TDocumento doc('D', anno, codnum, ++_ndoc); doc.put(DOC_TIPODOC, tpdoc); @@ -195,11 +262,31 @@ bool TGenera_documenti_app::crea_documento(const TISAM_recordset& plan, TLog_rep doc.put(DOC_TIPOCF, 'C'); doc.put(DOC_CODCF, codcli); doc.put(DOC_CODCONT, codcont); + doc.put(DOC_CODINDSP, codindsp); + doc.put(DOC_RAGGR, ragdoc); doc.put(DOC_CODPAG, codpag); doc.put(DOC_CODABIA, codabi); - doc.put(DOC_CODCABA, codcab); + doc.put(DOC_CODCABA, codcab); + doc.put(DOC_IBAN, iban); + doc.put(DOC_CODABIP, codabipr); + doc.put(DOC_CODCABP, codcabpr); doc.put(DOC_CODAG, codaut); + 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_CAUSMAG, causmag); + doc.put(DOC_PERCSPINC, speseinc); + doc.put(DOC_ADDBOLLI, addbolli); + doc.put(DOC_SCONTOPERC, sconto); doc.put("DATAGEN", datagen); //data generazione del documento doc.put("DATAPRCO", dtcons); //data prevista consegna doc.put("CODITI", coditi); //codice itinerario diff --git a/lv/lv2600.cpp b/lv/lv2600.cpp index 72ad7767f..24dd78cf5 100755 --- a/lv/lv2600.cpp +++ b/lv/lv2600.cpp @@ -358,25 +358,129 @@ TObject* TAcquisizione_cache::key2obj(const char* key) consegne.set_var("#ADATA", adata); consegne.move_first(); const TDate dataprco = consegne.get(LVRCONSPLAN_DTCONS).as_date(); + const int coditi = consegne.get(LVRCONSPLAN_CODITI).as_int(); + const long codaut = consegne.get(LVRCONSPLAN_CODAUT).as_int(); + + //recupero i dati di interesse dal cliente + 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 il codpag - const TString4 codpag = cache().get(LF_CLIFO, key, CLI_CODPAG); - //reupero la cuasale di magazzino di testata const TString16 causmag = cache().get("%TIP", _tipodoc, "S9"); - doc = new TDocumento('D', datadoc.year(), _codnum, ++_ndoc); - doc->put(DOC_TIPODOC, _tipodoc); + //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_CODSCC); 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; + } + + if (cont.get(LVCONDV_CODNUM).empty()) + { + doc = new TDocumento('D', datadoc.year(), _codnum, ++_ndoc); + doc->put(DOC_TIPODOC, _tipodoc); + } + else + { + doc = new TDocumento('D', datadoc.year(), cont.get(LVCONDV_CODNUM), ++_ndoc); + doc->put(DOC_TIPODOC, cont.get(LVCONDV_TPDOC)); + } + doc->put(DOC_STATO, _stato); doc->put(DOC_DATADOC, datadoc); doc->put(DOC_TIPOCF, 'C'); doc->put(DOC_CODCF, codcf); doc->put(DOC_CODCONT, codcont); + doc->put(DOC_CODINDSP, codindsp); doc->put(DOC_CODPAG, codpag); doc->put(DOC_CAUSMAG, causmag); + 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_CODAG, codaut); + 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_CAUSMAG, causmag); + doc->put(DOC_PERCSPINC, speseinc); + doc->put(DOC_ADDBOLLI, addbolli); + doc->put(DOC_SCONTOPERC, sconto); doc->put("DATACON", datadoc); //data conteggio doc->put("DATAGEN", datagen); //data generazione del documento doc->put("DATAPRCO", dataprco); //data prevista consegna + doc->put("CODITI", coditi); //codice itinerario } return doc; } diff --git a/lv/lv2900.cpp b/lv/lv2900.cpp index fd0138297..49e2790e8 100755 --- a/lv/lv2900.cpp +++ b/lv/lv2900.cpp @@ -94,15 +94,81 @@ TObject* TBuoni_cache::key2obj(const char* key) const int coditi = consegne.get(LVRCONSPLAN_CODITI).as_int(); const long codaut = consegne.get(LVRCONSPLAN_CODAUT).as_int(); - //recupero il codpag + //recupero i dati di interesse dal cliente 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 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); + //reupero la cuasale di magazzino di testata const TString16 causmag = cache().get("%TIP", _tipodoc, "S9"); + //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_CODSCC); 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; + } + if (cont.get(LVCONDV_CODNUM).empty()) { doc = new TDocumento('D', datadoc.year(), _codnum, ++_ndoc); @@ -119,11 +185,31 @@ TObject* TBuoni_cache::key2obj(const char* key) doc->put(DOC_TIPOCF, 'C'); doc->put(DOC_CODCF, codcf); doc->put(DOC_CODCONT, codcont); + doc->put(DOC_CODINDSP, codindsp); doc->put(DOC_CODPAG, codpag); doc->put(DOC_CAUSMAG, causmag); 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_CODAG, codaut); + 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_CAUSMAG, causmag); + doc->put(DOC_PERCSPINC, speseinc); + doc->put(DOC_ADDBOLLI, addbolli); + doc->put(DOC_SCONTOPERC, sconto); doc->put("DATACON", datadoc); //data conteggio doc->put("DATAGEN", datagen); //data generazione del documento doc->put("DATAPRCO", dataprco); //data prevista consegna diff --git a/lv/lv3200.cpp b/lv/lv3200.cpp index 0975b78f7..2403ce89a 100755 --- a/lv/lv3200.cpp +++ b/lv/lv3200.cpp @@ -380,9 +380,76 @@ void TEvasione_msk::genera_documento() 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); //reupero la cuasale di magazzino di testata const TString16 causmag = cache().get("%TIP", tipodoc, "S9"); + + //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 int codindsp = cfven.get_int(CFV_CODINDSP); + 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_CODSCC); 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; + } //preparo la testata del documento TDocumento doc('D', kdoc.anno(), codnum, ++_ndoc); @@ -393,12 +460,31 @@ void TEvasione_msk::genera_documento() doc.put(DOC_CODCF, codcf); doc.put(DOC_CODCONT, codcont); doc.put(DOC_CODPAG, codpag); + doc.put(DOC_CODINDSP, codindsp); 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_CODAG, codaut); + 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_CAUSMAG, causmag); + doc.put(DOC_PERCSPINC, speseinc); + doc.put(DOC_ADDBOLLI, addbolli); + doc.put(DOC_SCONTOPERC, sconto); doc.put("DATAGEN", datagen); //data generazione del documento - doc.put("DATAPRCO", dataprco); //data prevista consegna + doc.put("DATAPRCO", dataprco); //data prevista consegna doc.put("CODITI", coditi); //codice itinerario for (int i = 1; i <= bpre.rows(); i++) diff --git a/lv/lv3400.cpp b/lv/lv3400.cpp index 081c2a77b..70b6db01c 100755 --- a/lv/lv3400.cpp +++ b/lv/lv3400.cpp @@ -345,10 +345,76 @@ void TEvasione_ter_msk::genera_buono() 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 long codcab = clifo.get_long(CLI_CODCAB);const TString80 iban = clifo.get(CLI_IBAN); - //reupero la causale di magazzino di testata - const TString8 causmag = cache().get("%TIP", tipodoc, "S9"); + //reupero la cuasale di magazzino di testata + const TString16 causmag = cache().get("%TIP", tipodoc, "S9"); + + //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 int codindsp = cfven.get_int(CFV_CODINDSP); + 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_CODSCC); 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; + } //preparo la testata del documento TDocumento doc('D', kdoc.anno(), codnum, ++_ndoc); @@ -358,13 +424,32 @@ void TEvasione_ter_msk::genera_buono() doc.put(DOC_TIPOCF, 'C'); doc.put(DOC_CODCF, codcf); doc.put(DOC_CODCONT, codcont); + doc.put(DOC_CODINDSP, codindsp); 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_CODAG, codaut); + 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_CAUSMAG, causmag); + doc.put(DOC_PERCSPINC, speseinc); + doc.put(DOC_ADDBOLLI, addbolli); + doc.put(DOC_SCONTOPERC, sconto); doc.put("DATAGEN", datagen); //data generazione del documento - doc.put("DATAPRCO", dataprco); //data prevista consegna + doc.put("DATAPRCO", dataprco); //data prevista consegna doc.put("CODITI", coditi); //codice itinerario for (int i = 1; i <= bpre.rows(); i++)