Generazione automatica giri da contratti e correzioni varie

git-svn-id: svn://10.65.10.50/branches/R_10_00@22651 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2012-04-26 15:16:43 +00:00
parent b7afe8715d
commit 52faa371ab
13 changed files with 443 additions and 200 deletions

View File

@ -7,7 +7,6 @@ int main(int argc, char** argv)
const int r = (argc > 1) ? argv[1][1] - '0' : 0; const int r = (argc > 1) ? argv[1][1] - '0' : 0;
switch (r) switch (r)
{ {
case 0: lv2100(argc, argv); break; //generazione automatica del planning
case 1: lv2200(argc, argv); break; //manipolazione e stampa del planning case 1: lv2200(argc, argv); break; //manipolazione e stampa del planning
case 2: lv2300(argc, argv); break; //Stampa Giri Giornaliero/Settimanale case 2: lv2300(argc, argv); break; //Stampa Giri Giornaliero/Settimanale
case 3: lv2400(argc, argv); break; //generazione automatica bolle di consegna case 3: lv2400(argc, argv); break; //generazione automatica bolle di consegna
@ -16,6 +15,7 @@ int main(int argc, char** argv)
case 6: lv2700(argc, argv); break; //Riepilogo Bolle di Lavanderie case 6: lv2700(argc, argv); break; //Riepilogo Bolle di Lavanderie
case 7: lv2800(argc, argv); break; //Venduto Per Cliente nei 12 Mesi case 7: lv2800(argc, argv); break; //Venduto Per Cliente nei 12 Mesi
case 8: lv2900(argc, argv); break; //acquisizione del pulito case 8: lv2900(argc, argv); break; //acquisizione del pulito
case 9: lv2A00(argc, argv); break; //generazione automatica giri
default:lv2100(argc, argv); break; //generazione automatica del planning default:lv2100(argc, argv); break; //generazione automatica del planning
} }
return 0; return 0;

View File

@ -10,5 +10,6 @@ int lv2600(int argc, char* argv[]);
int lv2700(int argc, char* argv[]); //Riepilogo Bolle di Lavanderie -6 int lv2700(int argc, char* argv[]); //Riepilogo Bolle di Lavanderie -6
int lv2800(int argc, char* argv[]); //Venduto Per Cliente nei 12 Mesi -7 int lv2800(int argc, char* argv[]); //Venduto Per Cliente nei 12 Mesi -7
int lv2900(int argc, char* argv[]); int lv2900(int argc, char* argv[]);
int lv2A00(int argc, char* argv[]);
#endif // __LV2_H #endif // __LV2_H

View File

@ -221,7 +221,7 @@ BEGIN
FIELD FREQ FIELD FREQ
END END
LIST F_S_MODPASS 10 LIST F_S_MODPASS 1 10
BEGIN BEGIN
PROMPT 38 3 "Mod. pas. " PROMPT 38 3 "Mod. pas. "
ITEM "C|Consegna" ITEM "C|Consegna"

View File

@ -2283,7 +2283,7 @@ void TFatturazione_lav_app::main_loop()
if(!contr.ok()) if(!contr.ok())
{ {
TString msg; TString msg;
msg << "Non ci sono contratti in essere per il cliente " << clifo << " " << clirec.get(CLI_RICALT) << " in data " << datafat.string(); msg << TR("Non ci sono contratti in essere per il cliente ") << clifo << " " << clirec.get(CLI_RICALT) << TR(" in data ") << datafat.string();
_log->log(0, msg); _log->log(0, msg);
} }
const int contrper = contr.get_int(LVCONDV_PERFAT); const int contrper = contr.get_int(LVCONDV_PERFAT);

141
lv/lv2A00.cpp Normal file
View File

