Patch level : 12.0 896
Files correlati : ve0.exe ve1.exe ve1.exe ve5,exe ve6.exe tutti i profili Commento to : Gestione conai
This commit is contained in:
parent
fd54d70535
commit
99eeea09a7
src/mg
@ -340,21 +340,15 @@ class TArticolo_conai : TObject
|
||||
{
|
||||
private:
|
||||
const TString _codart;
|
||||
// Categoria -> Sottocategoria + peso
|
||||
std::map<TString, std::map<TString, real>> _catsotpes;
|
||||
TArray _sc;
|
||||
TArray _peso;// Categoria -> Sottocategoria + peso
|
||||
public:
|
||||
const std::map<TString, std::map<TString, real>>& get_map() { return _catsotpes; }
|
||||
const std::map<TString, real>* get_scat(const TString& cat);
|
||||
real get_peso(const TString& cat, const TString& scat);
|
||||
real get_peso(const TString& fcat) { return get_peso(fcat.left(2), fcat.right(2)); }
|
||||
const TString & get_scat(int i) {return _sc.objptr(i) != NULL ? (const TString &)_sc[i] : EMPTY_STRING;}
|
||||
const real get_peso(int i) {return _peso.objptr(i) != NULL ? (const real &)_peso[i] : ZERO;}
|
||||
|
||||
TArticolo_conai(const TString& codart);
|
||||
};
|
||||
|
||||
#define FOR_EACH_CONAI_CAT(_art_con, _cat) const auto& _map_conai = ac.get_map(); \
|
||||
for(const auto& _cat : _map_conai)
|
||||
#define FOR_EACH_CONAI_SOTTOCAT(_art_con, _cat, _sottocat) FOR_EACH_CONAI_CAT(_art_con, _cat) for(const auto& _sottocat : (_cat).second)
|
||||
|
||||
// *******************************
|
||||
// LIBRERIA DI utility del magazzino
|
||||
// *******************************
|
||||
|
@ -1882,10 +1882,12 @@ TArticolo_conai::TArticolo_conai(const TString& codart)
|
||||
int err = conart.read(_isgteq);
|
||||
while (err == NOERR && _codart == conart.get(CONART_CODART))
|
||||
{
|
||||
const TString& categoria = conart.get(CONART_CATEGORIA);
|
||||
const TString& sottocat = conart.get(CONART_SOTTOCAT);
|
||||
const int i = conart.get_int(CONART_NRIGA) - 1;
|
||||
TString categoria = conart.get(CONART_CATEGORIA);
|
||||
categoria << conart.get(CONART_SOTTOCAT);
|
||||
_sc.add(categoria, i);
|
||||
const real& peso = conart.get_real(CONART_PESO);
|
||||
_catsotpes[categoria][sottocat] = peso;
|
||||
_peso.add(peso, i);
|
||||
err = conart.next();
|
||||
}
|
||||
}
|
||||
@ -1894,51 +1896,30 @@ TArticolo_conai::TArticolo_conai(const TString& codart)
|
||||
* La risposta è semplice, tutti i programmi che non verranno aggiornati da queste modifiche (es. Importazione Pack/SKNT)
|
||||
* scrivono li e quindi va tenuta la compatibilità
|
||||
*/
|
||||
if (_sc.empty())
|
||||
{
|
||||
TLocalisamfile anamag(LF_ANAMAG);
|
||||
TRectype ranamag(LF_ANAMAG);
|
||||
TRectype & ranamag = anamag.curr();
|
||||
|
||||
ranamag.put(ANAMAG_CODART, _codart);
|
||||
if (ranamag.read(anamag) == NOERR) // Non dovrebbe mai fallire
|
||||
{
|
||||
const TString& conaisc = ranamag.get(ANAMAG_CONAISC);
|
||||
int startcon = -1;
|
||||
// Mi serve sapere dove iniziano i campi del conai
|
||||
const RecFieldDes* fs = ranamag.rec_des().Fd;
|
||||
for (int i = 0; i < ranamag.rec_des().NFields && startcon == -1; i++)
|
||||
startcon = strcmp(fs[i].Name, ANAMAG_CONACC) == 0 ? i : -1;
|
||||
|
||||
if (startcon > -1)
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
for (int i = 0; i < conaisc.len() / 4; i++)
|
||||
{
|
||||
const TString& con = conaisc.mid(i * 4, 4);
|
||||
const TString& categoria = con.left(2);
|
||||
const TString& sottocat = con.right(2);
|
||||
if (con.blank()) continue;
|
||||
const TString& con = conaisc.mid(i * 4, 4);
|
||||
const TString& categoria = con.left(2);
|
||||
const TString& sottocat = con.right(2);
|
||||
if (con.blank()) continue;
|
||||
|
||||
_catsotpes[categoria][sottocat] = ranamag.get_real(fs[startcon + i].Name);
|
||||
}
|
||||
_sc.add(con);
|
||||
_peso.add(ranamag.get_real(conai2anamagfld(categoria)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const std::map<TString, real>* TArticolo_conai::get_scat(const TString& cat)
|
||||
{
|
||||
if (_catsotpes.find(cat) != _catsotpes.end())
|
||||
return &_catsotpes[cat];
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
real TArticolo_conai::get_peso(const TString& cat, const TString& scat)
|
||||
{
|
||||
real peso = -UNO;
|
||||
if (_catsotpes.find(cat) != _catsotpes.end() && _catsotpes[cat].find(scat) != _catsotpes[cat].end())
|
||||
peso = _catsotpes[cat][scat];
|
||||
return peso;
|
||||
}
|
||||
|
||||
// causali
|
||||
|
||||
int TCausale_magazzino::sgn(TTipo_saldomag tiposaldo) const
|
||||
|
Loading…
x
Reference in New Issue
Block a user