Patch level :
Files correlati : Ricompilazione Demo : [ ] Commento : Aggiornamento prezzi GRIFFATO git-svn-id: svn://10.65.10.50/branches/R_10_00@22212 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
8ae3b85e7a
commit
3da9b353e9
14
ps/pg0002.cpp
Executable file
14
ps/pg0002.cpp
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#include <xvt.h>
|
||||||
|
|
||||||
|
#include "pg0002.h"
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
int n = argc > 1 ? atoi(argv[1]+1) : 0;
|
||||||
|
switch(n)
|
||||||
|
{
|
||||||
|
case 1: pg0002100(argc, argv); break; // Aggiornamento prezzi
|
||||||
|
default: pg0002100(argc, argv); break; // Aggiornamento prezzi
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
1
ps/pg0002.h
Executable file
1
ps/pg0002.h
Executable file
@ -0,0 +1 @@
|
|||||||
|
int pg0002100(int argc, char* argv[]); // Creazione cartellini
|
208
ps/pg0002100.cpp
Executable file
208
ps/pg0002100.cpp
Executable file
@ -0,0 +1,208 @@
|
|||||||
|
#include <applicat.h>
|
||||||
|
#include <automask.h>
|
||||||
|
#include <real.h>
|
||||||
|
#include <utility.h>
|
||||||
|
|
||||||
|
#include "pg0002100a.h"
|
||||||
|
#include <doc.h>
|
||||||
|
#include <rdoc.h>
|
||||||
|
#include "../cg/cglib01.h"
|
||||||
|
#include "../ve/velib.h"
|
||||||
|
#include "../ve/velib04.h"
|
||||||
|
|
||||||
|
// TAutomask
|
||||||
|
|
||||||
|
class TAggiorna_mask : public TAutomask
|
||||||
|
{
|
||||||
|
void serialize(bool bSave);
|
||||||
|
protected:
|
||||||
|
bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||||
|
public:
|
||||||
|
TAggiorna_mask() : TAutomask("pg0002100a") {}
|
||||||
|
virtual ~TAggiorna_mask() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
bool TAggiorna_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||||
|
{
|
||||||
|
switch (o.dlg())
|
||||||
|
{
|
||||||
|
case F_RICARICO :
|
||||||
|
if (e == fe_modify)
|
||||||
|
{
|
||||||
|
TMask & m = o.mask();
|
||||||
|
TArticolo & art = cached_article(m.get(F_CODART));
|
||||||
|
real costo(m.get(F_COSTO));
|
||||||
|
const real perc = cache().get("CVE", m.get(F_RICARICO), "R2");
|
||||||
|
real prezzo = costo * ( UNO + (perc / CENTO));
|
||||||
|
|
||||||
|
prezzo.round(TCurrency::get_firm_dec(true));
|
||||||
|
m.set(F_PREZZO, prezzo, 0x3);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case F_PREZZO :
|
||||||
|
if (e == fe_modify)
|
||||||
|
{
|
||||||
|
TMask & m = o.mask();
|
||||||
|
TArticolo & art = cached_article(m.get(F_CODART));
|
||||||
|
real prezzo(o.get());
|
||||||
|
TCodiceIVA c(art.get(ANAMAG_CODIVA));
|
||||||
|
|
||||||
|
prezzo = c.lordo(prezzo, 20);
|
||||||
|
prezzo.round(TCurrency::get_firm_dec(true));
|
||||||
|
m.set(F_PREZZOL, prezzo);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case F_PREZZOL :
|
||||||
|
if (e == fe_modify)
|
||||||
|
{
|
||||||
|
TMask & m = o.mask();
|
||||||
|
TArticolo & art = cached_article(m.get(F_CODART));
|
||||||
|
real prezzo(o.get());
|
||||||
|
TCodiceIVA c(art.get(ANAMAG_CODIVA));
|
||||||
|
|
||||||
|
c.scorpora(prezzo, 20);
|
||||||
|
prezzo.round(TCurrency::get_firm_dec(true));
|
||||||
|
m.set(F_PREZZO, prezzo);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
class TAggiorna_prezzi : public TSkeleton_application
|
||||||
|
{
|
||||||
|
TDocumento * _doc;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual const char * extra_modules() const { return "ba"; }
|
||||||
|
virtual void main_loop();
|
||||||
|
|
||||||
|
public:
|
||||||
|
const TDocumento & doc() { return *_doc; }
|
||||||
|
void aggiorna(TMask & m);
|
||||||
|
bool set_params(TMask & m);
|
||||||
|
};
|
||||||
|
|
||||||
|
// restituisce un riferimento all' applicazione
|
||||||
|
inline TAggiorna_prezzi & app() { return (TAggiorna_prezzi &) main_app();}
|
||||||
|
|
||||||
|
void TAggiorna_prezzi::aggiorna(TMask & m)
|
||||||
|
{
|
||||||
|
TSheet_field & sh = m.sfield(F_SHEET);
|
||||||
|
const int nrows = doc().physical_rows();
|
||||||
|
|
||||||
|
for (int i = 1; i <= nrows; i++)
|
||||||
|
{
|
||||||
|
const TRiga_documento & rdoc = doc()[i];
|
||||||
|
const TString & codart = rdoc.get(RDOC_CODARTMAG);
|
||||||
|
|
||||||
|
if (codart.full())
|
||||||
|
{
|
||||||
|
TToken_string & row = sh.row(-1);
|
||||||
|
|
||||||
|
row.add(codart, sh.cid2index(F_CODART));
|
||||||
|
row.add(rdoc.get(RDOC_UMQTA), sh.cid2index(F_UM));
|
||||||
|
const real costo = rdoc.get_real(RDOC_PREZZO);
|
||||||
|
row.add(costo.string(), sh.cid2index(F_COSTO));
|
||||||
|
TArticolo & art = cached_article(codart);
|
||||||
|
const TString4 ric = doc().clifor().vendite().get(CFV_CATVEN);
|
||||||
|
row.add(ric, sh.cid2index(F_RICARICO));
|
||||||
|
const real perc = cache().get("CVE", ric, "R2");
|
||||||
|
real prezzo = costo * ( UNO + (perc / CENTO));
|
||||||
|
|
||||||
|
prezzo.round(TCurrency::get_firm_dec(true));
|
||||||
|
row.add(prezzo.string(), sh.cid2index(F_PREZZO));
|
||||||
|
|
||||||
|
TCodiceIVA c(art.get(ANAMAG_CODIVA));
|
||||||
|
|
||||||
|
prezzo = c.lordo(prezzo, 20);
|
||||||
|
prezzo.round(TCurrency::get_firm_dec(true));
|
||||||
|
row.add(prezzo.string(), sh.cid2index(F_PREZZOL));
|
||||||
|
row.add(art.get(ANAMAG_DESCR), sh.cid2index(F_DESART));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m.run() == K_ENTER)
|
||||||
|
{
|
||||||
|
const int shrows = sh.items();
|
||||||
|
TLocalisamfile f(LF_UMART);
|
||||||
|
|
||||||
|
for (int i = 0; i < shrows; i++)
|
||||||
|
{
|
||||||
|
TToken_string & row = sh.row(i);
|
||||||
|
TArticolo & art = cached_article(row.get(sh.cid2index(F_CODART)));
|
||||||
|
real prezzo(row.get(sh.cid2index(F_PREZZO)));
|
||||||
|
|
||||||
|
art.convert_to_um(prezzo, EMPTY_STRING, row.get(sh.cid2index(F_UM)));
|
||||||
|
prezzo.round(TCurrency::get_firm_dec(true));
|
||||||
|
art.set_prezzo_vendita(prezzo);
|
||||||
|
art.um().row(1).rewrite(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
TDocumento & d = (TDocumento &)doc();
|
||||||
|
TElaborazione_esterna e(d.tipo().elaborazione());
|
||||||
|
|
||||||
|
d.stato(e.stato_finale_doc_iniziale()[0]);
|
||||||
|
d.rewrite();
|
||||||
|
const TFixed_string arg = argv(2);
|
||||||
|
TConfig c(arg.mid(2), "Transaction");
|
||||||
|
|
||||||
|
c.set("Result", "OUDOC");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TAggiorna_prezzi::set_params(TMask & m)
|
||||||
|
{
|
||||||
|
const TFixed_string arg = argv(2);
|
||||||
|
if ((arg[0] != '-' && arg[0] != '/') || (arg[1] != 'i' && arg[1] != 'I'))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
TString ini_name = arg.mid(2);
|
||||||
|
|
||||||
|
//controlla che il file su cui deve scrivere ci sia; se non c'é dá una segnalazione di errore
|
||||||
|
if (!fexist(ini_name))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
TString4 para; para.format("%d", LF_DOC);
|
||||||
|
TConfig ini(ini_name, para);
|
||||||
|
|
||||||
|
const char provv = ini.get(DOC_PROVV)[0];
|
||||||
|
const int anno = ini.get_int(DOC_ANNO);
|
||||||
|
const TString4 codnum = ini.get(DOC_CODNUM);
|
||||||
|
const long ndoc = ini.get_long(DOC_NDOC);
|
||||||
|
|
||||||
|
|
||||||
|
_doc = new TDocumento(provv, anno, codnum,ndoc);
|
||||||
|
|
||||||
|
m.set(F_PROVV, provv);
|
||||||
|
m.set(F_ANNO, anno);
|
||||||
|
m.set(F_CODNUM, codnum, 0x3);
|
||||||
|
m.set(F_NDOC, ndoc, 0x3);
|
||||||
|
|
||||||
|
return _doc != NULL && _doc->physical_rows() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TAggiorna_prezzi::main_loop() //definizione della member function main_loop, della classe TAggiorna_prezzi
|
||||||
|
{
|
||||||
|
open_files(LF_DOC, LF_RIGHEDOC, LF_UMART, 0);
|
||||||
|
if (argc() > 2)
|
||||||
|
{
|
||||||
|
|
||||||
|
TAggiorna_mask m;
|
||||||
|
|
||||||
|
if (set_params(m))
|
||||||
|
aggiorna(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////// Esecuzione del programma ///////////
|
||||||
|
|
||||||
|
int pg0002100(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
TAggiorna_prezzi app;
|
||||||
|
app.run(argc,argv,"Generazione etichette");
|
||||||
|
return 0;
|
||||||
|
}
|
20
ps/pg0002100a.h
Executable file
20
ps/pg0002100a.h
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#define F_CODART 101
|
||||||
|
#define F_UM 102
|
||||||
|
#define F_COSTO 103
|
||||||
|
#define F_RICARICO 104
|
||||||
|
#define F_PREZZOL 105
|
||||||
|
#define F_PREZZO 106
|
||||||
|
#define F_DESART 107
|
||||||
|
|
||||||
|
#define F_CODNUM 251
|
||||||
|
#define F_ANNO 252
|
||||||
|
#define F_PROVV 253
|
||||||
|
#define F_NDOC 254
|
||||||
|
#define F_CODDITTA 255
|
||||||
|
#define F_RAGSOCDITTA 256
|
||||||
|
#define F_SHEET 257
|
||||||
|
|
||||||
|
#define F_DESNUM 271
|
||||||
|
#define F_DESTIPODOC 272
|
||||||
|
|
||||||
|
#define F_DESCRIC 273
|
173
ps/pg0002100a.uml
Executable file
173
ps/pg0002100a.uml
Executable file
@ -0,0 +1,173 @@
|
|||||||
|
#include "pg0002100a.h"
|
||||||
|
|
||||||
|
TOOLBAR "Toolbar" 0 0 0 2
|
||||||
|
|
||||||
|
#include <stdbar.h>
|
||||||
|
|
||||||
|
ENDPAGE
|
||||||
|
|
||||||
|
PAGE "Aggiornamento Prezzi" 0 0 0 0
|
||||||
|
|
||||||
|
GROUPBOX DLG_NULL 78 3
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 1 "@bDitta"
|
||||||
|
END
|
||||||
|
|
||||||
|
NUMBER F_CODDITTA 5
|
||||||
|
BEGIN
|
||||||
|
PROMPT 3 2 "Codice "
|
||||||
|
FLAGS "FD"
|
||||||
|
USE LF_NDITTE
|
||||||
|
CHECKTYPE NORMAL
|
||||||
|
INPUT CODDITTA F_CODDITTA
|
||||||
|
OUTPUT F_RAGSOCDITTA RAGSOC
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_RAGSOCDITTA 50
|
||||||
|
BEGIN
|
||||||
|
PROMPT 17 2 "Ragione "
|
||||||
|
FLAGS "D"
|
||||||
|
END
|
||||||
|
|
||||||
|
GROUPBOX DLG_NULL 78 4
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 4 "Estremi del documento"
|
||||||
|
END
|
||||||
|
|
||||||
|
LISTBOX F_PROVV 14
|
||||||
|
BEGIN
|
||||||
|
FIELD PROVV
|
||||||
|
PROMPT 46 6 "Tipo "
|
||||||
|
ITEM "D|Definitiva "
|
||||||
|
ITEM "P|Provvisoria"
|
||||||
|
FLAGS "DPG"
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_CODNUM 4
|
||||||
|
BEGIN
|
||||||
|
PROMPT 2 5 "Numerazione "
|
||||||
|
FIELD CODNUM
|
||||||
|
HELP "Codice numerazione"
|
||||||
|
USE %NUM
|
||||||
|
INPUT CODTAB F_CODNUM
|
||||||
|
DISPLAY "Codice" CODTAB
|
||||||
|
DISPLAY "Descrizione@50" S0
|
||||||
|
OUTPUT F_CODNUM CODTAB
|
||||||
|
OUTPUT F_DESNUM S0
|
||||||
|
CHECKTYPE FORCED
|
||||||
|
FLAG "UPADG"
|
||||||
|
WARNING "Numerazione assente"
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_DESNUM 50
|
||||||
|
BEGIN
|
||||||
|
PROMPT 24 5 ""
|
||||||
|
HELP "Descrizione numerazione"
|
||||||
|
FLAGS "D"
|
||||||
|
END
|
||||||
|
|
||||||
|
NUMBER F_ANNO 4
|
||||||
|
BEGIN
|
||||||
|
PROMPT 2 6 "Esercizio "
|
||||||
|
FIELD ANNO
|
||||||
|
FLAG "APD"
|
||||||
|
END
|
||||||
|
|
||||||
|
NUMBER F_NDOC 6
|
||||||
|
BEGIN
|
||||||
|
PROMPT 24 6 "Numero "
|
||||||
|
FIELD NDOC
|
||||||
|
FLAG "RDG"
|
||||||
|
END
|
||||||
|
|
||||||
|
SPREADSHEET F_SHEET
|
||||||
|
BEGIN
|
||||||
|
PROMPT 0 8 ""
|
||||||
|
ITEM "Codice@20"
|
||||||
|
ITEM "UM@4"
|
||||||
|
ITEM "Costo@18"
|
||||||
|
ITEM "Ricarico"
|
||||||
|
ITEM "Prezzo Lordo@18"
|
||||||
|
ITEM "Prezzo@18"
|
||||||
|
ITEM "Descrizione@50"
|
||||||
|
END
|
||||||
|
|
||||||
|
ENDPAGE
|
||||||
|
|
||||||
|
ENDMASK
|
||||||
|
PAGE "Riga Documento" -1 -1 78 18
|
||||||
|
|
||||||
|
STRING F_CODART 20
|
||||||
|
BEGIN
|
||||||
|
PROMPT 4 1 "Codice articolo "
|
||||||
|
FIELD CODART
|
||||||
|
FLAGS "UD"
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_UM 20
|
||||||
|
BEGIN
|
||||||
|
PROMPT 4 3 "Unità di misura "
|
||||||
|
FIELD CODART
|
||||||
|
FLAGS "UD"
|
||||||
|
END
|
||||||
|
|
||||||
|
CURRENCY F_COSTO
|
||||||
|
BEGIN
|
||||||
|
PROMPT 4 5 "Costo "
|
||||||
|
FLAGS "D"
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_RICARICO 2
|
||||||
|
BEGIN
|
||||||
|
PROMPT 4 7 "Ricarico "
|
||||||
|
USE CVE
|
||||||
|
INPUT CODTAB F_RICARICO
|
||||||
|
DISPLAY "Codice vendita" CODTAB
|
||||||
|
DISPLAY "Descrizione@50" S0
|
||||||
|
OUTPUT F_RICARICO CODTAB
|
||||||
|
OUTPUT F_DESCRIC S0
|
||||||
|
CHECKTYPE REQUIRED
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_DESCRIC 50
|
||||||
|
BEGIN
|
||||||
|
PROMPT 25 7 ""
|
||||||
|
USE CVE KEY 2
|
||||||
|
INPUT S0 F_DESCRIC
|
||||||
|
DISPLAY "Descrizione@50" S0
|
||||||
|
DISPLAY "Codice vendita" CODTAB
|
||||||
|
COPY OUTPUT F_RICARICO
|
||||||
|
CHECKTYPE SEARCH
|
||||||
|
END
|
||||||
|
|
||||||
|
CURRENCY F_PREZZOL
|
||||||
|
BEGIN
|
||||||
|
PROMPT 4 9 "Prezzo lordo "
|
||||||
|
END
|
||||||
|
|
||||||
|
CURRENCY F_PREZZO
|
||||||
|
BEGIN
|
||||||
|
PROMPT 4 11 "Prezzo "
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_DESART 50
|
||||||
|
BEGIN
|
||||||
|
PROMPT 4 13 "Descrizione "
|
||||||
|
FLAGS "D"
|
||||||
|
END
|
||||||
|
|
||||||
|
ENDPAGE
|
||||||
|
TOOLBAR "Toolbar" 0 0 0 2
|
||||||
|
|
||||||
|
BUTTON DLG_OK 10 2
|
||||||
|
BEGIN
|
||||||
|
PROMPT -12 -1 ""
|
||||||
|
END
|
||||||
|
|
||||||
|
BUTTON DLG_CANCEL 10 2
|
||||||
|
BEGIN
|
||||||
|
PROMPT -22 -1 ""
|
||||||
|
END
|
||||||
|
|
||||||
|
ENDPAGE
|
||||||
|
ENDMASK
|
Loading…
x
Reference in New Issue
Block a user