Patch level : 10.0 320
Files correlati : ve0.exe ve1.exe Ricompilazione Demo : [ ] Commento : Corretta valorizzazione righe di tipo Risorse ed Attrezzature. Aggiunta possibilita' di stampare copie extra dei documenti in base alla variabile #PRINT_EXTRA_COPIES git-svn-id: svn://10.65.10.50/trunk@18961 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
999644b0a8
commit
9b94b01c61
@ -212,11 +212,14 @@ TDoc_recordset::~TDoc_recordset()
|
||||
class TReport_doc : public TReport
|
||||
{
|
||||
size_t _first_msg;
|
||||
int _extra_copies;
|
||||
|
||||
protected:
|
||||
virtual void include_libraries(bool reload);
|
||||
virtual size_t get_usr_words(TString_array& words) const;
|
||||
virtual bool execute_usr_word(unsigned int opcode, TVariant_stack& stack);
|
||||
virtual bool get_usr_val(const TString& name, TVariant& var) const;
|
||||
virtual bool set_usr_val(const TString& name, const TVariant& var);
|
||||
|
||||
TDocumentoEsteso& doc();
|
||||
TRiga_documento& riga_doc(int n = 0);
|
||||
@ -235,6 +238,7 @@ protected:
|
||||
public:
|
||||
bool print(const TRecordset& doc, TReport_book& book, bool def, word copies,
|
||||
bool alleg, bool arc, bool signature);
|
||||
int extra_copies() const { return _extra_copies; }
|
||||
|
||||
TReport_doc(const char* name);
|
||||
virtual ~TReport_doc();
|
||||
@ -746,11 +750,30 @@ void TReport_doc::include_libraries(bool reload)
|
||||
include("ve1300.alx");
|
||||
}
|
||||
|
||||
TReport_doc::TReport_doc(const char* name)
|
||||
bool TReport_doc::get_usr_val(const TString& name, TVariant& var) const
|
||||
{
|
||||
if (name == "#PRINT_EXTRA_COPIES")
|
||||
{
|
||||
var = long(_extra_copies);
|
||||
return true;
|
||||
}
|
||||
return TReport::get_usr_val(name, var);
|
||||
}
|
||||
|
||||
bool TReport_doc::set_usr_val(const TString& name, const TVariant& var)
|
||||
{
|
||||
if (name == "#PRINT_EXTRA_COPIES")
|
||||
{
|
||||
_extra_copies = var.as_int();
|
||||
return true;
|
||||
}
|
||||
return TReport::set_usr_val(name, var);
|
||||
}
|
||||
|
||||
TReport_doc::TReport_doc(const char* name) : _extra_copies(0)
|
||||
{
|
||||
// istanziamento e impostazione della relazione di gestione della ditta corrente
|
||||
load(name); // Faccio la load altrimenti non include la libreria 1300.alx
|
||||
|
||||
}
|
||||
|
||||
TReport_doc::~TReport_doc()
|
||||
@ -867,6 +890,7 @@ protected:
|
||||
const TString & get_mail_address() const;
|
||||
virtual bool get_next_mail(TToken_string& to, TToken_string& cc, TToken_string& ccn,
|
||||
TString& subj, TString& text, TToken_string& attach, bool& ui) const ;
|
||||
void print_extra_copies(TReport_doc& report, const TRecordset& doc, TReport_book& book) const;
|
||||
|
||||
public:
|
||||
virtual bool create();
|
||||
@ -910,8 +934,8 @@ bool TReport_doc_app::get_next_mail(TToken_string& to, TToken_string& cc, TToken
|
||||
ok = to.full();
|
||||
if (ok)
|
||||
{
|
||||
TDocumento doc('D', _anno, _codnum, _ndoc);
|
||||
doc.riferimento(subj);
|
||||
TDocumento doc('D', _anno, _codnum, _ndoc);
|
||||
doc.riferimento(subj);
|
||||
if (subj.blank())
|
||||
subj = doc.tipo().descrizione();
|
||||
text << "Invio documento " << subj;
|
||||
@ -969,6 +993,14 @@ bool TReport_doc_app::destroy()
|
||||
return TSkeleton_application::destroy();
|
||||
}
|
||||
|
||||
void TReport_doc_app::print_extra_copies(TReport_doc& report, const TRecordset& doc,
|
||||
TReport_book& book) const
|
||||
{
|
||||
const int extra_copies = report.extra_copies();
|
||||
if (extra_copies > 0)
|
||||
report.print(doc, book, false, extra_copies, false, false, false);
|
||||
}
|
||||
|
||||
bool TReport_doc_app::print_loop(const TString& query, TOutput_mode mode)
|
||||
{
|
||||
TISAM_recordset doc(query);
|
||||
@ -1023,10 +1055,13 @@ bool TReport_doc_app::print_loop(const TString& query, TOutput_mode mode)
|
||||
const TString& tipodoc = doc.get(DOC_TIPODOC).as_string();
|
||||
const TTipo_documento& tipo = cached_tipodoc(tipodoc);
|
||||
const bool send_mail = ( mode == out_mail || mode == out_signed_mail) && get_mail_address().full();
|
||||
const bool paperless = send_mail || mode == out_pdf || mode == out_signed_pdf;
|
||||
|
||||
TFilename profilo; // Tenta di costruirsi il nome del report
|
||||
bool ok = false;
|
||||
if (send_mail)
|
||||
|
||||
// Se non stampo su carta cerco di usare un profilo con sfondo
|
||||
if (paperless)
|
||||
ok = tipo.mail_print_profile(profilo);
|
||||
else
|
||||
ok = tipo.main_print_profile(profilo, 2);
|
||||
@ -1036,7 +1071,7 @@ bool TReport_doc_app::print_loop(const TString& query, TOutput_mode mode)
|
||||
int copies = _msk->get_int(F_NCOPIE);
|
||||
if (copies <= 0 && is_definitive)
|
||||
copies = tipo.ncopie();
|
||||
if (copies <= 0 || send_mail)
|
||||
if (copies <= 0 || paperless)
|
||||
copies = 1;
|
||||
|
||||
TReport_doc& report = reports.get(profilo);
|
||||
@ -1055,6 +1090,8 @@ bool TReport_doc_app::print_loop(const TString& query, TOutput_mode mode)
|
||||
{
|
||||
if (!report.print(doc, book, is_definitive, copies, true, arc, signature))
|
||||
break;
|
||||
if (!paperless)
|
||||
print_extra_copies(report, doc, book);
|
||||
}
|
||||
} //if(profilo.custom_path()...
|
||||
else
|
||||
@ -1082,7 +1119,11 @@ bool TReport_doc_app::print_loop(const TString& query, TOutput_mode mode)
|
||||
if (send_mail)
|
||||
allegato.print(doc, *mail_book, false, 1, false, false, false); // Non archivio gli allegati alla mail
|
||||
else
|
||||
{
|
||||
allegato.print(doc, book, false, copies, false, arc, signature);
|
||||
if (!paperless)
|
||||
print_extra_copies(allegato, doc, book);
|
||||
}
|
||||
}
|
||||
|
||||
if (mail_book != NULL)
|
||||
@ -1180,7 +1221,7 @@ void TReport_doc_app::main_loop()
|
||||
if (field.blank()) field = DOC_CODNUM;
|
||||
codnum = ini_get_string(CONFIG_DITTA, paragraph, field);
|
||||
}
|
||||
_msk->set(F_CODNUM, codnum); // Stampa da menu con numerazione imposta
|
||||
_msk->set(F_CODNUM, codnum); // Stampa da menu con numerazione imposta
|
||||
}
|
||||
|
||||
if (a > 6) // Stampa da riga di comando
|
||||
|
237
ve/velib02.cpp
237
ve/velib02.cpp
@ -223,7 +223,7 @@ const TSpesa_prest & TRiga_documento::spesa() const
|
||||
|
||||
test_firm();
|
||||
|
||||
const TString80 codice(get("CODART"));
|
||||
const TString80 codice(get(RDOC_CODART));
|
||||
TString80 index; index << tipor << codice;
|
||||
|
||||
TSpesa_prest * s = (TSpesa_prest *) _spese.objptr(index);
|
||||
@ -293,24 +293,23 @@ void TRiga_documento::set_variables(TExpression * e) const
|
||||
for (int i = 0; i < items; i++)
|
||||
{
|
||||
const TFieldref field(e->varname(i), LF_RIGHEDOC);
|
||||
|
||||
switch (field.file())
|
||||
{
|
||||
case LF_ANAMAG :
|
||||
e->setvar(i, articolo().get(field.name()));
|
||||
break;
|
||||
case LF_DOC :
|
||||
e->setvar(i, doc().get(field.name()));
|
||||
break;
|
||||
case LF_CLIFO :
|
||||
e->setvar(i, doc().clifor().get(field.name()));
|
||||
break;
|
||||
case LF_CFVEN :
|
||||
e->setvar(i, doc().clifor().vendite().get(field.name()));
|
||||
break;
|
||||
default:
|
||||
e->setvar(i, get(field.name()));
|
||||
break;
|
||||
case LF_ANAMAG :
|
||||
e->setvar(i, articolo().get(field.name()));
|
||||
break;
|
||||
case LF_DOC :
|
||||
e->setvar(i, doc().get(field.name()));
|
||||
break;
|
||||
case LF_CLIFO :
|
||||
e->setvar(i, doc().clifor().get(field.name()));
|
||||
break;
|
||||
case LF_CFVEN :
|
||||
e->setvar(i, doc().clifor().vendite().get(field.name()));
|
||||
break;
|
||||
default:
|
||||
e->setvar(i, get(field.name()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -470,121 +469,123 @@ real TRiga_documento::importo(bool scontato, bool lordo, int ndec) const
|
||||
|
||||
switch (tipor)
|
||||
{
|
||||
case RIGA_MERCE:
|
||||
c = _qtaprezzo;
|
||||
break;
|
||||
case RIGA_PRESTAZIONI:
|
||||
case RIGA_SPESEDOC:
|
||||
{
|
||||
const TSpesa_prest & s = spesa();
|
||||
const bool to_calc = _rit_calc || s.tipo_ritenuta() == '\0';
|
||||
|
||||
if (to_calc)
|
||||
case RIGA_MERCE:
|
||||
case RIGA_RISORSE:
|
||||
case RIGA_ATTREZZATURE:
|
||||
c = _qtaprezzo;
|
||||
break;
|
||||
case RIGA_PRESTAZIONI:
|
||||
case RIGA_SPESEDOC:
|
||||
{
|
||||
const TSpesa_prest & s = spesa();
|
||||
const bool to_calc = _rit_calc || s.tipo_ritenuta() == '\0';
|
||||
|
||||
if (to_calc)
|
||||
{
|
||||
switch (s.tipo())
|
||||
{
|
||||
switch (s.tipo())
|
||||
{
|
||||
case 'Q':
|
||||
c = _qtaprezzo;
|
||||
break;
|
||||
case 'P':
|
||||
{
|
||||
const TString16 field_perc(s.field_perc());
|
||||
c = _percentuale;
|
||||
valore = doc().get_real(field_perc);
|
||||
if (doc_al_lordo)
|
||||
valore = iva().lordo(valore, ALL_DECIMALS, doc().valuta());
|
||||
}
|
||||
break;
|
||||
case 'V':
|
||||
default:
|
||||
c = _valore;
|
||||
break;
|
||||
}
|
||||
case 'Q':
|
||||
c = _qtaprezzo;
|
||||
break;
|
||||
case 'P':
|
||||
{
|
||||
const TString16 field_perc(s.field_perc());
|
||||
c = _percentuale;
|
||||
valore = doc().get_real(field_perc);
|
||||
if (doc_al_lordo)
|
||||
valore = iva().lordo(valore, ALL_DECIMALS, doc().valuta());
|
||||
}
|
||||
break;
|
||||
case 'V':
|
||||
default:
|
||||
c = _valore;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RIGA_SCONTI:
|
||||
c = _scontopi;
|
||||
break;
|
||||
case RIGA_OMAGGI:
|
||||
if (_iva_calc_mode > 1 || (_iva_calc_mode == 1 && get_bool("ADDIVA")))
|
||||
c = _qtaprezzo;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case RIGA_SCONTI:
|
||||
c = _scontopi;
|
||||
break;
|
||||
case RIGA_OMAGGI:
|
||||
if (_iva_calc_mode > 1 || (_iva_calc_mode == 1 && get_bool("ADDIVA")))
|
||||
c = _qtaprezzo;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (c)
|
||||
{
|
||||
case _qtaprezzo:
|
||||
importo = prezzo(scontato, lordo, ALL_DECIMALS) * qta;
|
||||
break;
|
||||
case _valore:
|
||||
importo = prezzo(scontato, lordo, ndec);
|
||||
break;
|
||||
case _percentuale:
|
||||
importo = valore * get_real(RDOC_QTA) / CENTO;
|
||||
break;
|
||||
case _scontopi:
|
||||
case _qtaprezzo:
|
||||
importo = prezzo(scontato, lordo, ALL_DECIMALS) * qta;
|
||||
break;
|
||||
case _valore:
|
||||
importo = prezzo(scontato, lordo, ndec);
|
||||
break;
|
||||
case _percentuale:
|
||||
importo = valore * get_real(RDOC_QTA) / CENTO;
|
||||
break;
|
||||
case _scontopi:
|
||||
{
|
||||
TCond_vendita cv(NULL, NULL);
|
||||
|
||||
cv.set_sconto(get("SCONTO"));
|
||||
if (cv.get_sconto().not_empty())
|
||||
{
|
||||
TCond_vendita cv(NULL, NULL);
|
||||
importo = doc().basesconto();
|
||||
importo *= (cv.sconto_val() - UNO);
|
||||
doc_al_lordo = false;
|
||||
}
|
||||
else
|
||||
importo = -prezzo(false, lordo, ALL_DECIMALS);
|
||||
TGeneric_distrib d(importo, ALL_DECIMALS);
|
||||
TRiepilogo_iva * aliquota;
|
||||
|
||||
cv.set_sconto(get("SCONTO"));
|
||||
if (cv.get_sconto().not_empty())
|
||||
if (doc_al_lordo)
|
||||
{
|
||||
if (!lordo)
|
||||
{
|
||||
importo = doc().basesconto();
|
||||
importo *= (cv.sconto_val() - UNO);
|
||||
doc_al_lordo = false;
|
||||
}
|
||||
else
|
||||
importo = -prezzo(false, lordo, ALL_DECIMALS);
|
||||
TGeneric_distrib d(importo, ALL_DECIMALS);
|
||||
TRiepilogo_iva * aliquota;
|
||||
|
||||
if (doc_al_lordo)
|
||||
{
|
||||
if (!lordo)
|
||||
TAssoc_array & table = ((TDocumento &) doc()).tabella_iva(true);
|
||||
importo = ZERO;
|
||||
table.restart();
|
||||
for (aliquota = (TRiepilogo_iva *) table.get(); aliquota != NULL;
|
||||
aliquota = (TRiepilogo_iva *) table.get())
|
||||
d.add(aliquota->imp_orig());
|
||||
table.restart();
|
||||
for (aliquota = (TRiepilogo_iva *) table.get(); aliquota != NULL;
|
||||
aliquota = (TRiepilogo_iva *) table.get())
|
||||
{
|
||||
TAssoc_array & table = ((TDocumento &) doc()).tabella_iva(true);
|
||||
importo = ZERO;
|
||||
table.restart();
|
||||
for (aliquota = (TRiepilogo_iva *) table.get(); aliquota != NULL;
|
||||
aliquota = (TRiepilogo_iva *) table.get())
|
||||
d.add(aliquota->imp_orig());
|
||||
table.restart();
|
||||
for (aliquota = (TRiepilogo_iva *) table.get(); aliquota != NULL;
|
||||
aliquota = (TRiepilogo_iva *) table.get())
|
||||
{
|
||||
const TCodiceIVA & iva = aliquota->cod_iva();
|
||||
real slice = d.get();
|
||||
const TCodiceIVA & iva = aliquota->cod_iva();
|
||||
real slice = d.get();
|
||||
|
||||
iva.scorpora(slice, ALL_DECIMALS, ((TDocumento &) doc()).valuta());
|
||||
importo += slice;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lordo)
|
||||
{
|
||||
TAssoc_array & table = ((TDocumento &) doc()).tabella_iva(true);
|
||||
importo = ZERO;
|
||||
table.restart();
|
||||
for (aliquota = (TRiepilogo_iva *) table.get(); aliquota != NULL;
|
||||
aliquota = (TRiepilogo_iva *) table.get())
|
||||
d.add(aliquota->imp_orig());
|
||||
table.restart();
|
||||
for (aliquota = (TRiepilogo_iva *) table.get(); aliquota != NULL;
|
||||
aliquota = (TRiepilogo_iva *) table.get())
|
||||
{
|
||||
const TCodiceIVA & iva = aliquota->cod_iva();
|
||||
|
||||
importo += iva.lordo(d.get(), ALL_DECIMALS, ((TDocumento &) doc()).valuta());
|
||||
}
|
||||
iva.scorpora(slice, ALL_DECIMALS, ((TDocumento &) doc()).valuta());
|
||||
importo += slice;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
else
|
||||
{
|
||||
if (lordo)
|
||||
{
|
||||
TAssoc_array & table = ((TDocumento &) doc()).tabella_iva(true);
|
||||
importo = ZERO;
|
||||
table.restart();
|
||||
for (aliquota = (TRiepilogo_iva *) table.get(); aliquota != NULL;
|
||||
aliquota = (TRiepilogo_iva *) table.get())
|
||||
d.add(aliquota->imp_orig());
|
||||
table.restart();
|
||||
for (aliquota = (TRiepilogo_iva *) table.get(); aliquota != NULL;
|
||||
aliquota = (TRiepilogo_iva *) table.get())
|
||||
{
|
||||
const TCodiceIVA & iva = aliquota->cod_iva();
|
||||
|
||||
importo += iva.lordo(d.get(), ALL_DECIMALS, ((TDocumento &) doc()).valuta());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
importo.round(ndec); // arrotondamento finale
|
||||
return importo;
|
||||
|
@ -1918,7 +1918,6 @@ void TDocumento::update_tabella_iva(bool solo_imponibili)
|
||||
}
|
||||
|
||||
const bool doc_al_lordo = tipo().calcolo_lordo();
|
||||
TRiepilogo_iva * aliquota;
|
||||
const int ndec = decimals();
|
||||
|
||||
const TRecord_array& righe = body(LF_RIGHEDOC);
|
||||
@ -1933,15 +1932,14 @@ void TDocumento::update_tabella_iva(bool solo_imponibili)
|
||||
if (iva.ok())
|
||||
{
|
||||
const TString & cod = iva.codice();
|
||||
aliquota = (TRiepilogo_iva *) table.objptr(cod);
|
||||
TRiepilogo_iva* aliquota = (TRiepilogo_iva*)table.objptr(cod);
|
||||
if (aliquota == NULL)
|
||||
{
|
||||
aliquota = new TRiepilogo_iva(iva);
|
||||
table.add(cod, aliquota);
|
||||
}
|
||||
const real imponibile = doc_al_lordo ? r.importo(true, true, ndec) : r.imponibile();
|
||||
|
||||
aliquota->imp_orig() += imponibile;
|
||||
aliquota->imp_orig() += imponibile;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1981,7 +1979,7 @@ void TDocumento::update_tabella_iva(bool solo_imponibili)
|
||||
{
|
||||
const TString & cod = iva.codice();
|
||||
|
||||
aliquota = (TRiepilogo_iva *) table.objptr(cod);
|
||||
TRiepilogo_iva* aliquota = (TRiepilogo_iva *) table.objptr(cod);
|
||||
if (aliquota == NULL)
|
||||
{
|
||||
aliquota = new TRiepilogo_iva(iva);
|
||||
@ -2276,8 +2274,8 @@ real TDocumento::provvigione(bool first, int ndec) const
|
||||
{
|
||||
if (ndec == AUTO_DECIMALS)
|
||||
ndec = decimals();
|
||||
for (int i = rows(); i > 0; i--)
|
||||
val += ((TRiga_documento &) ((TDocumento *)this)->row(i)).provvigione(first, ndec);
|
||||
for (int i = physical_rows(); i > 0; i--)
|
||||
val += physical_row(i).provvigione(first, ndec);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
@ -2285,10 +2283,11 @@ real TDocumento::provvigione(bool first, int ndec) const
|
||||
real TDocumento::valore(bool totale, bool lordo, int ndec) const
|
||||
{
|
||||
real val;
|
||||
for (int i=rows(); i>0; i--)
|
||||
for (int i = physical_rows(); i>0; i--)
|
||||
{
|
||||
TRiga_documento &r = ((TRiga_documento &) ((TDocumento *)this)->row(i));
|
||||
if (r.is_merce() || r.is_spese() || r.is_prestazione())
|
||||
const TRiga_documento &r = physical_row(i);
|
||||
//if (r.is_merce() || r.is_spese() || r.is_prestazione())
|
||||
if (strchr("MSPRA", r.tipo().tipo()) != NULL) // Merce, Spese, Prestazioni, Risorse, Attrezzature
|
||||
val += r.valore(totale, lordo, ndec);
|
||||
}
|
||||
return val;
|
||||
@ -2311,7 +2310,7 @@ void TDocumento::put_str(const char* fieldname, const char* val)
|
||||
else
|
||||
if (strcmp(fieldname, DOC_CODCF) == 0)
|
||||
{
|
||||
const TString16 v(val);
|
||||
const TString8 v(val);
|
||||
put(DOC_SPESEUPD, TRectype::get(DOC_CODCF) == v);
|
||||
TAuto_variable_rectype::put_str(fieldname, v);
|
||||
dirty_fields();
|
||||
|
@ -448,7 +448,7 @@ TFormula_documento* TTipo_documento::succ_formula(bool restart)
|
||||
bool TTipo_documento::scarica_residuo() const
|
||||
{
|
||||
if (is_ordine() && !riporta_ordinato())
|
||||
return TRUE;
|
||||
return true;
|
||||
return get_bool("B4");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user