Aggiunto metodo TArticolo_giacenza::riporta_saldi().
Corretto il cast a const char* di _codice (e' un TRecfield*) Corretta visualizzazione finestra azzeramento saldi nella rebuild_balances(). Corretto ritorno nelle funzioni find_mag() e find_storico() git-svn-id: svn://10.65.10.50/trunk@5768 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
053fc81929
commit
dde8b847a6
22
mg/mglib.h
22
mg/mglib.h
@ -62,11 +62,17 @@ typedef enum {
|
|||||||
char * Nome_valorizz[];
|
char * Nome_valorizz[];
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
valorizz_ultcos , valorizz_mediacos , valorizz_przlist ,
|
valorizz_costmedio,
|
||||||
valorizz_coststd , valorizz_costmedio ,
|
valorizz_ultcos,
|
||||||
valorizz_FIFOa , valorizz_LIFOa ,
|
valorizz_mediacos,
|
||||||
valorizz_FIFO , valorizz_LIFO,
|
valorizz_przlist,
|
||||||
valorizz_FIFOr , valorizz_LIFOr
|
valorizz_coststd,
|
||||||
|
valorizz_FIFOa,
|
||||||
|
valorizz_LIFOa,
|
||||||
|
valorizz_FIFO,
|
||||||
|
valorizz_LIFO,
|
||||||
|
valorizz_FIFOr,
|
||||||
|
valorizz_LIFOr
|
||||||
} TTipo_valorizz;
|
} TTipo_valorizz;
|
||||||
|
|
||||||
class TArticolo : public TMultiple_rectype
|
class TArticolo : public TMultiple_rectype
|
||||||
@ -126,6 +132,12 @@ public:
|
|||||||
TRecord_array & mag(const char * annoes) const;
|
TRecord_array & mag(const char * annoes) const;
|
||||||
TRecord_array & storico(const char * annoesrif) const;
|
TRecord_array & storico(const char * annoesrif) const;
|
||||||
|
|
||||||
|
// La seguente funzione riporta le rimanenze finali dell'esercizio oldes come
|
||||||
|
// rimanenze iniziali dell'esercizio newes, valorizzando secondo il tipo passato
|
||||||
|
// Si suppone che i saldi siano coerenti con i movimenti (effettuare una rebuild_balances()
|
||||||
|
// di oldes.
|
||||||
|
bool riporta_saldi(const char * oldes, const char* newes, const TTipo_valorizz tipo, const char * catven ,const char * codlist);
|
||||||
|
|
||||||
real ultimo_costo(const char * annoes) const;
|
real ultimo_costo(const char * annoes) const;
|
||||||
real media_costi(const char * annoes) const;
|
real media_costi(const char * annoes) const;
|
||||||
real prezzo_listino(const char * annoes, const char * catven ,const char * codlist) const;
|
real prezzo_listino(const char * annoes, const char * catven ,const char * codlist) const;
|
||||||
|
@ -89,7 +89,7 @@ const TString & TArticolo::get_str(const char* fieldname) const
|
|||||||
void TArticolo::set_body_key(TRectype & rowrec)
|
void TArticolo::set_body_key(TRectype & rowrec)
|
||||||
{
|
{
|
||||||
const int logicnum = rowrec.num();
|
const int logicnum = rowrec.num();
|
||||||
const char * codice = (const char *) _codice;
|
const char * codice = (const char *) (*_codice);
|
||||||
|
|
||||||
switch (logicnum)
|
switch (logicnum)
|
||||||
{
|
{
|
||||||
@ -109,7 +109,7 @@ void TArticolo::set_body_key(TRectype & rowrec)
|
|||||||
|
|
||||||
int TArticolo::read(TRectype & rec, word op, word lockop)
|
int TArticolo::read(TRectype & rec, word op, word lockop)
|
||||||
{
|
{
|
||||||
if (op == _isequal && lockop == _nolock &&strcmp(rec.get(ANAMAG_CODART), (const char *) _codice) == 0)
|
if (op == _isequal && lockop == _nolock && strcmp (rec.get(ANAMAG_CODART), (const char *) (*_codice)) == 0)
|
||||||
return NOERR;
|
return NOERR;
|
||||||
|
|
||||||
*_codice = rec.get(ANAMAG_CODART);
|
*_codice = rec.get(ANAMAG_CODART);
|
||||||
@ -160,7 +160,7 @@ void TArticolo::update_ultcosti(real costo,TDate data)
|
|||||||
bool TArticolo::unlock()
|
bool TArticolo::unlock()
|
||||||
{
|
{
|
||||||
bool rv;
|
bool rv;
|
||||||
if (*(const char *)_codice)
|
if (*((const char *)*_codice))
|
||||||
{
|
{
|
||||||
TLocalisamfile anag(LF_ANAMAG);
|
TLocalisamfile anag(LF_ANAMAG);
|
||||||
anag.curr()=*this;
|
anag.curr()=*this;
|
||||||
@ -298,7 +298,7 @@ int TArticolo_giacenza::find_mag(const char * annoes, const char * codmag, const
|
|||||||
TRecord_array & rmag = mag(annoes);
|
TRecord_array & rmag = mag(annoes);
|
||||||
const int last = rmag.last_row();
|
const int last = rmag.last_row();
|
||||||
|
|
||||||
if (from <= last)
|
if (last > 0 && from <= last)
|
||||||
{
|
{
|
||||||
const int codmag_len = codmag ? strlen(codmag) : 0;
|
const int codmag_len = codmag ? strlen(codmag) : 0;
|
||||||
const int livello_len = livello ? strlen(livello) : 0;
|
const int livello_len = livello ? strlen(livello) : 0;
|
||||||
@ -323,7 +323,7 @@ int TArticolo_giacenza::find_storico(const char * annoesrif, const char * annoes
|
|||||||
TRecord_array & rsto = storico(annoesrif);
|
TRecord_array & rsto = storico(annoesrif);
|
||||||
const int last = rsto.last_row();
|
const int last = rsto.last_row();
|
||||||
|
|
||||||
if (from <= last)
|
if (last > 0 && from <= last)
|
||||||
{
|
{
|
||||||
const int codmag_len = codmag ? strlen(codmag) : 0;
|
const int codmag_len = codmag ? strlen(codmag) : 0;
|
||||||
|
|
||||||
@ -355,6 +355,75 @@ TRecord_array & TArticolo_giacenza::storico(const char * annoesrif) const
|
|||||||
|
|
||||||
HIDDEN int last_esercizio = -1;
|
HIDDEN int last_esercizio = -1;
|
||||||
|
|
||||||
|
bool TArticolo_giacenza::riporta_saldi(const char * oldes, const char* newes, const TTipo_valorizz tipo, const char* catven, const char* codlis)
|
||||||
|
{
|
||||||
|
TString codes(newes), mag, liv;
|
||||||
|
TRecord_array& rec_arr = TArticolo_giacenza::mag(oldes);
|
||||||
|
const int last = rec_arr.last_row();
|
||||||
|
real rim, val, giac, inpf, proc, icl, acl;
|
||||||
|
|
||||||
|
rec_arr.renum_key(MAG_ANNOES, codes); // Rinumera
|
||||||
|
for (int r = last;r > 0 ; r = rec_arr.pred_row(r)) // Scorre le righe
|
||||||
|
{
|
||||||
|
TRectype& rec = rec_arr[r];
|
||||||
|
mag = rec.get(MAG_CODMAG);
|
||||||
|
liv = rec.get(MAG_LIVELLO);
|
||||||
|
giac = rec.get_real(MAG_GIAC);
|
||||||
|
inpf = rec.get_real(MAG_PRODFIN);
|
||||||
|
proc = rec.get_real(MAG_PRODCOMP);
|
||||||
|
acl = rec.get_real(MAG_ACL);
|
||||||
|
icl = rec.get_real(MAG_INCL);
|
||||||
|
rim = giac + inpf - proc + acl - icl;
|
||||||
|
switch (tipo)
|
||||||
|
{
|
||||||
|
case valorizz_costmedio:
|
||||||
|
val = costo_medio(oldes, mag, liv);
|
||||||
|
break;
|
||||||
|
case valorizz_ultcos:
|
||||||
|
val = ultimo_costo(oldes);
|
||||||
|
break;
|
||||||
|
case valorizz_mediacos:
|
||||||
|
val = media_costi(oldes);
|
||||||
|
break;
|
||||||
|
case valorizz_przlist:
|
||||||
|
val = prezzo_listino(oldes, catven, codlis);
|
||||||
|
break;
|
||||||
|
case valorizz_coststd:
|
||||||
|
val = costo_standard(oldes);
|
||||||
|
break;
|
||||||
|
case valorizz_FIFOa:
|
||||||
|
val = FIFO_annuale(oldes, mag, liv);
|
||||||
|
break;
|
||||||
|
case valorizz_LIFOa:
|
||||||
|
val = LIFO_annuale(oldes, mag, liv);
|
||||||
|
break;
|
||||||
|
case valorizz_FIFO:
|
||||||
|
val = FIFO(oldes, mag, liv);
|
||||||
|
break;
|
||||||
|
case valorizz_LIFO:
|
||||||
|
val = LIFO(oldes, mag, liv);
|
||||||
|
break;
|
||||||
|
case valorizz_FIFOr:
|
||||||
|
val = FIFO_ragionieristico(oldes, mag, liv);
|
||||||
|
break;
|
||||||
|
case valorizz_LIFOr:
|
||||||
|
val = LIFO_ragionieristico(oldes, mag, liv);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
rec.put(MAG_RIM, rim); rec.put(MAG_VALRIM, val);
|
||||||
|
rec.zero(MAG_ACQ); rec.zero(MAG_VALACQ);
|
||||||
|
rec.zero(MAG_ENT); rec.zero(MAG_VALENT);
|
||||||
|
rec.zero(MAG_VEN); rec.zero(MAG_VALVEN);
|
||||||
|
rec.zero(MAG_USC); rec.zero(MAG_VALUSC);
|
||||||
|
rec.zero(MAG_SCARTI);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scrive il pastrocchio (eventualmente sovrascrive)
|
||||||
|
return rec_arr.write(TRUE) == NOERR;
|
||||||
|
}
|
||||||
|
|
||||||
real TArticolo_giacenza::ultimo_costo(const char * annoes) const
|
real TArticolo_giacenza::ultimo_costo(const char * annoes) const
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1386,6 +1455,8 @@ bool rebuild_balances(const TString16 annoes/*, bool reset_giac*/)
|
|||||||
TLocalisamfile mag(LF_MAG);
|
TLocalisamfile mag(LF_MAG);
|
||||||
// Il flag di reset delle giacenze viene impostato in base alla chiusura dell'esercizio
|
// Il flag di reset delle giacenze viene impostato in base alla chiusura dell'esercizio
|
||||||
// precedente
|
// precedente
|
||||||
|
// Aggiorna il cazzillo per caricare eventuali date di chiusura e altre amenita' simili
|
||||||
|
_esercizi.update();
|
||||||
const int pred_es = _esercizi.pred(atoi(annoes));
|
const int pred_es = _esercizi.pred(atoi(annoes));
|
||||||
const bool reset_giac = pred_es != 0 ? _esercizi.esercizio(pred_es).chiusura_mag() != TDate(NULLDATE) : TRUE;
|
const bool reset_giac = pred_es != 0 ? _esercizi.esercizio(pred_es).chiusura_mag() != TDate(NULLDATE) : TRUE;
|
||||||
if (reset_giac) {
|
if (reset_giac) {
|
||||||
@ -1393,14 +1464,16 @@ bool rebuild_balances(const TString16 annoes/*, bool reset_giac*/)
|
|||||||
mag.put("ANNOES",annoes);
|
mag.put("ANNOES",annoes);
|
||||||
mag.read(_isgteq);
|
mag.read(_isgteq);
|
||||||
TString information;
|
TString information;
|
||||||
TIndwin idle(40,"", FALSE);
|
//TIndwin idle(40,"Azzeramento saldi in corso...", FALSE);
|
||||||
|
TProgind idle(40,"Azzeramento saldi in corso...", FALSE,FALSE);
|
||||||
while (!mag.eof() && annoes==mag.get("ANNOES"))
|
while (!mag.eof() && annoes==mag.get("ANNOES"))
|
||||||
{
|
{
|
||||||
TString currcode(mag.get("CODART"));
|
TString currcode(mag.get("CODART"));
|
||||||
TArticolo articolo(currcode);
|
TArticolo articolo(currcode);
|
||||||
information="Azzeramento saldi";
|
//information="Azzeramento saldi articolo: ";
|
||||||
information << articolo.codice();
|
//information << articolo.codice();
|
||||||
idle.set_text(information);
|
//idle.set_text(information);
|
||||||
|
//do_events();
|
||||||
if (articolo.lock_and_prompt())
|
if (articolo.lock_and_prompt())
|
||||||
{
|
{
|
||||||
while (!mag.eof() && currcode==mag.get("CODART"))
|
while (!mag.eof() && currcode==mag.get("CODART"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user