Patch level :10.0
Files correlati : Ricompilazione Demo : [ ] Commento : generazione ordini a fornitore personalizzata per il cigno (che incidentalmente ne è l'unico utente): razionalizzato il programma esistente git-svn-id: svn://10.65.10.50/branches/R_10_00@22313 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
42f1e17b4a
commit
b2a2bb0fa7
527
ps/ps0430300.cpp
527
ps/ps0430300.cpp
@ -131,7 +131,13 @@ protected:
|
|||||||
public:
|
public:
|
||||||
void generate_orders();
|
void generate_orders();
|
||||||
void generate_carics();
|
void generate_carics();
|
||||||
void write_docs(const char tipo, const TMask& mask, const long minforn, const long maxforn, TAssoc_array& orders);
|
void generate_docs_head(const char type, const TSheet_field& sf,
|
||||||
|
long& minforn, long& maxforn, TAssoc_array& orders);
|
||||||
|
void generate_caric_row(const TSheet_field& sf, TToken_string* row, const real qta,
|
||||||
|
TDocumento* d,TRiga_documento& rdoc, TLocalisamfile& righedoc);
|
||||||
|
void generate_order_row(const TSheet_field& sf, TToken_string* row, const real qta,
|
||||||
|
TDocumento* d, TRiga_documento& rdoc, const TRectype& forn, const TRectype& fornven);
|
||||||
|
void write_docs(const char tipo, const long& minforn, const long& maxforn, TAssoc_array& orders);
|
||||||
|
|
||||||
virtual bool create();
|
virtual bool create();
|
||||||
virtual void main_loop();
|
virtual void main_loop();
|
||||||
@ -875,7 +881,255 @@ void TCreazione_ordini::aggiorna_stato_doc_orig(const TRectype& rdoc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCreazione_ordini::write_docs(const char tipo, const TMask& mask, const long minforn, const long maxforn, TAssoc_array& orders)
|
|
||||||
|
//genera la riga del documento di carico (una sola per chiamata)
|
||||||
|
void TCreazione_ordini::generate_caric_row(const TSheet_field& sf, TToken_string* row,
|
||||||
|
const real qta, TDocumento* d, TRiga_documento& rdoc, TLocalisamfile& righedoc)
|
||||||
|
{
|
||||||
|
const TDate dataord = row->get(sf.cid2index(S_DATADOC));
|
||||||
|
const long ndoc = row->get_long(sf.cid2index(S_NUMDOC));
|
||||||
|
const int nriga = row->get_int(sf.cid2index(S_NUMRIGA));
|
||||||
|
TRectype& rigcar = righedoc.curr();
|
||||||
|
rigcar.put(RDOC_PROVV, 'D');
|
||||||
|
rigcar.put(RDOC_ANNO, dataord.year());
|
||||||
|
rigcar.put(RDOC_CODNUM, _mask->get(F_CODNUM));
|
||||||
|
rigcar.put(RDOC_NDOC, ndoc);
|
||||||
|
rigcar.put(RDOC_NRIGA, nriga);
|
||||||
|
int err = righedoc.read(_isequal, _lock);
|
||||||
|
if (err == NOERR)
|
||||||
|
{
|
||||||
|
d->copy_data(rdoc, rigcar);
|
||||||
|
rdoc.put(rdoc.field_qta(), qta);
|
||||||
|
rigcar.add(rdoc.field_qtaevasa(), qta);
|
||||||
|
if (rigcar.get_real(rdoc.field_qtaevasa()) >= rigcar.get_real(rdoc.field_qta()))
|
||||||
|
rigcar.put(RDOC_RIGAEVASA, true);
|
||||||
|
rdoc.put(RDOC_DACODNUM, rigcar.get(RDOC_CODNUM));
|
||||||
|
rdoc.put(RDOC_DAANNO, rigcar.get(RDOC_ANNO));
|
||||||
|
rdoc.put(RDOC_DAPROVV, rigcar.get(RDOC_PROVV));
|
||||||
|
rdoc.put(RDOC_DANDOC, rigcar.get(RDOC_NDOC));
|
||||||
|
rdoc.put(RDOC_DAIDRIGA, rigcar.get(RDOC_NRIGA));
|
||||||
|
err = righedoc.rewrite();
|
||||||
|
if (err == NOERR)
|
||||||
|
aggiorna_stato_doc_orig(rigcar);
|
||||||
|
|
||||||
|
}
|
||||||
|
if (err != NOERR)
|
||||||
|
error_box(FR("Impossibile aggiornare la riga %d del doc. %ld"), nriga, ndoc);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//genera la riga del documento ordine (una sola per chiamata)
|
||||||
|
void TCreazione_ordini::generate_order_row(const TSheet_field& sf, TToken_string* row, const real qta,
|
||||||
|
TDocumento* d, TRiga_documento& rdoc, const TRectype& forn, const TRectype& fornven)
|
||||||
|
{
|
||||||
|
const TString codart = row->get(sf.cid2index(F_CODART));
|
||||||
|
|
||||||
|
TString8 codmag = _mask->get(F_MAG);
|
||||||
|
codmag.right_just(3);
|
||||||
|
codmag << _mask->get(F_DEP);
|
||||||
|
|
||||||
|
TString8 codmagc = _mask->get(F_MAGC);
|
||||||
|
codmagc.right_just(3);
|
||||||
|
codmagc << _mask->get(F_DEPC);
|
||||||
|
|
||||||
|
const bool ultimo_prezzo = _mask->get(F_PREZZO) == "U";
|
||||||
|
|
||||||
|
rdoc.put(RDOC_CODMAG, codmag);
|
||||||
|
rdoc.put(RDOC_CODMAGC, codmagc);
|
||||||
|
rdoc.put(RDOC_CODART, codart);
|
||||||
|
rdoc.put(RDOC_CODARTMAG, codart);
|
||||||
|
rdoc.put(RDOC_CHECKED, "X");
|
||||||
|
rdoc.put(RDOC_DESCR, row->get(sf.cid2index(F_DESCR)));
|
||||||
|
|
||||||
|
const TString descr_agg = row->get(sf.cid2index(F_DESCRAGG));
|
||||||
|
if (descr_agg.full())
|
||||||
|
{
|
||||||
|
rdoc.put(RDOC_DESCLUNGA, "X");
|
||||||
|
rdoc.put(RDOC_DESCEST, descr_agg);
|
||||||
|
}
|
||||||
|
|
||||||
|
rdoc.put(RDOC_UMQTA, row->get(sf.cid2index(F_UM)));
|
||||||
|
rdoc.put(RDOC_QTA, qta);
|
||||||
|
|
||||||
|
const TDate datacons(row->get(sf.cid2index(F_DATACONS)));
|
||||||
|
rdoc.put(RDOC_DATACONS, datacons);
|
||||||
|
|
||||||
|
const TRectype& articolo = cache().get(LF_ANAMAG, codart);
|
||||||
|
TPrice prezzo;
|
||||||
|
if (ultimo_prezzo)
|
||||||
|
prezzo = articolo.get_real(ANAMAG_ULTCOS1);
|
||||||
|
else
|
||||||
|
prezzo = articolo.get_real(ANAMAG_COSTSTD);
|
||||||
|
|
||||||
|
const TString4 codval = forn.get(CLI_CODVAL);
|
||||||
|
prezzo.change_value(codval);
|
||||||
|
rdoc.put(RDOC_PREZZO, prezzo.get_num());
|
||||||
|
|
||||||
|
const TString4 codiva = fornven.get(CFV_ASSFIS);
|
||||||
|
if (codiva.full())
|
||||||
|
rdoc.put(RDOC_CODIVA, codiva);
|
||||||
|
else
|
||||||
|
rdoc.put(RDOC_CODIVA, articolo.get(ANAMAG_CODIVA));
|
||||||
|
|
||||||
|
const TString commessa = row->get(sf.cid2index(S_CDC));
|
||||||
|
const TString fase = row->get(sf.cid2index(S_FSC));
|
||||||
|
rdoc.put(RDOC_CODCMS, commessa);
|
||||||
|
rdoc.put(RDOC_FASCMS, fase);
|
||||||
|
|
||||||
|
for (int i = 0; i < 10 ; i++)
|
||||||
|
if (_userfld.row(i).full())
|
||||||
|
rdoc.put(_userfld.row(i), _mask->get(F_USER1 + i));
|
||||||
|
|
||||||
|
rdoc.put(RDOC_CODAGG1, row->get(sf.cid2index(F_CODAGG1)));
|
||||||
|
rdoc.put(RDOC_CODAGG2, row->get(sf.cid2index(F_CODAGG2)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//genera la testata del documento di 'C'arico o dell''O'rdine
|
||||||
|
void TCreazione_ordini::generate_docs_head(const char type, const TSheet_field& sf,
|
||||||
|
long& minforn, long& maxforn, TAssoc_array& orders)
|
||||||
|
{
|
||||||
|
TString msg;
|
||||||
|
TString4 codnum, tipodoc;
|
||||||
|
TDate datadoc;
|
||||||
|
TLocalisamfile righedoc(LF_RIGHEDOC);
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case 'C':
|
||||||
|
{
|
||||||
|
datadoc = _mask->get_date(F_DATADOCCAR);
|
||||||
|
|
||||||
|
const char* const defpar = "or";
|
||||||
|
TConfig c(CONFIG_USER, defpar);
|
||||||
|
codnum = c.get("OR14_NUMCAR");
|
||||||
|
tipodoc = c.get("OR14_TIPCAR");
|
||||||
|
|
||||||
|
msg << "Generazione documenti di carico";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'O':
|
||||||
|
{
|
||||||
|
datadoc = _mask->get_date(F_DATADOC);
|
||||||
|
|
||||||
|
codnum = _mask->get(F_CODNUM);
|
||||||
|
tipodoc = _mask->get(F_TIPODOC);
|
||||||
|
|
||||||
|
msg << "Generazione ordini";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//parte comune ai casi 'C' ed 'O'
|
||||||
|
const TTipo_documento tipo(tipodoc);
|
||||||
|
const TString& commessa_testata = _mask->get(F_CDCT);
|
||||||
|
const TString& fase_testata = _mask->get(F_FSCT);
|
||||||
|
|
||||||
|
TProgind pi(sf.items(), msg, true, true);
|
||||||
|
|
||||||
|
//giro su tutte le righe dello sheet
|
||||||
|
FOR_EACH_SHEET_ROW(sf, n, row)
|
||||||
|
{
|
||||||
|
if (!pi.setstatus(n))
|
||||||
|
break;
|
||||||
|
if (row->get_char(sf.cid2index(S_DAEVADERE) == 'X'))
|
||||||
|
{
|
||||||
|
real qta;
|
||||||
|
TString8 codforn;
|
||||||
|
TDate datacons;
|
||||||
|
|
||||||
|
if (type == 'C')
|
||||||
|
{
|
||||||
|
qta = row->get(sf.cid2index(S_QTADAEVADERE));
|
||||||
|
codforn = row->get(sf.cid2index(S_FORNITORE));
|
||||||
|
datacons = row->get(sf.cid2index(S_DATACONS));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qta = row->get(sf.cid2index(F_QTA));
|
||||||
|
codforn = row->get(sf.cid2index(F_FORNITORE));
|
||||||
|
datacons = row->get(sf.cid2index(F_DATACONS));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!qta.is_zero())
|
||||||
|
{
|
||||||
|
//dati relativi al fornitore..
|
||||||
|
const long cod = atol(codforn);
|
||||||
|
TString8 key; key.format("F|%ld", cod);
|
||||||
|
const TRectype& forn = cache().get(LF_CLIFO, key);
|
||||||
|
//..e cfven collegato
|
||||||
|
const TRectype& forven = cache().get(LF_CFVEN, key);
|
||||||
|
|
||||||
|
TDocumento* d = (TDocumento*)orders.objptr(codforn);
|
||||||
|
if (d == NULL)
|
||||||
|
{
|
||||||
|
//il documento va creato
|
||||||
|
d = new TDocumento('D', datadoc.year(), codnum, 0L);
|
||||||
|
|
||||||
|
d->put(DOC_TIPODOC, tipodoc);
|
||||||
|
d->put(DOC_TIPOCF, "F");
|
||||||
|
d->put(DOC_CODCF, codforn);
|
||||||
|
d->put(DOC_DATADOC, datadoc);
|
||||||
|
d->put(DOC_DATACONS, datacons);
|
||||||
|
d->put(DOC_CODVAL, forn.get(CLI_CODVAL));
|
||||||
|
d->put(DOC_CODLIN, forn.get(CLI_CODLIN));
|
||||||
|
d->put(DOC_CODPAG, forn.get(CLI_CODPAG));
|
||||||
|
d->put(DOC_CODABIA, forn.get(CLI_CODABI));
|
||||||
|
d->put(DOC_CODCABA, forn.get(CLI_CODCAB));
|
||||||
|
d->put(DOC_IBAN, forn.get(CLI_IBAN));
|
||||||
|
d->put(DOC_CODABIP, forven.get(CFV_CODABIPR));
|
||||||
|
d->put(DOC_CODCABP, forven.get(CFV_CODCABPR));
|
||||||
|
d->put(DOC_RAGGR, forven.get(CFV_RAGGDOC));
|
||||||
|
d->put(DOC_RAGGREFF, forven.get(CFV_RAGGEFF));
|
||||||
|
d->put(DOC_CODINDSP, forven.get(CFV_CODINDSP));
|
||||||
|
d->put(DOC_CODAG, forven.get(CFV_CODAG));
|
||||||
|
d->put(DOC_ZONA, forven.get(CFV_CODZONA));
|
||||||
|
d->put(DOC_CODSPMEZZO, forven.get(CFV_CODSPMEZZO));
|
||||||
|
d->put(DOC_CODPORTO, forven.get(CFV_CODPORTO));
|
||||||
|
d->put(DOC_CODNOTESP1, forven.get(CFV_CODNOTESP1));
|
||||||
|
d->put(DOC_CODNOTESP2, forven.get(CFV_CODNOTESP2));
|
||||||
|
d->put(DOC_CODNOTE, forven.get(CFV_CODNOTE));
|
||||||
|
d->put(DOC_CODVETT1, forven.get(CFV_CODVETT1));
|
||||||
|
d->put(DOC_CODVETT2, forven.get(CFV_CODVETT2));
|
||||||
|
d->put(DOC_CODVETT3, forven.get(CFV_CODVETT3));
|
||||||
|
d->put(DOC_PERCSPINC, forven.get(CFV_PERCSPINC));
|
||||||
|
d->put(DOC_ADDBOLLI, forven.get(CFV_ADDBOLLI));
|
||||||
|
d->put(DOC_CATVEN, forven.get(CFV_CATVEN));
|
||||||
|
d->put(DOC_CODLIST, forven.get(CFV_CODLIST));
|
||||||
|
d->put(DOC_CODCMS, commessa_testata);
|
||||||
|
if (type == 'O')
|
||||||
|
d->put(DOC_NOTE, _mask->get(F_NOTE));
|
||||||
|
|
||||||
|
const TString& causmag = tipo.caus_mov();
|
||||||
|
d->put(DOC_CAUSMAG, causmag);
|
||||||
|
|
||||||
|
orders.add(codforn, d);
|
||||||
|
if (cod < minforn)
|
||||||
|
minforn = cod;
|
||||||
|
if (cod > maxforn)
|
||||||
|
maxforn = cod;
|
||||||
|
} //if (d == NULL)...
|
||||||
|
|
||||||
|
|
||||||
|
//generazione righe del documento
|
||||||
|
TRiga_documento& rdoc = d->new_row("01");
|
||||||
|
|
||||||
|
if (type == 'C')
|
||||||
|
generate_caric_row(sf, row, qta, d, rdoc, righedoc);
|
||||||
|
else
|
||||||
|
generate_order_row(sf, row, qta, d, rdoc, forn, forven);
|
||||||
|
|
||||||
|
|
||||||
|
} //if (!qta.is_zero())...
|
||||||
|
} //if (row->get_char...
|
||||||
|
} //FOR_EACH_SHEET_ROW(sf, n, row)...
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TCreazione_ordini::write_docs(const char tipo, const long& minforn, const long& maxforn, TAssoc_array& orders)
|
||||||
{
|
{
|
||||||
TString msg;
|
TString msg;
|
||||||
switch (tipo)
|
switch (tipo)
|
||||||
@ -922,7 +1176,7 @@ void TCreazione_ordini::write_docs(const char tipo, const TMask& mask, const lon
|
|||||||
} //for (long cod = minforn; cod <= maxforn; cod++)...
|
} //for (long cod = minforn; cod <= maxforn; cod++)...
|
||||||
if (yesno_box(TR("Sono stati generati %d documenti:\nSi desidera stamparli ora?"), cnt))
|
if (yesno_box(TR("Sono stati generati %d documenti:\nSi desidera stamparli ora?"), cnt))
|
||||||
{
|
{
|
||||||
const TString& codnum = mask.get(F_CODNUM);
|
const TString& codnum = _mask->get(F_CODNUM);
|
||||||
const TDate datadoc(TODAY);
|
const TDate datadoc(TODAY);
|
||||||
const int anno = datadoc.year();
|
const int anno = datadoc.year();
|
||||||
cmdline << " " << codnum << ' ' << anno << " D " << mindoc << ' ' << maxdoc;
|
cmdline << " " << codnum << ' ' << anno << " D " << mindoc << ' ' << maxdoc;
|
||||||
@ -932,141 +1186,22 @@ void TCreazione_ordini::write_docs(const char tipo, const TMask& mask, const lon
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TCreazione_ordini::generate_carics()
|
void TCreazione_ordini::generate_carics()
|
||||||
{
|
{
|
||||||
TGenera_ordini_mask& mask = *_mask;
|
//TGenera_ordini_mask& mask = *_mask;
|
||||||
TSheet_field& sf = mask.sfield(F_ORDERS);
|
TSheet_field& sf = _mask->sfield(F_ORDERS);
|
||||||
|
|
||||||
long minforn = 999999L;
|
long minforn = 999999L;
|
||||||
long maxforn = 0L;
|
long maxforn = 0L;
|
||||||
TAssoc_array orders;
|
TAssoc_array orders;
|
||||||
|
|
||||||
if (sf.items() > 0)
|
if (sf.items() > 0)
|
||||||
{
|
generate_docs_head('C', sf, minforn, maxforn, orders);
|
||||||
const TDate datadoc = mask.get_date(F_DATADOCCAR);
|
|
||||||
|
|
||||||
const char* const defpar = "or";
|
|
||||||
TConfig c(CONFIG_USER, defpar);
|
|
||||||
const TString& codnum = c.get("OR14_NUMCAR");
|
|
||||||
const TString& tipodoc = c.get("OR14_TIPCAR");
|
|
||||||
|
|
||||||
const TTipo_documento tipo(tipodoc);
|
|
||||||
|
|
||||||
//const bool ultimo_prezzo = mask.get(F_PREZZO) == "U";
|
|
||||||
const TString& commessat = mask.get(F_CDCT);
|
|
||||||
const TString& faset = mask.get(F_FSCT);
|
|
||||||
|
|
||||||
TLocalisamfile righedoc(LF_RIGHEDOC);
|
|
||||||
|
|
||||||
TProgind pi(sf.items(), TR("Generazione documenti di carico"), true, true);
|
|
||||||
FOR_EACH_SHEET_ROW(sf, n, row)
|
|
||||||
{
|
|
||||||
if (!pi.setstatus(n))
|
|
||||||
break;
|
|
||||||
if (row->get_char(sf.cid2index(S_DAEVADERE) == 'X'))
|
|
||||||
{
|
|
||||||
const real qta = row->get(sf.cid2index(S_QTADAEVADERE));
|
|
||||||
if (!qta.is_zero())
|
|
||||||
{
|
|
||||||
const TString8 codforn(row->get(sf.cid2index(S_FORNITORE)));
|
|
||||||
const long cod = atol(codforn);
|
|
||||||
TString8 key; key.format("F|%ld", cod);
|
|
||||||
const TRectype& forn = cache().get(LF_CLIFO, key);
|
|
||||||
const TDate datacons(row->get(sf.cid2index(S_DATACONS)));
|
|
||||||
const TString4 codval(forn.get(CLI_CODVAL));
|
|
||||||
const TRectype& forven = cache().get(LF_CFVEN, key);
|
|
||||||
const TString4 codiva(forven.get(CFV_ASSFIS));
|
|
||||||
const TString commessa = row->get(sf.cid2index(S_CDC));
|
|
||||||
const TString fase = row->get(sf.cid2index(S_FSC));
|
|
||||||
|
|
||||||
TDocumento* d = (TDocumento*)orders.objptr(codforn);
|
|
||||||
if (d == NULL)
|
|
||||||
{
|
|
||||||
d = new TDocumento('D', datadoc.year(), codnum, 0L);
|
|
||||||
d->put(DOC_TIPODOC, tipodoc);
|
|
||||||
d->put(DOC_TIPOCF, "F");
|
|
||||||
d->put(DOC_CODCF, codforn);
|
|
||||||
d->put(DOC_DATADOC, datadoc);
|
|
||||||
d->put(DOC_DATACONS, datacons);
|
|
||||||
d->put(DOC_CODVAL, codval);
|
|
||||||
d->put(DOC_CODLIN, forn.get(CLI_CODLIN));
|
|
||||||
d->put(DOC_CODPAG, forn.get(CLI_CODPAG));
|
|
||||||
d->put(DOC_CODABIA, forn.get(CLI_CODABI));
|
|
||||||
d->put(DOC_CODCABA, forn.get(CLI_CODCAB));
|
|
||||||
d->put(DOC_IBAN, forn.get(CLI_IBAN));
|
|
||||||
d->put(DOC_CODABIP, forven.get(CFV_CODABIPR));
|
|
||||||
d->put(DOC_CODCABP, forven.get(CFV_CODCABPR));
|
|
||||||
d->put(DOC_RAGGR, forven.get(CFV_RAGGDOC));
|
|
||||||
d->put(DOC_RAGGREFF, forven.get(CFV_RAGGEFF));
|
|
||||||
d->put(DOC_CODINDSP, forven.get(CFV_CODINDSP));
|
|
||||||
d->put(DOC_CODAG, forven.get(CFV_CODAG));
|
|
||||||
d->put(DOC_ZONA, forven.get(CFV_CODZONA));
|
|
||||||
d->put(DOC_CODSPMEZZO, forven.get(CFV_CODSPMEZZO));
|
|
||||||
d->put(DOC_CODPORTO, forven.get(CFV_CODPORTO));
|
|
||||||
d->put(DOC_CODNOTESP1, forven.get(CFV_CODNOTESP1));
|
|
||||||
d->put(DOC_CODNOTESP2, forven.get(CFV_CODNOTESP2));
|
|
||||||
d->put(DOC_CODNOTE, forven.get(CFV_CODNOTE));
|
|
||||||
d->put(DOC_CODVETT1, forven.get(CFV_CODVETT1));
|
|
||||||
d->put(DOC_CODVETT2, forven.get(CFV_CODVETT2));
|
|
||||||
d->put(DOC_CODVETT3, forven.get(CFV_CODVETT3));
|
|
||||||
d->put(DOC_PERCSPINC, forven.get(CFV_PERCSPINC));
|
|
||||||
d->put(DOC_ADDBOLLI, forven.get(CFV_ADDBOLLI));
|
|
||||||
d->put(DOC_CATVEN, forven.get(CFV_CATVEN));
|
|
||||||
d->put(DOC_CODLIST, forven.get(CFV_CODLIST));
|
|
||||||
d->put(DOC_CODCMS, commessat);
|
|
||||||
// le note non dovrebbero servire
|
|
||||||
//d->put(DOC_NOTE, mask.get(F_NOTE));
|
|
||||||
|
|
||||||
const TString& causmag = tipo.caus_mov();
|
|
||||||
d->put(DOC_CAUSMAG, causmag);
|
|
||||||
|
|
||||||
orders.add(codforn, d);
|
|
||||||
if (cod < minforn)
|
|
||||||
minforn = cod;
|
|
||||||
if (cod > maxforn)
|
|
||||||
maxforn = cod;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRiga_documento& rdoc = d->new_row("01");
|
|
||||||
|
|
||||||
const TDate dataord = row->get(sf.cid2index(S_DATADOC));
|
|
||||||
const long ndoc = row->get_long(sf.cid2index(S_NUMDOC));
|
|
||||||
const int nriga = row->get_int(sf.cid2index(S_NUMRIGA));
|
|
||||||
TRectype& rigord = righedoc.curr();
|
|
||||||
rigord.put(RDOC_PROVV, 'D');
|
|
||||||
rigord.put(RDOC_ANNO, dataord.year());
|
|
||||||
rigord.put(RDOC_CODNUM, mask.get(F_CODNUM));
|
|
||||||
rigord.put(RDOC_NDOC, ndoc);
|
|
||||||
rigord.put(RDOC_NRIGA, nriga);
|
|
||||||
int err = righedoc.read(_isequal, _lock);
|
|
||||||
if (err == NOERR)
|
|
||||||
{
|
|
||||||
d->copy_data(rdoc, rigord);
|
|
||||||
rdoc.put(rdoc.field_qta(), qta);
|
|
||||||
rigord.add(rdoc.field_qtaevasa(), qta);
|
|
||||||
if (rigord.get_real(rdoc.field_qtaevasa()) >= rigord.get_real(rdoc.field_qta()))
|
|
||||||
rigord.put(RDOC_RIGAEVASA, true);
|
|
||||||
rdoc.put(RDOC_DACODNUM, rigord.get(RDOC_CODNUM));
|
|
||||||
rdoc.put(RDOC_DAANNO, rigord.get(RDOC_ANNO));
|
|
||||||
rdoc.put(RDOC_DAPROVV, rigord.get(RDOC_PROVV));
|
|
||||||
rdoc.put(RDOC_DANDOC, rigord.get(RDOC_NDOC));
|
|
||||||
rdoc.put(RDOC_DAIDRIGA, rigord.get(RDOC_NRIGA));
|
|
||||||
err = righedoc.rewrite();
|
|
||||||
if (err == NOERR)
|
|
||||||
aggiorna_stato_doc_orig(rigord);
|
|
||||||
|
|
||||||
}
|
|
||||||
if (err != NOERR)
|
|
||||||
error_box(FR("Impossibile aggiornare la riga %d del doc. %ld"), nriga, ndoc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (orders.items() > 0)
|
if (orders.items() > 0)
|
||||||
{
|
write_docs('C', minforn, maxforn, orders);
|
||||||
write_docs('C', mask, minforn, maxforn, orders);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCreazione_ordini::generate_orders()
|
void TCreazione_ordini::generate_orders()
|
||||||
@ -1079,141 +1214,11 @@ void TCreazione_ordini::generate_orders()
|
|||||||
TAssoc_array orders;
|
TAssoc_array orders;
|
||||||
|
|
||||||
if (sf.items() > 0)
|
if (sf.items() > 0)
|
||||||
{
|
generate_docs_head('O', sf, minforn, maxforn, orders);
|
||||||
const TDate datadoc = mask.get_date(F_DATADOC);
|
|
||||||
const TString& codnum = mask.get(F_CODNUM);
|
|
||||||
const TString& tipodoc = mask.get(F_TIPODOC);
|
|
||||||
const TTipo_documento tipo(tipodoc);
|
|
||||||
|
|
||||||
const bool ultimo_prezzo = mask.get(F_PREZZO) == "U";
|
|
||||||
const TString& commessat = mask.get(F_CDCT);
|
|
||||||
const TString& faset = mask.get(F_FSCT);
|
|
||||||
|
|
||||||
TString8 codmag(mask.get(F_MAG));
|
|
||||||
codmag.right_just(3);
|
|
||||||
codmag << mask.get(F_DEP);
|
|
||||||
|
|
||||||
TString8 codmagc(mask.get(F_MAGC));
|
|
||||||
codmagc.right_just(3);
|
|
||||||
codmagc << mask.get(F_DEPC);
|
|
||||||
|
|
||||||
TProgind pi(sf.items(), TR("Generazione ordini"), true, true);
|
|
||||||
FOR_EACH_SHEET_ROW(sf, n, row)
|
|
||||||
{
|
|
||||||
if (!pi.setstatus(n))
|
|
||||||
break;
|
|
||||||
|
|
||||||
const real qta = row->get(sf.cid2index(F_QTA));
|
|
||||||
if (!qta.is_zero())
|
|
||||||
{
|
|
||||||
const TString8 codforn(row->get(sf.cid2index(F_FORNITORE)));
|
|
||||||
const long cod = atol(codforn);
|
|
||||||
TString8 key; key.format("F|%ld", cod);
|
|
||||||
const TRectype& forn = cache().get(LF_CLIFO, key);
|
|
||||||
const TDate datacons(row->get(sf.cid2index(F_DATACONS)));
|
|
||||||
const TString4 codval(forn.get(CLI_CODVAL));
|
|
||||||
const TRectype& forven = cache().get(LF_CFVEN, key);
|
|
||||||
const TString4 codiva(forven.get(CFV_ASSFIS));
|
|
||||||
const TString commessa = row->get(sf.cid2index(F_CDC));
|
|
||||||
const TString fase = row->get(sf.cid2index(F_FSC));
|
|
||||||
|
|
||||||
TDocumento* d = (TDocumento*)orders.objptr(codforn);
|
|
||||||
if (d == NULL)
|
|
||||||
{
|
|
||||||
d = new TDocumento('D', datadoc.year(), codnum, 0L);
|
|
||||||
d->put(DOC_TIPODOC, tipodoc);
|
|
||||||
d->put(DOC_TIPOCF, "F");
|
|
||||||
d->put(DOC_CODCF, codforn);
|
|
||||||
d->put(DOC_DATADOC, datadoc);
|
|
||||||
d->put(DOC_DATACONS, datacons);
|
|
||||||
d->put(DOC_CODVAL, codval);
|
|
||||||
d->put(DOC_CODLIN, forn.get(CLI_CODLIN));
|
|
||||||
d->put(DOC_CODPAG, forn.get(CLI_CODPAG));
|
|
||||||
d->put(DOC_CODABIA, forn.get(CLI_CODABI));
|
|
||||||
d->put(DOC_CODCABA, forn.get(CLI_CODCAB));
|
|
||||||
d->put(DOC_IBAN, forn.get(CLI_IBAN));
|
|
||||||
d->put(DOC_CODABIP, forven.get(CFV_CODABIPR));
|
|
||||||
d->put(DOC_CODCABP, forven.get(CFV_CODCABPR));
|
|
||||||
d->put(DOC_RAGGR, forven.get(CFV_RAGGDOC));
|
|
||||||
d->put(DOC_RAGGREFF, forven.get(CFV_RAGGEFF));
|
|
||||||
d->put(DOC_CODINDSP, forven.get(CFV_CODINDSP));
|
|
||||||
d->put(DOC_CODAG, forven.get(CFV_CODAG));
|
|
||||||
d->put(DOC_ZONA, forven.get(CFV_CODZONA));
|
|
||||||
d->put(DOC_CODSPMEZZO, forven.get(CFV_CODSPMEZZO));
|
|
||||||
d->put(DOC_CODPORTO, forven.get(CFV_CODPORTO));
|
|
||||||
d->put(DOC_CODNOTESP1, forven.get(CFV_CODNOTESP1));
|
|
||||||
d->put(DOC_CODNOTESP2, forven.get(CFV_CODNOTESP2));
|
|
||||||
d->put(DOC_CODNOTE, forven.get(CFV_CODNOTE));
|
|
||||||
d->put(DOC_CODVETT1, forven.get(CFV_CODVETT1));
|
|
||||||
d->put(DOC_CODVETT2, forven.get(CFV_CODVETT2));
|
|
||||||
d->put(DOC_CODVETT3, forven.get(CFV_CODVETT3));
|
|
||||||
d->put(DOC_PERCSPINC, forven.get(CFV_PERCSPINC));
|
|
||||||
d->put(DOC_ADDBOLLI, forven.get(CFV_ADDBOLLI));
|
|
||||||
d->put(DOC_CATVEN, forven.get(CFV_CATVEN));
|
|
||||||
d->put(DOC_CODLIST, forven.get(CFV_CODLIST));
|
|
||||||
d->put(DOC_CODCMS, commessat);
|
|
||||||
d->put(DOC_NOTE, mask.get(F_NOTE));
|
|
||||||
|
|
||||||
const TString& causmag = tipo.caus_mov();
|
|
||||||
d->put(DOC_CAUSMAG, causmag);
|
|
||||||
|
|
||||||
orders.add(codforn, d);
|
|
||||||
if (cod < minforn)
|
|
||||||
minforn = cod;
|
|
||||||
if (cod > maxforn)
|
|
||||||
maxforn = cod;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRiga_documento& rdoc = d->new_row("01");
|
|
||||||
const TString codart(row->get(sf.cid2index(F_CODART)));
|
|
||||||
|
|
||||||
rdoc.put(RDOC_CODMAG, codmag);
|
|
||||||
rdoc.put(RDOC_CODMAGC, codmagc);
|
|
||||||
rdoc.put(RDOC_CODART, codart);
|
|
||||||
rdoc.put(RDOC_CODARTMAG, codart);
|
|
||||||
rdoc.put(RDOC_CHECKED, "X");
|
|
||||||
rdoc.put(RDOC_DESCR, row->get(sf.cid2index(F_DESCR)));
|
|
||||||
|
|
||||||
const TString descr_agg(row->get(sf.cid2index(F_DESCRAGG)));
|
|
||||||
if (descr_agg.full())
|
|
||||||
{
|
|
||||||
rdoc.put(RDOC_DESCLUNGA, "X");
|
|
||||||
rdoc.put(RDOC_DESCEST, descr_agg);
|
|
||||||
}
|
|
||||||
|
|
||||||
rdoc.put(RDOC_UMQTA, row->get(sf.cid2index(F_UM)));
|
|
||||||
rdoc.put(RDOC_QTA, qta);
|
|
||||||
rdoc.put(RDOC_DATACONS, datacons);
|
|
||||||
|
|
||||||
const TRectype& articolo = cache().get(LF_ANAMAG, codart);
|
|
||||||
TPrice prezzo;
|
|
||||||
if (ultimo_prezzo)
|
|
||||||
prezzo = articolo.get_real(ANAMAG_ULTCOS1);
|
|
||||||
else
|
|
||||||
prezzo = articolo.get_real(ANAMAG_COSTSTD);
|
|
||||||
prezzo.change_value(codval);
|
|
||||||
rdoc.put(RDOC_PREZZO, prezzo.get_num());
|
|
||||||
if (codiva.full())
|
|
||||||
rdoc.put(RDOC_CODIVA, codiva);
|
|
||||||
else
|
|
||||||
rdoc.put(RDOC_CODIVA, articolo.get(ANAMAG_CODIVA));
|
|
||||||
rdoc.put(RDOC_CODCMS, commessa);
|
|
||||||
rdoc.put(RDOC_FASCMS, fase);
|
|
||||||
|
|
||||||
for (int i = 0; i < 10 ; i++)
|
|
||||||
if (_userfld.row(i).full())
|
|
||||||
rdoc.put(_userfld.row(i), mask.get(F_USER1 + i));
|
|
||||||
|
|
||||||
rdoc.put(RDOC_CODAGG1, row->get(sf.cid2index(F_CODAGG1)));
|
|
||||||
rdoc.put(RDOC_CODAGG2, row->get(sf.cid2index(F_CODAGG2)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (orders.items() > 0)
|
if (orders.items() > 0)
|
||||||
{
|
write_docs('O', minforn, maxforn, orders);
|
||||||
write_docs('O', mask, minforn, maxforn, orders);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCreazione_ordini::main_loop()
|
void TCreazione_ordini::main_loop()
|
||||||
|
@ -817,12 +817,14 @@ GR -1 80 3
|
|||||||
BE
|
BE
|
||||||
PR 1 8 "@bFornitore"
|
PR 1 8 "@bFornitore"
|
||||||
EN
|
EN
|
||||||
NU 114 6
|
|
||||||
BE
|
NUMBER S_FORNITORE 6
|
||||||
PR 2 10 ""
|
BEGIN
|
||||||
FI 33.CODCF
|
PROMPT 2 10 ""
|
||||||
FL "D"
|
FIELD 33.CODCF
|
||||||
EN
|
FLAGS "D"
|
||||||
|
END
|
||||||
|
|
||||||
ST 115 50
|
ST 115 50
|
||||||
BE
|
BE
|
||||||
PR 14 10 ""
|
PR 14 10 ""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user