@ -0,0 +1,141 @@
#include <applicat.h>
#include <automask.h>
#include <progind.h>
#include <recarray.h>
#include <recset.h>
#include <relation.h>
#include <reputils.h>
#include <clifo.h>
#include "lvcondv.h"
#include "lvpasplan.h"
#include "lv2a00a.h"
///////////////////////////////////////////////////////////
// TAutogiro_msk
///////////////////////////////////////////////////////////
class TAutogiro_msk : public TAutomask
{
protected:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
public:
TAutogiro_msk();
};
bool TAutogiro_msk::on_field_event(TOperable_field& o, TField_event e, long jolly)
{
return true;
}
TAutogiro_msk::TAutogiro_msk() : TAutomask("lv2a00a")
{
// Propone itinerario senza autista
TEdit_field& g = efield(F_ITINERARIO);
TCursor& gcur = *g.browse()->cursor();
for (gcur = gcur.items()-1; gcur.ok(); --gcur)
{
if (gcur.curr().get("S1").empty())
{
g.browse()->do_output();
break;
}
}
// Propone prima frequenza disponibile (settimanale)
TEdit_field& f = efield(F_FREQUENZA);
TCursor& fcur = *f.browse()->cursor();
if (fcur.items())
{
fcur = 0L;
f.browse()->do_output();
}
// Propone consegna e ritiro
set(F_CONSEGNA, "E");
// Preimposta i feriali
for (int d = 0; d < 5; d++)
set(F_LUNEDI+d, "X");
}
///////////////////////////////////////////////////////////
// TAutogiro_app
///////////////////////////////////////////////////////////
class TAutogiro_app : public TSkeleton_application
{
protected:
virtual void main_loop();
};
void TAutogiro_app::main_loop()
{
TAutogiro_msk msk;
while (msk.run() == K_ENTER)
{
const TDate oggi(TODAY);
TLocalisamfile pasplan(LF_LVPASPLAN);
TString query;
query << "USE LVCONDV SELECT LVPASPLAN->NRIGA!=1"
<< "\nJOIN LVPASPLAN INTO CODCF==CODCF CODCONT==CODCONT NRIGA==1";
TISAM_recordset contratti(query);
TProgind pi(contratti.items(), title());
TLog_report log;
for (bool ok = contratti.move_first(); ok; ok = contratti.move_next())
{
if (!pi.addstatus(1))
break;
const TDate datasc = contratti.get(LVCONDV_DATASC).as_date();
if (datasc.ok() && datasc < oggi)
continue;
int nriga = 1;
for (int day = 0; day < 7; day++) if (msk.get_bool(F_LUNEDI+day))
{
if (nriga == 1)
{
TString msg;
TString8 cod; cod.format("%06ld", contratti.get(LVCONDV_CODCF).as_int());
msg << TR("Contratto ") << cod << '/' << contratti.get(LVCONDV_CODCONT);
cod.insert("C|");
msg << " - " << cache().get(LF_CLIFO, cod, CLI_RAGSOC);
log.log(0, msg);
}
pasplan.zero();
pasplan.put(LVPASPLAN_CODCF, contratti.get(LVCONDV_CODCF).as_int());
pasplan.put(LVPASPLAN_CODCONT, contratti.get(LVCONDV_CODCONT).as_int());
pasplan.put(LVPASPLAN_NRIGA, nriga++);
pasplan.put(LVPASPLAN_CODITI, msk.get(F_ITINERARIO));
pasplan.put(LVPASPLAN_FREQ, msk.get(F_FREQUENZA));
pasplan.put(LVPASPLAN_MODPASS, msk.get(F_CONSEGNA));
pasplan.put(LVPASPLAN_GGCONS, day+1);
const int err = pasplan.write();
if (err != NOERR)
{
cantwrite_box(pasplan.description());
log.log(2, TR("Errore di scrittura sul file LVPASPLAN"));
contratti.move_last();
break;
}
}
}
log.preview();
}
}
int lv2A00(int argc, char* argv[])
{
TAutogiro_app app;
app.run(argc, argv, TR("Generazione automatica giri"));
return 0;
}

10
lv/lv2a00a.h Normal file
View File

@ -0,0 +1,10 @@
#define F_ITINERARIO 101
#define F_FREQUENZA 102
#define F_CONSEGNA 103
#define F_LUNEDI 111
#define F_MARTEDI 112
#define F_MERCOLEDI 113
#define F_GIOVEDI 114
#define F_VENERDI 115
#define F_SABATO 116
#define F_DOMENICA 117

95
lv/lv2a00a.uml Normal file
View File

@ -0,0 +1,95 @@
#include "lv2a00a.h"
PAGE "Generazione automatica giri" -1 -1 53 9
GROUPBOX DLG_NULL 50 3
BEGIN
PROMPT 1 0 "@bParametri standard per contratti privi di giri"
END
STRING F_ITINERARIO 3
BEGIN
PROMPT 2 1 "Itinerario "
USE &ITI
JOIN &AUT TO &ITI ALIAS 1000 INTO CODTAB==S1
JOIN &MEZ TO &ITI ALIAS 2000 INTO CODTAB==S2
INPUT CODTAB F_ITINERARIO
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@50" S0
DISPLAY "Autista" S1
DISPLAY "Descrizione Autista@50" 1000@->S0
DISPLAY "Targa@8" S2
DISPLAY "Descrizione Mezzo@50" 2000@->S0
OUTPUT F_ITINERARIO CODTAB
FLAGS "UZ"
CHECKTYPE REQUIRED
END
NUMBER F_FREQUENZA 2
BEGIN
PROMPT 25 1 "Frequenza "
USE &FRQ
INPUT CODTAB F_FREQUENZA
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@50" S0
OUTPUT F_FREQUENZA CODTAB
CHECKTYPE REQUIRED
FLAGS "UZ"
END
RADIOBUTTON F_CONSEGNA 50
BEGIN
PROMPT 1 3 "@bModalità di consegna"
ITEM "C|Consegna"
ITEM "R|Ritiro"
ITEM "E|Entrambi"
FLAGS "Z"
END
GROUPBOX DLG_NULL 50 3
BEGIN
PROMPT 1 6 "@bGiorni di passaggio"
END
BOOLEAN F_LUNEDI
BEGIN
PROMPT 2 7 "Lun"
END
BOOLEAN F_MARTEDI
BEGIN
PROMPT 9 7 "Mar"
END
BOOLEAN F_MERCOLEDI
BEGIN
PROMPT 16 7 "Mer"
END
BOOLEAN F_GIOVEDI
BEGIN
PROMPT 23 7 "Gio"
END
BOOLEAN F_VENERDI
BEGIN
PROMPT 30 7 "Ven"
END
BOOLEAN F_SABATO
BEGIN
PROMPT 37 7 "Sab"
END
BOOLEAN F_DOMENICA
BEGIN
PROMPT 43 7 "Dom"
END
ENDPAGE
TOOLBAR "topbar" 0 0 0 2
#include "elabar.h"
END
ENDMASK

View File

