Patch level : 10.0

Files correlati     : lv0 lv2 lv3
Ricompilazione Demo : [ ]
Commento            :
Aggiunti parametri in configurazione

Aggiunti i campi di dotazione odierna e temporanea sulle bolle con relativa movimentazione

Cambiata la logica del calcolo del conguaglio nella generazione automatica delle bolle


git-svn-id: svn://10.65.10.50/trunk@18089 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
luca83 2009-01-23 10:36:46 +00:00
parent 84a298abcd
commit 08884f84d9
8 changed files with 774 additions and 171 deletions

View File

@ -31,14 +31,31 @@
#define F_BUONIRIT 218
#define F_BUONIANT 219
#define F_DOCCONG 220
#define F_DOCDOT 221
#define F_BUONIPREL 220
#define F_DOCCONG 221
#define F_DOCDOT 222
#define F_CAUSLAV 222
#define F_CAUSLAVDESC 223
#define F_UNICONT 224
#define F_AUTGIRI 225
#define F_ALMANAC 226
#define F_CAUSLAV 223
#define F_CAUSLAVDESC 224
#define F_CODMAGN 225
#define F_DESMAGN 226
#define F_CODMAGC 227
#define F_DESMAGC 228
#define F_PATH_CON 229
#define F_PATH_MAN 230
#define F_PATH_LAVA 231
#define F_UNICONT 232
#define F_AUTGIRI 233
#define F_DATAFISSA 234
#define F_AGGCONG 235
#define F_PERARR 236
#define F_RIFOR 237
#define F_ARTCANFIS 238
#define F_GESTSACA 239
#define F_ALMANAC 240
#define S_CODNUM_RIT 101
#define S_TIPODOC_RIT 102
@ -46,6 +63,12 @@
#define S_STATO_RIT 104
#define S_DESNUM_RIT 105
#define S_CODNUM_PRE 101
#define S_TIPODOC_PRE 102
#define S_DESTIPODOC_PRE 103
#define S_STATO_PRE 104
#define S_DESNUM_PRE 105
#define S_CODNUM_ANT 101
#define S_TIPODOC_ANT 102
#define S_DESTIPODOC_ANT 103

View File

