Patch level : 10.0 686
Files correlati : lv2.exe Ricompilazione Demo : [ ] Commento : Impostata la percentuale di provvigione nella fatturazione lavanderie git-svn-id: svn://10.65.10.50/trunk@20284 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
033e7e754f
commit
3abe3896c1
@ -1,3 +1,3 @@
|
||||
168
|
||||
0
|
||||
$lvcondv|||189|0|Tabella testate di contratto|||
|
||||
$lvcondv|235|243|191|0|Tabella testate di contratto|||
|
||||
|
@ -1,5 +1,5 @@
|
||||
168
|
||||
47
|
||||
48
|
||||
CODCONT|3|6|0|Codice Contratto
|
||||
STATUS|1|2|0|Stato del contratto, <CH>chiuso, <CO>confermato, <DC>da confermare
|
||||
PROPOSTA|8|1|0|Proposta di contratto
|
||||
@ -47,5 +47,6 @@ COMMENTI|11|10|0|Commenti e note
|
||||
CODNUM|1|4|0|Codice numerazione Buono di Consegna
|
||||
TPDOC|1|4|0|Tipo documento Buono di Consegna
|
||||
REDDI|1|5|0|Reddività
|
||||
RAGGCGRUP|8|1|0|Raggruppa sul capogruppo
|
||||
1
|
||||
CODCF+CODCONT|
|
||||
|
218
lv/lv2500.cpp
218
lv/lv2500.cpp
@ -7,10 +7,13 @@
|
||||
#include "lvlib.h"
|
||||
#include "lv2500a.h"
|
||||
|
||||
#include "../pr/agenti.h"
|
||||
#include "../pr/percprov.h"
|
||||
#include "clifo.h"
|
||||
#include "cfven.h"
|
||||
#include "lvcondv.h"
|
||||
#include "lvrcondv.h"
|
||||
#include "doc.h"
|
||||
#include "rdoc.h"
|
||||
|
||||
#include "../db/dblib.h"
|
||||
@ -100,6 +103,7 @@ class TFatturazione_lavanderie:public TFatturazione_bolle
|
||||
TDate _data_elab;
|
||||
TToken_string _campi_raggruppamento;
|
||||
TAssoc_array _output_rows_02;
|
||||
TAssoc_array _doc_grouped;
|
||||
bool _prova;
|
||||
|
||||
protected:
|
||||
@ -117,7 +121,12 @@ protected:
|
||||
virtual TRiga_documento& find_or_create_row(TDocumento& doc_out, const TRiga_documento & rin,const char lavtype);
|
||||
void aggiorna_fattura(TDocumento & doc, int codcont);
|
||||
bool fatt_02() const { return !_prova &&lv_is_02_active(); }
|
||||
void add_doc_to_list(const TString & key, const TDocumento & doc);
|
||||
real get_percprovv(const TRiga_documento & row, char tipoprovv, const TString & codpr, bool first, const TRectype & age) const;
|
||||
|
||||
public:
|
||||
int write_fatt_ragg();
|
||||
void set_perc_provv(TRiga_documento & row, bool prima = true);
|
||||
virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||
const TDate& data_elab, bool interattivo = false);
|
||||
|
||||
@ -273,9 +282,196 @@ void TFatturazione_lavanderie::aggiorna_fattura(TDocumento & doc, int codcont)
|
||||
|
||||
rdoc.put(RDOC_CODIVA, codiva);
|
||||
rdoc.put(RDOC_CODAGG1, ini_get_string(CONFIG_DITTA, "lv", "CAUSLAV"));
|
||||
set_perc_provv(rdoc);
|
||||
set_perc_provv(rdoc, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TFatturazione_lavanderie::add_doc_to_list(const TString & key, const TDocumento & doc)
|
||||
{
|
||||
TDocumento * doc_cli = (TDocumento *) _doc_grouped.objptr(key);
|
||||
|
||||
if (doc_cli == NULL)
|
||||
_doc_grouped.add(key, doc);
|
||||
else
|
||||
{
|
||||
const int nrows = doc.physical_rows();
|
||||
|
||||
for (int r = 1; r <=nrows; r++)
|
||||
{
|
||||
const TRiga_documento & row = doc[r];
|
||||
TRiga_documento & new_row = doc_cli->new_row(row.get(RDOC_TIPORIGA));
|
||||
|
||||
doc_cli->copy_data(new_row, row);
|
||||
}
|
||||
}
|
||||
}
|
||||
real TFatturazione_lavanderie::get_percprovv(const TRiga_documento & row, char tipoprovv, const TString & codpr, bool first, const TRectype & age) const
|
||||
{
|
||||
real val = ZERO;
|
||||
const TDocumento & doc = row.doc();
|
||||
const TRectype & anamag = cache().get(LF_ANAMAG, row.get(RDOC_CODARTMAG));
|
||||
|
||||
switch (tipoprovv)
|
||||
{
|
||||
case 'A':
|
||||
val = age.get_real(AGE_PERCPROVV);
|
||||
break;
|
||||
case 'M':
|
||||
val = anamag.get_real(ANAMAG_PERCPROVV);
|
||||
break;
|
||||
case 'C':
|
||||
val = doc.clifor().vendite().get_real(first ? CFV_PERCPROVV : CFV_PERCPROVV1);
|
||||
break;
|
||||
case 'V':
|
||||
{
|
||||
const TString16 catven = doc.get(DOC_CATVEN);
|
||||
if (catven.not_empty())
|
||||
val = real(cache().get("CVE", catven, "R0"));
|
||||
}
|
||||
break;
|
||||
case 'O':
|
||||
// val = _rcondv.get_real("PERCPROVV");
|
||||
break;
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
{
|
||||
const TString16 ord = cache().get("APR", codpr, "S3");
|
||||
|
||||
int len = ord.len();
|
||||
TString key;
|
||||
TString80 campo;
|
||||
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
switch (ord[i])
|
||||
{
|
||||
case 'C':
|
||||
campo = doc.clifor().get(CLI_CODCF);
|
||||
campo.lpad(doc.clifor().length(CLI_CODCF));
|
||||
break;
|
||||
case 'V':
|
||||
campo = doc.get(DOC_CATVEN);
|
||||
campo.rpad(doc.length(DOC_CATVEN));
|
||||
break;
|
||||
case 'A':
|
||||
campo = doc.get(DOC_CODAG);
|
||||
campo.rpad(doc.length(DOC_CODAG));
|
||||
break;
|
||||
case 'P':
|
||||
campo = doc.get(DOC_CODPAG);
|
||||
campo.rpad(doc.length(DOC_CODPAG));
|
||||
break;
|
||||
case 'S':
|
||||
campo = doc.clifor().vendite().get(CFV_CODSCC);
|
||||
campo.rpad(doc.clifor().length(CFV_CODSCC));
|
||||
break;
|
||||
case 'Z':
|
||||
campo = doc.get(DOC_ZONA);
|
||||
campo.rpad(doc.length(DOC_ZONA));
|
||||
break;
|
||||
case 'M':
|
||||
campo = row.get( RDOC_CODARTMAG );
|
||||
campo.rpad(row.length(RDOC_CODARTMAG));
|
||||
break;
|
||||
case 'E':
|
||||
campo = anamag.get(ANAMAG_GRMERC);
|
||||
campo.rpad(anamag.length(ANAMAG_GRMERC));
|
||||
campo.cut(3);
|
||||
break;
|
||||
case 'R':
|
||||
campo = anamag.get(ANAMAG_GRMERC);
|
||||
campo.rpad(anamag.length(ANAMAG_GRMERC));
|
||||
break;
|
||||
case 'F':
|
||||
campo = anamag.get(ANAMAG_RAGGFIS);
|
||||
campo.rpad(anamag.length(ANAMAG_RAGGFIS));
|
||||
break;
|
||||
default:
|
||||
campo.cut(0);
|
||||
break;
|
||||
|
||||
}
|
||||
key << campo;
|
||||
}
|
||||
|
||||
TLocalisamfile perc(LF_PERCPROV);
|
||||
|
||||
perc.put(PER_CODPR, codpr);
|
||||
perc.put(PER_KEYORD, key);
|
||||
if (perc.read() == NOERR)
|
||||
val= perc.get_real(PER_PERCPROVV);
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
void TFatturazione_lavanderie::set_perc_provv(TRiga_documento & row, bool prima)
|
||||
{
|
||||
const TString & codage = row.doc().get(prima ? DOC_CODAG : DOC_CODAGVIS);
|
||||
|
||||
if (codage.full())
|
||||
{
|
||||
const TRectype & age = cache().get(LF_AGENTI, codage);
|
||||
|
||||
if (!age.empty())
|
||||
{
|
||||
TString16 seqric(age.get(AGE_SEQRIC));
|
||||
real percprovv;
|
||||
|
||||
if (seqric[0] == '-')
|
||||
seqric = ini_get_string(CONFIG_DITTA, "ve", "AGETIPOPERC");
|
||||
|
||||
int len = seqric.len();
|
||||
int i;
|
||||
|
||||
for (i = 0; percprovv.is_zero() && seqric[i] != '\0' && seqric[i] != '-'; i++)
|
||||
{
|
||||
TString16 codric;
|
||||
if (isdigit(seqric[i]))
|
||||
codric = age.get(format("CODRICPR%d", i+1));
|
||||
percprovv = get_percprovv(row, seqric[i], codric, prima, age);
|
||||
}
|
||||
real percalt;
|
||||
seqric = age.get(AGE_SEQALT);
|
||||
for (i = 0; percalt.is_zero() && seqric[i] != '\0' && seqric[i] != '-'; i++)
|
||||
{
|
||||
TString16 codric;
|
||||
if (isdigit(seqric[i]))
|
||||
codric = age.get(format("CODALTPR%d", i+1));
|
||||
percalt = get_percprovv(row, seqric[i], codric, prima, age);
|
||||
}
|
||||
percprovv += percalt;
|
||||
row.put(prima ? RDOC_PERCPROV : RDOC_PERCPROV1, percprovv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int TFatturazione_lavanderie::write_fatt_ragg()
|
||||
{
|
||||
int items = _doc_grouped.items();
|
||||
TString_array kl;
|
||||
|
||||
_doc_grouped.get_keys(kl);
|
||||
kl.sort();
|
||||
FOR_EACH_ARRAY_ROW(kl, r, key)
|
||||
{
|
||||
TDocumento * d = (TDocumento *)_doc_grouped.objptr(*key);
|
||||
|
||||
if (d != NULL)
|
||||
d->write();
|
||||
}
|
||||
_doc_grouped.destroy();
|
||||
return items;
|
||||
}
|
||||
|
||||
//POST_PROCESS: metodo che elabora i documenti di output dopo che si sono svolte
|
||||
//le operazioni di base sugli stessi, in modo da raggruppare le righe raggruppabili
|
||||
//e/o eliminare quelle inutili e/o aggiungere quelle per il ciclaggio su 2 linee
|
||||
@ -396,6 +592,8 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
|
||||
riga.put(RDOC_CODART,codartcfg);
|
||||
riga.put(RDOC_DESCR,descart);
|
||||
riga.put(RDOC_CODIVA,codiva);
|
||||
set_perc_provv(riga);
|
||||
set_perc_provv(riga, false);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -775,6 +973,8 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
|
||||
congrow.put(RDOC_DESCR, "Conguaglio valore convenzionale");
|
||||
congrow.put(RDOC_QTA, UNO);
|
||||
congrow.put(RDOC_PREZZO, impconvtot - consumotot);
|
||||
set_perc_provv(congrow);
|
||||
set_perc_provv(congrow, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1057,6 +1257,8 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
|
||||
key = tipocf;
|
||||
key.add(new_cli);
|
||||
const TRectype & new_reccliven = cache().get(LF_CFVEN, key);
|
||||
TLaundry_contract contr(new_cli, doc.get_long(DOC_CODINDSP), _data_elab);
|
||||
|
||||
doc.put(DOC_CODINDSP, new_reccliven.get(CFV_CODINDDOC));
|
||||
|
||||
TString descr;
|
||||
@ -1066,6 +1268,12 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
|
||||
descr << act_cli << " " << reccli.get(CLI_RAGSOC);
|
||||
r.put(RDOC_DESCLUNGA, "X");
|
||||
r.put(RDOC_DESCEST, descr);
|
||||
if (contr.get_bool(LVCONDV_RAGGCGRUP))
|
||||
{
|
||||
add_doc_to_list(key, doc);
|
||||
doc_out.destroy(id);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1154,6 +1362,9 @@ TRiga_documento& TFatturazione_lavanderie::find_or_create_row(TDocumento& doc_ou
|
||||
TRiga_documento& row = doc_out.new_row("01");
|
||||
doc_out.copy_data(row, rin);
|
||||
row.put(RDOC_TIPORIGA, "01");
|
||||
set_perc_provv(row);
|
||||
set_perc_provv(row, false);
|
||||
|
||||
|
||||
const TRectype& anamag = cache().get(LF_ANAMAG, rin.get(RDOC_CODART));
|
||||
row.put(RDOC_CODIVA, anamag.get(ANAMAG_CODIVA));
|
||||
@ -1542,6 +1753,8 @@ void TFatturazione_lav_app::genera_bolle_nolo(TAssoc_array& cliela, TFatturazion
|
||||
rdoc.put(RDOC_CODIVA, codiva);
|
||||
|
||||
rdoc.put(RDOC_CODAGG1, ini_get_string(CONFIG_DITTA, "lv", "CAUSLAV"));
|
||||
elab.set_perc_provv(rdoc);
|
||||
elab.set_perc_provv(rdoc, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1806,8 +2019,9 @@ void TFatturazione_lav_app::main_loop()
|
||||
}
|
||||
|
||||
genera_bolle_nolo(cliela, elab, numdocgen);
|
||||
|
||||
TString str;
|
||||
numdocgen += elab.write_fatt_ragg();
|
||||
|
||||
TString str;
|
||||
|
||||
if (numdocgen > 1 || numdocgen == 0)
|
||||
str << "Sono state generate " << numdocgen << " fatture";
|
||||
|
@ -49,5 +49,6 @@
|
||||
#define LVCONDV_CODNUM "CODNUM"
|
||||
#define LVCONDV_TPDOC "TPDOC"
|
||||
#define LVCONDV_REDDI "REDDI"
|
||||
#define LVCONDV_RAGGCGRUP "RAGGCGRUP"
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user