Patch level : 10.0 577
Files correlati : lv2.exe Ricompilazione Demo : [ ] Commento : Fatturazione 02 e velocizzazione calcolo consegnato mensile git-svn-id: svn://10.65.10.50/trunk@19909 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
92b49ffe09
commit
70c1ab9ead
@ -1,4 +1,5 @@
|
||||
#include <confapp.h>
|
||||
#include <modaut.h>
|
||||
|
||||
#include "lvlib.h"
|
||||
#include "../ci/cilib.h"
|
||||
@ -96,7 +97,13 @@ public:
|
||||
TMask* TConf_Lavanderie::create_mask(const TFilename & f)
|
||||
{
|
||||
if (_mask == NULL)
|
||||
{
|
||||
_mask = new TConf_lavanderie_mask(f);
|
||||
const bool l2 = has_module(L2AUT);
|
||||
|
||||
if (!l2)
|
||||
_mask->hide(-1);
|
||||
}
|
||||
return _mask;
|
||||
}
|
||||
|
||||
|
@ -83,6 +83,8 @@
|
||||
#define F_PATH_PUL 264
|
||||
#define F_FILE_PUL 265
|
||||
|
||||
#define F_BACKUP 300
|
||||
|
||||
#define S_CODNUM_RIT 101
|
||||
#define S_TIPODOC_RIT 102
|
||||
#define S_DESTIPODOC_RIT 103
|
||||
|
@ -763,6 +763,19 @@ BEGIN
|
||||
FIELD Gestsaca
|
||||
END
|
||||
|
||||
TEXT -1
|
||||
BEGIN
|
||||
PROMPT 40 20 "@bOpzioni backup"
|
||||
GROUP 1
|
||||
END
|
||||
|
||||
STRING F_BACKUP 128 25
|
||||
BEGIN
|
||||
PROMPT 41 21 "Percorso di backup "
|
||||
FIELD Backup
|
||||
GROUP 1
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
PAGE "File da elaborare" 0 0 0 0
|
||||
|
@ -59,7 +59,7 @@ class TContratti_msk: public TAutomask
|
||||
int _riga;
|
||||
|
||||
protected:
|
||||
bool on_art_select(/*TField_event e*/);
|
||||
bool on_art_select(TField_event e);
|
||||
virtual void on_idle();
|
||||
virtual bool on_field_event(TOperable_field& o,TField_event e,long jolly);
|
||||
|
||||
@ -71,7 +71,7 @@ public:
|
||||
|
||||
//ON_ART_SELECT: metodo che riempie i campi delle dotazioni e del consegnato sullo sheet e sulla maschera
|
||||
//e riporta i dati dello sheet nel dettaglio sulla maschera (sotto lo sheet)
|
||||
bool TContratti_msk::on_art_select(/*TField_event e*/)
|
||||
bool TContratti_msk::on_art_select(TField_event e)
|
||||
{
|
||||
//dallo sheet identifico la riga selezionata e estraggo i dati di interesse
|
||||
TSheet_field& ss = sfield(F_RIGHE);
|
||||
@ -139,27 +139,23 @@ bool TContratti_msk::on_art_select(/*TField_event e*/)
|
||||
|
||||
//ciclo i dati di interesse della riga selezionata nel dettaglio
|
||||
//sulla maschera principale
|
||||
|
||||
//I COMMENTI SULLA ON_ART_SELECT() servono per evitare una modifica da fare in futuro ma già pronta
|
||||
//if (e != fe_init)
|
||||
//{
|
||||
for (short id = F_CODART; id <= F_CODART + 36; id++)
|
||||
{
|
||||
const int pos = id2pos(id);
|
||||
if (pos > 0)
|
||||
{
|
||||
TMask_field& f = fld(pos);
|
||||
const TString& oldval = f.get();
|
||||
const char* newval = row.get(ss.cid2index(id - 400));
|
||||
if (oldval != newval)
|
||||
{
|
||||
f.set(newval);
|
||||
if (f.is_kind_of(CLASS_LIST_FIELD))
|
||||
f.on_hit();
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
if (e != fe_init)
|
||||
for (short id = F_CODART; id <= F_CODART + 36; id++)
|
||||
{
|
||||
const int pos = id2pos(id);
|
||||
if (pos > 0)
|
||||
{
|
||||
TMask_field& f = fld(pos);
|
||||
const TString& oldval = f.get();
|
||||
const char* newval = row.get(ss.cid2index(id - 400));
|
||||
if (oldval != newval)
|
||||
{
|
||||
f.set(newval);
|
||||
if (f.is_kind_of(CLASS_LIST_FIELD))
|
||||
f.on_hit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ppconf <= 0)
|
||||
{
|
||||
@ -607,11 +603,11 @@ bool TContratti_msk::on_field_event(TOperable_field& o,TField_event e,long jolly
|
||||
//se all'articolo è associata un'unità di misura, la propongo
|
||||
//in automatico e richiamo il metodo ON_ART_SELECT(); altrimenti lo richiamo
|
||||
//solo se è arrivato un fe_init al campo
|
||||
on_art_select(/*e*/);
|
||||
on_art_select(e);
|
||||
}
|
||||
else
|
||||
if (e == fe_init)
|
||||
on_art_select(/*e*/);
|
||||
on_art_select(e);
|
||||
}
|
||||
break;
|
||||
case S_CONG:
|
||||
|
466
lv/lv2500.cpp
466
lv/lv2500.cpp
@ -1,5 +1,6 @@
|
||||
#include <progind.h>
|
||||
#include <config.h>
|
||||
#include <utility.h>
|
||||
|
||||
#include "lvlib.h"
|
||||
#include "lv2500a.h"
|
||||
@ -9,9 +10,82 @@
|
||||
#include "lvrcondv.h"
|
||||
#include "rdoc.h"
|
||||
|
||||
#include "../db/dblib.h"
|
||||
#include "../mg/mglib.h"
|
||||
#include "../ve/ve6200.h"
|
||||
#include "../ve/ve6200a.h"
|
||||
|
||||
class TFatturazione_lavanderie;
|
||||
|
||||
////////////////////////////////////////
|
||||
//// classe TFatturazione_msk ////
|
||||
////////////////////////////////////////
|
||||
|
||||
class TFatturazione_msk: public TAutomask
|
||||
{
|
||||
protected:
|
||||
virtual bool on_field_event(TOperable_field& o,TField_event e,long jolly){return true;}
|
||||
public:
|
||||
TFatturazione_msk();
|
||||
};
|
||||
|
||||
////////////////////////////////////////
|
||||
//// TFatturazione_lavanderie app ////
|
||||
////////////////////////////////////////
|
||||
|
||||
//Classe TFatturazione_lavanderie_app
|
||||
class TFatturazione_lav_app: public TSkeleton_application
|
||||
{
|
||||
TFatturazione_msk* _msk;
|
||||
|
||||
protected:
|
||||
virtual void main_loop();
|
||||
|
||||
void genera_bolle_nolo(TAssoc_array& cliela, TFatturazione_lavanderie& elab, int& numdocgen);
|
||||
bool controlli_preliminari();
|
||||
};
|
||||
|
||||
TFatturazione_lav_app & app() { return (TFatturazione_lav_app &) main_app();}
|
||||
|
||||
////////////////////////////////////////
|
||||
//// TCalc_02_data ////
|
||||
////////////////////////////////////////
|
||||
|
||||
//Classe TCalc_02_data
|
||||
class TCalc_02_data : public TObject
|
||||
{
|
||||
TString _key;
|
||||
TGeneric_distrib _distr;
|
||||
TGeneric_distrib _distr_rit;
|
||||
TAssoc_array _bol_rows;
|
||||
|
||||
virtual TObject* dup() const;
|
||||
void copy(const TCalc_02_data & d);
|
||||
|
||||
public:
|
||||
TCalc_02_data & operator = (const TCalc_02_data & d) { copy(d); return *this; }
|
||||
const TString & key() const { return _key; }
|
||||
TGeneric_distrib & distr() { return _distr; }
|
||||
TGeneric_distrib & distr_rit() { return _distr_rit; }
|
||||
TAssoc_array & bol_rows() { return _bol_rows; }
|
||||
|
||||
TCalc_02_data(const char * key) : _key(key) {}
|
||||
TCalc_02_data(const TCalc_02_data & d) {copy(d);}
|
||||
};
|
||||
|
||||
void TCalc_02_data::copy(const TCalc_02_data & d)
|
||||
{
|
||||
_key = d._key;
|
||||
_distr = d._distr;
|
||||
_bol_rows = d._bol_rows;
|
||||
}
|
||||
|
||||
TObject* TCalc_02_data::dup() const
|
||||
{
|
||||
TCalc_02_data* o = new TCalc_02_data(*this);
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////
|
||||
//// TFatturazione_lavanderie ////
|
||||
@ -22,13 +96,14 @@ class TFatturazione_lavanderie:public TFatturazione_bolle
|
||||
{
|
||||
TDate _data_elab;
|
||||
TToken_string _campi_raggruppamento;
|
||||
TAssoc_array _output_rows_02;
|
||||
|
||||
protected:
|
||||
virtual void add_rows(TRiga_documento & rout, TRiga_documento & rin);
|
||||
virtual void create_row(TDocumento& doc_out, const TRiga_documento & rin);
|
||||
virtual void pre_process_input(TLista_documenti& doc_in) {}
|
||||
virtual void post_process_input(TLista_documenti& doc_out) {}
|
||||
virtual void post_process_output(TLista_documenti& doc_out);
|
||||
virtual void pre_process_input(TLista_documenti& doc_in);
|
||||
virtual void post_process_input(TLista_documenti& doc_in) {}
|
||||
virtual void post_process(TLista_documenti& doc_out, TLista_documenti& doc_in);
|
||||
virtual bool da_raggruppare(const TRiga_documento & rin);
|
||||
virtual bool doc_raggruppabili(const TDocumento& doc_in, const TDocumento& doc_out, TToken_string& campi) const ;
|
||||
virtual bool doc_raggruppabile(const TDocumento & doc) const { return true; }
|
||||
@ -36,6 +111,7 @@ protected:
|
||||
virtual bool gestione_riferimenti() const { return true; }
|
||||
virtual bool riferimenti_in_testa() const { return true; }
|
||||
virtual TRiga_documento& find_or_create_row(TDocumento& doc_out, const TRiga_documento & rin,const char lavtype);
|
||||
void aggiorna_fattura(TDocumento & doc, int codcont);
|
||||
|
||||
public:
|
||||
virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||
@ -113,10 +189,94 @@ bool TFatturazione_lavanderie::da_raggruppare(const TRiga_documento & rin)
|
||||
return false;
|
||||
}
|
||||
|
||||
//POST_PROCESS_OUTPUT: metodo che elabora i documenti di output dopo che si sono svolte
|
||||
void TFatturazione_lavanderie::pre_process_input(TLista_documenti& doc_in)
|
||||
{
|
||||
for (int id = 0; id < doc_in.items(); id++)
|
||||
{
|
||||
TDocumento& doc = doc_in[id];
|
||||
const int rows = doc.physical_rows();
|
||||
|
||||
for (int i = 1; i <= rows; i++)
|
||||
{
|
||||
TRiga_documento & row = doc[i];
|
||||
TString str_real = row.get(RDOC_QTAREALE);
|
||||
|
||||
if (str_real.full())
|
||||
{
|
||||
real qta_real(decode(str_real));
|
||||
|
||||
row.put(RDOC_QTA, qta_real);
|
||||
row.zero(RDOC_QTAREALE);
|
||||
}
|
||||
str_real = row.get(RDOC_QTARITREALE);
|
||||
|
||||
if (str_real.full())
|
||||
{
|
||||
real qta_real(decode(str_real));
|
||||
|
||||
row.put(RDOC_QTAGG1, qta_real);
|
||||
row.zero(RDOC_QTARITREALE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TFatturazione_lavanderie::aggiorna_fattura(TDocumento & doc, int codcont)
|
||||
{
|
||||
const int nrows = doc.physical_rows();
|
||||
const long codcf = doc.get_long(DOC_CODCF);
|
||||
|
||||
TString str;
|
||||
str << "USE LVRCONDV\n"
|
||||
<< "FROM CODCF=" << codcf << " CODCONT=" << codcont << "\n"
|
||||
<< "TO CODCF=" << codcf << " CODCONT=" << codcont;
|
||||
|
||||
TISAM_recordset rcont(str);
|
||||
|
||||
for(bool ok = rcont.move_first(); ok; ok = rcont.move_next())
|
||||
{
|
||||
TRectype& riga = rcont.cursor()->curr();
|
||||
int forfait = riga.get_int(LVRCONDV_TIPOFORF);
|
||||
const TString & codart = riga.get(LVRCONDV_CODART);
|
||||
bool to_add = forfait != 0;
|
||||
|
||||
|
||||
for (int i = 1; to_add && i <= nrows ; i++)
|
||||
{
|
||||
TRiga_documento& rout = doc[i];
|
||||
const TString80 codart_contr = rout.get(RDOC_CODART);
|
||||
|
||||
if (codart == codart_contr)
|
||||
to_add = false;
|
||||
}
|
||||
if (to_add)
|
||||
{
|
||||
TRiga_documento& rdoc = doc.new_row("21");
|
||||
|
||||
rdoc.put(RDOC_CODART, codart);
|
||||
rdoc.put(RDOC_CODARTMAG, riga.get(LVRCONDV_CODART));
|
||||
rdoc.put(RDOC_DESCR, cached_article(codart).get(ANAMAG_DESCR));
|
||||
rdoc.put(RDOC_CHECKED, true);
|
||||
rdoc.put(RDOC_QTA, 1);
|
||||
rdoc.put(RDOC_QTAGG1, 1);
|
||||
rdoc.put(RDOC_UMQTA, riga.get(LVRCONDV_UM));
|
||||
|
||||
TToken_string key;
|
||||
key.add('C');
|
||||
key.add(codcf);
|
||||
TString8 codiva = cache().get(LF_CFVEN, key, CFV_ASSFIS);
|
||||
if (codiva.blank())
|
||||
codiva = cache().get(LF_ANAMAG, riga.get(LVRCONDV_CODART), ANAMAG_CODIVA);
|
||||
|
||||
rdoc.put(RDOC_CODIVA, codiva);
|
||||
rdoc.put(RDOC_CODAGG1, ini_get_string(CONFIG_DITTA, "lv", "CAUSLAV"));
|
||||
}
|
||||
}
|
||||
}
|
||||
//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
|
||||
void TFatturazione_lavanderie::post_process_output(TLista_documenti& doc_out)
|
||||
void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_documenti& doc_in)
|
||||
{
|
||||
//scorro tutti i documenti di output generati precedentemente
|
||||
for (int id = 0; id < doc_out.items(); id++)
|
||||
@ -125,6 +285,9 @@ void TFatturazione_lavanderie::post_process_output(TLista_documenti& doc_out)
|
||||
//il contratto del cliente in questione
|
||||
TDocumento& doc = doc_out[id];
|
||||
const long clifo = doc.get_long(DOC_CODCF);
|
||||
|
||||
if (clifo >550l && clifo <580l)
|
||||
int i = 1;
|
||||
const int indsped = doc.get_int(DOC_CODINDSP);
|
||||
TLaundry_contract contr(clifo,indsped,_data_elab);
|
||||
//flag per il calcolo sul valore convenzionale e sul fisso per dotazione iniziale
|
||||
@ -170,6 +333,8 @@ void TFatturazione_lavanderie::post_process_output(TLista_documenti& doc_out)
|
||||
|
||||
const bool ragart = contr.get_bool(LVCONDV_RAGART); // leggo il flag di testata raggruppa su unico articolo
|
||||
const int tipocan = contr.get_int(LVCONDV_TIPOCAN); // leggo il tipo canone
|
||||
const real redditivita = contr.get_real(LVCONDV_REDDI);
|
||||
|
||||
|
||||
if (ragart)
|
||||
{
|
||||
@ -183,7 +348,7 @@ void TFatturazione_lavanderie::post_process_output(TLista_documenti& doc_out)
|
||||
totmerc += riga.importo(true,false);
|
||||
}
|
||||
|
||||
const int rigamerce = doc[1].is_descrizione()?2:1;
|
||||
const int rigamerce = doc[1].is_descrizione() ? 2 : 1;
|
||||
|
||||
for (int i=rigamerce; i <= rows; i++)
|
||||
doc.destroy_row(i);
|
||||
@ -224,7 +389,7 @@ void TFatturazione_lavanderie::post_process_output(TLista_documenti& doc_out)
|
||||
break;
|
||||
}
|
||||
else // se non è selezionato raggrupa su unico articolo controllo il tipo canone se è impostato a importo fisso
|
||||
if (tipocan==1) //se è selezionato tipo canone = importo fisso
|
||||
if (tipocan == 1) //se è selezionato tipo canone = importo fisso
|
||||
{
|
||||
// estraggo il canone fisso e l'articolo in configurazione
|
||||
const real canfis=contr.get_real(LVCONDV_IMPFIX);
|
||||
@ -253,7 +418,6 @@ void TFatturazione_lavanderie::post_process_output(TLista_documenti& doc_out)
|
||||
}
|
||||
|
||||
const int rigamerce = doc[1].is_descrizione()?2:1;
|
||||
|
||||
TRiga_documento& fixrow=doc.insert_row(rigamerce, "01"); // creo una nuova riga in cima al documento e imposto i valori appena estratti
|
||||
|
||||
fixrow.put(RDOC_QTA,UNO);
|
||||
@ -294,8 +458,10 @@ void TFatturazione_lavanderie::post_process_output(TLista_documenti& doc_out)
|
||||
}
|
||||
else // se il tipo canone è impostato a nessuno o % sul valore convenzionale per cliente vado in ambedue i casi ad eseguire il ciclo che analizza i tipi forfait
|
||||
{
|
||||
if (!contr.get_bool(LVCONDV_FORFNOCONS))
|
||||
aggiorna_fattura(doc, contr.get_int(LVCONDV_CODCONT));
|
||||
//per ogni documento, scorro tutte le sue righe
|
||||
for (int i = 1; i <= doc.physical_rows(); i++)
|
||||
for (int i = 1; i <= doc.physical_rows() ; i++)
|
||||
{
|
||||
TRiga_documento& rout = doc[i];
|
||||
|
||||
@ -579,8 +745,195 @@ void TFatturazione_lavanderie::post_process_output(TLista_documenti& doc_out)
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (redditivita > ZERO && lv_is_02_active() && !ragart && tipocan != 1)
|
||||
{
|
||||
const real totdoc = doc.totale_doc();
|
||||
const real provvigione1 = doc.provvigione();
|
||||
const real provvigione2 = doc.provvigione(false);
|
||||
|
||||
doc.put(RDOC_TOTREALE, encode(totdoc.string()));
|
||||
doc.put(RDOC_PROVV1REALE, encode(provvigione1.string()));
|
||||
doc.put(RDOC_PROVV2REALE, encode(provvigione2.string()));
|
||||
|
||||
for(int j = doc.physical_rows(); j > 0; j--)
|
||||
{
|
||||
TRiga_documento& rdoc = doc[j];
|
||||
const TString80 codart = rdoc.get(RDOC_CODARTMAG);
|
||||
const TRectype& rcont = contr.row(codart);
|
||||
const int tipoforf = rcont.get_int(LVRCONDV_TIPOFORF);
|
||||
long ppconf = cached_article(codart).get_long(ANAMAG_PPCONF);
|
||||
const real real_qta = rdoc.get(RDOC_QTA);
|
||||
|
||||
if (rcont.get_int(LVRCONDV_CALCCONS) != 1 || ppconf == 0)
|
||||
ppconf = 1;
|
||||
|
||||
const char lvtype = rdoc.get_char("LVTYPE");
|
||||
bool row_has_02 = (tipoforf == 0) && (real_qta / ppconf > UNO) && (lvtype == 'C');
|
||||
|
||||
// 0 forfait = NESSUN FORFAIT SI
|
||||
// 1 forfait = A VALORE FISSO NO
|
||||
// 2 forfait = NOLO NO
|
||||
// 3 forfait = CICLAGGIO NO
|
||||
// 4 forfait = % SUL VALORE CONVENZIONALE NO
|
||||
// 5 forfait = FISSO SU DOTAZIONE INIZIALE NO
|
||||
|
||||
if (row_has_02)
|
||||
{
|
||||
const TString key = format("%04d%04d", doc.get_int("FATID"), rdoc.get_int(RDOC_IDRIGA));
|
||||
real new_qta = real_qta;
|
||||
TCalc_02_data * data = (TCalc_02_data *) _output_rows_02.objptr(key);
|
||||
|
||||
rdoc.put(RDOC_QTAREALE, encode(real_qta.string()));
|
||||
|
||||
if (data != NULL)
|
||||
{
|
||||
new_qta /= ppconf;
|
||||
|
||||
real test = new_qta;
|
||||
|
||||
test.ceil();
|
||||
|
||||
if (test * ppconf != real_qta)
|
||||
{
|
||||
warning_box(FR("L'articolo %s per il cliente %ld ha una quantità %s\nnon coincidente coi pacchi. Controllare le bolle"),
|
||||
(const char *)codart, doc.get_long(DOC_CODCF), real_qta.string());
|
||||
ppconf = 1;
|
||||
}
|
||||
new_qta *= (CENTO - redditivita) / CENTO;
|
||||
new_qta.round();
|
||||
data->distr() = new_qta;
|
||||
new_qta *= ppconf;
|
||||
rdoc.put(RDOC_QTA, new_qta);
|
||||
|
||||
real new_qta_rit = rdoc.get_real("TOTRIT");
|
||||
new_qta_rit *= (CENTO - redditivita) / CENTO;
|
||||
new_qta_rit.round();
|
||||
data->distr_rit() = new_qta_rit;
|
||||
|
||||
TAssoc_array & bol_rows = data->bol_rows();
|
||||
|
||||
FOR_EACH_ASSOC_OBJECT(bol_rows, obj, wkey, item)
|
||||
{
|
||||
TToken_string bolkey(wkey);
|
||||
const long ndoc = bolkey.get_long(3);
|
||||
const long id = bolkey.get_long(4);
|
||||
|
||||
for (int i = 0; i < doc_in.items(); i++)
|
||||
{
|
||||
TDocumento& doc = doc_in[i];
|
||||
|
||||
if (doc.get_long(DOC_NDOC) == ndoc)
|
||||
{
|
||||
TRiga_documento * bolrow = (TRiga_documento *) doc.get_row_id(id);
|
||||
|
||||
if (bolrow != NULL)
|
||||
{
|
||||
const TString8 causale = bolrow->get(RDOC_CODAGG1);
|
||||
const TCausale_lavanderie & cau = cached_causale_lavanderie(causale);
|
||||
if (cau.is_rotto())
|
||||
break;
|
||||
bool fatturo_ritirato = cau.is_ritiro();
|
||||
bool fatturo_consegnato = cau.is_consegna();
|
||||
|
||||
if (fatturo_ritirato)
|
||||
{
|
||||
const TCausale_magazzino& rit = cau.causale_ritiro();
|
||||
|
||||
fatturo_ritirato = rit.sgn(s_consmese) != 0;
|
||||
}
|
||||
if (fatturo_consegnato)
|
||||
{
|
||||
const TCausale_magazzino& con = cau.causale_consegna();
|
||||
|
||||
fatturo_consegnato = con.sgn(s_consmese) != 0;
|
||||
}
|
||||
|
||||
TString str_real = bolrow->get(RDOC_QTA);
|
||||
real qta = real(str_real) / ppconf;
|
||||
|
||||
qta.round();
|
||||
if (str_real.full())
|
||||
bolrow->put(RDOC_QTAREALE, encode(str_real));
|
||||
str_real = bolrow->get(RDOC_QTAGG1);
|
||||
|
||||
real qtarit = real(str_real);
|
||||
|
||||
data->distr_rit().add(qtarit);
|
||||
if (str_real.full())
|
||||
bolrow->put(RDOC_QTARITREALE, encode(str_real));
|
||||
if (fatturo_ritirato && !fatturo_consegnato) // ! fatturo il ritirato o fatturo il consegnato
|
||||
{
|
||||
qtarit = real(str_real) / ppconf;
|
||||
qtarit.round();
|
||||
data->distr().add(qtarit);
|
||||
}
|
||||
else
|
||||
data->distr().add(qta);
|
||||
}
|
||||
else
|
||||
message_box("Riga_bolla smarrita %d - %s - %ld - id = %ld", bolkey.get_int(1), bolkey.get(0), bolkey.get(3), bolkey.get(4));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FOR_EACH_ASSOC_OBJECT(bol_rows, obj1, wkey1, item1)
|
||||
{
|
||||
TToken_string bolkey(wkey);
|
||||
const long ndoc = bolkey.get_long(3);
|
||||
const long id = bolkey.get_long(4);
|
||||
|
||||
for (int i = 0; i < doc_in.items(); i++)
|
||||
{
|
||||
TDocumento& doc = doc_in[i];
|
||||
|
||||
if (doc.get_long(DOC_NDOC) == ndoc)
|
||||
{
|
||||
TRiga_documento * bolrow = (TRiga_documento *) doc.get_row_id(id);
|
||||
|
||||
if (bolrow != NULL)
|
||||
{
|
||||
const TString8 causale = bolrow->get(RDOC_CODAGG1);
|
||||
const TCausale_lavanderie & cau = cached_causale_lavanderie(causale);
|
||||
if (cau.is_rotto())
|
||||
break;
|
||||
bool fatturo_ritirato = cau.is_ritiro();
|
||||
bool fatturo_consegnato = cau.is_consegna();
|
||||
|
||||
if (fatturo_ritirato)
|
||||
{
|
||||
const TCausale_magazzino& rit = cau.causale_ritiro();
|
||||
|
||||
fatturo_ritirato = rit.sgn(s_consmese) != 0;
|
||||
}
|
||||
if (fatturo_consegnato)
|
||||
{
|
||||
const TCausale_magazzino& con = cau.causale_consegna();
|
||||
|
||||
fatturo_consegnato = con.sgn(s_consmese) != 0;
|
||||
}
|
||||
|
||||
const real qta = data->distr().get() * ppconf;
|
||||
const real qtarit = data->distr_rit().get();
|
||||
|
||||
bolrow->put(RDOC_QTAGG1, qtarit);
|
||||
if ((!fatturo_ritirato) || (fatturo_consegnato)) // ! fatturo il ritirato o fatturo il consegnato
|
||||
bolrow->put(RDOC_QTA, qta);
|
||||
else
|
||||
int c = 1; // placeholder
|
||||
}
|
||||
else
|
||||
message_box("Riga_bolla smarrita %d - %s - %ld - id = %ld", bolkey.get_int(1), bolkey.get(0), bolkey.get(3), bolkey.get(4));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int h = doc.physical_rows(); h > 0; h--)
|
||||
{
|
||||
TRiga_documento& rdoc = doc[h];
|
||||
@ -588,6 +941,22 @@ void TFatturazione_lavanderie::post_process_output(TLista_documenti& doc_out)
|
||||
doc.destroy_row(h, true);
|
||||
}
|
||||
}
|
||||
for (int id = doc_out.items() - 1; id >= 0 ; id--)
|
||||
{
|
||||
TDocumento& doc = doc_out[id];
|
||||
const int rows = doc.physical_rows();
|
||||
bool to_delete = true;
|
||||
|
||||
for (int i = rows; to_delete && i > 0; i--)
|
||||
{
|
||||
const TRiga_documento& riga = doc[i];
|
||||
|
||||
if (!riga.is_descrizione())
|
||||
to_delete = (riga.imponibile() == ZERO && riga.get_real(RDOC_QTA) == ZERO);
|
||||
}
|
||||
if (to_delete)
|
||||
doc_out.destroy(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -665,6 +1034,20 @@ TRiga_documento& TFatturazione_lavanderie::find_or_create_row(TDocumento& doc_ou
|
||||
row.put("LVTYPE", lavtype);
|
||||
r = row.get_int(RDOC_NRIGA);
|
||||
}
|
||||
if (lv_is_02_active())
|
||||
{
|
||||
doc_out.set_row_ids();
|
||||
const TString key = format("%04d%04d", doc_out.get_int("FATID"), doc_out[r].get_int(RDOC_IDRIGA));
|
||||
TCalc_02_data * data = (TCalc_02_data *) _output_rows_02.objptr(key);
|
||||
|
||||
if (data == NULL)
|
||||
{
|
||||
data = new TCalc_02_data(key);
|
||||
_output_rows_02.add(key, data);
|
||||
}
|
||||
TString bolkey = rin.get_rdoc_key();
|
||||
data->bol_rows().add(bolkey, bolkey);
|
||||
}
|
||||
return doc_out[r];
|
||||
}
|
||||
|
||||
@ -673,7 +1056,7 @@ void TFatturazione_lavanderie::create_row(TDocumento& doc_out, const TRiga_docum
|
||||
{
|
||||
//leggo la causale della riga del documento di ingresso
|
||||
const TString8 causale = rin.get(RDOC_CODAGG1);
|
||||
const TCausale_lavanderie cau(causale);
|
||||
const TCausale_lavanderie & cau = cached_causale_lavanderie(causale);
|
||||
|
||||
//recupero i dati cliente dalla testata del documento e instanzio il contratto
|
||||
const long clifo = rin.doc().get_long(DOC_CODCF);
|
||||
@ -728,6 +1111,7 @@ void TFatturazione_lavanderie::create_row(TDocumento& doc_out, const TRiga_docum
|
||||
TRiga_documento& rr = find_or_create_row(doc_out, rin, 'C');
|
||||
rr.add(RDOC_QTA, sgnrit * qta1);
|
||||
rr.put(RDOC_PREZZO, prezzo);
|
||||
rr.add("TOTRIT", qta1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -771,6 +1155,7 @@ void TFatturazione_lavanderie::create_row(TDocumento& doc_out, const TRiga_docum
|
||||
TRiga_documento& rc = find_or_create_row(doc_out, rin, 'C');
|
||||
rc.add(RDOC_QTA, sgncons * qta);
|
||||
rc.put(RDOC_PREZZO, prezzo);
|
||||
rc.add("TOTRIT", qta1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -783,6 +1168,7 @@ bool TFatturazione_lavanderie::elabora(TLista_documenti& doc_in, TLista_document
|
||||
{
|
||||
_data_elab = data_elab;
|
||||
campi_raggruppamento_righe(_campi_raggruppamento);
|
||||
_output_rows_02.destroy();
|
||||
return TFatturazione_bolle::elabora(doc_in, doc_out, data_elab, interattivo);
|
||||
}
|
||||
|
||||
@ -790,16 +1176,6 @@ bool TFatturazione_lavanderie::elabora(TLista_documenti& doc_in, TLista_document
|
||||
//// TFatturazione_msk ////
|
||||
/////////////////////////////////
|
||||
|
||||
//classe TFatturazione_msk
|
||||
class TFatturazione_msk: public TAutomask
|
||||
{
|
||||
protected:
|
||||
virtual bool on_field_event(TOperable_field& o,TField_event e,long jolly){return true;}
|
||||
public:
|
||||
TFatturazione_msk();
|
||||
};
|
||||
|
||||
|
||||
TFatturazione_msk::TFatturazione_msk():TAutomask("lv2500a")
|
||||
{
|
||||
//imposto il periodo di fatturazione dal primo del mese precedente all'ultimo del mese precedente
|
||||
@ -828,6 +1204,8 @@ TFatturazione_msk::TFatturazione_msk():TAutomask("lv2500a")
|
||||
TString8 codela = ini_get_string(CONFIG_DITTA, "lv", tpela);
|
||||
set(F_COD_ELAB, codela);
|
||||
field(F_COD_ELAB).check();
|
||||
disable(F_COD_ELAB);
|
||||
disable(F_DESC_ELAB);
|
||||
}
|
||||
}
|
||||
|
||||
@ -835,17 +1213,6 @@ TFatturazione_msk::TFatturazione_msk():TAutomask("lv2500a")
|
||||
//// TFatturazione_lav_app ////
|
||||
/////////////////////////////////////
|
||||
|
||||
//classe TFatturazione_lav_app
|
||||
class TFatturazione_lav_app: public TSkeleton_application
|
||||
{
|
||||
TFatturazione_msk* _msk;
|
||||
protected:
|
||||
virtual void main_loop();
|
||||
|
||||
void genera_bolle_nolo(TAssoc_array& cliela, TFatturazione_lavanderie& elab, int& numdocgen);
|
||||
bool controlli_preliminari();
|
||||
};
|
||||
|
||||
//GENERA_BOLLE_NOLO: metodo che genera le fatture di solo nolo per quei clienti a cui non è stato consegnato niente
|
||||
void TFatturazione_lav_app::genera_bolle_nolo(TAssoc_array& cliela, TFatturazione_lavanderie& elab, int& numdocgen)
|
||||
{
|
||||
@ -885,7 +1252,7 @@ void TFatturazione_lav_app::genera_bolle_nolo(TAssoc_array& cliela, TFatturazion
|
||||
if (contr.get(LVCONDV_PERFAT).as_int() > _msk->get_int(F_PERFAT))
|
||||
continue;
|
||||
|
||||
//sacrto tutti quelli a cui ho già fatturato
|
||||
//scarto tutti quelli a cui ho già fatturato
|
||||
if(cliela.is_key(contr.get(LVCONDV_CODCF).as_string()))
|
||||
continue;
|
||||
|
||||
@ -952,7 +1319,7 @@ void TFatturazione_lav_app::genera_bolle_nolo(TAssoc_array& cliela, TFatturazion
|
||||
}
|
||||
|
||||
doc_out.destroy(-1);
|
||||
|
||||
|
||||
doc_in.destroy(-1);
|
||||
}
|
||||
}
|
||||
@ -1072,7 +1439,8 @@ void TFatturazione_lav_app::main_loop()
|
||||
//instanzio il recordset
|
||||
TISAM_recordset recset(query);
|
||||
TProgind pi(recset.items(), "Fatturazione", true, true);
|
||||
long last_clifo=0;
|
||||
long last_clifo = 0;
|
||||
int numdocgen = 0;
|
||||
|
||||
//TAssoc_array dei clienti per cui ho generato dei documenti
|
||||
TAssoc_array cliela;
|
||||
@ -1101,16 +1469,21 @@ void TFatturazione_lav_app::main_loop()
|
||||
//elaboro tutti i documenti, li salvo nei file di Campo e svuoto le TList_file
|
||||
elab.put("B15", 'X');
|
||||
elab.elabora(docsin, docsout, datafat);
|
||||
docsout.write();
|
||||
const int items = docsout.items();
|
||||
if (items > 0)
|
||||
{
|
||||
docsout.write();
|
||||
numdocgen += items;
|
||||
TString tmp;
|
||||
tmp << lastcli;
|
||||
cliela.add(tmp, tmp);
|
||||
}
|
||||
|
||||
docsout.destroy(-1);
|
||||
docsin.rewrite();
|
||||
docsin.destroy(-1);
|
||||
}
|
||||
lastcli = clifo;
|
||||
|
||||
TString tmp;
|
||||
tmp << lastcli;
|
||||
cliela.add(tmp, tmp);
|
||||
}
|
||||
|
||||
//preparo la chiave e recupero da CFVEN i dati di quel cliente
|
||||
@ -1155,7 +1528,6 @@ void TFatturazione_lav_app::main_loop()
|
||||
}
|
||||
}
|
||||
|
||||
int numdocgen;
|
||||
//se ho dei documenti in lista li elaboro e poi svuoto le TList_file
|
||||
if (docsin.items() != 0)
|
||||
{
|
||||
@ -1163,9 +1535,15 @@ void TFatturazione_lav_app::main_loop()
|
||||
elab.put("B15", true); //forzo la descrizione abbreviata
|
||||
elab.elabora(docsin, docsout, datafat);
|
||||
|
||||
numdocgen = docsout.items();
|
||||
|
||||
docsout.write();
|
||||
const int items = docsout.items();
|
||||
if (items > 0)
|
||||
{
|
||||
docsout.write();
|
||||
numdocgen += items;
|
||||
TString tmp;
|
||||
tmp << lastcli;
|
||||
cliela.add(tmp, tmp);
|
||||
}
|
||||
docsout.destroy(-1);
|
||||
docsin.rewrite();
|
||||
docsin.destroy(-1);
|
||||
|
@ -92,7 +92,6 @@ BEGIN
|
||||
OUTPUT F_COD_ELAB CODTAB
|
||||
OUTPUT F_DESC_ELAB S0
|
||||
CHECKTYPE REQUIRED
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING F_DESC_ELAB 50 30
|
||||
@ -105,7 +104,6 @@ BEGIN
|
||||
DISPLAY "Numerazione" S5
|
||||
COPY OUTPUT F_COD_ELAB
|
||||
CHECKTYPE REQUIRED
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING F_CODCATC 2
|
||||
|
@ -48,5 +48,6 @@
|
||||
#define LVCONDV_COMMENTI "COMMENTI"
|
||||
#define LVCONDV_CODNUM "CODNUM"
|
||||
#define LVCONDV_TPDOC "TPDOC"
|
||||
#define LVCONDV_REDDI "REDDI"
|
||||
|
||||
#endif
|
20
lv/lvlib.h
20
lv/lvlib.h
@ -21,10 +21,18 @@
|
||||
#include "../ve/velib.h"
|
||||
#endif
|
||||
|
||||
#define RDOC_QTAREALE "CIN01"
|
||||
#define RDOC_TOTREALE "CIN02"
|
||||
#define RDOC_PROVV1REALE "CIN03"
|
||||
#define RDOC_PROVV2REALE "CIN04"
|
||||
#define RDOC_QTARITREALE "CIN05"
|
||||
|
||||
void lv_set_creation_info(TRectype& rec);
|
||||
void lv_set_update_info(TRectype& rec);
|
||||
long lv_find_contract(const long codcf, const long indsped, const TDate& data);
|
||||
bool lv_is_holiday(const TDate& data);
|
||||
bool lv_is_02_active();
|
||||
const TFilename & lv_backup_path();
|
||||
|
||||
class TLaundry_contract : public TRectype
|
||||
{
|
||||
@ -41,6 +49,8 @@ public:
|
||||
|
||||
//metodi per la gestione delle righe
|
||||
const TRectype& row(const char* codart) const;
|
||||
const int rows() const ;
|
||||
const TRectype& row(int i) const;
|
||||
|
||||
int add_row(const char* codart);
|
||||
int update_row(const char* codart, const char* fieldname, const bool bol);
|
||||
@ -150,9 +160,6 @@ public:
|
||||
|
||||
class TCausale_lavanderie : public TRectype
|
||||
{
|
||||
TCausale_magazzino _rit;
|
||||
TCausale_magazzino _cons;
|
||||
|
||||
protected:
|
||||
//metodi che restituiscono le indicazioni sulle causali di magazzino associate
|
||||
const TString& caurit() const {return get("S1");}
|
||||
@ -168,13 +175,16 @@ public:
|
||||
const bool is_rotto() const {return get_bool("B3");}
|
||||
const bool movcong() const {return !get_bool("B4");}
|
||||
//metodi che restituiscono le causali di magazzino associate
|
||||
const TCausale_magazzino& causale_ritiro() const {return _rit;}
|
||||
const TCausale_magazzino& causale_consegna() const {return _cons;}
|
||||
const TCausale_magazzino& causale_ritiro() const {return cached_causale_magazzino(caurit());}
|
||||
const TCausale_magazzino& causale_consegna() const {return cached_causale_magazzino(caucon());}
|
||||
//costruttore
|
||||
TCausale_lavanderie(const char * codice);
|
||||
TCausale_lavanderie(const TRectype &r);
|
||||
|
||||
virtual ~TCausale_lavanderie() {}
|
||||
};
|
||||
|
||||
TCausale_lavanderie & cached_causale_lavanderie(const char * codcaus);
|
||||
|
||||
////////////////////////
|
||||
//// TDOC_KEY ////
|
||||
|
Loading…
x
Reference in New Issue
Block a user