@ -59,7 +59,7 @@ END
ENDPAGE
PAGE "Parametri" 0 0 0 0
PAGE "Documenti" 0 0 0 0
GROUPBOX DLG_NULL 78 4
BEGIN
@ -293,9 +293,15 @@ BEGIN
COPY OUTPUT F_TIPODOC_ORC
END
GROUPBOX DLG_NULL 78 3
BEGIN
PROMPT 1 17 "@bCausale di default"
END
STRING F_CAUSLAV 3
BEGIN
PROMPT 2 17 "Causale di default"
PROMPT 2 18 "Causale "
USE &CAU
INPUT CODTAB F_CAUSLAV
DISPLAY "Codice" CODTAB
@ -306,9 +312,9 @@ BEGIN
CHECKTYPE REQUIRED
END
STRING F_CAUSLAVDESC 50 47
STRING F_CAUSLAVDESC 50
BEGIN
PROMPT 28 17 ""
PROMPT 24 18 ""
USE CAU KEY 2
INPUT S0 F_CAUSLAVDESC
DISPLAY "Descrizione@50" S0
@ -317,18 +323,6 @@ BEGIN
CHECKTYPE REQUIRED
END
BOOLEAN F_UNICONT
BEGIN
PROMPT 2 18 "Numera i contratti per ditta "
FIELD UniCont
END
BOOLEAN F_AUTGIRI
BEGIN
PROMPT 40 18 "Generazione automatica giri "
FIELD Autgiri
END
ENDPAGE
PAGE "Buoni" 0 2 0 0
@ -338,7 +332,7 @@ BEGIN
PROMPT -11 0 "@bBuoni di ritiro"
END
SPREADSHEET F_BUONIRIT 0 8
SPREADSHEET F_BUONIRIT 0 5
BEGIN
PROMPT 0 1 "Buoni di ritiro"
ITEM "Numerazione"
@ -350,12 +344,27 @@ END
TEXT DLG_NULL
BEGIN
PROMPT -11 10 "@bBuoni di anticipo"
PROMPT -11 7 "@bBuoni di prelievo"
END
SPREADSHEET F_BUONIANT 0 8
SPREADSHEET F_BUONIPREL 0 5
BEGIN
PROMPT 0 11 "Buoni di anticipo"
PROMPT 0 8 "Buoni di prelievo"
ITEM "Numerazione"
ITEM "Tipo documento"
ITEM "Desczrizione tipo documento"
ITEM "Stato"
ITEM "Descrizione numerazione"
END
TEXT DLG_NULL
BEGIN
PROMPT -11 14 "@bBuoni di anticipo"
END
SPREADSHEET F_BUONIANT 0 5
BEGIN
PROMPT 0 15 "Buoni di anticipo"
ITEM "Numerazione"
ITEM "Tipo documento"
ITEM "Desczrizione tipo documento"
@ -399,6 +408,131 @@ END
ENDPAGE
PAGE "Parametri" 0 0 0 0
GROUPBOX DLG_NULL 78 6
BEGIN
PROMPT 1 1 "@bMagazzini"
END
STRING F_CODMAGN 4
BEGIN
PROMPT 2 2 "Magazzino del nuovo "
HELP "Codice deposito del nuovo"
CHECKTYPE REQUIRED
FLAGS "UPA"
END
STRING F_DESMAGN 50
BEGIN
PROMPT 2 3 " "
HELP "Descrizione Magazzino"
END
STRING F_CODMAGC 4
BEGIN
PROMPT 2 4 "Magazzino del circolante "
HELP "Codice deposito del circolante"
CHECKTYPE REQUIRED
FLAGS "UPA"
END
STRING F_DESMAGC 50
BEGIN
PROMPT 2 5 " "
HELP "Descrizione Magazzino"
END
GROUPBOX DLG_NULL 78 5
BEGIN
PROMPT 1 7 "@bPercorsi file"
END
STRING F_PATH_CON 256 50
BEGIN
PROMPT 2 8 "Cartella contapezzi "
DSELECT
CHECKTYPE REQUIRED
FIELD PathContapezzi
END
STRING F_PATH_MAN 256 50
BEGIN
PROMPT 2 9 "Cartella mangano "
DSELECT
CHECKTYPE REQUIRED
FIELD PathMangano
END
STRING F_PATH_LAVA 256 50
BEGIN
PROMPT 2 10 "Cartella lavacontinua "
DSELECT
CHECKTYPE REQUIRED
FIELD PathLavacontinua
END
GROUPBOX DLG_NULL 78 5
BEGIN
PROMPT 1 12 "@bOpzioni documenti"
END
BOOLEAN F_UNICONT
BEGIN
PROMPT 2 13 "Numera i contratti per ditta"
FIELD UniCont
END
BOOLEAN F_AUTGIRI
BEGIN
PROMPT 30 13 "Generazione automatica giri"
FIELD Autgiri
END
BOOLEAN F_DATAFISSA
BEGIN
PROMPT 2 14 "Data documenti fissa"
FIELD Datafissa
END
BOOLEAN F_AGGCONG
BEGIN
PROMPT 30 14 "Aggiorna conguaglio su modifiche manuali"
FIELD Aggcong
END
NUMBER F_PERARR 3
BEGIN
PROMPT 2 15 "Percentuale per il calcolo dell'arrotondamento "
FIELD Perarr
END
GROUPBOX DLG_NULL 78 4
BEGIN
PROMPT 1 17 "@bOpzioni articoli"
END
BOOLEAN F_RIFOR
BEGIN
PROMPT 2 18 "Rigo forfait"
FIELD Rifor
END
BOOLEAN F_ARTCANFIS
BEGIN
PROMPT 40 18 "Articolo a canone fisso"
FIELD Artcanfis
END
BOOLEAN F_GESTSACA
BEGIN
PROMPT 2 19 "Gestione sacchi/carrello"
FIELD Gestsaca
END
ENDPAGE
PAGE "Calendario" 0 2 0 0
ALMANAC F_ALMANAC 60 -2
@ -503,6 +637,99 @@ ENDPAGE
ENDMASK
PAGE "Buoni di prelievo" -1 -1 80 5
STRING S_CODNUM_PRE 4
BEGIN
PROMPT 1 1 "Numerazione "
FIELD NUM_PRE
HELP "Codice numerazione"
USE %NUM
INPUT CODTAB S_CODNUM_PRE
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@50" S0
OUTPUT S_CODNUM_PRE CODTAB
OUTPUT S_DESNUM_PRE S0
CHECKTYPE REQUIRED
FLAGS "UPA"
WARNING "Numerazione assente"
END
STRING S_DESNUM_PRE 50
BEGIN
PROMPT 20 1 ""
HELP "Descrizione numerazione"
USE %NUM KEY 2
INPUT S0 S_DESNUM_PRE
DISPLAY "Descrizione@50" S0
DISPLAY "Codice" CODTAB
COPY OUTPUT S_CODNUM_PRE
END
STRING S_TIPODOC_PRE 4
BEGIN
PROMPT 1 2 "Tipo "
FIELD TIPODOC_PRE
HELP "Codice tipo documento"
USE %TIP
INPUT CODTAB S_TIPODOC_PRE
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@50" S0
OUTPUT S_TIPODOC_PRE CODTAB
OUTPUT S_DESTIPODOC_PRE S0
CHECKTYPE REQUIRED
FLAGS "UP"
END
STRING S_DESTIPODOC_PRE 50
BEGIN
PROMPT 20 2 ""
HELP "Descrizione tipo documento"
USE %TIP KEY 2
INPUT S0 S_DESTIPODOC_PRE
DISPLAY "Descrizione@50" S0
DISPLAY "Codice" CODTAB
COPY OUTPUT S_TIPODOC_PRE
END
STRING S_STATO_PRE 1
BEGIN
PROMPT 1 3 "Stato "
USE %STD
CHECKTYPE REQUIRED
INPUT CODTAB S_STATO_PRE
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@50" S0
OUTPUT S_STATO_PRE CODTAB
FIELD STATO_PRE
FLAGS "U"
END
ENDPAGE
TOOLBAR "" 0 0 0 2
BUTTON DLG_OK 2 2
BEGIN
PROMPT 1 1 ""
END
BUTTON DLG_DELREC 2 2
BEGIN
PROMPT 2 1 "Elimina"
MESSAGE EXIT,K_DEL
PICTURE BMP_DELREC
END
BUTTON DLG_CANCEL 2 2
BEGIN
PROMPT 4 1 ""
END
ENDPAGE
ENDMASK
PAGE "Buoni d'anticipo" -1 -1 80 5
GROUPBOX DLG_NULL 78 4

View File