@ -11,7 +11,7 @@ int main(int argc, char** argv)
case 1: lv3200(argc, argv); break; // evasione buoni di prelievo lv3200 case 1: lv3200(argc, argv); break; // evasione buoni di prelievo lv3200
case 2: lv3300(argc, argv); break; // gestione manuale buoni di prelievo lv3300 case 2: lv3300(argc, argv); break; // gestione manuale buoni di prelievo lv3300
case 3: lv3400(argc, argv); break; // evasione buoni di prelievo terminale lv3400 case 3: lv3400(argc, argv); break; // evasione buoni di prelievo terminale lv3400
case 4: lv3500(argc, argv); break; // sitauzione a mag. di un art. lv3500 case 4: lv3500(argc, argv); break; // situazione a mag. di un art. lv3500
case 5: lv3600(argc, argv); break; // invio dati a contapezzi Montanari lv3600 case 5: lv3600(argc, argv); break; // invio dati a contapezzi Montanari lv3600
case 6: lv3700(argc, argv); break; // inventario da terminale lv3700 case 6: lv3700(argc, argv); break; // inventario da terminale lv3700
case 7: lv3800(argc, argv); break; // invio dati a contapezzi Skema lv3800 case 7: lv3800(argc, argv); break; // invio dati a contapezzi Skema lv3800

View File

@ -23,8 +23,8 @@
//Definizione della classe della maschera //Definizione della classe della maschera
class TGestione_bolle_msk : public TDocumento_mask class TGestione_bolle_msk : public TDocumento_mask
{ {
long _stcodcf; long _stcodcf, _stcodcont;
long _stcodcont; int _autoselect;
protected: protected:
static void arrotonda(const TMask& msk, real& quantita); static void arrotonda(const TMask& msk, real& quantita);
@ -48,17 +48,15 @@ protected:
virtual void on_idle(); virtual void on_idle();
public: public:
virtual void user_set_handler( short fieldid, int index); virtual void user_set_handler( short fieldid, int index);
virtual void user_set_row_handler(TMask& rm, short field, int index); virtual void user_set_row_handler(TMask& rm, short field, int index);
void reset_var_mask() {_stcodcf = 0; _stcodcont = 0;} void reset_var_mask() { _stcodcf = _stcodcont = 0; }
TDate proponi_dataprco() const; TDate proponi_dataprco() const;
TString8 proponi_autista() const; TString8 proponi_autista() const;
void reset_autoselect() { _autoselect = 0; }
TGestione_bolle_msk(const char* tipodoc); TGestione_bolle_msk(const char* tipodoc);
int _autoselect;
}; };
////////////////////////////////////////// //////////////////////////////////////////
@ -79,7 +77,7 @@ protected:
virtual void init_modify_mode( TMask& m ); virtual void init_modify_mode( TMask& m );
void elimina_vuote( const TMask& m); void elimina_vuote( const TMask& m);
void salva_conguaglio( const TMask& m); void salva_conguaglio( const TDocumento_mask& m);
void date_dotmp( const TMask& m); void date_dotmp( const TMask& m);
virtual const char * query_mask_name() { return "lv3100a"; } virtual const char * query_mask_name() { return "lv3100a"; }
@ -604,7 +602,7 @@ bool TGestione_bolle_msk::lv_bolla_handler(TMask_field& f, KEY k)
f->on_hit(); f->on_hit();
} }
dmsk.highlight(); dmsk.highlight();
dmsk._autoselect = 0; dmsk.reset_autoselect();
} }
return ok; return ok;
} }
@ -787,7 +785,7 @@ bool TGestione_bolle_msk::lv_codart_handler(TMask_field& f, KEY k)
if (k == K_ENTER && rcont.get_int(LVRCONDV_CALCCONS) == 1) if (k == K_ENTER && rcont.get_int(LVRCONDV_CALCCONS) == 1)
{ {
TSheet_field* sheet = msk.get_sheet(); TSheet_field* sheet = msk.get_sheet();
TRiga_documento rdoc = dmsk.doc()[sheet->selected()+1]; const TRiga_documento& rdoc = dmsk.doc()[sheet->selected()+1];
const real ritor = rdoc.get_real(RDOC_QTAGG4); const real ritor = rdoc.get_real(RDOC_QTAGG4);
const real conor = rdoc.get_real(RDOC_QTAGG3); const real conor = rdoc.get_real(RDOC_QTAGG3);
@ -802,7 +800,6 @@ bool TGestione_bolle_msk::lv_codart_handler(TMask_field& f, KEY k)
if (cau.movcong() && (ritor != ritat || conor != conat) && ini_get_bool(CONFIG_DITTA, "lv", "Aggcong")) if (cau.movcong() && (ritor != ritat || conor != conat) && ini_get_bool(CONFIG_DITTA, "lv", "Aggcong"))
{ {
const real congor = rcont.get_real(LVRCONDV_QTACONG); const real congor = rcont.get_real(LVRCONDV_QTACONG);
const real congat = conat - conor - ritat + ritor + congor; const real congat = conat - conor - ritat + ritor + congor;
msk.set(FR_QTAGG5, congat); msk.set(FR_QTAGG5, congat);
@ -1325,17 +1322,15 @@ void TGestione_bolle_app::elimina_vuote( const TMask& m)
} }
} }
void TGestione_bolle_app::salva_conguaglio( const TMask& m) void TGestione_bolle_app::salva_conguaglio(const TDocumento_mask& mask)
{ {
if (ini_get_bool(CONFIG_DITTA, "lv", "Aggcong")) if (ini_get_bool(CONFIG_DITTA, "lv", "Aggcong"))
{ {
TDocumento_mask& mask = (TDocumento_mask&) m; const TDocumento& d = mask.doc();
TDocumento& d = mask.doc();
TSheet_field& sheet = mask.sfield(F_SHEET);
const long codcf = mask.get_long(F_CODCF); const long codcf = mask.get_long(F_CODCF);
const int indsped = mask.get_int(F_CODINDSP); const int indsped = mask.get_int(F_CODINDSP);
TDate datadoc = mask.get_date(F_DATADOC); const TDate datadoc = mask.get_date(F_DATADOC);
const TLaundry_contract cont(codcf, indsped, datadoc); const TLaundry_contract cont(codcf, indsped, datadoc);
const int codcont = cont.get_int(LVCONDV_CODCONT); const int codcont = cont.get_int(LVCONDV_CODCONT);
@ -1345,17 +1340,25 @@ void TGestione_bolle_app::salva_conguaglio( const TMask& m)
FOR_EACH_DOC_ROW_BACK(d, r, row) FOR_EACH_DOC_ROW_BACK(d, r, row)
{ {
TRiga_documento& rdoc = (TRiga_documento&)*row; TRiga_documento& rdoc = (TRiga_documento&)*row;
const TCausale_lavanderie cau(rdoc.get(RDOC_CODAGG1));
if (cau.movcong())
{
rcondv.put(LVRCONDV_CODCF, codcf); rcondv.put(LVRCONDV_CODCF, codcf);
rcondv.put(LVRCONDV_CODCONT, codcont); rcondv.put(LVRCONDV_CODCONT, codcont);
rcondv.put(LVRCONDV_CODART, rdoc.get(RDOC_CODART)); rcondv.put(LVRCONDV_CODART, rdoc.get(RDOC_CODART));
if (rcondv.read() == NOERR) if (rcondv.read() == NOERR)
{
rcondv.put(LVRCONDV_QTACONG, rdoc.get_real(RDOC_QTAGG5)); rcondv.put(LVRCONDV_QTACONG, rdoc.get_real(RDOC_QTAGG5));
rcondv.rewrite();
}
}
const real ritat = rdoc.get_real(RDOC_QTAGG1); const real ritat = rdoc.get_real(RDOC_QTAGG1);
const real conat = rdoc.get_real(RDOC_QTA); const real conat = rdoc.get_real(RDOC_QTA);
rdoc.put(RDOC_QTAGG4, ritat); rdoc.put(RDOC_QTAGG4, ritat);
rdoc.put(RDOC_QTAGG3, conat); rdoc.put(RDOC_QTAGG3, conat);
} }
rcondv.rewrite();
} }
} }
@ -1434,7 +1437,7 @@ int TGestione_bolle_app::write( const TMask& m )
{ {
elimina_vuote(m); elimina_vuote(m);
salva_conguaglio(m); salva_conguaglio((TDocumento_mask&)m);
date_dotmp(m); date_dotmp(m);
@ -1446,7 +1449,7 @@ int TGestione_bolle_app::rewrite( const TMask& m )
{ {
elimina_vuote(m); elimina_vuote(m);
salva_conguaglio(m); salva_conguaglio((TDocumento_mask&)m);
date_dotmp(m); date_dotmp(m);
@ -1474,7 +1477,7 @@ int TGestione_bolle_app::read(TMask& m)
//real dotmp = _giac.giac_att(rdoc, false); //real dotmp = _giac.giac_att(rdoc, false);
} }
mask.doc2mask(); mask.doc2mask();
mask._autoselect = 0; mask.reset_autoselect();
} }
return err; return err;

