Patch level : 12.0 412
Files correlati : ve2.exe md1.exe ve0.exe ve1.exe ve5.exe ve6.exe Modificato il modo di aggiornare le giacenze di magazzino: 1) Viene bloccato il record di giacenza singolo. 2) l'aggiornamento dell'anagrafica non scrive più le giacenze, l'aggiornamento si può attivare premendo Shift-F12 3) l'aggiornamento dall'anagrafica di magazzino aggiorna solo i record cambiati di giacenza e di giacenza per cliente. git-svn-id: svn://10.65.10.50/branches/R_10_00@23901 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
a250aef70a
commit
5ed80b3ffb
@ -25,7 +25,6 @@ class TMask_movmag : public TMask
|
|||||||
real proposed_price(const char * codart, real quant,const char * causrig);
|
real proposed_price(const char * codart, real quant,const char * causrig);
|
||||||
int _autorows;
|
int _autorows;
|
||||||
TArray _old_qta;
|
TArray _old_qta;
|
||||||
int _check_giac_neg;
|
|
||||||
bool _shift_f12;
|
bool _shift_f12;
|
||||||
TMagazzini _magazzini;
|
TMagazzini _magazzini;
|
||||||
|
|
||||||
@ -155,7 +154,6 @@ TMask_movmag::TMask_movmag(TMov_mag * m_m) : TMask("mg1100")
|
|||||||
sm.field(F_DESDEP).enable(gd);
|
sm.field(F_DESDEP).enable(gd);
|
||||||
ss.enable_column(ss.cid2index(F_CODDEP),gd);
|
ss.enable_column(ss.cid2index(F_CODDEP),gd);
|
||||||
_autorows = prassid.get_int("AUTOROWS", "mg");
|
_autorows = prassid.get_int("AUTOROWS", "mg");
|
||||||
_check_giac_neg = prassid.get_int("CHECK_GIAC", "mg");
|
|
||||||
if (!prassid.get_bool("MOV_INDSPED", "mg"))
|
if (!prassid.get_bool("MOV_INDSPED", "mg"))
|
||||||
{
|
{
|
||||||
hide(F_INDSPED);
|
hide(F_INDSPED);
|
||||||
@ -360,6 +358,7 @@ bool TMask_movmag::notify_righe(TSheet_field& ss, int r, KEY key)
|
|||||||
codcaus = ss.mask().get(F_CODCAUS);
|
codcaus = ss.mask().get(F_CODCAUS);
|
||||||
const TCausale_magazzino cau(codcaus);
|
const TCausale_magazzino cau(codcaus);
|
||||||
const int check_giac_neg = cau.get_int("I4");
|
const int check_giac_neg = cau.get_int("I4");
|
||||||
|
|
||||||
if (check_giac_neg)
|
if (check_giac_neg)
|
||||||
{
|
{
|
||||||
real giac = ss.sheet_mask().get_real(F_GIAC);
|
real giac = ss.sheet_mask().get_real(F_GIAC);
|
||||||
|
1569
src/mg/mglib.h
1569
src/mg/mglib.h
File diff suppressed because it is too large
Load Diff
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "anamag.h"
|
#include "anamag.h"
|
||||||
#include "mag.h"
|
#include "mag.h"
|
||||||
|
#include "clifogiac.h"
|
||||||
#include "movmag.h"
|
#include "movmag.h"
|
||||||
#include "rmovmag.h"
|
#include "rmovmag.h"
|
||||||
|
|
||||||
@ -288,6 +289,100 @@ bool TArticolo::lock_and_prompt(word lockop)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TArticolo::unlock_giac(TRectype& magrec)
|
||||||
|
{
|
||||||
|
bool rv = false;
|
||||||
|
if (magrec.full())
|
||||||
|
{
|
||||||
|
TLocalisamfile mag(LF_MAG);
|
||||||
|
rv = mag.read(magrec, _isequal,_unlock) == NOERR;
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TArticolo::lock_and_prompt_giac(TRectype& magrec, word lockop)
|
||||||
|
{
|
||||||
|
TLocalisamfile f(LF_MAG);
|
||||||
|
|
||||||
|
f.setkey(2);
|
||||||
|
int err = magrec.read(f, _isequal, lockop != _nolock ? _testandlock : _nolock);
|
||||||
|
|
||||||
|
if (err != NOERR)
|
||||||
|
{
|
||||||
|
TString mess;
|
||||||
|
|
||||||
|
if (err == _iskeyerr)
|
||||||
|
{
|
||||||
|
mess << TR("Il codice articolo '") << _codice << TR("' non e' valido");
|
||||||
|
|
||||||
|
TTimed_skipbox bbox((const char *)mess, 3);
|
||||||
|
|
||||||
|
bbox.run();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (lockop != _nolock)
|
||||||
|
{
|
||||||
|
while (err == _islocked)
|
||||||
|
{
|
||||||
|
mess << TR("Il record di giacenza\ndell'articolo '") << _codice << TR(" anno ") << magrec.get_int(MAG_ANNOES) << TR(" magazzino ") << (const char *) magrec.get(MAG_CODMAG) << TR("' e' gia' usato da un altro programma.");
|
||||||
|
TTimed_skipbox bbox((const char *)mess, 1);
|
||||||
|
bbox.run();
|
||||||
|
err = magrec.read(f, _isequal, _testandlock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TArticolo::unlock_giac_cf(TRectype& clifo_magrec)
|
||||||
|
{
|
||||||
|
bool rv = false;
|
||||||
|
if (clifo_magrec.full())
|
||||||
|
{
|
||||||
|
TLocalisamfile clifo_mag(LF_CLIFOGIAC);
|
||||||
|
rv = clifo_mag.read(clifo_magrec, _isequal,_unlock) == NOERR;
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TArticolo::lock_and_prompt_giac_cf(TRectype& clifomagrec, word lockop)
|
||||||
|
{
|
||||||
|
TLocalisamfile f(LF_CLIFOGIAC);
|
||||||
|
|
||||||
|
f.setkey(2);
|
||||||
|
int err = clifomagrec.read(f, _isequal, lockop != _nolock ? _testandlock : _nolock);
|
||||||
|
|
||||||
|
if (err != NOERR)
|
||||||
|
{
|
||||||
|
TString mess;
|
||||||
|
|
||||||
|
if (err == _iskeyerr)
|
||||||
|
{
|
||||||
|
mess << TR("Il codice articolo '") << _codice << TR("' non e' valido");
|
||||||
|
|
||||||
|
TTimed_skipbox bbox((const char *)mess, 3);
|
||||||
|
|
||||||
|
bbox.run();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (lockop != _nolock)
|
||||||
|
{
|
||||||
|
while (err == _islocked)
|
||||||
|
{
|
||||||
|
mess << TR("Il record di giacenza\ndell'articolo '") << _codice << TR(" anno ") << clifomagrec.get_int(CLIFOGIAC_ANNOES) << TR(" magazzino ")
|
||||||
|
<< ((clifomagrec.get(CLIFOGIAC_TIPOCF) == "C") ? TR(" Cliente -") : TR(" Fornitore -"))
|
||||||
|
<< clifomagrec.get_long(CLIFOGIAC_CODCF) << TR("' e' gia' usato da un altro programma.");
|
||||||
|
|
||||||
|
TTimed_skipbox bbox((const char *)mess, 2);
|
||||||
|
|
||||||
|
bbox.run();
|
||||||
|
err = clifomagrec.read(f,_isequal,_testandlock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
int TArticolo::find_um(const char* um, int from) const
|
int TArticolo::find_um(const char* um, int from) const
|
||||||
{
|
{
|
||||||
return find(LF_UMART, UMART_UM, um, from);
|
return find(LF_UMART, UMART_UM, um, from);
|
||||||
@ -402,11 +497,13 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
TArticolo& art(const char* key) { return (TArticolo&)query(key); }
|
TArticolo& art(const char* key) { return (TArticolo&)query(key); }
|
||||||
|
void discard_art(const char* key) { TRecord_cache::discard(key); }
|
||||||
|
|
||||||
TCache_articoli();
|
TCache_articoli();
|
||||||
virtual ~TCache_articoli() { }
|
virtual ~TCache_articoli() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
HIDDEN TCache_articoli __cache_articoli;
|
||||||
|
|
||||||
TCache_articoli::TCache_articoli()
|
TCache_articoli::TCache_articoli()
|
||||||
: TRecord_cache(LF_ANAMAG, 1)
|
: TRecord_cache(LF_ANAMAG, 1)
|
||||||
@ -415,9 +512,13 @@ TCache_articoli::TCache_articoli()
|
|||||||
set_items_limit(257); // Numero primo!
|
set_items_limit(257); // Numero primo!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void refresh_article(const char* codart)
|
||||||
|
{
|
||||||
|
__cache_articoli.discard_art(codart);
|
||||||
|
}
|
||||||
|
|
||||||
TArticolo& cached_article(const char* codart)
|
TArticolo& cached_article(const char* codart)
|
||||||
{
|
{
|
||||||
HIDDEN TCache_articoli __cache_articoli;
|
|
||||||
if (codart == NULL)
|
if (codart == NULL)
|
||||||
{
|
{
|
||||||
__cache_articoli.destroy();
|
__cache_articoli.destroy();
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// oggetto TMov_Mag , multirecord del movimento di magazzino
|
// oggetto TMov_Mag , multirecord del movimento di magazzino
|
||||||
// funzione di ricostruzione saldi
|
// funzione di ricostruzione saldi
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
#include <diction.h>
|
#include <diction.h>
|
||||||
#include <progind.h>
|
#include <progind.h>
|
||||||
#include <recset.h>
|
#include <recset.h>
|
||||||
@ -596,22 +597,16 @@ bool TMov_mag::update_balances(bool lock)
|
|||||||
const TRecord_array& b = body();
|
const TRecord_array& b = body();
|
||||||
for (int i = b.last_row(); i > 0; i = b.pred_row(i)) if (causale(i).update_ultcos())
|
for (int i = b.last_row(); i > 0; i = b.pred_row(i)) if (causale(i).update_ultcos())
|
||||||
{
|
{
|
||||||
|
refresh_articolo(i);
|
||||||
|
|
||||||
const TRectype& rec = b[i];
|
const TRectype& rec = b[i];
|
||||||
TArticolo& art = articolo(i);
|
TArticolo& art = articolo(i);
|
||||||
|
const real prezzo = art.convert_to_um(rec.get_real(RMOVMAG_PREZZO), NULL, rec.get(RMOVMAG_UM), false);
|
||||||
|
const long numreg = get_long(MOVMAG_NUMREG);
|
||||||
|
|
||||||
art.set_nuovo(false);
|
art.set_nuovo(false);
|
||||||
if (art.lock_and_prompt(lock ? _testandlock : _nolock))
|
art.update_ultcosti(prezzo,get_date(MOVMAG_DATACOMP), numreg, i);
|
||||||
{
|
art.rewrite();
|
||||||
const real prezzo = art.convert_to_um(rec.get_real(RMOVMAG_PREZZO), NULL, rec.get(RMOVMAG_UM), false);
|
|
||||||
const long numreg = get_long(MOVMAG_NUMREG);
|
|
||||||
art.update_ultcosti(prezzo,get_date(MOVMAG_DATACOMP), numreg, i);
|
|
||||||
art.rewrite();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (lock)
|
|
||||||
art.unlock();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_saldi_mag.items() > 0)
|
if (_saldi_mag.items() > 0)
|
||||||
@ -623,6 +618,7 @@ bool TMov_mag::update_balances(bool lock)
|
|||||||
TString_array keys_mag;
|
TString_array keys_mag;
|
||||||
_saldi_mag.get_keys(keys_mag);
|
_saldi_mag.get_keys(keys_mag);
|
||||||
keys_mag.sort();
|
keys_mag.sort();
|
||||||
|
int err = NOERR;
|
||||||
|
|
||||||
TString msg;
|
TString msg;
|
||||||
msg << TR("Aggiornamento saldi del movimento ") << get(MOVMAG_NUMREG)
|
msg << TR("Aggiornamento saldi del movimento ") << get(MOVMAG_NUMREG)
|
||||||
@ -636,28 +632,25 @@ bool TMov_mag::update_balances(bool lock)
|
|||||||
TArticolo_giacenza& art = cached_article_balances(codart);
|
TArticolo_giacenza& art = cached_article_balances(codart);
|
||||||
const TCausale_magazzino& caus = cached_causale_magazzino(saldo.codcaus());
|
const TCausale_magazzino& caus = cached_causale_magazzino(saldo.codcaus());
|
||||||
|
|
||||||
if (art.lock_and_prompt(lock ? _testandlock : _nolock))
|
giac_putkey(magcurr, saldo);
|
||||||
|
err = art.lock_and_prompt_giac(magcurr, lock ? _testandlock : _nolock);
|
||||||
|
if (err != NOERR)
|
||||||
{
|
{
|
||||||
|
TRecord_array& sld = art.mag(saldo.codes());
|
||||||
|
const int nriga = sld.rows() + 1;
|
||||||
giac_putkey(magcurr, saldo);
|
giac_putkey(magcurr, saldo);
|
||||||
int err = mag.read();
|
magcurr.put(MAG_NRIGA, nriga);
|
||||||
if (err != NOERR)
|
sld.add_row(magcurr);
|
||||||
{
|
err = mag.write();
|
||||||
TRecord_array& sld = art.mag(saldo.codes());
|
CHECKD(err == NOERR, "Errore di write:" , err);
|
||||||
const int nriga = sld.rows() + 1;
|
}
|
||||||
giac_putkey(magcurr, saldo);
|
update_balances(magcurr, saldo, caus);
|
||||||
magcurr.put(MAG_NRIGA, nriga);
|
err = mag.rewrite();
|
||||||
sld.add_row(magcurr);
|
if (err != NOERR)
|
||||||
err = mag.write();
|
updated_bal = false;
|
||||||
CHECKD(err == NOERR, "Errore di write:" , err);
|
|
||||||
}
|
|
||||||
update_balances(magcurr, saldo, caus);
|
|
||||||
err = mag.rewrite();
|
|
||||||
if (err != NOERR)
|
|
||||||
updated_bal = false;
|
|
||||||
|
|
||||||
if (lock)
|
if (lock)
|
||||||
art.unlock();
|
art.unlock_giac(magcurr);
|
||||||
}
|
|
||||||
pi.add_status();
|
pi.add_status();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -672,43 +665,41 @@ bool TMov_mag::update_balances(bool lock)
|
|||||||
|
|
||||||
_saldi_mag_clifo.get_keys(keys_clifo);
|
_saldi_mag_clifo.get_keys(keys_clifo);
|
||||||
keys_clifo.sort();
|
keys_clifo.sort();
|
||||||
|
int err = NOERR;
|
||||||
|
|
||||||
for (TToken_string* curr_key = (TToken_string*)keys_clifo.first_item();
|
for (TToken_string* curr_key = (TToken_string*)keys_clifo.first_item();
|
||||||
curr_key != NULL; curr_key = (TToken_string*)keys_clifo.succ_item())
|
curr_key != NULL; curr_key = (TToken_string*)keys_clifo.succ_item())
|
||||||
{
|
{
|
||||||
TSaldo_mag_clifo & saldo=(TSaldo_mag_clifo &)_saldi_mag_clifo[*curr_key];
|
TSaldo_mag_clifo & saldo=(TSaldo_mag_clifo &)_saldi_mag_clifo[*curr_key];
|
||||||
|
const TCodice_articolo& codart = saldo.codart();
|
||||||
|
|
||||||
TArticolo_giacenza & art = cached_article_balances(saldo.codart());
|
TArticolo_giacenza & art = cached_article_balances(codart);
|
||||||
|
giac_putkey_clifo(clifomag_curr, saldo);
|
||||||
if (art.lock_and_prompt(lock ? _testandlock : _nolock))
|
err = art.lock_and_prompt_giac_cf(clifomag_curr, lock ? _testandlock : _nolock);
|
||||||
|
if (err != NOERR)
|
||||||
{
|
{
|
||||||
|
// non trovato: aggiungo
|
||||||
|
clifomag.setkey(1);
|
||||||
giac_putkey_clifo(clifomag_curr, saldo);
|
giac_putkey_clifo(clifomag_curr, saldo);
|
||||||
if (clifomag.read() != NOERR)
|
clifomag_curr.put(CLIFOGIAC_NRIGA, 999);
|
||||||
{
|
if (clifomag.read(_isgteq) == NOERR)
|
||||||
// non trovato: aggiungo
|
clifomag.prev();
|
||||||
clifomag.setkey(1);
|
int nriga = 1;
|
||||||
giac_putkey_clifo(clifomag_curr, saldo);
|
if (clifomag_curr.get_int(CLIFOGIAC_ANNOES) == saldo.codes() &&
|
||||||
clifomag_curr.put(CLIFOGIAC_NRIGA, 999);
|
clifomag_curr.get_char(CLIFOGIAC_TIPOCF) == saldo.tipocf() &&
|
||||||
if (clifomag.read(_isgteq) == NOERR)
|
clifomag_curr.get(CLIFOGIAC_CODCF) == saldo.codcf() &&
|
||||||
clifomag.prev();
|
clifomag_curr.get(CLIFOGIAC_CODART) == saldo.codart() &&
|
||||||
int nriga = 1;
|
clifomag_curr.get(CLIFOGIAC_LIVELLO ) == saldo.livello())
|
||||||
if (clifomag_curr.get_int(CLIFOGIAC_ANNOES) == saldo.codes() &&
|
nriga = clifomag_curr.get_int(CLIFOGIAC_NRIGA) + 1;
|
||||||
clifomag_curr.get_char(CLIFOGIAC_TIPOCF) == saldo.tipocf() &&
|
giac_putkey_clifo(clifomag_curr, saldo);
|
||||||
clifomag_curr.get(CLIFOGIAC_CODCF) == saldo.codcf() &&
|
clifomag_curr.put(CLIFOGIAC_NRIGA, nriga);
|
||||||
clifomag_curr.get(CLIFOGIAC_CODART) == saldo.codart() &&
|
clifomag.write();
|
||||||
clifomag_curr.get(CLIFOGIAC_LIVELLO ) == saldo.livello())
|
}
|
||||||
nriga = clifomag_curr.get_int(CLIFOGIAC_NRIGA) + 1;
|
update_balances_clifo(clifomag_curr, saldo);
|
||||||
giac_putkey_clifo(clifomag_curr, saldo);
|
clifomag.rewrite();
|
||||||
clifomag_curr.put(CLIFOGIAC_NRIGA, nriga);
|
|
||||||
clifomag.write();
|
|
||||||
clifomag.setkey(2);
|
|
||||||
}
|
|
||||||
update_balances_clifo(clifomag_curr, saldo);
|
|
||||||
clifomag.rewrite();
|
|
||||||
|
|
||||||
if (lock)
|
if (lock)
|
||||||
art.unlock();
|
art.unlock_giac_cf(clifomag_curr);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_saldi_mag.destroy();
|
_saldi_mag.destroy();
|
||||||
@ -929,20 +920,34 @@ void reset_clifogiac(TRectype& rec, const TRectype& oldrec, bool closed)
|
|||||||
rec.zero(CLIFOGIAC_ORDC);
|
rec.zero(CLIFOGIAC_ORDC);
|
||||||
rec.zero(CLIFOGIAC_VALORDC);
|
rec.zero(CLIFOGIAC_VALORDC);
|
||||||
}
|
}
|
||||||
//if (closed) // Gestione che pare insensata
|
|
||||||
{
|
const bool preserve_dot = ini_get_bool(CONFIG_DITTA, "lv", "Aggcong") ||
|
||||||
rec.put(CLIFOGIAC_DOTOD, oldrec.get(CLIFOGIAC_DOTOD));
|
ini_get_bool(CONFIG_DITTA, "mg", "GESMAG");
|
||||||
rec.put(CLIFOGIAC_DOTIN, oldrec.get(CLIFOGIAC_DOTIN));
|
|
||||||
rec.put(CLIFOGIAC_DOTTM, oldrec.get(CLIFOGIAC_DOTTM));
|
if (preserve_dot)
|
||||||
}
|
{
|
||||||
/*
|
if (closed)
|
||||||
else
|
{
|
||||||
{
|
rec.add(CLIFOGIAC_DOTOD, oldrec.get_real(CLIFOGIAC_DOTOD));
|
||||||
rec.zero(CLIFOGIAC_DOTOD);
|
rec.add(CLIFOGIAC_DOTIN, oldrec.get_real(CLIFOGIAC_DOTIN));
|
||||||
rec.zero(CLIFOGIAC_DOTIN);
|
rec.add(CLIFOGIAC_DOTTM, oldrec.get_real(CLIFOGIAC_DOTTM));
|
||||||
rec.zero(CLIFOGIAC_DOTTM);
|
}
|
||||||
}
|
}
|
||||||
*/
|
else
|
||||||
|
{
|
||||||
|
if (closed)
|
||||||
|
{
|
||||||
|
rec.put(CLIFOGIAC_DOTOD, oldrec.get(CLIFOGIAC_DOTOD));
|
||||||
|
rec.put(CLIFOGIAC_DOTIN, oldrec.get(CLIFOGIAC_DOTIN));
|
||||||
|
rec.put(CLIFOGIAC_DOTTM, oldrec.get(CLIFOGIAC_DOTTM));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rec.zero(CLIFOGIAC_DOTOD);
|
||||||
|
rec.zero(CLIFOGIAC_DOTIN);
|
||||||
|
rec.zero(CLIFOGIAC_DOTTM);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user