@ -197,8 +197,10 @@ bool TGenera_documenti_app::crea_documento(const TISAM_recordset& plan)
//CREA_RIGA: questa funzione crea una riga merce per una bolla di consegna
void TGenera_documenti_app::crea_riga(const TString& codart, const char modpas, const int tplis, const bool tmp, const bool prinbo,TDocumento& doc)
{
const int perarr = _configlv->get_int("Perarr");
//creo la nuova riga
TRiga_documento& rdoc = doc.new_row("01");
TRiga_documento& rdoc = doc.new_row("21");
const long codcli = doc.get_long(DOC_CODCF);
const long codcont = doc.get_long(DOC_CODCONT);
@ -232,10 +234,13 @@ void TGenera_documenti_app::crea_riga(const TString& codart, const char modpas,
long arr = quantita_arr.integer() % ppconf.integer();
//se sforo (arr > 0) allora calcolo quanti pezzi in più gli devo dare e aggiorno la quantità
if (arr > 0)
{
arr = ppconf.integer() - arr;
quantita_arr += arr;
}
if (arr > ppconf.integer() * perarr / 100) //arr <= ppconf*perarr/100 -> formula calcolo congualgio di Tassan
{
arr = ppconf.integer() - arr;
quantita_arr += arr;
}
else
quantita_arr -= arr;
}
//scrivo le quantità

View File

@ -8,25 +8,215 @@
#include "lvlib.h"
#include "lvcondv.h"
#include "lvrcondv.h"
#include "../mg/clifogiac.h"
//definizione della maschera di inserimento
////////////////////////////////////
//// CLASSE TGIAC_PER_CLI ////
////////////////////////////////////
//Definizione della classe Giacenza per Cliente
class TGiac_per_cli : public TObject
{
private:
TAssoc_array _odierna; //TAssoc_array che conterrà le dotazioni odierne
TAssoc_array _temporanea; //TAssoc_array che conterrà le dotazioni temporanee
long _clifo; //variabile che conterrà il cliente selezionato
long _cont; //variabile che conterrà il contratto selezionato
int _year; //variabile che conterrà l'anno documento
long _indsped; //variabile che conterrà l'indirizzo di spedizione
protected:
real& giacart_od(const TString& codart); //restituisce un puntatore al valore della dot. od. salvato
real& giacart_tmp(const TString& codart); //restituisce un puntatore al valore valore della dot. temp. salvato
long giac_in_mag(const TString& codart, bool odierna) const; //restituisce il valore salvato nel magazzino
public:
bool reset(const TDocumento& doc); //svuota i TAssoc_array e carica cli e cont
bool load_row(const TRiga_documento& rdoc); //popola i TAssoc_array
long giac_att(TRiga_documento& rdoc, bool odierna); //restituisce le quantità attuali di dotazione
TGiac_per_cli(); //costruttore
};
//GIACART_OD: metodo che restituisce un puntatore al real che contiene il valore
//della dotazione odierna per un determinato articolo
real& TGiac_per_cli::giacart_od(const TString& codart)
{
real *giac = (real*)_odierna.objptr(codart);
if (giac == NULL)
{
giac = new real(giac_in_mag(codart, true));
_odierna.add(codart,giac);
}
return *giac;
};
//GIACART_TMP: metodo che restituisce un puntatore al real che contiene il valore
//della dotazione temporanea per un determinato articolo
real& TGiac_per_cli::giacart_tmp(const TString& codart)
{
real *giac = (real*)_temporanea.objptr(codart);
if (giac == NULL)
{
giac = new real(giac_in_mag(codart, false));
_temporanea.add(codart,giac);
}
return *giac;
};
//GIAC_IN_MAG: questo metodo restituisce le quantità presenti sul file 166 (clifogiac)
//restituendo il valore salvato in dotazione odierna se odierna == true,
//oppure il valore salvato in dotazione temporanea se odierna = false
long TGiac_per_cli::giac_in_mag(const TString& codart, bool odierna) const
{
//recupero i valori delle dotazioni odierne e temporanee dal magazzino del cliente
TLocalisamfile magcli(LF_CLIFOGIAC);
magcli.put(CLIFOGIAC_ANNOES, _year);
magcli.put(CLIFOGIAC_TIPOCF, 'C');
magcli.put(CLIFOGIAC_CODCF, _clifo);
magcli.put(CLIFOGIAC_INDSPED, _indsped);
magcli.put(CLIFOGIAC_CODART, codart);
//leggo il record corrispondente
if (magcli.read() == NOERR)
return magcli.get_long( odierna ? CLIFOGIAC_DOTOD : CLIFOGIAC_DOTTM);
return 0;
}
//RESET: metodo che distrugge i due TAssoc_array e carica la coppia cliente - contratto
bool TGiac_per_cli::reset(const TDocumento& doc)
{
//estraggo i dati di interesse dal documento
_clifo = doc.get_long(DOC_CODCF);
_cont = doc.get_long(DOC_CODCONT);
_year = doc.get_date(DOC_DATADOC).year();
_indsped = doc.get_long(DOC_CODINDSP);
//distruggo i due TAssoc_array
_odierna.destroy();
_temporanea.destroy();
return true;
}
//LOAD_ROW: questo metodo popola e aggiorna i TAssoc_array
bool TGiac_per_cli::load_row(const TRiga_documento& rdoc)
{
//recupero il documento e la sua maschera a partire dalla riga documento
const TDocumento& doc = rdoc.doc();
//se sul documento leggo o il cliente o il contratto o l'indirizzo di spedizione
//diversi da quelli che avevo salvato vuol dire che ho cambiato uno dei due,
//e quindi le giacenze non vanno più bene; in tal caso resetto i TAssoc_array e riparto
if (doc.get_long(DOC_CODCF) != _clifo || doc.get_long(DOC_CODCONT) != _cont || doc.get_long(DOC_CODINDSP) != _indsped)
reset(doc);
real& dotazione = giacart_od(rdoc.get(RDOC_CODART));
//RDOC_QTA contiene il consegnato - RDOC_QTAGG1 contiene il ritirato
//queste quantità vanno rispettivamente sommate e sottratte alla dotazione iniziale
int saldo = rdoc.get_int(RDOC_QTA) - rdoc.get_int(RDOC_QTAGG1);
dotazione -= saldo;
//instanzio una cache sulla tabella delle causali
TString4 causale = rdoc.get(RDOC_CODAGG1);
const TRectype& cau = cache().get("&CAU", causale);
//movimento o meno la dotazione temporanea a seconda di cosa prevede la causale
if (cau.get_bool("B0") || cau.get_bool("B1"))
{
const TRectype& caumagr = cache().get("%CAU", cau.get(cau.get_bool("B0") ? "S1": "S2"));
TString4 str = caumagr.get("S2").mid(32,2);
if (atoi(str) != ZERO)
{
real& dotmp = giacart_tmp(rdoc.get(RDOC_CODART));
int saldotmp = rdoc.get_int(RDOC_QTA) - rdoc.get_int(RDOC_QTAGG1);
dotmp -= saldo;
}
}
return true;
}
//GIAC_ATT: questo metodo restituisce il valore della dotazione da scrivere a video in base ai valori
//di consegnato e ritirato; ATTENZIONE: restituisce la dotazione odierna se odierna = true,
//restituisce la dotazione temporanea se odierna = false
long TGiac_per_cli::giac_att(TRiga_documento& rdoc, bool odierna)
{
const TString& codart = rdoc.get(RDOC_CODART);
long giac = odierna ? giacart_od(codart).integer() : giacart_tmp(codart).integer();
//RDOC_QTA contiene il consegnato - RDOC_QTAGG1 contiene il ritirato
//queste quantità vanno rispettivamente sommate e sottratte alla dotazione
long saldo = rdoc.get_long(RDOC_QTA) - rdoc.get_long(RDOC_QTAGG1);
giac += saldo;
return giac;
}
//costruttore
TGiac_per_cli::TGiac_per_cli()
{
_clifo = 0;
_cont = 0;
_year = 0;
_indsped = 0;
}
//////////////////////////////////////////
//// CLASSE TGESTIONE_BOLLE_APP ////
//////////////////////////////////////////
// Definizione della classe dell'applicazione motore
class TGestione_bolle_app : public TMotore_application
{
TGiac_per_cli _giac;
protected:
virtual TMask* get_mask( int mode );
virtual int write( const TMask& m );
virtual int rewrite( const TMask& m );
virtual int read ( TMask& m );
virtual void init_insert_mode( TMask& m );
public:
TGiac_per_cli& giacenza();
TGestione_bolle_app() {}
};
inline TGestione_bolle_app& gbapp() { return (TGestione_bolle_app &)main_app(); };
//////////////////////////////////////////
//// CLASSE TGESTIONE_BOLLE_MSK ////
//////////////////////////////////////////
//Definizione della classe della maschera
class TGestione_bolle_msk : public TDocumento_mask
{
protected:
static void arrotonda(const TMask& msk, real& quantita);
protected:
static void arrotonda(const TMask& msk, real& quantita);
//hanlder di documento:
static bool lv_bolla_handler(TMask_field& f, KEY k);
//handler di riga:
static bool lv_ritirato_handler(TMask_field& f, KEY k);
static bool lv_consegnato_handler(TMask_field& f, KEY k);
static bool lv_codart_handler(TMask_field& f, KEY k);
static bool lv_causale_handler(TMask_field& f, KEY k);
public:
virtual void user_set_handler( short fieldid, int index);
virtual void user_set_row_handler(TMask& rm, short field, int index);
TGestione_bolle_msk(const char* tipodoc);
};
//ARROTONDA: metodo che arrotonda la quantità che gli passo se è previsto sul contratto
void TGestione_bolle_msk::arrotonda(const TMask& msk, real& quantita)
{
TConfig* configlv = new TConfig(CONFIG_DITTA,"lv");
int perarr = configlv->get_int("Perarr");
const TString& codart = msk.get(FR_CODART);
//instanzio una cache sulla tabella del magazzino
const TRectype& anamag = cache().get(LF_ANAMAG,codart);
@ -51,92 +241,25 @@ void TGestione_bolle_msk::arrotonda(const TMask& msk, real& quantita)
if (rcont.get_bool(LVRCONDV_ARROT))
{
//calcolo di quanti pezzi sforo
const long arr = quantita.integer() % ppconf;
//se sforo (arr > 0) allora calcolo quanti pezzi in più gli devo dare e aggiorno la quantità
if (arr > 0)
quantita += ppconf - arr;
long arr = quantita.integer() % ppconf;
//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
{
arr = ppconf - arr;
quantita += arr;
}
else
quantita -= arr;
}
}
}
bool TGestione_bolle_msk::lv_ritirato_handler(TMask_field& f, KEY k)
{
if (f.to_check(k) && !f.empty())
{
TMask& msk = f.mask();
if (msk.field(FR_QTA).enabled() && msk.field(FR_QTA).empty())
{
real ritirato = f.get();
arrotonda(msk,ritirato);
msk.set(FR_QTA,ritirato);
}
}
return true;
}
bool TGestione_bolle_msk::lv_consegnato_handler(TMask_field& f, KEY k)
{
bool ok = true;
TMask& msk = f.mask();
switch(f.dlg())
{
case FR_QTA: ok = qta_handler( f, k ); break;
default: break;
}
/*if (ok && k == K_ENTER && f.dirty() && msk.field(FR_QTAGG1).enabled() && !f.empty())
{
real ritirato = msk.get_real(FR_QTAGG1);
real consegnato = f.get();
arrotonda(msk, consegnato);
arrotonda(msk, ritirato);
if (consegnato.integer() != ritirato.integer() &&
!yesno_box(TR("Si desidera consegnare una quantita' di merce diversa da quella ritirata?")))
f.set(ritirato.string());
else
f.set(consegnato.string());
}*/
return ok;
}
bool TGestione_bolle_msk::lv_codart_handler(TMask_field& f, KEY k)
{
bool ok = true;
switch(f.dlg())
{
case FR_CODART: ok = codart_handler( f, k ); break;
default: break;
}
if (ok && k == K_ENTER && f.dirty())
{
TMask& msk = f.mask();
const TString& codart = msk.get(FR_CODART);
if (codart.full())
{
TDocumento_mask& dmsk = (TDocumento_mask&) msk.get_sheet()->mask();
//recupero dal documento i dati di interesse per recuperare...
//...i dati dalla riga contratto
const long codcf = dmsk.get_long(F_CODCF);
const int indsped = dmsk.get_int(F_CODINDSP);
TDate datadoc = dmsk.get_date(F_DATADOC);
if (!datadoc.ok())
datadoc = TODAY;
const TLaundry_contract cont(codcf, indsped, datadoc);
if (cont.row(codart).empty() &&
yesno_box(TR("L'articolo in esame non fa parte della dotazione standard di questo cliente."
"Si desidera aggiungerla ai contratti?")))
cont.edit();
}
}
return ok;
}
////////////////////////////
// HANDLER DI DOCUMENTO //
////////////////////////////
//LV_BOLLA_HANDLER: handler di bolla, carica le righe contratto sulle bolle, preparando la struttura del documento
bool TGestione_bolle_msk::lv_bolla_handler(TMask_field& f, KEY k)
{
bool ok = true;
@ -146,12 +269,12 @@ bool TGestione_bolle_msk::lv_bolla_handler(TMask_field& f, KEY k)
case F_DATADOC: ok = data_hndl( f, k ); break;
default: break;
}
TDocumento_mask& dmsk = (TDocumento_mask&)f.mask();
if (ok && k == K_TAB && f.focusdirty())
if (ok && k == K_TAB && ((dmsk.insert_mode() && f.to_check(k, true)) || f.focusdirty()))
{
f.set_focusdirty(false);
TDocumento_mask& dmsk = (TDocumento_mask&)f.mask();
TDocumento& doc = dmsk.doc();
static long stcodcf = 0, stcodcont = 0;
@ -209,16 +332,17 @@ bool TGestione_bolle_msk::lv_bolla_handler(TMask_field& f, KEY k)
//recupero i dati di interesse dalla riga del contratto e li inserisco sullo sheet
const TString80 codart = rcont.get(LVRCONDV_CODART).as_string();
//instanzio una cache sulla tabella del magazzino
const TRectype& anamag = cache().get(LF_ANAMAG,codart);
TString4 causale = rcont.get(LVRCONDV_CAUSLAV).as_string();
if (causale.blank())
if (causale.blank() || causale == "000")
{
TConfig* configlv = new TConfig(CONFIG_DITTA,"lv");
causale = configlv->get("CAUSLAV");
}
}
//instanzio una cache sulle anagrafice di magazzino
const TRectype& anamag = cache().get(LF_ANAMAG,codart);
rdoc.put(RDOC_CODART,codart);
rdoc.put(RDOC_CODARTMAG,codart);
@ -226,6 +350,7 @@ bool TGestione_bolle_msk::lv_bolla_handler(TMask_field& f, KEY k)
rdoc.put(RDOC_DESCR,anamag.get(ANAMAG_DESCR));
rdoc.put(RDOC_UMQTA,rcont.get(LVRCONDV_UM).as_string());
rdoc.put(RDOC_CODAGG1,causale);
rdoc.put(RDOC_CODIVA,anamag.get(ANAMAG_CODIVA));
//elaborazione per il prezzo: o lo prendo dalle righe contratto, o dall'anagrafica magazzino
const TString& sconto = rcont.get(LVRCONDV_SCONTPERC).as_string();
@ -236,7 +361,7 @@ bool TGestione_bolle_msk::lv_bolla_handler(TMask_field& f, KEY k)
prezzo = rcont.get(LVRCONDV_PREZZO).as_real();
else
prezzo = anamag.get_real(ANAMAG_COSTSTD);
rdoc.put(RDOC_PREZZO, prezzo);
rdoc.put(RDOC_PREZZO, prezzo);
}
dmsk.doc2mask(false);
@ -253,6 +378,202 @@ bool TGestione_bolle_msk::lv_bolla_handler(TMask_field& f, KEY k)
return ok;
}
///////////////////////
// HANDLER DI RIGA //
///////////////////////
//LV_RITIRATO_HANDLER: handler sul campo ritirato, che copia nel campo consegnato
//lo stesso valore eventualmente arrotondato e aggiorna il campo "dotazione odierna" (sempre)
//e il campo "dotazione temporanea" (se la causale è giusta)
bool TGestione_bolle_msk::lv_ritirato_handler(TMask_field& f, KEY k)
{
if (f.to_check(k) && !f.empty())
{
TMask& msk = f.mask();
real ritirato = f.get();
if (msk.field(FR_QTA).enabled() && msk.field(FR_QTA).empty())
{
arrotonda(msk,ritirato);
msk.set(FR_QTA,ritirato);
}
//gestione campi dotazione odierna e dotazione temporanea
TSheet_field* sheet = msk.get_sheet();
TDocumento_mask& dmask = (TDocumento_mask&)sheet->mask();
TRiga_documento& rdoc = dmask.doc()[sheet->selected()+1];
rdoc.put(RDOC_QTAGG1,ritirato);
TGiac_per_cli& giac = gbapp().giacenza();
long dotod = giac.giac_att(rdoc, true);
msk.set(FR_JOLLY1, dotod);
//instanzio una cache sulla tabella delle causali
TString4 causale = rdoc.get(RDOC_CODAGG1);
const TRectype& cau = cache().get("&CAU", causale);
//movimento o meno la dotazione temporanea a seconda di cosa prevede la causale
if (cau.get_bool("B0") || cau.get_bool("B1"))
{
const TRectype& caumagr = cache().get("%CAU", cau.get(cau.get_bool("B0") ? "S1": "S2"));
TString4 str = caumagr.get("S2").mid(32,2);
if (atoi(str) != ZERO)
{
long dotmp = giac.giac_att(rdoc, false);
msk.set(FR_JOLLY2, dotmp);
}
}
sheet->force_update();
}
return true;
}
//LV_CONSEGNATO_HANDLER: per adesso è solo un segna - posto
bool TGestione_bolle_msk::lv_consegnato_handler(TMask_field& f, KEY k)
{
bool ok = true;
switch(f.dlg())
{
case FR_QTA: ok = qta_handler( f, k ); break;
default: break;
}
//gestione campi dotazione odierna e dotazione temporanea
TSheet_field* sheet = msk.get_sheet();
TDocumento_mask& dmask = (TDocumento_mask&)sheet->mask();
TRiga_documento& rdoc = dmask.doc()[sheet->selected()+1];
rdoc.put(RDOC_QTAGG1,ritirato);
TGiac_per_cli& giac = gbapp().giacenza();
long dotod = giac.giac_att(rdoc, true);
msk.set(FR_JOLLY1, dotod);
//instanzio una cache sulla tabella delle causali
TString4 causale = rdoc.get(RDOC_CODAGG1);
const TRectype& cau = cache().get("&CAU", causale);
//movimento o meno la dotazione temporanea a seconda di cosa prevede la causale
if (cau.get_bool("B0") || cau.get_bool("B1"))
{
const TRectype& caumagr = cache().get("%CAU", cau.get(cau.get_bool("B0") ? "S1": "S2"));
TString4 str = caumagr.get("S2").mid(32,2);
if (atoi(str) != ZERO)
{
long dotmp = giac.giac_att(rdoc, false);
msk.set(FR_JOLLY2, dotmp);
}
}
sheet->force_update();
return ok;
}
//LV_CODART_HANDLER: handler sul campo codice articolo, che carica la causale relativa all'articolo
//e controlla se l'articolo che si sta inserendo fa parte della dotazione del cliente
bool TGestione_bolle_msk::lv_codart_handler(TMask_field& f, KEY k)
{
bool ok = true;
switch(f.dlg())
{
case FR_CODART: ok = codart_handler( f, k ); break;
default: break;
}
if (ok && (k == K_ENTER || k == K_TAB))
{
TMask& msk = f.mask();
const TString& codart = msk.get(FR_CODART);
if (codart.full())
{
TGestione_bolle_msk& dmsk = (TGestione_bolle_msk&) msk.get_sheet()->mask();
//recupero dal documento i dati di interesse per recuperare...
//...i dati dalla riga contratto
const long codcf = dmsk.get_long(F_CODCF);
const int indsped = dmsk.get_int(F_CODINDSP);
TDate datadoc = dmsk.get_date(F_DATADOC);
if (!datadoc.ok())
datadoc = TODAY;
const TLaundry_contract cont(codcf, indsped, datadoc);
const TRectype& rcont = cont.row(codart);
//cerco la causale relativa all'articolo; se non la trovo prendo quella standard
TString4 causale = rcont.get(LVRCONDV_CAUSLAV);
if (causale.blank() || causale == "000")
{
TConfig* configlv = new TConfig(CONFIG_DITTA,"lv");
causale = configlv->get("CAUSLAV");
}
//controllo se si vuole aggiungere un eventuale nuovo articolo al contratto
if (rcont.empty() &&
yesno_box(TR("L'articolo in esame non fa parte della dotazione standard di questo cliente."
"Si desidera aggiungerla ai contratti?")))
cont.edit();
}
}
return ok;
}
//LV_CAUSALE_HANDLER: handler che abilita e/o disabilita i campi di consegnato e ritirato in base alla causale
//e tenendo conto se l'articolo è bloccato o meno
bool TGestione_bolle_msk::lv_causale_handler(TMask_field& f, KEY k)
{
if (f.to_check(k, true))
{
//leggo la causale che ho scritto nella riga corrente dello sheet
TString4 causale = f.get();
if (causale.full())
{
TMask& msk = f.mask();
//leggo il codart che ho scritto nella riga corrente delle sheet
const TString& codart = msk.get(FR_CODART);
//recupero i dati di interesse dalla testata per poter trovare il contratto
TDocumento_mask& dmsk = (TDocumento_mask&) msk.get_sheet()->mask();
const long codcf = dmsk.get_long(F_CODCF);
const int indsped = dmsk.get_int(F_CODINDSP);
TDate datadoc = dmsk.get_date(F_DATADOC);
if (!datadoc.ok())
datadoc = TODAY;
//trovo il contratto utlizzato e la riga contratto specifica che mi serve
const TLaundry_contract cont(codcf, indsped, datadoc);
const TRectype& rcont = cont.row(codart);
//instanzio una cache sulla tabella delle causali
const TRectype& cau = cache().get("&CAU", causale);
//abilito o disabilito azzerandolo il campo "Ritirato" a seconda di cosa prevede la causale
if (cau.get_bool("B0"))
msk.field(FR_QTAGG1).enable(true);
else
{
msk.field(FR_QTAGG1).set((long)0);
msk.field(FR_QTAGG1).disable();
}
//abilito o disabilito azzerandolo il campo "Consegnato" a seconda di cosa prevede la causale
//ATTENZIONE: questo campo risulta sempre disabilitato se l'articolo è bloccato
if (cau.get_bool("B1") && rcont.get(LVRCONDV_ARTBLOC).empty())
msk.field(FR_QTA).enable(true);
else
{
msk.field(FR_QTA).set((long)0);
msk.field(FR_QTA).disable();
}
}
}
return true;
}
//metodo che setta gli handler sui campi di riga
void TGestione_bolle_msk::user_set_row_handler(TMask& rm, short field, int index)
{
switch(index)
@ -260,10 +581,12 @@ void TGestione_bolle_msk::user_set_row_handler(TMask& rm, short field, int index
case 4101: rm.set_handler(field, lv_ritirato_handler); break;
case 4102: rm.set_handler(field, lv_consegnato_handler); break;
case 4103: rm.set_handler(field, lv_codart_handler); break;
case 4104: rm.set_handler(field, lv_causale_handler); break;
default : TDocumento_mask::user_set_row_handler(rm, field, index); break;
}
}
//metodo che setta l'handler di bolla
void TGestione_bolle_msk::user_set_handler( short fieldid, int index)
{
switch(index)
@ -278,20 +601,10 @@ TGestione_bolle_msk::TGestione_bolle_msk(const char* tipodoc) : TDocumento_mask(
sfield(F_SHEET).set_nav_column(FR_QTA, FR_QTAGG1);
sfield(F_SHEET).set_auto_append();
}
// Definizione della classe dell'applicazione motore
class TGestione_bolle_app : public TMotore_application
{
protected:
virtual TMask* get_mask( int mode );
virtual int write( const TMask& m );
virtual int rewrite( const TMask& m );
public:
TGestione_bolle_app() {}
};
inline TGestione_bolle_app& gbapp() { return (TGestione_bolle_app &) main_app(); };
//////////////////////////////////////////
//// CLASSE TGESTIONE_BOLLE_APP ////
//////////////////////////////////////////
//ridefinisco il metodo get_mask delle TMotore_application
TMask* TGestione_bolle_app::get_mask( int mode )
@ -318,17 +631,17 @@ TMask* TGestione_bolle_app::get_mask( int mode )
return TMotore_application::get_mask(mode);
}
#define FOR_EACH_DOC_ROW_BACK(d, r, row) const TRiga_documento* row = NULL; for (int r = d.rows(); r > 0 && (row = &d[r]) != NULL; r--)
//ridefinisco il metodo write delle TMotore_application
int TGestione_bolle_app::write( const TMask& m )
{
TDocumento_mask& mask = (TDocumento_mask&) m;
TDocumento& d = mask.doc();
for (int r = d.rows() ; r > 0 ; r--)
FOR_EACH_DOC_ROW_BACK(d, r, row)
{
const TRiga_documento& dr = d[r];
if (dr.get_int(RDOC_QTA) == 0 && dr.get_int(RDOC_QTAGG1) == 0)
if (row->get_int(RDOC_QTA) == 0 && row->get_int(RDOC_QTAGG1) == 0)
d.destroy_row(r,true);
}
@ -341,17 +654,46 @@ int TGestione_bolle_app::rewrite( const TMask& m )
TDocumento_mask& mask = (TDocumento_mask&) m;
TDocumento& d = mask.doc();
for (int r = d.rows() ; r > 0 ; r--)
FOR_EACH_DOC_ROW_BACK(d, r, row)
{
const TRiga_documento& dr = d[r];
if (dr.get_int(RDOC_QTA) == 0 && dr.get_int(RDOC_QTAGG1) == 0)
if (row->get_int(RDOC_QTA) == 0 && row->get_int(RDOC_QTAGG1) == 0)
d.destroy_row(r,true);
}
return TMotore_application::rewrite(m);
}
//ridefinisco il metodo read della TMotore_application
int TGestione_bolle_app::read(TMask& m)
{
const int err = TMotore_application::read(m);
TDocumento_mask& mask = (TDocumento_mask&) m;
TDocumento& d = mask.doc();
_giac.reset(d);
FOR_EACH_DOC_ROW_BACK(d, r, row)
_giac.load_row((TRiga_documento&)*row);
return err;
}
//ridefinisco il metodo init_insert_mode della TMotore_application
void TGestione_bolle_app::init_insert_mode(TMask &m)
{
TDocumento_mask& mask = (TDocumento_mask&) m;
TDocumento& d = mask.doc();
_giac.reset(d);
return TMotore_application::init_insert_mode(m);
}
//metodo che mi restituisce la giac
TGiac_per_cli& TGestione_bolle_app::giacenza()
{
return _giac;
}
int lv3100( int argc, char* argv[])
{
TGestione_bolle_app a;

View File

@ -35,9 +35,10 @@ OCFPI = S_DISABILITATO //100
COFI = S_NON_VISIBILE //100
STATOPAIV = S_NON_VISIBILE //100
PAIVA = S_NON_VISIBILE //100
RICALT = S_NORMALE //100
GOLEM = S_NORMALE //100
GRRECAPITO = S_NASCOSTO //100
INDCF = S_NON_VISIBILE //100
INDCF = S_NON_VISIBILE //100
CIVCF = S_NON_VISIBILE //100
LOCALITACF = S_NON_VISIBILE //100
CAPCF = S_NON_VISIBILE //100
@ -102,8 +103,8 @@ DENCOMSP = S_DISABILITATO //900
PROVCOMSP = S_DISABILITATO //900
STATOSP = S_DISABILITATO //900
DESSTATOSP = S_DISABILITATO //900
DATADOCRIF = S_NORMALE //1000
NUMDOCRIF = S_NOCHECK //1000
DATADOCRIF = S_NORMALE //1000
NUMDOCRIF = S_NOCHECK //1000
CODAGVIS = S_NASCOSTO //1110
DESAGVIS = S_NASCOSTO //1110
CODAG = S_NORMALE //1100
@ -152,17 +153,17 @@ UMPNETTO = S_NORMALE //2700
PNETTO = S_NORMALE //2700
DESUMPNETTO = S_NASCOSTO //2700
NCOLLI = S_NORMALE //2800
CAUSMAG = S_OBBLIGATORIO // 2900
CAUSMAGC = S_DISABILITATO // 2900
DESCRMAG = S_NORMALE // 2900
DESCRMAGC = S_DISABILITATO // 2900
CODCMS = S_NORMALE // 3000
DESCRCMS = S_NORMALE // 3000
FASCMS = S_NORMALE // 3000
DESCRFAS = S_NORMALE // 3000
BLANK = S_DISABILITATO // 4000
CODNOTE = S_NORMALE // 2500
NOTECLI = S_NOCHECK // 2500
CAUSMAG = S_OBBLIGATORIO //2900
CAUSMAGC = S_DISABILITATO //2900
DESCRMAG = S_NORMALE //2900
DESCRMAGC = S_DISABILITATO //2900
CODCMS = S_NORMALE //3000
DESCRCMS = S_NORMALE //3000
FASCMS = S_NORMALE //3000
DESCRFAS = S_NORMALE //3000
BLANK = S_DISABILITATO //4000
CODNOTE = S_NORMALE //2500
NOTECLI = S_NOCHECK //2500
[DEFAULT]
Default(0)=F_CAUSTRASP|VEN
@ -173,7 +174,7 @@ Col(1)=FR_LIV1
Col(2)=FR_LIV2
Col(3)=FR_LIV3
Col(4)=FR_LIV4
Col(5)=FR_DESCR|30
Col(5)=FR_DESCR||30
Col(6)=FR_UMQTA
Col(7)=FR_CAULAV|Caus.|4
Col(8)=FR_RITIRO|Ritirato|10

8
lv/lvrig21.inc Executable file
View File

@ -0,0 +1,8 @@
NUMBER FR_JOLLY1 5
BEGIN
PROMPT 2 13 "Dot.od "
END
NUMBER FR_JOLLY2 5
BEGIN
PROMPT 20 13 "Dot.temp "
END

View File

@ -5,8 +5,9 @@ CAMPICALC=
IMPONIBILE=IMPNS
[HANDLERS]
NHANDLER = 3
NHANDLER = 4
1 = 133|4101
2 = 112|4102
3 = 105|4103
4 = 152|4104

View File

@ -1,4 +1,4 @@
#include "verigdef.h"
#include "..\ve\verigdef.h"
#define FULL_SCREEN
// else
@ -16,7 +16,7 @@ DEFINE_FIELD(CODART)
DEFINE_FIELD(DESCRART)
DEFINE_FIELD(UMQTA)
DEFINE_FIELD(QTA)
F_POS(QTA, 21, 9,"Consegnato " )
F_POS(QTA, 21, 10,"Consegnato " )
F_DEC(QTA, 0)
DEFINE_FIELD(PREZZO)
F_POS(PREZZO, 47, 9,"Prezzo " )
@ -27,9 +27,9 @@ F_POS(PERCPROV, 42, 11,"Provvigione" )
DEFINE_FIELD(CODIVA)
DEFINE_FIELD(DESIVA)
DEFINE_FIELD(CAULAV)
F_POS(CAULAV, 47, 10,"Causale Lavanderie " )
F_POS(CAULAV, 47, 10,"Caus. Lavanderie " )
DEFINE_FIELD(RITIRO)
F_POS(RITIRO, 21, 10,"Ritirato " )
F_POS(RITIRO, 21, 9,"Ritirato " )
F_DEC(RITIRO, 0)
DEFINE_FIELD(NCOLLI)
DEFINE_FIELD(PNETTO)
@ -43,12 +43,8 @@ DEFINE_FIELD(CODDEPC)
F_POS(CODDEPC, 2, 16,"Deposito ")
DEFINE_FIELD(DESDEPC)
F_POS(DESDEPC, 22, 16,"")
DEFINE_FIELD(JOLLY1)
F_POS(JOLLY1, 21, 11, "Dot.od. ")
DEFINE_FIELD(JOLLY2)
F_POS(JOLLY2, 21, 12, "Dot.Temp. ")
#define USR_PAGE_1 "..\lv\lvrig21.inc"
#include "verig.uml"
#include "..\ve\verig.uml"