Patch level : 10.0
Files correlati : ve0100b.msk ve0.exe ve6.exe Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/branches/R_10_00@21462 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
8052cf0ebb
commit
70544fb760
@ -92,7 +92,7 @@ END
|
||||
|
||||
STRING F_CODNUM_ELAB 4
|
||||
BEGIN
|
||||
PROMPT 2 4 "Cod. num. "
|
||||
PROMPT 2 4 "Numerazione "
|
||||
HELP "Codice numerazione"
|
||||
USE %NUM
|
||||
INPUT CODTAB F_CODNUM_ELAB
|
||||
|
@ -180,7 +180,7 @@ public:
|
||||
bool kill_descrizione_estesa() const { return get_bool("B10"); }
|
||||
bool pack_rif() const { return get_bool("B15"); }
|
||||
bool calcola_scarti() const { return get_bool("B11"); }
|
||||
bool reload_prices() { return get_bool("B13"); }
|
||||
bool reload_prices() const { return get_bool("B13"); }
|
||||
const TString & num_riferimenti_in() const { return get("S11"); }
|
||||
|
||||
int intestazioni_sheet() const { return get_int("I1"); }
|
||||
@ -223,9 +223,10 @@ protected:
|
||||
bool calcola_ncolli_tara_pnetto(const TString& codart, const real& qta,
|
||||
real& nolli, real& tara, real& pnetto) const;
|
||||
bool aggiorna_ncolli_tara_pnetto(TRiga_documento& r) const;
|
||||
bool genera_righe_riferimento(const TDocumento& indoc, TDocumento& outdoc, TSheet_field& s) const;
|
||||
|
||||
public:
|
||||
bool nettifica() { return get_bool("B12"); }
|
||||
bool nettifica() const { return get_bool("B12"); }
|
||||
virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||
const TDate& data_elab, bool interattivo = false);
|
||||
|
||||
|
@ -2293,7 +2293,7 @@ error_type TContabilizzazione::compile_rows_mov(TDocumento& doc)
|
||||
static TString_array tabella_ripartizione;
|
||||
if (fat_com && tabella_ripartizione.empty())
|
||||
{
|
||||
TConfig cnf(CONFIG_STUDIO);
|
||||
TConfig cnf(CONFIG_STUDIO, "ve");
|
||||
for (int k = 1; k <= MAX_IVA_SLICES; k++)
|
||||
{
|
||||
TToken_string* tt = new TToken_string();
|
||||
@ -2312,8 +2312,7 @@ error_type TContabilizzazione::compile_rows_mov(TDocumento& doc)
|
||||
const TString4 tiporiga = r.get(RDOC_TIPORIGA);
|
||||
if (valid_row_type(tiporiga)) // controlla l'esistenza della riga
|
||||
{
|
||||
TBill conto;
|
||||
TBill contomat;
|
||||
TBill conto, contomat;
|
||||
real pricemat;
|
||||
const char tipo = r.tipo().tipo();
|
||||
// Le righe omaggio senza addebito IVA vanno saltate
|
||||
@ -2322,7 +2321,6 @@ error_type TContabilizzazione::compile_rows_mov(TDocumento& doc)
|
||||
{
|
||||
const bool spesa = r.tipo().tipo() == RIGA_SPESEDOC;
|
||||
char tipo_rit = '\0';
|
||||
|
||||
if (spesa)
|
||||
tipo_rit = r.spesa().tipo_ritenuta();
|
||||
|
||||
@ -2338,22 +2336,15 @@ error_type TContabilizzazione::compile_rows_mov(TDocumento& doc)
|
||||
if (good())
|
||||
{
|
||||
static TString16 fldvalmat("883");
|
||||
|
||||
if (fldvalmat == "883")
|
||||
{
|
||||
TConfig c(CONFIG_DITTA, "ve");
|
||||
|
||||
fldvalmat = c.get("FldValMat", "");
|
||||
|
||||
}
|
||||
fldvalmat = ini_get_string(CONFIG_DITTA, "ve", "FldValMat", "");
|
||||
if (fldvalmat.full())
|
||||
{
|
||||
pricemat = real(cache().get(LF_ANAMAG, r.get(RDOC_CODARTMAG), fldvalmat));
|
||||
|
||||
if (pricemat != ZERO)
|
||||
if (!pricemat.is_zero())
|
||||
{
|
||||
contomat = conto;
|
||||
search_costo_ricavo_mat(contomat,r); // l'errore eventuale viene settato qui dentro
|
||||
search_costo_ricavo_mat(contomat, r); // l'errore eventuale viene settato qui dentro
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2488,33 +2479,22 @@ error_type TContabilizzazione::compile_rows_mov(TDocumento& doc)
|
||||
// crea le righe di contabilita'
|
||||
if (good())
|
||||
{
|
||||
const TString descr_cr(doc.clifor().get(CLI_RAGSOC));
|
||||
|
||||
const TString descr_cr = doc.clifor().get(CLI_RAGSOC); // Probabile porcata ... che Pharmatex non vuole!
|
||||
switch (_movimento->recalc_cg_rows(descr_cr, *_caus))
|
||||
{
|
||||
case 1 :
|
||||
_error = movement_error;
|
||||
break;
|
||||
case 2 :
|
||||
_error = cau_ritintra_error;
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
case 1 : _error = movement_error; break;
|
||||
case 2 : _error = cau_ritintra_error; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
const TRegistro& registro = _caus->reg();
|
||||
const bool iva_mov = registro.ok();
|
||||
|
||||
if (!iva_mov)
|
||||
{
|
||||
static int __check_sez = 2;
|
||||
if (__check_sez > 1)
|
||||
{
|
||||
TConfig c(CONFIG_DITTA, "ve");
|
||||
|
||||
__check_sez = c.get_bool("CHECK_SEZ", false);
|
||||
}
|
||||
static int __check_sez = -1;
|
||||
if (__check_sez < 0)
|
||||
__check_sez = ini_get_bool(CONFIG_DITTA, "ve", "CHECK_SEZ");
|
||||
bool swap = false;
|
||||
|
||||
if (__check_sez)
|
||||
@ -2667,10 +2647,10 @@ error_type TContabilizzazione::write_scadenze(TDocumento& doc)
|
||||
{
|
||||
const int tmov = _caus->tipomov();
|
||||
const TString80 desc(head.get(MOV_DESCR));
|
||||
const TString16 codcaus(_caus->codice());
|
||||
const TString4 codcaus(_caus->codice());
|
||||
const TString4 v(head.get(MOV_CODVAL));
|
||||
const TDate d(head.get_date(MOV_DATACAM));
|
||||
const real c(head.get_real(MOV_CAMBIO));
|
||||
const TDate d(head.get_date(MOV_DATACAM));
|
||||
const real c(head.get_real(MOV_CAMBIO));
|
||||
const TValuta cambio(v, d, c); // verificare
|
||||
const TString8 agente(doc.get(DOC_CODAG));
|
||||
const int ndec = doc.decimals();
|
||||
@ -2686,17 +2666,17 @@ error_type TContabilizzazione::write_scadenze(TDocumento& doc)
|
||||
const int nuova_riga = partita.get_int(PART_NRIGA);
|
||||
|
||||
// put data on partita
|
||||
partita.put(PART_TIPOMOV, tmov);
|
||||
partita.put(PART_NREG, nreg); // Riferimento alla registrazione contabile
|
||||
partita.put(PART_NUMRIG, 1); // Riferimento alla riga contabile del totale
|
||||
partita.put(PART_DATAREG, head.get(MOV_DATAREG));
|
||||
partita.put(PART_DATADOC, head.get(MOV_DATADOC));
|
||||
partita.put(PART_NUMDOC, head.get(MOV_NUMDOC));
|
||||
partita.put(PART_DESCR, desc);
|
||||
partita.put(PART_CODCAUS, codcaus);
|
||||
partita.put(PART_REG, _caus->reg().name());
|
||||
partita.put(PART_PROTIVA, head.get(MOV_PROTIVA));
|
||||
partita.put(PART_SEZ, sezione);
|
||||
partita.put(PART_TIPOMOV, tmov);
|
||||
partita.put(PART_NREG, nreg); // Riferimento alla registrazione contabile
|
||||
partita.put(PART_NUMRIG, 1); // Riferimento alla riga contabile del totale
|
||||
partita.put(PART_DATAREG, head.get(MOV_DATAREG));
|
||||
partita.put(PART_DATADOC, head.get(MOV_DATADOC));
|
||||
partita.put(PART_NUMDOC, head.get(MOV_NUMDOC));
|
||||
partita.put(PART_DESCR, desc);
|
||||
partita.put(PART_CODCAUS, codcaus);
|
||||
partita.put(PART_REG, _caus->reg().name());
|
||||
partita.put(PART_PROTIVA, head.get(MOV_PROTIVA));
|
||||
partita.put(PART_SEZ, sezione);
|
||||
|
||||
const real totdoc(head.get(MOV_TOTDOC));
|
||||
const real totdocval(head.get(MOV_TOTDOCVAL));
|
||||
|
803
ve/velib04d.cpp
803
ve/velib04d.cpp
@ -18,9 +18,7 @@ protected:
|
||||
|
||||
public:
|
||||
void doc2mask(const TDocumento& doc, const TString & articolo);
|
||||
|
||||
TConsegna_mask(TConfig & c,int header_code = 0, bool per_codice = false, bool ignora_descrizioni = false);
|
||||
virtual ~TConsegna_mask() { }
|
||||
TConsegna_mask(int header_code = 0, bool per_codice = false, bool ignora_descrizioni = false);
|
||||
};
|
||||
|
||||
bool TConsegna_mask::on_field_event(class TOperable_field& f, TField_event e, long jolly)
|
||||
@ -114,13 +112,13 @@ int rows_sort_func(TSheet_field& s, int i, int j)
|
||||
{
|
||||
const TToken_string& s1 = s.row(i);
|
||||
const TToken_string& s2 = s.row(j);
|
||||
TString ss1, ss2;
|
||||
TString80 ss1, ss2;
|
||||
TDate dd1, dd2;
|
||||
real rr1, rr2;
|
||||
const int fields[] = { S_CODART, S_LIVGIAC1, S_LIVGIAC2, S_LIVGIAC3, S_LIVGIAC4,
|
||||
S_CODMAG, S_CODDEP, S_RIGAEVASA, S_DATACONS, S_QTARESIDUA, -1 };
|
||||
int ret = 0, field = 0;
|
||||
while (fields[field] >= 0)
|
||||
int ret = 0;
|
||||
for (short field = 0; fields[field] > 0; field++)
|
||||
{
|
||||
if (fields[field] == S_QTARESIDUA)
|
||||
{
|
||||
@ -143,7 +141,6 @@ int rows_sort_func(TSheet_field& s, int i, int j)
|
||||
}
|
||||
if (ret != 0)
|
||||
break;
|
||||
field++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -179,7 +176,7 @@ void TConsegna_mask::doc2mask(const TDocumento& doc, const TString & articolo)
|
||||
if (rec.is_descrizione())
|
||||
show_line = !_ignora_descrizioni;
|
||||
|
||||
if ( show_line && (articolo.blank() || articolo == rec.get(RDOC_CODART)))
|
||||
if ( show_line && (articolo.blank() || articolo == rec.get(RDOC_CODART)) )
|
||||
{
|
||||
TToken_string& r = s.row(-1);
|
||||
r = " ";
|
||||
@ -219,8 +216,8 @@ void TConsegna_mask::doc2mask(const TDocumento& doc, const TString & articolo)
|
||||
s.sort(rows_sort_func);
|
||||
}
|
||||
|
||||
TConsegna_mask::TConsegna_mask(TConfig & c, int header_code, bool per_codice, bool ignora_descrizioni)
|
||||
: TAutomask("velib04d") , _ordina_per_codice(per_codice), _doc(NULL),
|
||||
TConsegna_mask::TConsegna_mask(int header_code, bool per_codice, bool ignora_descrizioni)
|
||||
: TAutomask("velib04d"), _ordina_per_codice(per_codice), _doc(NULL),
|
||||
_ignora_descrizioni(ignora_descrizioni)
|
||||
{
|
||||
TCodgiac_livelli cl;
|
||||
@ -228,47 +225,35 @@ TConsegna_mask::TConsegna_mask(TConfig & c, int header_code, bool per_codice, bo
|
||||
cl.set_sheet_columns(s, S_LIVGIAC1);
|
||||
if (header_code == 1)
|
||||
{
|
||||
TString h;
|
||||
h = HR("Quantita'\nconsegnata");
|
||||
s.set_column_header(S_QTARESIDUA, h);
|
||||
s.set_column_header(S_QTARESIDUA, HR("Quantita'\nconsegnata"));
|
||||
s.sheet_mask().field(S_QTARESIDUA).set_prompt(PR("Q.ta' consegnata"));
|
||||
|
||||
h = HR("Quantita'\nda fatturare");
|
||||
s.set_column_header(S_QTADAEVADERE, h);
|
||||
s.set_column_header(S_QTADAEVADERE, HR("Quantita'\nda fatturare"));
|
||||
s.sheet_mask().field(S_QTADAEVADERE).set_prompt(PR("Q.ta' da fatturare"));
|
||||
}
|
||||
else
|
||||
if (header_code == 2)
|
||||
{
|
||||
TString h;
|
||||
h = HR("Residuo");
|
||||
s.set_column_header(S_QTARESIDUA, h);
|
||||
s.sheet_mask().field(S_QTARESIDUA).set_prompt(PR("Residuo "));
|
||||
} else
|
||||
if (header_code == 2)
|
||||
{
|
||||
s.set_column_header(S_QTARESIDUA, HR("Residuo"));
|
||||
s.sheet_mask().field(S_QTARESIDUA).set_prompt(PR("Residuo "));
|
||||
|
||||
h = HR("Da evadere");
|
||||
s.set_column_header(S_QTADAEVADERE, h);
|
||||
s.sheet_mask().field(S_QTADAEVADERE).set_prompt(PR("Da evadere "));
|
||||
s.set_column_header(S_QTADAEVADERE, HR("Da evadere"));
|
||||
s.sheet_mask().field(S_QTADAEVADERE).set_prompt(PR("Da evadere "));
|
||||
}
|
||||
|
||||
TConfig c(CONFIG_DITTA, "ve");
|
||||
for (int i = 1; i <= 2; i++)
|
||||
{
|
||||
TString8 n; n.format("CODAGG%d", i);
|
||||
if (c.exist(n))
|
||||
{
|
||||
const short id = i == 1 ? S_CODAGG1 : S_CODAGG2;
|
||||
TString80 codagg = c.get(n);
|
||||
TMask_field& agg = s.sheet_mask().field(id);
|
||||
s.set_column_header(id, codagg);
|
||||
codagg.rpad(strlen(agg.prompt()));
|
||||
agg.set_prompt(codagg);
|
||||
}
|
||||
|
||||
if (c.exist("CODAGG1"))
|
||||
{
|
||||
TString80 codagg1 = c.get("CODAGG1");
|
||||
TMask_field & agg1 =s.sheet_mask().field(S_CODAGG1);
|
||||
|
||||
s.set_column_header(S_CODAGG1, codagg1);
|
||||
codagg1.rpad(strlen(agg1.prompt()));
|
||||
agg1.set_prompt(codagg1);
|
||||
}
|
||||
|
||||
if (c.exist("CODAGG2"))
|
||||
{
|
||||
TString80 codagg2 = c.get("CODAGG2");
|
||||
TMask_field & agg2 =s.sheet_mask().field(S_CODAGG2);
|
||||
|
||||
s.set_column_header(S_CODAGG2, codagg2);
|
||||
codagg2.rpad(strlen(agg2.prompt()));
|
||||
agg2.set_prompt(codagg2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -279,7 +264,7 @@ bool TConsegna_ordini::calcola_ncolli_tara_pnetto(const TString& codart, const r
|
||||
real& ncolli, real& tara, real& pnetto) const
|
||||
{
|
||||
const TRectype& articolo = cache().get(LF_ANAMAG, codart);
|
||||
real ppcollo = articolo.get_real(ANAMAG_PPCOLLO);
|
||||
const real ppcollo = articolo.get_real(ANAMAG_PPCOLLO);
|
||||
|
||||
if (ppcollo > ZERO)
|
||||
{
|
||||
@ -298,7 +283,7 @@ bool TConsegna_ordini::calcola_ncolli_tara_pnetto(const TString& codart, const r
|
||||
bool TConsegna_ordini::aggiorna_ncolli_tara_pnetto(TRiga_documento& r) const
|
||||
{
|
||||
const TString& codart = r.get(RDOC_CODARTMAG);
|
||||
TArticolo & articolo = cached_article(codart);
|
||||
TArticolo& articolo = cached_article(codart);
|
||||
const real qta = articolo.convert_to_um(r.quantita(), NULL, r.get(RDOC_UMQTA));
|
||||
real ncolli, tara, pnetto;
|
||||
|
||||
@ -313,6 +298,153 @@ bool TConsegna_ordini::aggiorna_ncolli_tara_pnetto(TRiga_documento& r) const
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TConsegna_ordini::genera_righe_riferimento(const TDocumento& indoc, TDocumento& outdoc, TSheet_field& s) const
|
||||
{
|
||||
// Determina ed eventualmente crea la riga di riferimento
|
||||
const int riga_rif = riferimenti_in_testa() ? 1 : outdoc.physical_rows()+1;
|
||||
if (riga_rif > outdoc.physical_rows())
|
||||
{
|
||||
TRiga_documento& rout = outdoc.new_row();
|
||||
rout.forza_sola_descrizione();
|
||||
}
|
||||
|
||||
TRiga_documento& rout = outdoc[riga_rif];
|
||||
TString memo(1024);
|
||||
|
||||
memo = rout.get(RDOC_DESCR);
|
||||
|
||||
if (rout.get_bool(RDOC_DESCLUNGA))
|
||||
memo << rout.get(RDOC_DESCEST);
|
||||
// Costruisce la stringa di riferimento
|
||||
|
||||
TString rifrow(indoc.tipo().descrizione());
|
||||
TString rifext;
|
||||
|
||||
indoc.riferimento(rifext);
|
||||
|
||||
const int posrif = rifext.find("[RIF]");
|
||||
|
||||
if (rifext.full() && posrif < 0)
|
||||
{
|
||||
rifrow = rifext;
|
||||
rifext.cut(0);
|
||||
}
|
||||
|
||||
const TString4 numrif = num_riferimenti_in();
|
||||
|
||||
if (numrif.full())
|
||||
{
|
||||
TAssoc_array doc_rows;
|
||||
TString riferimenti;
|
||||
|
||||
FOR_EACH_SHEET_ROW(s, n, row)
|
||||
{
|
||||
const int r = row->get_int(s.cid2index(S_NUMRIGA));
|
||||
if (row->get_char(0) > ' ') // E' da consegnare?
|
||||
{
|
||||
const TRiga_documento& rin = indoc[r];
|
||||
TString query("USE RDOC KEY 4");
|
||||
TString select;
|
||||
const char provv = rin.get_char(RDOC_PROVV);
|
||||
const int anno = rin.get_int(RDOC_ANNO);
|
||||
const TString4 codnum = rin.get(RDOC_CODNUM);
|
||||
const long ndoc = rin.get_long(RDOC_NDOC);
|
||||
const int idriga = rin.get_int(RDOC_IDRIGA);
|
||||
|
||||
query << "\nSELECT CODNUM=\"" << numrif << '\"';
|
||||
select.format("DAPROVV=\"%c\" DAANNO=%d DACODNUM=\"%s\" DANDOC=%ld DAIDRIGA=%d", provv, anno, (const char *) codnum, ndoc, idriga);
|
||||
query << "\nFROM " << select;
|
||||
query << "\nTO " << select;
|
||||
|
||||
TISAM_recordset recset(query);
|
||||
|
||||
for (bool ok = recset.move_first(); ok; ok = recset.move_next())
|
||||
{
|
||||
const char provv = recset.get(RDOC_PROVV).as_string()[0];
|
||||
const int anno = recset.get(RDOC_ANNO).as_int();
|
||||
const TString4 codnum = recset.get(RDOC_CODNUM).as_string();
|
||||
const long ndoc = recset.get(RDOC_NDOC).as_int();
|
||||
TString doc_key; doc_key.format("%c|%d|%s|%ld", provv, anno, (const char *) codnum, ndoc);
|
||||
if (!doc_rows.is_key(doc_key))
|
||||
{
|
||||
const TDocumento d(provv, anno, codnum, ndoc);
|
||||
TString rif;
|
||||
|
||||
if (!d.empty())
|
||||
{
|
||||
d.riferimento(rif);
|
||||
TString80 nrifin = d.get(DOC_NUMDOCRIF);
|
||||
|
||||
if (nrifin.blank())
|
||||
nrifin = d.get(DOC_DOC1);
|
||||
if (nrifin.blank())
|
||||
nrifin = d.get(DOC_DOC2);
|
||||
if (nrifin.blank())
|
||||
nrifin = d.get(DOC_DOC3);
|
||||
|
||||
if (usa_doc_rif() && nrifin.full())
|
||||
{
|
||||
rif << " n. " << nrifin;
|
||||
rif << " del " << d.get(DOC_DATADOCRIF);
|
||||
}
|
||||
else
|
||||
{
|
||||
rif << " n. " << d.numero();
|
||||
rif << " del " << d.data().string();
|
||||
}
|
||||
if (riferimenti.full())
|
||||
riferimenti << '\n';
|
||||
riferimenti << rif; }
|
||||
doc_rows.add(doc_key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
memo.insert(riferimenti);
|
||||
}
|
||||
TString80 nrif = indoc.get(DOC_NUMDOCRIF);
|
||||
|
||||
if (nrif.blank())
|
||||
nrif = indoc.get(DOC_DOC1);
|
||||
if (nrif.blank())
|
||||
nrif = indoc.get(DOC_DOC2);
|
||||
if (nrif.blank())
|
||||
nrif = indoc.get(DOC_DOC3);
|
||||
if (usa_doc_rif() && nrif.full())
|
||||
{
|
||||
rifrow << " n. " << nrif;
|
||||
rifrow << " del " << indoc.get(DOC_DATADOCRIF);
|
||||
}
|
||||
else
|
||||
{
|
||||
rifrow << " n. " << indoc.numero();
|
||||
rifrow << " del " << indoc.data().string();
|
||||
}
|
||||
if (memo.full())
|
||||
memo << '\n';
|
||||
if (rifext.blank())
|
||||
memo << rifrow;
|
||||
else
|
||||
{
|
||||
if (posrif >= 0)
|
||||
{
|
||||
int i ;
|
||||
|
||||
for (i = 0; rifext[posrif + i + 5] != '\0'; i++)
|
||||
rifext[posrif + i] = rifext[posrif + i + 5];
|
||||
rifext[posrif + i] = '\0';
|
||||
rifext.insert(rifrow, posrif);
|
||||
}
|
||||
memo << rifext;
|
||||
}
|
||||
rout.put(RDOC_DESCLUNGA, memo.len() > 50);
|
||||
rout.put(RDOC_DESCR, memo.left(50));
|
||||
rout.put(RDOC_DESCEST, memo.mid(50));
|
||||
rout.put("RIFR", "X");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TConsegna_ordini::elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||
const TDate& data_elab, bool interattivo)
|
||||
{
|
||||
@ -323,32 +455,38 @@ bool TConsegna_ordini::elabora(TLista_documenti& doc_in, TLista_documenti& doc_o
|
||||
CHECK(items_in == 1 || items_out == 1 || items_out == items_in,
|
||||
"Numero di documenti da elaborare 'strano'");
|
||||
|
||||
bool ok = true;
|
||||
|
||||
bool ok = false; // Ho elaborato almeno una riga?
|
||||
const int header_code = intestazioni_sheet();
|
||||
|
||||
TConfig c(CONFIG_DITTA, "ve");
|
||||
const bool ordina_per_doc = c.get_bool("ORDINA_PER_DOC", "ve", -1, true);
|
||||
TConsegna_mask m(c, header_code, ordina_per_codice(), get_bool("B3"));
|
||||
TConsegna_mask m(header_code, ordina_per_codice(), get_bool("B3"));
|
||||
|
||||
const int items_max = items_in > items_out ? items_in : items_out;
|
||||
|
||||
const TString& articolo = params().get("ARTICOLO");
|
||||
const bool multi_evasion = interattivo && articolo.full() && !real::is_null(params().get("QUANTITA"));
|
||||
|
||||
pre_process_input(doc_in);
|
||||
for (int d = 0; d < items_max && ok; d++)
|
||||
|
||||
for (int d = 0; d < items_max; d++)
|
||||
{
|
||||
TDocumento& indoc = doc_in[d < items_in ? d : 0];
|
||||
TDocumento& outdoc = doc_out[d < items_out ? d : 0];
|
||||
const TString& articolo = params().get("ARTICOLO");
|
||||
|
||||
m.doc2mask(indoc, articolo);
|
||||
// if (articolo.full())
|
||||
// params().set("QUANTITA", ZERO);
|
||||
if (articolo.full())
|
||||
if (multi_evasion)
|
||||
{
|
||||
const TString& um = params().get("UM");
|
||||
m.show(F_UMQTA);
|
||||
m.set(F_UMQTA, params().get("UM"));
|
||||
m.show(F_QTA);
|
||||
m.set(F_QTA, params().get("QUANTITA"));
|
||||
m.set(F_UMQTA, um);
|
||||
|
||||
int dec = 5;
|
||||
TReal_field& fld_qta = (TReal_field&)m.efield(F_QTA);
|
||||
const TRectype& rum = cache().get("%UMS", um);
|
||||
if (!rum.empty() && rum.get_bool("B0"))
|
||||
dec = rum.get_int("I0");
|
||||
fld_qta.set_decimals(dec);
|
||||
|
||||
fld_qta.show();
|
||||
fld_qta.set(params().get("QUANTITA"));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -356,360 +494,234 @@ bool TConsegna_ordini::elabora(TLista_documenti& doc_in, TLista_documenti& doc_o
|
||||
m.hide(F_QTA);
|
||||
}
|
||||
|
||||
ok = m.run() == K_ENTER;
|
||||
if (ok)
|
||||
if (m.run() != K_ENTER)
|
||||
break;
|
||||
|
||||
TSheet_field& s = m.sfield(F_ROWS);
|
||||
bool one_checked = false;
|
||||
if (!s.empty())
|
||||
{
|
||||
if (gestione_riferimenti())
|
||||
{
|
||||
// Determina ed eventualmente crea la riga di riferimento
|
||||
const int riga_rif = riferimenti_in_testa() ? 1 : outdoc.physical_rows()+1;
|
||||
if (riga_rif > outdoc.physical_rows())
|
||||
{
|
||||
TRiga_documento& rout = outdoc.new_row();
|
||||
rout.forza_sola_descrizione();
|
||||
}
|
||||
|
||||
TRiga_documento& rout = outdoc[riga_rif];
|
||||
TString memo(1024);
|
||||
|
||||
memo = rout.get(RDOC_DESCR);
|
||||
|
||||
if (rout.get_bool(RDOC_DESCLUNGA))
|
||||
memo << rout.get(RDOC_DESCEST);
|
||||
// Costruisce la stringa di riferimento
|
||||
|
||||
TString rifrow(indoc.tipo().descrizione());
|
||||
TString rifext;
|
||||
|
||||
indoc.riferimento(rifext);
|
||||
|
||||
const int posrif = rifext.find("[RIF]");
|
||||
|
||||
if (rifext.full() && posrif < 0)
|
||||
{
|
||||
rifrow = rifext;
|
||||
rifext.cut(0);
|
||||
}
|
||||
|
||||
const TString4 numrif = num_riferimenti_in();
|
||||
|
||||
if (numrif.full())
|
||||
{
|
||||
TSheet_field& s = m.sfield(F_ROWS);
|
||||
TAssoc_array doc_rows;
|
||||
TString riferimenti;
|
||||
|
||||
FOR_EACH_SHEET_ROW(s, n, row)
|
||||
{
|
||||
const int r = row->get_int(s.cid2index(S_NUMRIGA));
|
||||
if (row->get_char(0) > ' ') // E' da consegnare?
|
||||
{
|
||||
const TRiga_documento& rin = indoc[r];
|
||||
TString query("USE RDOC KEY 4");
|
||||
TString select;
|
||||
const char provv = rin.get_char(RDOC_PROVV);
|
||||
const int anno = rin.get_int(RDOC_ANNO);
|
||||
const TString4 codnum = rin.get(RDOC_CODNUM);
|
||||
const long ndoc = rin.get_long(RDOC_NDOC);
|
||||
const int idriga = rin.get_int(RDOC_IDRIGA);
|
||||
|
||||
query << "\nSELECT CODNUM=\"" << numrif << '\"';
|
||||
select.format("DAPROVV=\"%c\" DAANNO=%d DACODNUM=\"%s\" DANDOC=%ld DAIDRIGA=%d", provv, anno, (const char *) codnum, ndoc, idriga);
|
||||
query << "\nFROM " << select;
|
||||
query << "\nTO " << select;
|
||||
|
||||
TISAM_recordset recset(query);
|
||||
|
||||
for (bool ok = recset.move_first(); ok; ok = recset.move_next())
|
||||
{
|
||||
const char provv = recset.get(RDOC_PROVV).as_string()[0];
|
||||
const int anno = recset.get(RDOC_ANNO).as_int();
|
||||
const TString4 codnum = recset.get(RDOC_CODNUM).as_string();
|
||||
const long ndoc = recset.get(RDOC_NDOC).as_int();
|
||||
TString doc_key; doc_key.format("%c|%d|%s|%ld", provv, anno, (const char *) codnum, ndoc);
|
||||
if (!doc_rows.is_key(doc_key))
|
||||
{
|
||||
const TDocumento d(provv, anno, codnum, ndoc);
|
||||
TString rif;
|
||||
|
||||
if (!d.empty())
|
||||
{
|
||||
d.riferimento(rif);
|
||||
TString80 nrifin = d.get(DOC_NUMDOCRIF);
|
||||
|
||||
if (nrifin.blank())
|
||||
nrifin = d.get(DOC_DOC1);
|
||||
if (nrifin.blank())
|
||||
nrifin = d.get(DOC_DOC2);
|
||||
if (nrifin.blank())
|
||||
nrifin = d.get(DOC_DOC3);
|
||||
|
||||
if (usa_doc_rif() && nrifin.full())
|
||||
{
|
||||
rif << " n. " << nrifin;
|
||||
rif << " del " << d.get(DOC_DATADOCRIF);
|
||||
}
|
||||
else
|
||||
{
|
||||
rif << " n. " << d.numero();
|
||||
rif << " del " << d.data().string();
|
||||
}
|
||||
if (riferimenti.full())
|
||||
riferimenti << '\n';
|
||||
riferimenti << rif; }
|
||||
doc_rows.add(doc_key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
memo.insert(riferimenti);
|
||||
}
|
||||
TString80 nrif = indoc.get(DOC_NUMDOCRIF);
|
||||
|
||||
if (nrif.blank())
|
||||
nrif = indoc.get(DOC_DOC1);
|
||||
if (nrif.blank())
|
||||
nrif = indoc.get(DOC_DOC2);
|
||||
if (nrif.blank())
|
||||
nrif = indoc.get(DOC_DOC3);
|
||||
if (usa_doc_rif() && nrif.full())
|
||||
{
|
||||
rifrow << " n. " << nrif;
|
||||
rifrow << " del " << indoc.get(DOC_DATADOCRIF);
|
||||
}
|
||||
else
|
||||
{
|
||||
rifrow << " n. " << indoc.numero();
|
||||
rifrow << " del " << indoc.data().string();
|
||||
}
|
||||
if (memo.full())
|
||||
memo << '\n';
|
||||
if (rifext.blank())
|
||||
memo << rifrow;
|
||||
else
|
||||
{
|
||||
if (posrif >= 0)
|
||||
{
|
||||
int i ;
|
||||
|
||||
for (i = 0; rifext[posrif + i + 5] != '\0'; i++)
|
||||
rifext[posrif + i] = rifext[posrif + i + 5];
|
||||
rifext[posrif + i] = '\0';
|
||||
rifext.insert(rifrow, posrif);
|
||||
}
|
||||
memo << rifext;
|
||||
}
|
||||
rout.put(RDOC_DESCLUNGA, memo.len() > 50);
|
||||
rout.put(RDOC_DESCR, memo.left(50));
|
||||
rout.put(RDOC_DESCEST, memo.mid(50));
|
||||
rout.put("RIFR", "X");
|
||||
}
|
||||
|
||||
|
||||
TToken_string campi_riga(80);
|
||||
const bool ragg_rig = raggruppa_righe();
|
||||
|
||||
if (ragg_rig)
|
||||
{
|
||||
campi_riga = "CODART|LIVELLO|UMQTA"; // Uguali sempre
|
||||
// Uguali opzionalmente
|
||||
if (riga_uguale(0)) campi_riga.add("CODMAG");
|
||||
if (riga_uguale(1)) campi_riga.add("CODIVA");
|
||||
if (riga_uguale(2)) campi_riga.add("PREZZO|SCONTO");
|
||||
}
|
||||
|
||||
const bool evadi = outdoc.tipo().da_evadere();
|
||||
TAssoc_array scarti;
|
||||
|
||||
TSheet_field& s = m.sfield(F_ROWS);
|
||||
FOR_EACH_SHEET_ROW(s, n, row)
|
||||
{
|
||||
const int r = row->get_int(s.cid2index(S_NUMRIGA));
|
||||
if (row->get_char(0) > ' ') // E' da consegnare?
|
||||
{
|
||||
TRiga_documento& inrec = indoc[r];
|
||||
const real daeva = row->get(S_QTADAEVADERE - FIRST_FIELD);
|
||||
const bool eva = row->get_char(S_RIGAEVASA - FIRST_FIELD) > ' ';
|
||||
if (evadi && (daeva > ZERO || eva))
|
||||
{
|
||||
const char* fqe = inrec.field_qtaevasa();
|
||||
inrec.add(fqe, daeva); // nuovo modo di incrementare
|
||||
inrec.put(RDOC_RIGAEVASA, eva ? "X" : "");
|
||||
one_checked = row->get_char(0) > ' '; // E' da consegnare?;
|
||||
if (one_checked)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!one_checked)
|
||||
continue;
|
||||
|
||||
// Genera riferimenti solo se c'e' almeno una riga spuntata
|
||||
if (gestione_riferimenti())
|
||||
genera_righe_riferimento(indoc, outdoc, s);
|
||||
|
||||
TToken_string campi_riga(80);
|
||||
const bool ragg_rig = raggruppa_righe();
|
||||
|
||||
if (ragg_rig)
|
||||
{
|
||||
campi_riga = "CODART|LIVELLO|UMQTA"; // Uguali sempre
|
||||
// Uguali opzionalmente
|
||||
if (riga_uguale(0)) campi_riga.add("CODMAG");
|
||||
if (riga_uguale(1)) campi_riga.add("CODIVA");
|
||||
if (riga_uguale(2)) campi_riga.add("PREZZO|SCONTO");
|
||||
}
|
||||
|
||||
if (eva && calcola_scarti())
|
||||
const bool evadi = outdoc.tipo().da_evadere();
|
||||
TAssoc_array scarti;
|
||||
|
||||
FOR_EACH_SHEET_ROW(s, n, row)
|
||||
{
|
||||
const int r = row->get_int(s.cid2index(S_NUMRIGA));
|
||||
TRiga_documento& inrec = indoc[r];
|
||||
if (row->get_char(0) > ' ') // E' da consegnare?
|
||||
{
|
||||
const real daeva = row->get(S_QTADAEVADERE - FIRST_FIELD);
|
||||
const bool eva = row->get_char(S_RIGAEVASA - FIRST_FIELD) > ' ';
|
||||
if (evadi && (daeva > ZERO || eva))
|
||||
{
|
||||
ok = true; // Ho evaso almeno una riga!
|
||||
const char* fqe = inrec.field_qtaevasa();
|
||||
inrec.add(fqe, daeva); // nuovo modo di incrementare
|
||||
inrec.put(RDOC_RIGAEVASA, eva ? "X" : "");
|
||||
|
||||
if (eva && calcola_scarti())
|
||||
{
|
||||
real scarto = inrec.quantita() - inrec.qtaevasa();
|
||||
if (scarto > ZERO)
|
||||
{
|
||||
real scarto = inrec.quantita() - inrec.qtaevasa();
|
||||
if (scarto > ZERO)
|
||||
const TString& articolo = inrec.get(RDOC_CODARTMAG);
|
||||
if (articolo.full())
|
||||
{
|
||||
const TString& articolo = inrec.get(RDOC_CODARTMAG);
|
||||
if (articolo.full())
|
||||
TToken_string* ska = (TToken_string*)scarti.objptr(articolo);
|
||||
if (ska == NULL)
|
||||
{
|
||||
TToken_string* ska = (TToken_string*)scarti.objptr(articolo);
|
||||
if (ska == NULL)
|
||||
{
|
||||
ska = new TToken_string(inrec.get(RDOC_UMQTA));
|
||||
ska->add(scarto.string(), 1);
|
||||
scarti.add(articolo, ska);
|
||||
}
|
||||
else
|
||||
{
|
||||
scarto = inrec.articolo().convert_to_um(scarto, inrec.get(RDOC_UMQTA), ska->get(0));
|
||||
real s = ska->get(1); s += scarto;
|
||||
ska->add(s.string(), 1);
|
||||
}
|
||||
ska->add(r, 2);
|
||||
ska = new TToken_string(inrec.get(RDOC_UMQTA));
|
||||
ska->add(scarto.string(), 1);
|
||||
scarti.add(articolo, ska);
|
||||
}
|
||||
else
|
||||
{
|
||||
scarto = inrec.articolo().convert_to_um(scarto, inrec.get(RDOC_UMQTA), ska->get(0));
|
||||
real s = ska->get(1); s += scarto;
|
||||
ska->add(s.string(), 1);
|
||||
}
|
||||
ska->add(r, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (articolo.not_empty())
|
||||
{
|
||||
const TString4 um(inrec.get(RDOC_UMQTA));
|
||||
const real qta = inrec.articolo().convert_to_um(daeva, params().get("UM"), um);
|
||||
params().set("QUANTITA", params().get_real("QUANTITA") - qta);
|
||||
}
|
||||
}
|
||||
if (multi_evasion)
|
||||
{
|
||||
const TString4 um = inrec.get(RDOC_UMQTA);
|
||||
const real qta = inrec.articolo().convert_to_um(daeva, params().get("UM"), um);
|
||||
params().set("QUANTITA", params().get_real("QUANTITA") - qta);
|
||||
}
|
||||
|
||||
bool elaborata = false;
|
||||
if (ragg_rig)
|
||||
bool elaborata = false;
|
||||
if (ragg_rig)
|
||||
{
|
||||
for (int i = 1; i <= outdoc.physical_rows(); i++)
|
||||
{
|
||||
for (int i = 1; i <= outdoc.physical_rows(); i++)
|
||||
{
|
||||
TRiga_documento& outrec = outdoc[i];
|
||||
if (outrec.sola_descrizione()) // Ignora le righe descrittive
|
||||
continue;
|
||||
if (inrec.raggruppabile(outrec, campi_riga)) // Se esiste una riga compatibile ...
|
||||
{
|
||||
if (!daeva.is_zero())
|
||||
{
|
||||
const TString& qta_field = outrec.field_qta();
|
||||
outrec.add(qta_field, daeva); // nuovo modo di incrementare
|
||||
TRiga_documento& outrec = outdoc[i];
|
||||
if (outrec.sola_descrizione()) // Ignora le righe descrittive
|
||||
continue;
|
||||
if (inrec.raggruppabile(outrec, campi_riga)) // Se esiste una riga compatibile ...
|
||||
{
|
||||
if (!daeva.is_zero())
|
||||
{
|
||||
const TString& qta_field = outrec.field_qta();
|
||||
outrec.add(qta_field, daeva); // nuovo modo di incrementare
|
||||
|
||||
real ncolli, tara, pnetto;
|
||||
calcola_ncolli_tara_pnetto(outrec.get(RDOC_CODARTMAG), daeva, ncolli, tara, pnetto);
|
||||
outrec.add(RDOC_NCOLLI, ncolli);
|
||||
outrec.add(RDOC_TARA, tara);
|
||||
outrec.add(RDOC_PNETTO, pnetto);
|
||||
real ncolli, tara, pnetto;
|
||||
calcola_ncolli_tara_pnetto(outrec.get(RDOC_CODARTMAG), daeva, ncolli, tara, pnetto);
|
||||
outrec.add(RDOC_NCOLLI, ncolli);
|
||||
outrec.add(RDOC_TARA, tara);
|
||||
outrec.add(RDOC_PNETTO, pnetto);
|
||||
|
||||
outrec.dirty_fields(); // Forza ricalcolo formule
|
||||
}
|
||||
elaborata = true; // Ricorda di averla gia' elaborata
|
||||
break;
|
||||
}
|
||||
outrec.dirty_fields(); // Forza ricalcolo formule
|
||||
}
|
||||
elaborata = true; // Ricorda di averla gia' elaborata
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!elaborata) // Se la riga non e' stata gia' sommata ...
|
||||
{
|
||||
int j = outdoc.physical_rows();
|
||||
|
||||
const bool ordina_per_doc = ini_get_bool(CONFIG_DITTA, "ve", "ORDINA_PER_DOC", true);
|
||||
if (ordina_per_doc)
|
||||
{
|
||||
TToken_string key = inrec.get_rdoc_key();
|
||||
|
||||
key.add("",4);
|
||||
for (; j >= 1; j--)
|
||||
{
|
||||
TToken_string keyrow = outdoc[j].get_original_rdoc_key();
|
||||
keyrow.add("",4);
|
||||
|
||||
if (key == keyrow)
|
||||
break;
|
||||
}
|
||||
}
|
||||
const TString4 tiporiga = inrec.get(RDOC_TIPORIGA);
|
||||
TRiga_documento& outrec = j < 1 || j >= outdoc.physical_rows() ? outdoc.new_row(tiporiga) : outdoc.insert_row(j + 1, tiporiga);
|
||||
const TString& qta_field_orig = inrec.field_qta();
|
||||
const TString& qta_field = outrec.field_qta();
|
||||
const TString& qtaevasa_field = inrec.field_qtaevasa();
|
||||
|
||||
TDocumento::copy_data(outrec, inrec);
|
||||
if (qta_field_orig != RDOC_QTA)
|
||||
{
|
||||
outrec.put(RDOC_QTA, UNO);
|
||||
outrec.put(qta_field_orig, daeva);
|
||||
}
|
||||
else
|
||||
{
|
||||
outrec.put(qta_field, daeva);
|
||||
if (qta_field != RDOC_QTA)
|
||||
outrec.put(RDOC_QTA, UNO);
|
||||
}
|
||||
aggiorna_ncolli_tara_pnetto(outrec);
|
||||
if (outrec.tipo().tipo() != RIGA_DESCRIZIONI && kill_descrizione_estesa()) // Cancello eventualmente la descrizione estesa
|
||||
{
|
||||
outrec.zero(RDOC_DESCLUNGA);
|
||||
outrec.zero(RDOC_DESCEST);
|
||||
}
|
||||
if (!elaborata) // Se la riga non e' stata gia' sommata ...
|
||||
{
|
||||
int j = outdoc.physical_rows();
|
||||
|
||||
if (ordina_per_doc)
|
||||
outrec.dirty_fields(); // Forza ricalcolo peso etc.
|
||||
outrec.zero(qtaevasa_field); // Azzera quantita' evasa erroneamente copiata dall'ordine
|
||||
outrec.zero(RDOC_RIGAEVASA); // Azzera flag di evasa erroneamente copiata dall'ordine
|
||||
outrec.set_original_rdoc_key(inrec);
|
||||
if (reload_prices())
|
||||
outrec.zero(RDOC_CHECKED);
|
||||
|
||||
if (prezzo_da_ordine())
|
||||
{
|
||||
//const bool doc_al_lordo = outdoc.tipo().calcolo_lordo();
|
||||
const TString & codart = outrec.get(RDOC_CODARTMAG);
|
||||
const TRectype & anamag = cache().get(LF_ANAMAG, codart);
|
||||
|
||||
if (!anamag.empty())
|
||||
{
|
||||
TToken_string key = inrec.get_rdoc_key();
|
||||
|
||||
key.add("",4);
|
||||
for (; j >= 1; j--)
|
||||
const TString16 field_prezzo = outdoc.tipo().field_prezzo();
|
||||
if (field_prezzo.full())
|
||||
outrec.put(RDOC_PREZZO, anamag.get_real(field_prezzo));
|
||||
else
|
||||
{
|
||||
TToken_string keyrow = outdoc[j].get_original_rdoc_key();
|
||||
keyrow.add("",4);
|
||||
|
||||
if (key == keyrow)
|
||||
break;
|
||||
const TString4 um = outrec.get(RDOC_UMQTA);
|
||||
if (um.full())
|
||||
{
|
||||
TLocalisamfile umart(LF_UMART);
|
||||
umart.setkey(2);
|
||||
umart.put(UMART_CODART, codart);
|
||||
umart.put(UMART_UM, um);
|
||||
if (umart.read() == NOERR)
|
||||
outrec.put(RDOC_PREZZO, umart.get_real(UMART_PREZZO));
|
||||
}
|
||||
}
|
||||
}
|
||||
const TString4 tiporiga = inrec.get(RDOC_TIPORIGA);
|
||||
TRiga_documento& outrec = j < 1 || j >= outdoc.physical_rows() ? outdoc.new_row(tiporiga) : outdoc.insert_row(j + 1, tiporiga);
|
||||
const TString& qta_field_orig = inrec.field_qta();
|
||||
const TString& qta_field = outrec.field_qta();
|
||||
const TString& qtaevasa_field = inrec.field_qtaevasa();
|
||||
|
||||
TDocumento::copy_data(outrec, inrec);
|
||||
if (qta_field_orig != RDOC_QTA)
|
||||
{
|
||||
outrec.put(RDOC_QTA, UNO);
|
||||
outrec.put(qta_field_orig, daeva);
|
||||
}
|
||||
else
|
||||
{
|
||||
outrec.put(qta_field, daeva);
|
||||
if (qta_field != RDOC_QTA)
|
||||
outrec.put(RDOC_QTA, UNO);
|
||||
}
|
||||
aggiorna_ncolli_tara_pnetto(outrec);
|
||||
if (outrec.tipo().tipo() != RIGA_DESCRIZIONI && kill_descrizione_estesa()) // Cancello eventualmente la descrizione estesa
|
||||
{
|
||||
outrec.zero(RDOC_DESCLUNGA);
|
||||
outrec.zero(RDOC_DESCEST);
|
||||
}
|
||||
|
||||
outrec.dirty_fields(); // Forza ricalcolo peso etc.
|
||||
outrec.zero(qtaevasa_field); // Azzera quantita' evasa erroneamente copiata dall'ordine
|
||||
outrec.zero(RDOC_RIGAEVASA); // Azzera flag di evasa erroneamente copiata dall'ordine
|
||||
outrec.set_original_rdoc_key(inrec);
|
||||
if (reload_prices())
|
||||
outrec.zero(RDOC_CHECKED);
|
||||
|
||||
if (prezzo_da_ordine())
|
||||
{
|
||||
const TString & codart = outrec.get(RDOC_CODARTMAG);
|
||||
const bool doc_al_lordo = outdoc.tipo().calcolo_lordo();
|
||||
const TRectype & anamag = cache().get(LF_ANAMAG, codart);
|
||||
|
||||
if (!anamag.empty())
|
||||
{
|
||||
TString16 field_prezzo(outdoc.tipo().field_prezzo());
|
||||
|
||||
if (field_prezzo.full())
|
||||
outrec.put(RDOC_PREZZO, anamag.get_real(field_prezzo));
|
||||
else
|
||||
{
|
||||
const TString16 um(outrec.get(RDOC_UMQTA));
|
||||
|
||||
if (um.full())
|
||||
{
|
||||
TLocalisamfile umart(LF_UMART);
|
||||
umart.setkey(2);
|
||||
umart.put("CODART", codart);
|
||||
umart.put("UM", um);
|
||||
if (umart.read() == NOERR)
|
||||
outrec.put(RDOC_PREZZO, umart.get_real("PREZZO"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const int last_row = outdoc.physical_rows();
|
||||
if (gestione_riferimenti() && j > 0 && last_row > 0 && outdoc[last_row].tipo().tipo() == RIGA_DESCRIZIONI && outdoc[last_row].get("RIFR").full())
|
||||
}
|
||||
|
||||
const int last_row = outdoc.physical_rows();
|
||||
if (j > 0 && last_row > 0 && gestione_riferimenti())
|
||||
{
|
||||
const TRiga_documento& last_rdoc = outdoc[last_row];
|
||||
if (last_rdoc.is_descrizione() && last_rdoc.get("RIFR").full())
|
||||
outdoc.destroy_row(last_row, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Inserisce le eventuali righe di scarto al posto giusto
|
||||
FOR_EACH_ASSOC_OBJECT(scarti, h, codart, obj)
|
||||
{
|
||||
TString4 tiporiga = "01"; // Riga merce standard
|
||||
int i = 0;
|
||||
// Cerca l'ultima riga del documento avente lo stesso articolo dello scarto
|
||||
for (i = outdoc.physical_rows(); i > 0; i--)
|
||||
{
|
||||
const TRiga_documento& or = outdoc[i];
|
||||
if (or.get(RDOC_CODARTMAG) == codart && or.is_articolo())
|
||||
{
|
||||
tiporiga = or.get(RDOC_TIPORIGA); // Memorizza tipo riga preferito dall'utente
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Crea una nuova riga merce senza articolo e con sola descrizione, qta ed um
|
||||
TRiga_documento& outrec = outdoc.insert_row(i+1, tiporiga);
|
||||
TString descr;
|
||||
descr << TR("Scarto") << ' ' << codart;
|
||||
outrec.put(RDOC_DESCR, descr);
|
||||
TToken_string& ska = *(TToken_string*)obj;
|
||||
outrec.put(RDOC_UMQTA, ska.get(0));
|
||||
outrec.put(RDOC_QTA, ska.get());
|
||||
const TRiga_documento & inrec = indoc[ska.get_int()];
|
||||
outrec.set_original_rdoc_key(inrec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Inserisce le eventuali righe di scarto al posto giusto
|
||||
FOR_EACH_ASSOC_OBJECT(scarti, h, codart, obj)
|
||||
{
|
||||
TString4 tiporiga = "01"; // Riga merce standard
|
||||
int i = 0;
|
||||
// Cerca l'ultima riga del documento avente lo stesso articolo dello scarto
|
||||
for (i = outdoc.physical_rows(); i > 0; i--)
|
||||
{
|
||||
const TRiga_documento& or = outdoc[i];
|
||||
if (or.get(RDOC_CODARTMAG) == codart && or.is_articolo())
|
||||
{
|
||||
tiporiga = or.get(RDOC_TIPORIGA); // Memorizza tipo riga preferito dall'utente
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Crea una nuova riga merce senza articolo e con sola descrizione, qta ed um
|
||||
TRiga_documento& outrec = outdoc.insert_row(i+1, tiporiga);
|
||||
TString descr;
|
||||
descr << TR("Scarto") << ' ' << codart;
|
||||
outrec.put(RDOC_DESCR, descr);
|
||||
TToken_string& ska = *(TToken_string*)obj;
|
||||
outrec.put(RDOC_UMQTA, ska.get(0));
|
||||
outrec.put(RDOC_QTA, ska.get());
|
||||
const TRiga_documento & inrec = indoc[ska.get_int()];
|
||||
outrec.set_original_rdoc_key(inrec);
|
||||
}
|
||||
|
||||
if (reload_prices())
|
||||
{
|
||||
TDocumento_mask * m = new TDocumento_mask(outdoc.get(DOC_TIPODOC));
|
||||
@ -723,11 +735,9 @@ bool TConsegna_ordini::elabora(TLista_documenti& doc_in, TLista_documenti& doc_o
|
||||
|
||||
if (nettifica())
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = indoc.physical_rows(); i >= 1; i--)
|
||||
FOR_EACH_PHYSICAL_RDOC_BACK(indoc, i, rdoc)
|
||||
{
|
||||
TRiga_documento& inrec = indoc[i];
|
||||
TRiga_documento& inrec = *rdoc;
|
||||
const int nrow = inrec.get_int(RDOC_NRIGA);
|
||||
|
||||
if (inrec.is_evasa())
|
||||
@ -744,11 +754,14 @@ bool TConsegna_ordini::elabora(TLista_documenti& doc_in, TLista_documenti& doc_o
|
||||
}
|
||||
}
|
||||
if (indoc.is_evaso())
|
||||
{
|
||||
indoc.stato(stato_finale_doc_iniziale()[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if (ok) // Ho elaborato almeno una riga?
|
||||
{
|
||||
post_process_input(doc_in);
|
||||
post_process(doc_out, doc_in);
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
127
ve/velib06.cpp
127
ve/velib06.cpp
@ -2927,6 +2927,19 @@ bool TElabora_mask::on_field_event(TOperable_field& o, TField_event e, long joll
|
||||
if (e == fe_modify)
|
||||
update_ndoc_filter();
|
||||
break;
|
||||
case F_UMQTA:
|
||||
if (e == fe_init || e == fe_modify)
|
||||
{
|
||||
int dec = 5;
|
||||
if (!o.empty())
|
||||
{
|
||||
const TRectype& um = cache().get("%UMS", o.get());
|
||||
if (!um.empty() && um.get_bool("B0")) // Ha dei decimali specificati?
|
||||
dec = um.get_int("I0");
|
||||
}
|
||||
((TReal_field&)field(F_QTA)).set_decimals(dec);
|
||||
}
|
||||
break;
|
||||
case F_TYPE:
|
||||
if (e == fe_init || e == fe_modify)
|
||||
{
|
||||
@ -2956,7 +2969,7 @@ bool TElabora_mask::on_field_event(TOperable_field& o, TField_event e, long joll
|
||||
const TString_array& handlers = _main->doc().tipo().handlers();
|
||||
const int items = handlers.items();
|
||||
|
||||
for (int i = 0; i < items; i ++ )
|
||||
for (int i = 0; i < items; i++)
|
||||
{
|
||||
TToken_string& riga = (TToken_string&) handlers[i];
|
||||
|
||||
@ -3128,10 +3141,10 @@ bool TElabora_mask::on_field_event(TOperable_field& o, TField_event e, long joll
|
||||
int TElabora_mask::update_list()
|
||||
{
|
||||
TString_array elabs;
|
||||
const TString16 tipo(_main->get(F_TIPODOC));
|
||||
const TString16 stato(_main->get(F_STATO));
|
||||
const TString16 tipo_elab(get(F_TIPODOC_ELAB));
|
||||
const TString16 stato_elab(get(F_STATODOC_ELAB));
|
||||
const TString4 tipo(_main->get(F_TIPODOC));
|
||||
const TString4 stato(_main->get(F_STATO));
|
||||
const TString4 tipo_elab(get(F_TIPODOC_ELAB));
|
||||
const TString4 stato_elab(get(F_STATODOC_ELAB));
|
||||
const bool from_elab = !get_bool(F_TYPE);
|
||||
int items = 0;
|
||||
|
||||
@ -3146,7 +3159,7 @@ int TElabora_mask::update_list()
|
||||
items = _elab.select(elabs, tipo_elab, stato_elab, tipo, stato);
|
||||
}
|
||||
|
||||
TList_field & f = (TList_field &) field(F_ELAB);
|
||||
TList_field & f = lfield(F_ELAB);
|
||||
TToken_string codes;
|
||||
TToken_string descrs;
|
||||
for (int i = 0; i < items; i++)
|
||||
@ -3301,6 +3314,13 @@ bool TElabora_mask::elabora()
|
||||
update_mask = true;
|
||||
}
|
||||
in.rewrite();
|
||||
|
||||
// Aggiorna eventuale residuo da consegnare
|
||||
if (e->tipo() == _consegna_ordini)
|
||||
{
|
||||
TParametri_elaborazione& p = e->params();
|
||||
set(F_QTA, p.get("QUANTITA"));
|
||||
}
|
||||
}
|
||||
const TString8 num_in = e->codice_numerazione_iniziale();
|
||||
set(F_CODNUM_ELAB, num_in);
|
||||
@ -3330,7 +3350,7 @@ TElaborazione * TElabora_mask::curr_elab()
|
||||
|
||||
void TElabora_mask::add_valuta_filter(TString& filter) const
|
||||
{
|
||||
TString16 valuta = get(F_CODVAL_ELAB);
|
||||
TString4 valuta = get(F_CODVAL_ELAB);
|
||||
if (::is_firm_value(valuta))
|
||||
{
|
||||
filter << "((CODVAL==\"" << valuta << "\")";
|
||||
@ -3394,7 +3414,7 @@ void TElabora_mask::update_ndoc_filter(bool is_tipo_elaborazione)
|
||||
//field(F_STATODOC_ELAB).check(); // sostituito da 0x2
|
||||
|
||||
// Azzero anno di elaaborazione quando ho a che fare con degli ordini
|
||||
const TTipo_documento& tipodocin = cached_tipodoc(tipo_in);
|
||||
const TTipo_documento& tipodocin = cached_tipodoc(tipo_in);
|
||||
if (tipodocin.is_ordine())
|
||||
reset(F_ANNO_ELAB);
|
||||
}
|
||||
@ -3435,18 +3455,18 @@ void TElabora_mask::update_ndoc_filter(bool is_tipo_elaborazione)
|
||||
}
|
||||
else
|
||||
{
|
||||
bool almost_one = FALSE;
|
||||
bool almost_one = false;
|
||||
|
||||
for (int i = 0; i < TElaborazione::_max_tipi_doc_elab; i++)
|
||||
{
|
||||
const TString16 tipo_in(e->tipo_iniziale(i));
|
||||
if (tipo_in.not_empty())
|
||||
const TString4 tipo_in(e->tipo_iniziale(i));
|
||||
if (tipo_in.full())
|
||||
{
|
||||
if (almost_one)
|
||||
filter << "||";
|
||||
else
|
||||
filter << "&&(";
|
||||
almost_one = TRUE;
|
||||
almost_one = true;
|
||||
filter << "((TIPODOC==\"" << tipo_in << "\")";
|
||||
|
||||
const char stato_in[2] = { e->stato_iniziale(i), '\0' };
|
||||
@ -3599,55 +3619,54 @@ bool TDocumento_mask::elabora_handler( TMask_field& f, KEY key )
|
||||
{
|
||||
TDocumento_mask& m = (TDocumento_mask&)f.mask();
|
||||
m.update_progs();
|
||||
if (m.check_fields()) // Check values
|
||||
if (!m.check_fields()) // Check values
|
||||
return false;
|
||||
|
||||
TElabora_mask* selection = new TElabora_mask(m); // No woman no stack
|
||||
bool do_checks = false;
|
||||
const char stato_iniziale = m.doc().stato();
|
||||
m.update_father_rows();
|
||||
while (selection->run() == K_ENTER) //NON riportare modifiche dalla 3.1!! Già sistemato
|
||||
{
|
||||
TElabora_mask* selection = new TElabora_mask(m); // No woman no stack
|
||||
bool do_checks = false;
|
||||
const char stato_iniziale = m.doc().stato();
|
||||
|
||||
m.update_father_rows();
|
||||
while (selection->run() == K_ENTER) //NON riportare modifiche dalla 3.1!! Già sistemato
|
||||
{
|
||||
m.mask2doc();
|
||||
const bool processed = selection->elabora();
|
||||
do_checks |= processed;
|
||||
m.mask2doc();
|
||||
const bool processed = selection->elabora();
|
||||
do_checks |= processed;
|
||||
|
||||
if (m.doc().stato() != stato_iniziale)
|
||||
break;
|
||||
if (m.doc().stato() != stato_iniziale)
|
||||
break;
|
||||
|
||||
if (processed)
|
||||
{
|
||||
m.doc2mask(false);
|
||||
TSheet_field& ss = m.sfield(F_SHEET);
|
||||
for (int i = 0; i < ss.items(); i++)
|
||||
{
|
||||
m.ss_notify(ss,i,K_TAB);
|
||||
m.ss_notify(ss,i,K_SPACE);
|
||||
m.ss_notify(ss,i,K_ENTER);
|
||||
}
|
||||
}
|
||||
|
||||
if (!m.get_bool(F_TYPE)) // non aggiunge al documento attuale
|
||||
break;
|
||||
}
|
||||
if (do_checks) //NON riportare modifiche dalla 3.1!! Già sistemato
|
||||
{
|
||||
m.doc2mask(false);
|
||||
// Provoca decodifiche necessarie
|
||||
const int tutti = m.fields();
|
||||
int i;
|
||||
for (i = 0; i < tutti; i++)
|
||||
if (processed)
|
||||
{
|
||||
m.doc2mask(false);
|
||||
TSheet_field& ss = m.sfield(F_SHEET);
|
||||
for (int i = 0; i < ss.items(); i++)
|
||||
{
|
||||
TMask_field& f = m.fld(i);
|
||||
if (f.dlg() <= BASE_PIEDE)
|
||||
f.check(STARTING_CHECK);
|
||||
m.ss_notify(ss,i,K_TAB);
|
||||
m.ss_notify(ss,i,K_SPACE);
|
||||
m.ss_notify(ss,i,K_ENTER);
|
||||
}
|
||||
for (i = tutti-1; i >= 0; i--)
|
||||
m.fld(i).set_dirty(FALSE);
|
||||
}
|
||||
m.update_father_rows(false);
|
||||
delete selection;
|
||||
|
||||
if (!selection->get_bool(F_TYPE)) // non aggiunge al documento attuale
|
||||
break;
|
||||
}
|
||||
if (do_checks) //NON riportare modifiche dalla 3.1!! Già sistemato
|
||||
{
|
||||
m.doc2mask(false);
|
||||
// Provoca decodifiche necessarie
|
||||
const int tutti = m.fields();
|
||||
int i;
|
||||
for (i = 0; i < tutti; i++)
|
||||
{
|
||||
TMask_field& f = m.fld(i);
|
||||
if (f.dlg() <= BASE_PIEDE)
|
||||
f.check(STARTING_CHECK);
|
||||
}
|
||||
for (i = tutti-1; i >= 0; i--)
|
||||
m.fld(i).set_dirty(FALSE);
|
||||
}
|
||||
m.update_father_rows(false);
|
||||
delete selection;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user