View File

@ -42,7 +42,7 @@ protected:
void riordina_righe(); void riordina_righe();
void genera_documento(); void genera_documento();
void evadi_tutto(); void evadi_tutto();
int arrotonda(const int quantita); int arrotonda(const TString& codart, const int quantita);
void spezza_riga(); void spezza_riga();
void salva(); void salva();
void annulla_operazioni(); void annulla_operazioni();
@ -392,7 +392,7 @@ void TEvasione_msk::genera_documento()
const TString80 iban = clifo.get(CLI_IBAN); const TString80 iban = clifo.get(CLI_IBAN);
//reupero la cuasale di magazzino di testata //reupero la cuasale di magazzino di testata
const TString16 causmag = cache().get("%TIP", tipodoc, "S9"); const TString8 causmag = cache().get("%TIP", tipodoc, "S9");
//recupero i dati di interesse dal file CFVEN //recupero i dati di interesse dal file CFVEN
const TRectype& cfven = cache().get(LF_CFVEN, key); const TRectype& cfven = cache().get(LF_CFVEN, key);
@ -557,23 +557,30 @@ void TEvasione_msk::genera_documento()
rdoc.put(RDOC_QTA, rbpre.qta_consegnata()); //consegnato rdoc.put(RDOC_QTA, rbpre.qta_consegnata()); //consegnato
rdoc.put(RDOC_QTAGG1, rbpre.qta_ritirata()); //ritirato rdoc.put(RDOC_QTAGG1, rbpre.qta_ritirata()); //ritirato
const real diff = rbpre.qta_consegnata() - rbpre.qta_ritirata();
dotod += (rbpre.qta_consegnata() - rbpre.qta_ritirata()); dotod += diff;
rdoc.put("DOTOD", dotod); rdoc.put("DOTOD", dotod);
bool dtmp = false; const bool dtmp = datagen >= rcont.get_date(LVRCONDV_INDTTMP) && datagen <= rcont.get_date(LVRCONDV_FIDTTMP);
if (datagen >= rcont.get_date(LVRCONDV_INDTTMP) && datagen <= rcont.get_date(LVRCONDV_FIDTTMP))
dtmp = true;
if (dtmp) if (dtmp)
{ rdoc.put("DOTMP", dottmp + diff);
rdoc.put("DOTMP", dottmp);
rdoc.add("DOTMP", rbpre.qta_consegnata() - rbpre.qta_ritirata());
}
const TCausale_lavanderie cau(rbpre.causale()); const TCausale_lavanderie cau(rbpre.causale());
rdoc.put(RDOC_CODAGG1, cau.codice()); rdoc.put(RDOC_CODAGG1, cau.codice());
// Aggiorna conguaglio su contratto se necessario 26-04-2012
if (!diff.is_zero() && cau.movcong() && ini_get_bool(CONFIG_DITTA, "lv", "Aggcong"))
{
real cong = rcont.get(LVRCONDV_QTACONG);
cong += diff;
rdoc.put(RDOC_QTAGG5, cong);
TLocalisamfile rcondv(LF_LVRCONDV);
((TRectype&)rcont).put(LVRCONDV_QTACONG, cong);
rcont.rewrite(rcondv);
}
const TRectype& anamag = cache().get(LF_ANAMAG, codart); const TRectype& anamag = cache().get(LF_ANAMAG, codart);
//gestione prezzo //gestione prezzo
if (prinbo) if (prinbo)
@ -592,8 +599,8 @@ void TEvasione_msk::genera_documento()
rdoc.put(RDOC_CODIVA, anamag.get(ANAMAG_CODIVA)); rdoc.put(RDOC_CODIVA, anamag.get(ANAMAG_CODIVA));
//scrivo il magazzino //scrivo il magazzino
TCausale_magazzino rit(cau.causale_ritiro()); const TCausale_magazzino rit(cau.causale_ritiro());
TCausale_magazzino con(cau.causale_consegna()); const TCausale_magazzino con(cau.causale_consegna());
TString8 magazzino; TString8 magazzino;
TString8 magazzinoc; TString8 magazzinoc;
@ -630,7 +637,7 @@ void TEvasione_msk::genera_documento()
if (!rbpre.evaso()) if (!rbpre.evaso())
continue; continue;
TDoc_key kbuono = rbpre.rifbcon(); const TDoc_key kbuono = rbpre.rifbcon();
if (kbuono.full()) if (kbuono.full())
continue; continue;
@ -641,7 +648,8 @@ void TEvasione_msk::genera_documento()
if (controlla()) if (controlla())
{ {
const TString4 stato = cache().get("%TIP", ini_get_string(CONFIG_DITTA, "lv", "TIPODOC_PRE", NULL, 0), "S2").mid(2,1); const TString4 tipo = ini_get_string(CONFIG_DITTA, "lv", "TIPODOC_PRE", NULL, 0);
const TString4 stato = cache().get("%TIP", tipo, "S2").mid(2,1);
bpre.put(DOC_STATO, stato); bpre.put(DOC_STATO, stato);
set(F_STATO, stato); set(F_STATO, stato);
} }
@ -650,7 +658,7 @@ void TEvasione_msk::genera_documento()
if (err == NOERR) if (err == NOERR)
{ {
if (yesno_box(TR("Il documento è stato generato; si desiderla stamparlo?"))) if (yesno_box(TR("Il documento è stato generato.\nSi desiderla stamparlo?")))
{ {
//stampa automatica //stampa automatica
TString80 str; TString80 str;
@ -680,17 +688,15 @@ void TEvasione_msk::evadi_tutto()
genera_documento(); genera_documento();
} }
int TEvasione_msk::arrotonda(const int quantita) int TEvasione_msk::arrotonda(const TString& codart, const int quantita)
{ {
int perarr = ini_get_int(CONFIG_DITTA, "lv", "Perarr");
int qta = quantita; int qta = quantita;
const TString& codart = get(FR_CODART);
//instanzio una cache sulla tabella del magazzino //instanzio una cache sulla tabella del magazzino
const TRectype& anamag = cache().get(LF_ANAMAG,codart); const TRectype& anamag = cache().get(LF_ANAMAG,codart);
//recupero i dati di interesse dall'anagrafica di magazzino //recupero i dati di interesse dall'anagrafica di magazzino
const long ppconf = anamag.get_long(ANAMAG_PPCONF); const long ppconf = anamag.get_long(ANAMAG_PPCONF);
if (ppconf > 0) if (ppconf > 1)
{ {
//recupero dal documento i dati di interesse per recuperare... //recupero dal documento i dati di interesse per recuperare...
//...i dati dalla riga contratto //...i dati dalla riga contratto
@ -703,15 +709,13 @@ int TEvasione_msk::arrotonda(const int quantita)
//recupero i dati di interesse dalla riga del contratto //recupero i dati di interesse dalla riga del contratto
if (rcont.get_int(LVRCONDV_CALCCONS) == 1) if (rcont.get_int(LVRCONDV_CALCCONS) == 1)
{ {
const int perarr = ini_get_int(CONFIG_DITTA, "lv", "Perarr");
//calcolo di quanti pezzi sforo //calcolo di quanti pezzi sforo
long arr = quantita % ppconf; const long arr = quantita % ppconf;
//calcolo quanti pezzi in più o in meno gli devo dare e aggiorno la quantità //calcolo quanti pezzi in più o in meno gli devo dare e aggiorno la quantità
if (arr > ppconf * perarr / 100) //arr <= ppconf*perarr/100 -> formula calcolo congualgio di Tassan if (arr > ppconf * perarr / 100) //arr <= ppconf*perarr/100 -> formula calcolo congualgio di Tassan
{ qta += ppconf - arr;
arr = ppconf - arr;
qta += arr;
}
else else
qta -= arr; qta -= arr;
} }
@ -736,7 +740,8 @@ void TEvasione_msk::spezza_riga()
idriga2 *= -1; idriga2 *= -1;
//scrivi le quantità sulla seconda riga //scrivi le quantità sulla seconda riga
const int dacons2 = arrotonda(riga2.get_int(sheet.cid2index(S_RITIRATO)) - riga2.get_int(sheet.cid2index(S_CONSEGNATO))); const TString80 codart = riga1->get(sheet.cid2index(S_CODART));
const int dacons2 = arrotonda(codart, riga2.get_int(sheet.cid2index(S_RITIRATO)) - riga2.get_int(sheet.cid2index(S_CONSEGNATO)));
riga2.add(dacons2, sheet.cid2index(S_RITIRATO)); riga2.add(dacons2, sheet.cid2index(S_RITIRATO));
riga2.add(dacons2, sheet.cid2index(S_DACONS)); riga2.add(dacons2, sheet.cid2index(S_DACONS));
riga2.add(0L, sheet.cid2index(S_CONSEGNATO)); riga2.add(0L, sheet.cid2index(S_CONSEGNATO));
@ -777,7 +782,7 @@ void TEvasione_msk::salva()
const int rowid = riga->get_int(sheet.cid2index(S_NROW)); const int rowid = riga->get_int(sheet.cid2index(S_NROW));
const TRiga_documento* riori = doc.get_row_id(abs(rowid)); const TRiga_documento* riori = doc.get_row_id(abs(rowid));
int nriga = riori ? riori->get_int(RDOC_NRIGA) : -1; int nriga = riori ? riori->get_int(RDOC_NRIGA) : -1;
if (rowid < 0) if (nriga <= 0)
{ {
TRiga_documento& row = doc.new_row("24"); TRiga_documento& row = doc.new_row("24");
if (riori != NULL) if (riori != NULL)
@ -787,11 +792,7 @@ void TEvasione_msk::salva()
TBuono_prelievo_row rdoc(doc[nriga]); TBuono_prelievo_row rdoc(doc[nriga]);
const char flgev = riga->get(sheet.cid2index(S_EVASO))[0]; const char flgev = riga->get(sheet.cid2index(S_EVASO))[0];
bool flag; const bool flag = flgev == 'X';
if (flgev == 'X')
flag = true;
else
flag = false;
const TString80 codart = riga->get(sheet.cid2index(S_CODART)); const TString80 codart = riga->get(sheet.cid2index(S_CODART));
@ -860,7 +861,7 @@ void TEvasione_msk::salva()
magazzino << ini_get_string(CONFIG_DITTA, "lv", "CODMAG") << ini_get_string(CONFIG_DITTA, "lv", "CODMAGP"); magazzino << ini_get_string(CONFIG_DITTA, "lv", "CODMAG") << ini_get_string(CONFIG_DITTA, "lv", "CODMAGP");
TEsercizi_contabili es; TEsercizi_contabili es;
int annoes = es.date2esc(datadoc); const int annoes = es.date2esc(datadoc);
TMov_mag movmag(++nummov); TMov_mag movmag(++nummov);
movmag.put(MOVMAG_ANNOES, annoes); movmag.put(MOVMAG_ANNOES, annoes);
@ -888,7 +889,6 @@ void TEvasione_msk::salva()
TRectype& rmovmag = movmag.new_row(); TRectype& rmovmag = movmag.new_row();
rmovmag.put(RMOVMAG_CODMAG, magazzino); rmovmag.put(RMOVMAG_CODMAG, magazzino);
rmovmag.put(RMOVMAG_CODART, codart); rmovmag.put(RMOVMAG_CODART, codart);
rmovmag.put(RMOVMAG_UM, um); rmovmag.put(RMOVMAG_UM, um);
rmovmag.put(RMOVMAG_QUANT, qta); rmovmag.put(RMOVMAG_QUANT, qta);
} }
@ -1027,7 +1027,7 @@ void TEvasione_msk::evadi_da_barcode()
if (scodart == codart) if (scodart == codart)
{ {
if (yesno_box(TR("ATTENZIONE: il pacco risulta già conteggato; si desidera annularlo?"))) if (yesno_box(TR("ATTENZIONE: il pacco risulta già conteggato!\nSi desidera annularlo?")))
{ {
int qtadacon = riga->get_int(sheet.cid2index(S_DACONS)); int qtadacon = riga->get_int(sheet.cid2index(S_DACONS));
int pacchi = riga->get_int(pospa); pacchi -= 1; int pacchi = riga->get_int(pospa); pacchi -= 1;
@ -1140,26 +1140,23 @@ bool TEvasione_msk::on_field_event(TOperable_field& f, TField_event e, long joll
switch (f.dlg()) switch (f.dlg())
{ {
case DLG_SELECT: case DLG_SELECT:
{
if (e == fe_button) if (e == fe_button)
evadi_tutto(); evadi_tutto();
}
break; break;
case DLG_PREVIEW: case DLG_PREVIEW:
{ if (e == fe_button)
riordina_righe(); riordina_righe();
}
break; break;
case DLG_ELABORA: case DLG_ELABORA:
{
if (e == fe_button) if (e == fe_button)
{
if (controlla()) if (controlla())
genera_documento(); genera_documento();
else else
{ {
if(yesno_box(TR("ATTENZIONE: non tutte le righe sono evase. Si desidera continuare ugualmente?"))) if (yesno_box(TR("ATTENZIONE: non tutte le righe sono evase.\nSi desidera continuare ugualmente?")))
{ {
if(yesno_box(TR("Si desidera considerare evase tutte le righe?" if (yesno_box(TR("Si desidera considerare evase tutte le righe?\n"
"(in caso contrario le righe evase parzialmente verranno spezzate su due righe)"))) "(in caso contrario le righe evase parzialmente verranno spezzate su due righe)")))
evadi_tutto(); evadi_tutto();
else else
@ -1174,23 +1171,19 @@ bool TEvasione_msk::on_field_event(TOperable_field& f, TField_event e, long joll
} }
break; break;
case DLG_SAVEREC: case DLG_SAVEREC:
{
if (e == fe_button) if (e == fe_button)
salva(); salva();
}
break; break;
case DLG_CANCEL: case DLG_CANCEL:
{
if (e == fe_button && jolly == 0) if (e == fe_button && jolly == 0)
{ {
annulla_operazioni(); annulla_operazioni();
return false; return false;
} }
}
break; break;
case F_NDOC: case F_NDOC:
{
if (e == fe_modify) if (e == fe_modify)
{
if (f.get_long() > 0) if (f.get_long() > 0)
carica_righe(); carica_righe();
else else
@ -1209,19 +1202,14 @@ bool TEvasione_msk::on_field_event(TOperable_field& f, TField_event e, long joll
} }
break; break;
case F_DATADOC: case F_DATADOC:
{
if (e == fe_modify) if (e == fe_modify)
setta_campi_data(); setta_campi_data();
}
break; break;
case F_CODCF: case F_CODCF:
{
if (e == fe_modify) if (e == fe_modify)
setta_campi_cliente(); setta_campi_cliente();
}
break; break;
case F_BARCODE: case F_BARCODE:
{
if (e == fe_modify && f.get().full()) if (e == fe_modify && f.get().full())
{ {
_autoselect = 1; _autoselect = 1;
@ -1231,10 +1219,8 @@ bool TEvasione_msk::on_field_event(TOperable_field& f, TField_event e, long joll
if (controlla()) if (controlla())
send_key(K_SPACE, DLG_ELABORA); send_key(K_SPACE, DLG_ELABORA);
} }
}
break; break;
case S_CONSEGNATO: case S_CONSEGNATO:
{
if (e == fe_modify) if (e == fe_modify)
{ {
TSheet_field& sheet = sfield(F_RIGHE); TSheet_field& sheet = sfield(F_RIGHE);
@ -1261,13 +1247,10 @@ bool TEvasione_msk::on_field_event(TOperable_field& f, TField_event e, long joll
if (controlla()) if (controlla())
send_key(K_SPACE, DLG_ELABORA, &f); send_key(K_SPACE, DLG_ELABORA, &f);
} }
}
break; break;
case S_PACCHI: case S_PACCHI:
{
if (e == fe_modify) if (e == fe_modify)
sistema_quantita(); sistema_quantita();
}
break; break;
default:break; default:break;
} }

View File

@ -78,7 +78,7 @@ protected:
virtual void init_modify_mode( TMask& m ); virtual void init_modify_mode( TMask& m );
void elimina_vuote( const TMask& m); void elimina_vuote( const TMask& m);
void salva_conguaglio( const TMask& m); bool salva_conguaglio( const TDocumento_mask& m);
void date_dotmp( const TMask& m); void date_dotmp( const TMask& m);
virtual const char * query_mask_name() { return "lv3300a"; } virtual const char * query_mask_name() { return "lv3300a"; }
@ -97,7 +97,7 @@ inline TGestione_buoni_app& gbapp() { return (TGestione_buoni_app &)main_app();
//ARROTONDA: metodo che arrotonda la quantità che gli passo se è previsto sul contratto //ARROTONDA: metodo che arrotonda la quantità che gli passo se è previsto sul contratto
void TGestione_buoni_msk::arrotonda(const TMask& msk, real& quantita) void TGestione_buoni_msk::arrotonda(const TMask& msk, real& quantita)
{ {
int perarr = ini_get_int(CONFIG_DITTA, "lv", "Perarr"); const int perarr = ini_get_int(CONFIG_DITTA, "lv", "Perarr");
const TString& codart = msk.get(FR_CODART); const TString& codart = msk.get(FR_CODART);
//instanzio una cache sulla tabella del magazzino //instanzio una cache sulla tabella del magazzino
@ -141,7 +141,7 @@ void TGestione_buoni_msk::arrotonda(const TMask& msk, real& quantita)
void TGestione_buoni_msk::dettaglio_causale(TSheet_field& ss) void TGestione_buoni_msk::dettaglio_causale(TSheet_field& ss)
{ {
TGestione_buoni_msk& dmsk = (TGestione_buoni_msk&) ss.mask(); TGestione_buoni_msk& dmsk = (TGestione_buoni_msk&) ss.mask();
TString4 causale = ss.cell(ss.selected(),ss.cid2index(FR_CODAGG1)); const TString4 causale = ss.cell(ss.selected(),ss.cid2index(FR_CODAGG1));
//instanzio una cache sulle causali //instanzio una cache sulle causali
const TCausale_lavanderie cau(causale); const TCausale_lavanderie cau(causale);
@ -1276,12 +1276,12 @@ void TGestione_buoni_app::elimina_vuote( const TMask& m)
} }
} }
void TGestione_buoni_app::salva_conguaglio( const TMask& m) bool TGestione_buoni_app::salva_conguaglio( const TDocumento_mask& mask)
{ {
if (ini_get_bool(CONFIG_DITTA, "lv", "Aggcong")) if (!ini_get_bool(CONFIG_DITTA, "lv", "Aggcong"))
{ return false;
TDocumento_mask& mask = (TDocumento_mask&) m;
TDocumento& d = mask.doc(); const TDocumento& d = mask.doc();
TSheet_field& sheet = mask.sfield(F_SHEET); TSheet_field& sheet = mask.sfield(F_SHEET);
const long codcf = mask.get_long(F_CODCF); const long codcf = mask.get_long(F_CODCF);
@ -1296,18 +1296,27 @@ void TGestione_buoni_app::salva_conguaglio( const TMask& m)
FOR_EACH_DOC_ROW_BACK(d, r, row) FOR_EACH_DOC_ROW_BACK(d, r, row)
{ {
TRiga_documento& rdoc = (TRiga_documento&)*row; TRiga_documento& rdoc = (TRiga_documento&)*row;
const TCausale_lavanderie cau(rdoc.get(RDOC_CODAGG1));
if (cau.movcong())
{
rcondv.put(LVRCONDV_CODCF,codcf); rcondv.put(LVRCONDV_CODCF,codcf);
rcondv.put(LVRCONDV_CODCONT, codcont); rcondv.put(LVRCONDV_CODCONT, codcont);
rcondv.put(LVRCONDV_CODART, rdoc.get(RDOC_CODART)); rcondv.put(LVRCONDV_CODART, rdoc.get(RDOC_CODART));
if (rcondv.read() == NOERR) if (rcondv.read() == NOERR)
{
rcondv.put(LVRCONDV_QTACONG, rdoc.get_real(RDOC_QTAGG5)); rcondv.put(LVRCONDV_QTACONG, rdoc.get_real(RDOC_QTAGG5));
rcondv.rewrite();
}
}
const real ritat = rdoc.get_real(RDOC_QTAGG1); const real ritat = rdoc.get_real(RDOC_QTAGG1);
const real conat = rdoc.get_real(RDOC_QTA); const real conat = rdoc.get_real(RDOC_QTA);
rdoc.put(RDOC_QTAGG4, ritat); rdoc.put(RDOC_QTAGG4, ritat);
rdoc.put(RDOC_QTAGG3, conat); rdoc.put(RDOC_QTAGG3, conat);
} }
rcondv.rewrite();
} return true;
} }
void TGestione_buoni_app::date_dotmp( const TMask& m) void TGestione_buoni_app::date_dotmp( const TMask& m)
@ -1318,7 +1327,7 @@ void TGestione_buoni_app::date_dotmp( const TMask& m)
TSheet_field& sheet = mask.sfield(F_SHEET); TSheet_field& sheet = mask.sfield(F_SHEET);
const long codcf = mask.get_long(F_CODCF); const long codcf = mask.get_long(F_CODCF);
const int indsped = mask.get_int(F_CODINDSP); const int indsped = mask.get_int(F_CODINDSP);
TDate datadoc = mask.get_date(F_DATADOC); const TDate datadoc = mask.get_date(F_DATADOC);
const TLaundry_contract cont(codcf, indsped, datadoc); const TLaundry_contract cont(codcf, indsped, datadoc);
const int codcont = cont.get_int(LVCONDV_CODCONT); const int codcont = cont.get_int(LVCONDV_CODCONT);
@ -1369,7 +1378,7 @@ int TGestione_buoni_app::write( const TMask& m )
{ {
elimina_vuote(m); elimina_vuote(m);
salva_conguaglio(m); salva_conguaglio((const TDocumento_mask&)m);
date_dotmp(m); date_dotmp(m);
@ -1381,7 +1390,7 @@ int TGestione_buoni_app::rewrite( const TMask& m )
{ {
elimina_vuote(m); elimina_vuote(m);
salva_conguaglio(m); salva_conguaglio((const TDocumento_mask&)m);
date_dotmp(m); date_dotmp(m);

View File

@ -108,6 +108,7 @@ Module = 41
Flags = "" Flags = ""
Item_01 = "Generazione automatica", "lv2 -0", "F" Item_01 = "Generazione automatica", "lv2 -0", "F"
Item_02 = "Gestione manuale", "lv2 -1", "F" Item_02 = "Gestione manuale", "lv2 -1", "F"
Item_03 = "Generazione da contratti", "lv2 -9", "F"
[LVMENU_032] [LVMENU_032]
Caption = "Stampe" Caption = "Stampe"

View File

@ -1,4 +1,4 @@
#include "tctbtpg.h" #include "../tc/tctbtpg.h"
TOOLBAR "topbar" 0 0 0 2 TOOLBAR "topbar" 0 0 0 2
#include <relapbar.h> #include <relapbar.h>