Patch level : 12.0 897
Files correlati : ve2.exe tp0.exe tutti i profili Commento to : Gestione conai
This commit is contained in:
parent
94dd6e348f
commit
d255f2e26d
@ -185,8 +185,8 @@ class TArticolo_pack : public TRectype
|
||||
{
|
||||
TString _cust_code, _paper_comp;
|
||||
|
||||
TString4 _conai_scat[CONAI_CLASSES];
|
||||
real _conai_peso[CONAI_CLASSES];
|
||||
TArray _conai_scat;
|
||||
TArray _conai_peso;
|
||||
|
||||
public:
|
||||
void set_customer_code(const TString& cc) { _cust_code = cc; }
|
||||
@ -195,10 +195,11 @@ public:
|
||||
void set_paper_composition(const TString& pc) { _paper_comp = pc; }
|
||||
const TString& paper_composition() const { return _paper_comp; }
|
||||
|
||||
const TString& conai_subclass(TCONAI_class cc) const { CHECK_CONAI(cc); return _conai_scat[cc]; }
|
||||
const real& conai_weight(TCONAI_class cc) const { CHECK_CONAI(cc); return _conai_peso[cc]; }
|
||||
bool set_conai(TCONAI_class cc, const TString& scat, const real& weight);
|
||||
|
||||
const TString& conai_subclass(int i) const { return _conai_scat.objptr(i) ? (const TString &)_conai_scat[i] : EMPTY_STRING; }
|
||||
const real& conai_weight(int i) const { return _conai_peso.objptr(i) ? (const real &) _conai_peso[i] : ZERO; }
|
||||
bool set_conai(const TString& scat, const real& weight);
|
||||
void reset_conai();
|
||||
|
||||
TArticolo_pack(const TRectype& anamag);
|
||||
TArticolo_pack();
|
||||
};
|
||||
|
@ -2,34 +2,38 @@
|
||||
|
||||
#include "../cg/cfban.h"
|
||||
#include "../mg/codcorr.h"
|
||||
#include "../include/conart.h"
|
||||
|
||||
// Assegna sottocategoria e peso di una classe CONAI solo se non vuoti
|
||||
bool TArticolo_pack::set_conai(TCONAI_class cc, const TString& scat, const real& weight)
|
||||
bool TArticolo_pack::set_conai(const TString& scat, const real& weight)
|
||||
{
|
||||
const bool ok = conai_configured_class(cc) && scat.full(); // && !weight.is_zero();
|
||||
if (ok)
|
||||
const bool ok = scat.full(); // && !weight.is_zero();
|
||||
|
||||
if (ok)
|
||||
{
|
||||
_conai_scat[cc] = scat;
|
||||
_conai_peso[cc] = weight;
|
||||
_conai_scat.add(scat);
|
||||
_conai_peso.add(weight);
|
||||
}
|
||||
else
|
||||
_conai_scat[cc] = EMPTY_STRING;
|
||||
return ok;
|
||||
}
|
||||
|
||||
void TArticolo_pack::reset_conai()
|
||||
{
|
||||
_conai_scat.destroy();
|
||||
_conai_peso.destroy();
|
||||
}
|
||||
|
||||
TArticolo_pack::TArticolo_pack(const TRectype& anamag) : TRectype(anamag)
|
||||
{
|
||||
FOR_EACH_CONFIGURED_CONAI_CLASS(cc)
|
||||
set_conai(cc, EMPTY_STRING, ZERO);
|
||||
FOR_EACH_CONFIGURED_CONAI_CLASS(cc)
|
||||
TArticolo_conai ac(get(ANAMAG_CODART));
|
||||
|
||||
reset_conai();
|
||||
for (int i = 0; i < FR_CMAX; i++)
|
||||
{
|
||||
const TFieldref anamag_sotcat(conai_sottocat_name(cc, LF_ANAMAG), LF_ANAMAG);
|
||||
const TFieldref anamag_weight(conai_peso_name(cc, LF_ANAMAG), LF_ANAMAG);
|
||||
const TString4 sotcat = ac.get_scat(i); // Usually CA40
|
||||
const real peso = ac.get_peso(i); // Should be > 0
|
||||
|
||||
const TString4 sotcat = anamag_sotcat.read(anamag); // Usually CA40
|
||||
const real peso = anamag_weight.read(anamag); // Should be > 0
|
||||
|
||||
set_conai(cc, sotcat, peso); // Validates all parameters
|
||||
set_conai(sotcat, peso); // Validates all parameters
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,44 +124,43 @@ int TCache_art::get_extra_info(const char* key, TArticolo_pack& art)
|
||||
<< "FROM Articles_environmentTax\n"
|
||||
<< "WHERE Articles_environmentTax.ArticleCode=" << article_code << ';';
|
||||
TODBC_recordset envtax(qry);
|
||||
for (bool et = envtax.move_first(); et; et = envtax.move_next())
|
||||
|
||||
art.reset_conai();
|
||||
for (bool et = envtax.move_first(); et; et = envtax.move_next())
|
||||
{
|
||||
const TString& sc = envtax.get(0u).as_string();
|
||||
const real wkg = envtax.get(1).as_real();
|
||||
const TCONAI_class cc = conai_str2class(sc);
|
||||
if (cc == TCONAI_class::CONAI_NONE)
|
||||
{
|
||||
TString err = "ATTENZIONE!! Classe conai errata per articolo "; err << article_code;
|
||||
warning_box(err);
|
||||
}
|
||||
if (art.set_conai(cc, sc, wkg))
|
||||
if (art.set_conai(sc, wkg))
|
||||
info = 2;
|
||||
}
|
||||
|
||||
if (info == 2) // Ho trovato dati sul CONAI
|
||||
{
|
||||
bool update = false;
|
||||
FOR_EACH_CONFIGURED_CONAI_CLASS(cc)
|
||||
{
|
||||
const TFieldref anamag_sotcat(conai_sottocat_name(cc, LF_ANAMAG), LF_ANAMAG);
|
||||
const TFieldref anamag_weight(conai_peso_name(cc, LF_ANAMAG), LF_ANAMAG);
|
||||
const TString4 sotcat = anamag_sotcat.read(art);
|
||||
const TString16 peso = anamag_weight.read(art); // Faccio i confronti su stringa per evitare decimali impazziti
|
||||
if (sotcat != art.conai_subclass(cc) || peso != art.conai_weight(cc).string())
|
||||
{
|
||||
anamag_sotcat.write(art.conai_subclass(cc), art);
|
||||
anamag_weight.write(art.conai_weight(cc).string(), art);
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
if (update) // Aggiorno anagrafica se necessario
|
||||
{
|
||||
_anamag.curr() = art;
|
||||
test_rewrite(_anamag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TRecord_array conart(article_code, LF_CONART);
|
||||
TRectype conrec(LF_CONART);
|
||||
int r = 1;
|
||||
|
||||
conart.destroy_rows();
|
||||
// Infine salvo i nuovi dati in conart
|
||||
for (int i = 0; i < FR_CMAX; i++)
|
||||
{
|
||||
const TString4 sotcat = art.conai_subclass(i);
|
||||
const real peso = art.conai_weight(i); // Faccio i confronti su stringa per evitare decimali impazziti
|
||||
|
||||
if (sotcat.full())
|
||||
{
|
||||
conrec.zero();
|
||||
conrec.put(CONART_CODART, article_code);
|
||||
conrec.put(CONART_NRIGA, r++);
|
||||
conrec.put(CONART_CATEGORIA, sotcat.left(2));
|
||||
conrec.put(CONART_SOTTOCAT, sotcat.mid(2));
|
||||
conrec.put(CONART_PESO, peso);
|
||||
conart.add_row(conrec);
|
||||
}
|
||||
}
|
||||
conart.write(true);
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
@ -176,25 +179,27 @@ TObject* TCache_art::key2obj(const char* key)
|
||||
const TString& desc = get_str("ArtDesc");
|
||||
_anamag.put(ANAMAG_DESCR, desc);
|
||||
|
||||
TString4 conai_class = get_str("SubclassCode");
|
||||
if (conai_class.blank())
|
||||
{
|
||||
conai_class = get_str("ClassCode");
|
||||
if (conai_class.full())
|
||||
conai_class << 99;
|
||||
}
|
||||
// Basic CONAI info
|
||||
|
||||
// Basic CONAI info
|
||||
const TCONAI_class cc = conai_str2class(conai_class);
|
||||
if (conai_configured_class(cc))
|
||||
{
|
||||
const TFieldref fld_sc(conai_sottocat_name(cc, LF_ANAMAG), LF_ANAMAG);
|
||||
fld_sc.write(conai_class, _anamag.curr());
|
||||
{
|
||||
TFast_isamfile conart(LF_CONART);
|
||||
TString4 sotcat = get_str("SubclassCode");
|
||||
|
||||
const TFieldref fld_wt(conai_peso_name(cc, LF_ANAMAG), LF_ANAMAG);
|
||||
fld_wt.write(get_real_str("WeightETUnit"), _anamag.curr());
|
||||
}
|
||||
if (sotcat.blank())
|
||||
{
|
||||
sotcat = get_str("ClassCode");
|
||||
if (sotcat.full())
|
||||
sotcat << 99;
|
||||
}
|
||||
|
||||
conart.zero();
|
||||
conart.put(CONART_CODART, key);
|
||||
conart.put(CONART_NRIGA, 1);
|
||||
conart.put(CONART_CATEGORIA, sotcat.left(2));
|
||||
conart.put(CONART_SOTTOCAT, sotcat.mid(2));
|
||||
conart.put(CONART_PESO, get_real_str("WeightETUnit"));
|
||||
conart.write_rewrite(true);
|
||||
}
|
||||
const long gruconto = get_long("AccountCode");
|
||||
const long sottoconto = get_long("AccountSubCode");
|
||||
_anamag.put(ANAMAG_GRUPPOV, gruconto / 1000);
|
||||
@ -827,27 +832,28 @@ bool TPack_ddt::trasferisci()
|
||||
if (conai_scheme == 1)
|
||||
{
|
||||
// La sottocategoria della bolla prevale su quella anagrafica
|
||||
int i = 0;
|
||||
if (conai_subclass.len() == 4)
|
||||
{
|
||||
rdoc.put(conai_sottocat_name(ct, LF_RIGHEDOC), conai_subclass);
|
||||
rdoc.put(conai_sottocat_name(1), conai_subclass);
|
||||
peso_imballo_ddt = real(get_real_str("WeightETUnit"));
|
||||
if (peso_imballo_ddt.is_zero())
|
||||
peso_imballo_ddt = peso_imballo_anamag;
|
||||
}
|
||||
if (conai_subclass.blank())
|
||||
{
|
||||
FOR_EACH_CONFIGURED_CONAI_CLASS(cc)
|
||||
for (int i = 1; i < FR_CMAX; i++)
|
||||
{
|
||||
const TString& cs = art.conai_subclass(cc); // Codice sottocategoria su ANAMAG
|
||||
const TString& cs = art.conai_subclass(i - 1); // Codice sottocategoria su ANAMAG
|
||||
|
||||
if (cs.full()) // la presenza della sottoclasse implica anche un peso positivo
|
||||
{
|
||||
const real& weight = art.conai_weight(cc); // Peso imballo su ANAMAG
|
||||
const real& weight = art.conai_weight(i - 1); // Peso imballo su ANAMAG
|
||||
|
||||
rdoc.put(conai_sottocat_name(cc, LF_RIGHEDOC), cs);
|
||||
rdoc.put(conai_peso_name(cc, LF_RIGHEDOC), weight); // ex QTAGG1
|
||||
rdoc.put(conai_esenzione_name(cc, LF_RIGHEDOC),
|
||||
cfven.get(conai_esenzione_name(cc, LF_CFVEN))); // ex QTAGG2
|
||||
rdoc.put(conai_sottocat_name(i + 1), cs);
|
||||
rdoc.put(conai_peso_name(i + 1), weight); // ex QTAGG1
|
||||
rdoc.put(conai_esenzione_name(conai_str2class(cs.left(2)), LF_RIGHEDOC),
|
||||
cfven.get(conai_esenzione_name(conai_str2class(cs.left(2)), LF_CFVEN))); // ex QTAGG2
|
||||
peso_imballo_anamag += weight;
|
||||
pesi_anamag++;
|
||||
}
|
||||
@ -856,18 +862,18 @@ bool TPack_ddt::trasferisci()
|
||||
}
|
||||
else
|
||||
{
|
||||
FOR_EACH_CONFIGURED_CONAI_CLASS(cc)
|
||||
for (int i = 1; i < FR_CMAX; i++)
|
||||
{
|
||||
const TString& cs = art.conai_subclass(cc); // Codice sottocategoria su ANAMAG
|
||||
|
||||
const TString& cs = art.conai_subclass(i - 1); // Codice sottocategoria su ANAMAG
|
||||
|
||||
if (cs.full()) // la presenza della sottoclasse implica anche un peso positivo
|
||||
{
|
||||
const real& weight = art.conai_weight(cc); // Peso imballo su ANAMAG
|
||||
const real& weight = art.conai_weight(i - 1); // Peso imballo su ANAMAG
|
||||
|
||||
rdoc.put(conai_sottocat_name(cc, LF_RIGHEDOC), cs);
|
||||
rdoc.put(conai_peso_name(cc, LF_RIGHEDOC), weight); // ex QTAGG1
|
||||
rdoc.put(conai_esenzione_name(cc, LF_RIGHEDOC),
|
||||
cfven.get(conai_esenzione_name(cc, LF_CFVEN))); // ex QTAGG2
|
||||
rdoc.put(conai_sottocat_name(i + 1), cs);
|
||||
rdoc.put(conai_peso_name(i + 1), weight); // ex QTAGG1
|
||||
rdoc.put(conai_esenzione_name(conai_str2class(cs.left(2)), LF_RIGHEDOC),
|
||||
cfven.get(conai_esenzione_name(conai_str2class(cs.left(2)), LF_CFVEN))); // ex QTAGG2
|
||||
peso_imballo_anamag += weight;
|
||||
pesi_anamag++;
|
||||
}
|
||||
@ -875,14 +881,13 @@ bool TPack_ddt::trasferisci()
|
||||
// La sottocategoria della bolla prevale su quella anagrafica impostata sopra
|
||||
if (conai_subclass.len() == 4)
|
||||
{
|
||||
rdoc.put(conai_sottocat_name(ct, LF_RIGHEDOC), conai_subclass);
|
||||
rdoc.put(conai_sottocat_name(1), conai_subclass);
|
||||
peso_imballo_ddt = real(get_real_str("WeightETUnit"));
|
||||
if (peso_imballo_ddt.is_zero())
|
||||
peso_imballo_ddt = peso_imballo_anamag;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if (pesi_anamag > 1) // Con imballi composti da vari materiali devo riportare o riproporzionare
|
||||
// {
|
||||
// Arrotondo la eventuale differenza di pesi al grammo
|
||||
@ -891,19 +896,20 @@ bool TPack_ddt::trasferisci()
|
||||
if (!diff.is_zero() && !peso_imballo_ddt.is_zero())
|
||||
{
|
||||
TGeneric_distrib d(peso_imballo_ddt, 3);
|
||||
FOR_EACH_CONFIGURED_CONAI_CLASS(cc)
|
||||
if (rdoc.get(conai_sottocat_name(cc, LF_RIGHEDOC)).full())
|
||||
d.add(art.conai_weight(cc));
|
||||
FOR_EACH_CONFIGURED_CONAI_CLASS(cc)
|
||||
if (rdoc.get(conai_sottocat_name(cc, LF_RIGHEDOC)).full())
|
||||
rdoc.put(conai_peso_name(cc), d.get());
|
||||
|
||||
for (int i = 1; i < FR_CMAX; i++)
|
||||
if (rdoc.get(conai_sottocat_name(i + 1)).full())
|
||||
d.add(art.conai_weight(i - 1));
|
||||
for (int i = 1; i < FR_CMAX; i++)
|
||||
if (rdoc.get(conai_sottocat_name(i + 1)).full())
|
||||
rdoc.put(conai_peso_name(i - 1), d.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Il peso in bolla coincide con quello in anagrafica: devo riportarli
|
||||
FOR_EACH_CONFIGURED_CONAI_CLASS(cc)
|
||||
if (rdoc.get(conai_sottocat_name(cc, LF_RIGHEDOC)).full())
|
||||
rdoc.put(conai_peso_name(cc), art.conai_weight(cc));
|
||||
for (int i = 0; i < FR_CMAX; i++)
|
||||
if (rdoc.get(conai_sottocat_name(i + 1)).full())
|
||||
rdoc.put(conai_peso_name(i + 1), art.conai_weight(i));
|
||||
}
|
||||
|
||||
rdoc.put("FAMILY", get_str("FamilyCode")); // Uso campo virtuale RG1:FAMILY
|
||||
|
@ -255,7 +255,7 @@ void TDichiarazione_CONAI::scrivi_csv_doc_speciale(const TDocumento& doc, TDichi
|
||||
//prende il cliente ed i suoi dati
|
||||
const TCli_for& clifo = doc.clifor();
|
||||
TString80 clifo_paiv;
|
||||
//cerca la percentuale di esenzione conai sul cliente (controllo)
|
||||
//cerca la percentuale di esenzione conai sul cliente (controllo
|
||||
const real cfven_perc_conai = clifo_conai(clifo, conai_specie, clifo_paiv);
|
||||
|
||||
const int nrighe = doc.rows();
|
||||
@ -563,13 +563,19 @@ void TDichiarazione_CONAI::elabora(const TMask& mask) const
|
||||
//..le quantita' etc) e le righe generate da CONAI (per avere i prezzi)
|
||||
|
||||
TString16 scat_fieldname = conai_sottocat_name(conai_specie);
|
||||
|
||||
if (scat_fieldname.blank())
|
||||
return;
|
||||
scat_fieldname.insert("RG1:");
|
||||
TString16 peso_fieldname = conai_peso_name(conai_specie);
|
||||
|
||||
if (peso_fieldname.blank())
|
||||
return;
|
||||
peso_fieldname.insert("RG1:");
|
||||
|
||||
TString query;
|
||||
query << "USE RDOC";
|
||||
query << "\nSELECT BETWEEN(33.DATADOC,#DADATA,#ADATA)&&BETWEEN(33.TIPODOC,#TIPODOC,#TIPODOC)&&(" << scat_fieldname <<"!=\"\")";
|
||||
query << "\nSELECT BETWEEN(33.DATADOC,#DADATA,#ADATA)&&BETWEEN(33.TIPODOC,#TIPODOC,#TIPODOC)&&((" << scat_fieldname <<"!=\"\")||(" << peso_fieldname << "!=0.00))";
|
||||
query << "\nJOIN DOC INTO PROVV==PROVV ANNO==ANNO CODNUM==CODNUM NDOC==NDOC";
|
||||
query << "\nFROM PROVV=D ANNO=#ANNO CODNUM=#CODNUM";
|
||||
query << "\nTO PROVV=D ANNO=#ANNO CODNUM=#CODNUM";
|
||||
@ -583,6 +589,8 @@ void TDichiarazione_CONAI::elabora(const TMask& mask) const
|
||||
rdoc.set_var("#ADATA", datafin);
|
||||
//rdoc.set_var("#CODART", codart);
|
||||
|
||||
|
||||
|
||||
//creazione del csv recordset che verra' riempito dai record del recordset rdoc
|
||||
TDichiarazione_CONAI_csv_recordset* csv = new TDichiarazione_CONAI_csv_recordset;
|
||||
|
||||
@ -611,6 +619,7 @@ void TDichiarazione_CONAI::elabora(const TMask& mask) const
|
||||
{
|
||||
if (!pi.add_status())
|
||||
break;
|
||||
|
||||
const long ndoc = rdoc.get(RDOC_NDOC).as_int();
|
||||
if (ndoc != last_ndoc)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user