Patch level : 10.0

Files correlati     : tp0
Ricompilazione Demo : [ ]
Commento            :
Corretta gestione nomi campi CONAI


git-svn-id: svn://10.65.10.50/trunk@19331 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2009-09-24 15:27:38 +00:00
parent be94adbc11
commit 348c0344ed
9 changed files with 144 additions and 99 deletions

View File

@ -77,7 +77,7 @@ ARTLAVCONT|1|4|0|Art. Lavacont (Lavanderie)
MANGDEST|1|3|0|Mangano destinazione (Lavanderie)
LIVPERART|8|1|0|LIvellli di giacenza per articolo
G1|11|10|0|Campi virtuali
SCACONTR|1|30|0|Sottocategorie contributo CONAI (una ogni 4 caratteri)
SCACONTR|1|24|0|Sottocategorie contributo CONAI (una ogni 4 caratteri)
USER1|1|40|0|Campo libero 1
USER2|1|20|0|Campo libero 2
USER3|1|20|0|Campo libero 3

View File

@ -434,7 +434,6 @@ void TDocumento_form::print_footer(TPrinter& pr)
for (word j = 0; j < r; j++)
pr.setfooterline(j, foot.row(j));
}
void TDocumento_form::doc_header_handler(TPrinter& pr)
@ -1392,7 +1391,15 @@ void TStampaDoc_application::print_selected(KEY k)
TPrinter& pr = printer();
if (_interattivo)
pr.set_printtype(k == 'A' ? screenvis : winprinter);
{
if (k == 'A')
pr.set_printtype(screenvis);
else
{
if (pr.printtype() != acrobatprinter)
pr.set_printtype(winprinter);
}
}
pr.open();
TProgind* pi = pr.printtype() != screenvis ?
@ -1550,7 +1557,8 @@ void TStampaDoc_application::print_documento(TDocumento_form& f)
behaviour TStampaDoc_application::on_module_change(const TString &modulo, TString &modulo_prec)
{
if (!_interattivo) return skip; // se siamo in interattivo il documento viene saltato...
if (!_interattivo)
return skip; // se siamo in interattivo il documento viene saltato...
else
{ // ...altrimenti viene chiesto all'utente il da farsi
int risp= yesnocancel_box(FR("Il modulo di carta è cambiato: inserire il modulo '%s' e premere 'Si' per continuare,"
@ -1934,9 +1942,7 @@ bool TStampaDoc_application::tipodoc_handler(TMask_field& f, KEY key)
bool TStampaDoc_application::filter_clifo(const TRelation* r)
{
const long codcf = r->lfile().get_long(CLI_CODCF);
TString16 key;
key.format("%06ld", codcf);
TString8 key; key.format("%06ld", codcf);
return app()._clifo_sel.is_key(key);
}

View File

@ -1168,8 +1168,7 @@ bool TReport_doc_app::print_loop(const TString& query, TOutput_mode mode)
case out_pdf:
case out_signed_pdf:
{
TFilename pdf;
pdf.tempdir();
TFilename pdf; pdf.tempdir();
pdf << SLASH << _anno <<'_' << _codnum << '_' << _ndoc;
pdf.ext("pdf");
if (book.export_pdf(pdf, mode == out_signed_pdf))

View File

@ -468,21 +468,26 @@ public:
// Gestione CONAI
///////////////////////////////////////////////////////////
enum TCONAI_type { CONAI_NONE=-1, CONAI_FIRST=0,
enum TCONAI_class { CONAI_NONE=-1, CONAI_FIRST=0,
CONAI_ACC=0, CONAI_ACCIAIO =0,
CONAI_ALL=1, CONAI_ALLUMINIO=1,
CONAI_CAR=2, CONAI_CARTA =2,
CONAI_PLA=3, CONAI_PLASTICA =3,
CONAI_LEG=4, CONAI_LEGNO =4,
CONAI_VET=5, CONAI_VETRO =5,
CONAI_LAST=5, CONAI_CATEGORIES=6
CONAI_LAST=5, CONAI_CLASSES=6
};
TCONAI_type conai_str2type(const char* str);
const char* conai_contr_name(TCONAI_type type);
bool conai_configured_type(TCONAI_type type);
const char* conai_peso_name(TCONAI_type type);
const char* conai_sottocat_name(TCONAI_type type);
TCONAI_class conai_str2class(const char* class_or_subclass);
const char* conai_material(TCONAI_class cc);
bool conai_configured_class(TCONAI_class cc);
const char* conai_peso_name(TCONAI_class cc, int logic_num = LF_RIGHEDOC);
const char* conai_sottocat_name(TCONAI_class cc, int logic_num = LF_RIGHEDOC);
const char* conai_esenzione_name(TCONAI_class cc, int logicnum = LF_RIGHEDOC);
#define CHECK_CONAI(cc) CHECKD(cc>=CONAI_FIRST&&cc<CONAI_CLASSES, "Classe CONAI errata: ", cc)
#define FOR_EACH_CONAI_CLASS(cc) for (TCONAI_class cc = CONAI_FIRST; cc < CONAI_CLASSES; cc=TCONAI_class(cc+1))
#define FOR_EACH_CONFIGURED_CONAI_CLASS(cc) FOR_EACH_CONAI_CLASS(cc) if (conai_configured_class(cc))
///////////////////////////////////////////////////////////
// TRiga_documento
@ -596,7 +601,7 @@ public:
virtual real quantita_mag() const;
virtual real qtaevasa_mag() const;
virtual real qtaresidua_mag() const;
real calc_conai_qta(TCONAI_type type) const;
real calc_conai_qta(TCONAI_class type) const;
real valore(bool totale, bool lordo = false, int ndec = AUTO_DECIMALS) const;
const TString & codice_costo() const;
@ -826,7 +831,7 @@ public:
TPagamento & pagamento();
void update_spese_aut(TString_array & spese, bool preserve_old = FALSE, TSheet_field * sh = NULL);
real calc_conai_qta(TCONAI_type type);
real calc_conai_qta(TCONAI_class type);
void update_conai();
bool is_generic() const { return tipo_valido() && tipo().is_generic(); }

View File

@ -787,14 +787,14 @@ real TRiga_documento::qtaresidua_mag() const
return ZERO;
}
TCONAI_type conai_str2type(const char* code)
TCONAI_class conai_str2class(const char* code)
{
TCONAI_type ct = CONAI_NONE;
TCONAI_class ct = CONAI_NONE;
if (code && *code)
{
switch(code[0])
{
case 'A': ct = code[1] == 'L' ? CONAI_ALL : CONAI_ACC; break;
case 'A': ct = code[1] == 'C' ? CONAI_ACC : CONAI_ALL; break;
case 'C': ct = CONAI_CAR; break;
case 'L': ct = CONAI_LEG; break;
case 'P': ct = CONAI_PLA; break;
@ -805,54 +805,96 @@ TCONAI_type conai_str2type(const char* code)
return ct;
}
// Controlla attivazione di una categoria CONAI
bool conai_configured_type(TCONAI_type type)
const char* conai_material(TCONAI_class cc)
{
static TBit_array* __con_conf = NULL;
if (__con_conf == NULL)
{
__con_conf = new TBit_array;
const char* const __conai_conf_names[CONAI_CATEGORIES] = {"CONFACC", "CONFALL", "CONFCAR", "CONFPLA", "CONFLEG", "CONFVET"};
TConfig c(CONFIG_DITTA, "ve");
for (int i = CONAI_FIRST; i <= CONAI_LAST; i++)
(*__con_conf).set(i, c.get_bool(__conai_conf_names[i]));
}
return type >= CONAI_FIRST && type <= CONAI_LAST && (*__con_conf)[type];
CHECK_CONAI(cc);
const char* const mat[CONAI_CLASSES] = {
"Acciaio", "Alluminio", "Carta", "Plastica", "Legno", "Vetro" };
return cc >= CONAI_FIRST && cc < CONAI_CLASSES ? mat[cc] : "";
}
// Campi virtuali per contributo CONAI
const char* conai_contr_name(TCONAI_type type)
// Controlla attivazione di una categoria CONAI
bool conai_configured_class(TCONAI_class cc)
{
const char* const __conai_contr_names[] = {"CONACC", "CONALL", "CONCAR", "CONPLA", "CONLEG", "CONVET"};
return (type >= CONAI_FIRST && type <= CONAI_LAST) ? __conai_contr_names[type] : "";
CHECK_CONAI(cc);
static bool* __con_conf = NULL;
if (__con_conf == NULL)
{
__con_conf = new bool[CONAI_CLASSES];
const char* const __conai_conf_names[CONAI_CLASSES] = {"CONFACC", "CONFALL", "CONFCAR", "CONFPLA", "CONFLEG", "CONFVET"};
TConfig c(CONFIG_DITTA, "ve");
FOR_EACH_CONAI_CLASS(i)
__con_conf[i] = c.get_bool(__conai_conf_names[i]);
}
return cc>=CONAI_FIRST && cc<=CONAI_LAST && __con_conf[cc];
}
// Campi virtuali per peso CONAI su RDOC in Kg
const char* conai_peso_name(TCONAI_type type)
const char* conai_peso_name(TCONAI_class type, int logicnum)
{
const char* const __conai_peso_names[] = {"PUNACC", "PUNALL", "PUNCAR", "PUNPLA", "PUNLEG", "PUNVET"};
return conai_configured_type(type) ? __conai_peso_names[type] : "";
if (conai_configured_class(type))
{
const char* const __conai_peso_rdoc[] = {"PUNACC", "PUNALL", "PUNCAR", "PUNPLA", "PUNLEG", "PUNVET"};
const char* const __conai_peso_anmg[] = {"CONACC", "CONALL", "CONCAR", "CONPLA", "CONLEG", "CONVET"};
switch (logicnum)
{
case LF_ANAMAG : return __conai_peso_anmg[type];
case LF_RIGHEDOC: return __conai_peso_rdoc[type];
default : break;
}
}
return "";
}
// Campi virtuali per sottocategoria CONAI su RDOC
const char* conai_sottocat_name(TCONAI_type type)
const char* conai_sottocat_name(TCONAI_class type, int logicnum)
{
const char* const __conai_scat_names[] = {"SCAACC", "SCAALL", "SCACAR", "SCAPLA", "SCALEG", "SCAVET"};
return conai_configured_type(type) ? __conai_scat_names[type] : "";
if (conai_configured_class(type))
{
const char* const __conai_scat_rdoc[CONAI_CLASSES] =
{ "SCAACC", "SCAALL", "SCACAR", "SCAPLA", "SCALEG", "SCAVET" };
const char* const __conai_scat_anmg[CONAI_CLASSES] =
{ "SCACONTR[1,4]", "SCACONTR[5,8]", "SCACONTR[9,12]", "SCACONTR[13,16]", "SCACONTR[17,20]", "SCACONTR[21,24]" };
switch (logicnum)
{
case LF_ANAMAG : return __conai_scat_anmg[type];
case LF_RIGHEDOC: return __conai_scat_rdoc[type];
default : break;
}
}
return "";
}
real TRiga_documento::calc_conai_qta(TCONAI_type type) const
{
real qta = ZERO;
if (is_merce() && conai_configured_type(type))
{
TArticolo & art = articolo();
const TString4 um = get(RDOC_UMQTA);
const char* conai_esenzione_name(TCONAI_class cc, int logicnum)
{
if (conai_configured_class(cc))
{
const char* const __conai_ese_cfven[CONAI_CLASSES] = { CFV_ESACC, CFV_ESALL, CFV_ESCAR, CFV_ESPLA, CFV_ESLEG, CFV_ESVET };
switch (logicnum)
{
case LF_RIGHEDOC:
case LF_CFVEN : return __conai_ese_cfven[cc];
default : break;
}
}
return "";
}
qta = art.convert_to_um(get_real(RDOC_QTA), NULL, um);
qta *= get_real(conai_peso_name(type));
real TRiga_documento::calc_conai_qta(TCONAI_class type) const
{
real qta;
if (is_merce() && conai_configured_class(type))
{
qta = quantita();
if (!qta.is_zero())
{
TArticolo& art = articolo();
const TString4 um = get(RDOC_UMQTA);
qta = art.convert_to_um(qta, NULL, um);
qta *= get_real(conai_peso_name(type));
}
}
return qta;
}
@ -866,7 +908,7 @@ real TRiga_documento::valore(bool totale, bool lordo, int ndec) const
{
real val;
const TString & f_qta = field_qta();
const TString& f_qta = field_qta();
const bool qta_is_price = f_qta == RDOC_PREZZO;
if (totale)
@ -890,7 +932,7 @@ real TRiga_documento::valore(bool totale, bool lordo, int ndec) const
const TString & TRiga_documento::codice_costo() const
{
const TString & cod_cos = get(RDOC_CODCOSTO);
const TString& cod_cos = get(RDOC_CODCOSTO);
return cod_cos.empty() ? doc().get(DOC_CODCOSTO) : cod_cos;
}
@ -925,7 +967,7 @@ bool TRiga_documento::doc_dependent() const
return spesa().tipo() == 'P';
else
if (tipor == RIGA_SCONTI)
return get("SCONTO").not_empty();
return get(RDOC_SCONTO).not_empty();
}
return FALSE;
}

View File

@ -23,6 +23,7 @@
///////////////////////////////////////////////////////////
// TTipo_documento_cache
///////////////////////////////////////////////////////////
class TTipo_documento_cache : public TRecord_cache
{
protected:
@ -2644,7 +2645,7 @@ void TDocumento::update_spese_aut(TString_array & spese_aut, bool preserve_old,
put(DOC_SPESEUPD, true);
}
real TDocumento::calc_conai_qta(TCONAI_type type)
real TDocumento::calc_conai_qta(TCONAI_class type)
{
real qta;
@ -2666,16 +2667,15 @@ void TDocumento::update_conai()
{
const TRectype& cfven = clifor().vendite();
const bool cli_add_conai = cfven.get_bool("ADDCONAI");
const char* const conai_mat[CONAI_CATEGORIES] = { "Acciaio", "Alluminio", "Carta", "Plastica", "Legno", "Vetro" };
const char * const __conai_cf_names[] = {"ESACC", "ESALL", "ESCAR", "ESPLA", "ESLEG", "ESVET"};
const TDate datadoc = get(DOC_DATADOC);
const TDate dataes = cfven.get(CFV_DATAECONAI);
bool esponi_esenti = false;
TString_array conai_sp(CONAI_CATEGORIES); // Codici spesa conai
TString_array conai_sp(CONAI_CLASSES); // Codici spesa conai
{
const char* const conai_cod[CONAI_CATEGORIES] = { "CODACC", "CODALL", "CODCAR", "CODPLA", "CODLEG", "CODVET" };
const char* const conai_cod[CONAI_CLASSES] = { "CODACC", "CODALL", "CODCAR", "CODPLA", "CODLEG", "CODVET" };
TConfig c(CONFIG_DITTA, "ve");
for (int i = 0; i < 6; i++)
conai_sp.add(c.get(conai_cod[i]));
@ -2683,7 +2683,7 @@ void TDocumento::update_conai()
esponi_esenti = c.get_bool("ESPONIESENTI");
}
bool updated[CONAI_CATEGORIES] = {false,false,false,false,false,false};
bool updated[CONAI_CLASSES] = {false,false,false,false,false,false};
for (int i = physical_rows(); i > 0; i--)
{
TRiga_documento& r = row(i);
@ -2693,7 +2693,7 @@ void TDocumento::update_conai()
if (tipo_conai)
{
const TString& cod = r.get(RDOC_CODART);
const TCONAI_type pos = (TCONAI_type)conai_sp.find(cod);
const TCONAI_class pos = (TCONAI_class)conai_sp.find(cod);
if (pos >= CONAI_FIRST && pos <= CONAI_LAST)
{
@ -2729,7 +2729,7 @@ void TDocumento::update_conai()
const TString4 cod_iva_cli = codesiva() ;
TSpesa_prest sp;
for (TCONAI_type ct = CONAI_FIRST; ct <= CONAI_LAST; ct=TCONAI_type(ct+1))
FOR_EACH_CONAI_CLASS(ct)
{
if (!updated[ct])
{
@ -2745,7 +2745,7 @@ void TDocumento::update_conai()
if (sp.read(s) != NOERR)
message_box("Il codice spesa CONAI %s specificato nei parametri ditta e' assente: '%s'",
conai_mat[ct], (const char*)s);
conai_material(ct), (const char*)s);
else
{
const TString4 tipo = sp.tipo_riga();

View File

@ -71,15 +71,15 @@ TColor_rule::TColor_rule(const char* desc, const char* expr, TTypeexp type, COLO
// Gestione campi CONAI su maschera righe
///////////////////////////////////////////////////////////
short conai_peso_id(TCONAI_type type)
short conai_peso_id(TCONAI_class type)
{ return type >= CONAI_FIRST && type <= CONAI_LAST ? FR_PUNACC + 2 * type : DLG_NULL; }
short conai_sottocat_id(TCONAI_type type)
short conai_sottocat_id(TCONAI_class type)
{ return type >= CONAI_FIRST && type <= CONAI_LAST ? FR_SCAACC + 2*type : DLG_NULL; }
TCONAI_type conai_id2type(short id)
TCONAI_class conai_id2class(short id)
{
const TCONAI_type t = TCONAI_type((id-FR_SCAACC) / 2);
const TCONAI_class t = TCONAI_class((id-FR_SCAACC) / 2);
return t >= CONAI_FIRST && t <= CONAI_LAST ? t : CONAI_NONE;
}
@ -523,14 +523,14 @@ void TDocumento_mask::configura_sheet(TSheet_field& sheet)
to_delete.set(0L);
to_delete.reset(1);
for (TCONAI_type ct = CONAI_FIRST; ct <= CONAI_LAST; ct = TCONAI_type(ct + 1))
FOR_EACH_CONAI_CLASS(ct)
{
const short posc = conai_sottocat_id(ct);
const short posp = conai_peso_id(ct);
const int colc = sheet.cid2index(posc);
const int colp = sheet.cid2index(posp);
if (conai_configured_type(ct))
if (conai_configured_class(ct))
{
to_delete.reset(colc);
if (colonne.find(format("%d", posc)) < 0)
@ -1356,11 +1356,11 @@ TVariable_mask* TDocumento_mask::riga_mask(int numriga)
f.add_driver(-F_CODVAL);
}
for (TCONAI_type type = CONAI_FIRST; type <= CONAI_LAST; type = TCONAI_type(type + 1))
FOR_EACH_CONAI_CLASS(type)
{
const short posc = conai_sottocat_id(type);
const short posp = conai_peso_id(type);
if (conai_configured_type(type))
if (conai_configured_class(type))
{
m->show(posc);
m->set_handler(posc, sottocat_conai_handler);

View File

@ -1690,22 +1690,19 @@ bool codart_handler(TMask_field& f, KEY key )
else
mask.doc()[current_doc_row].put(RDOC_PREZZO, row_mask.get(FR_PREZZO));
for (TCONAI_type type = CONAI_FIRST; type <= CONAI_LAST; type = TCONAI_type(type + 1))
FOR_EACH_CONFIGURED_CONAI_CLASS(type)
{
if (conai_configured_type(type))
{
short id = conai_sottocat_id(type);
int pos = row_mask.id2pos(id);
short id = conai_sottocat_id(type);
int pos = row_mask.id2pos(id);
if (pos >= 0 && row_mask.fld(pos).get().blank())
row_mask.fld(pos).set(anamag.get(ANAMAG_SCACONTR).smid(type * 4, 4));
if (pos >= 0 && row_mask.fld(pos).get().blank())
row_mask.fld(pos).set(anamag.get(ANAMAG_SCACONTR).smid(type * 4, 4));
id = conai_peso_id(type);
pos = row_mask.id2pos(id);
id = conai_peso_id(type);
pos = row_mask.id2pos(id);
if (pos >= 0 && row_mask.fld(pos).get().blank())
row_mask.fld(pos).set(anamag.get(conai_contr_name(type)));
}
if (pos >= 0 && row_mask.fld(pos).get().blank())
row_mask.fld(pos).set(anamag.get(conai_peso_name(type, LF_ANAMAG)));
}
const int pos = row_mask.id2pos(FR_CODIVA);
@ -2864,12 +2861,11 @@ bool sottocat_conai_handler(TMask_field& f, KEY key )
{
if (key == K_F8)
{
const TString & codart = f.mask().get(FR_CODARTMAG);
TArticolo & articolo = cached_article(codart);
const short id = f.dlg();
const TCONAI_type type = conai_id2type(id);
f.set(articolo.get(ANAMAG_SCACONTR).smid(type * 4, 4));
const TString& codart = f.mask().get(FR_CODARTMAG);
const TArticolo& articolo = cached_article(codart);
const TCONAI_class type = conai_id2class(f.dlg());
const TFieldref fld(conai_sottocat_name(type, LF_ANAMAG), LF_ANAMAG);
f.set(fld.read(articolo));
}
return true;
}
@ -2880,10 +2876,8 @@ bool peso_conai_handler(TMask_field& f, KEY key )
{
const TString & codart = f.mask().get(FR_CODARTMAG);
TArticolo & articolo = cached_article(codart);
const short id = f.dlg();
const TCONAI_type type = conai_id2type(id);
f.set(articolo.get(conai_contr_name(type)));
const TCONAI_class type = conai_id2class(f.dlg());
f.set(articolo.get(conai_peso_name(type, LF_ANAMAG)));
}
return true;
}

View File

@ -38,7 +38,6 @@ bool gen_livelli_handler(TMask_field& f, KEY key );
bool peso_conai_handler(TMask_field& f, KEY key );
bool sottocat_conai_handler(TMask_field& f, KEY key );
bool codcms_handler(TMask_field &f, KEY key);
bool numdocrif_hndl(TMask_field& field, KEY key);
bool smart_hndl(TMask_field& field, KEY key);
@ -46,9 +45,9 @@ bool fido_hndl(TMask_field& field, KEY key);
bool tipodoc_ok(const TString & tipodoc);
TCONAI_type conai_id2type(short id);
short conai_peso_id(TCONAI_type type);
short conai_sottocat_id(TCONAI_type type);
TCONAI_class conai_id2class(short id);
short conai_peso_id(TCONAI_class cc);
short conai_sottocat_id(TCONAI_class cc);
#endif