Patch level : 12.0 no-patch
Files correlati : mg Commento : Aggiunta classe TConai_articolo per gestire il conai di un articolo specifico Implemented #56
This commit is contained in:
parent
1be4579e67
commit
02998fe78a
@ -197,6 +197,7 @@
|
||||
#define LF_FPCCAUS 177
|
||||
#define LF_FPCART 178
|
||||
#define LF_FPCADG 179
|
||||
#define LF_CONART 180
|
||||
|
||||
#define LF_EXTERNAL 1000 // Files with id >= are considered to be externals
|
||||
|
||||
|
@ -48,6 +48,8 @@
|
||||
#include "../mg/rmovmag.h"
|
||||
#endif
|
||||
|
||||
#include <map>
|
||||
|
||||
// campi comuni alla maschere di magazzino
|
||||
typedef enum
|
||||
{
|
||||
@ -330,6 +332,23 @@ void refresh_article(const char* codart);
|
||||
TArticolo& cached_article(const char* codart);
|
||||
TArticolo_giacenza& cached_article_balances(const char* codart);
|
||||
|
||||
class TArticolo_conai : TObject
|
||||
{
|
||||
private:
|
||||
const TString _codart;
|
||||
// Categoria -> Sottocategoria + peso
|
||||
std::map<TString, std::map<TString, real>> _catsotpes;
|
||||
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)); }
|
||||
|
||||
|
||||
|
||||
TArticolo_conai(const TString& codart);
|
||||
};
|
||||
|
||||
// *******************************
|
||||
// LIBRERIA DI utility del magazzino
|
||||
// *******************************
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "clifogiac.h"
|
||||
#include "movmag.h"
|
||||
#include "rmovmag.h"
|
||||
#include "conart.h"
|
||||
|
||||
// libreria per i movimenti
|
||||
class TTimed_skipbox: public TTimed_breakbox
|
||||
@ -1840,6 +1841,97 @@ TArticolo_giacenza& cached_article_balances(const char* codart)
|
||||
return __cache_articoli_giacenza.art(codart);
|
||||
}
|
||||
|
||||
const char* conai2anamagfld(const TString& conai_cat)
|
||||
{
|
||||
if (conai_cat == "AL")
|
||||
return "CONALL";
|
||||
else if (conai_cat == "AC")
|
||||
return "CONACC";
|
||||
else if (conai_cat == "CA")
|
||||
return "CONCAR";
|
||||
else if (conai_cat == "PL")
|
||||
return "CONPLA";
|
||||
else if (conai_cat == "LE")
|
||||
return "CONLEG";
|
||||
else if (conai_cat == "VE")
|
||||
return "CONVET";
|
||||
else
|
||||
return "ERROR";
|
||||
}
|
||||
|
||||
// Conai nell'articolo
|
||||
TArticolo_conai::TArticolo_conai(const TString& codart)
|
||||
: _codart(codart)
|
||||
{
|
||||
/* Devo caricarmi tutti i codici conai presenti nell'articolo
|
||||
* Cerco inizialmente la presenza dell'articolo in tabmod,
|
||||
* se non lo trovo sarà salvato nel vecchio metodo
|
||||
*/
|
||||
{
|
||||
TLocalisamfile conart(LF_CONART);
|
||||
conart.put(CONART_CODART, _codart);
|
||||
if (conart.read(_isgteq) == NOERR)
|
||||
{
|
||||
while (_codart == conart.get(CONART_CODART))
|
||||
{
|
||||
const TString& categoria = conart.get(CONART_CATEGORIA);
|
||||
const TString& sottocat = conart.get(CONART_SOTTOCAT);
|
||||
const real& peso = conart.get_real(CONART_PESO);
|
||||
_catsotpes[categoria][sottocat] = peso;
|
||||
++conart;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Vado a cercare sempre nelle vecchie tabelle dell'articolo, Perchè giovane padawan?
|
||||
* 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à
|
||||
*/
|
||||
{
|
||||
TLocalisamfile anamag(LF_ANAMAG);
|
||||
TRectype ranamag(LF_ANAMAG);
|
||||
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 < 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;
|
||||
|
||||
_catsotpes[categoria][sottocat] = ranamag.get_real(fs[startcon + i].Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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