git-svn-id: svn://10.65.10.50/branches/R_10_00@23160 c028cbd2-c16b-5b4b-a496-9718f37d4682

This commit is contained in:
guy 2015-12-21 11:19:46 +00:00
parent 5a6ba3428f
commit 04a1ce4267
37 changed files with 1125 additions and 737 deletions

View File

@ -679,7 +679,7 @@ bool TMotore_application::user_create( )
_msk->set_handler(F_ANNO, TDocumento_mask::anno_handler);
_msk->set_handler(F_CODNUM, TDocumento_mask::num_handler);
_msk->set_handler(F_NUMDOCRIF, TDocumento_mask::numdocrif_search_handler);
_msk->set_handler(F_RAGSOCSEARCH, TDocumento_mask::ragsoc_search_handler);
//_msk->set_handler(F_RAGSOCSEARCH, TDocumento_mask::ragsoc_search_handler);
_msk->set_handler(F_NDOC, ndoc_handler);
const int args = argc() ;

View File

@ -159,12 +159,23 @@ END
NUMBER F_CODCF 6
BEGIN
PROMPT 24 8 "Codice "
/*
USE LF_DOC KEY 2 SELECT (CODNUM==#F_CODNUM)&&(PROVV==#F_PROVV)&&(ANNO==#F_ANNO)&&((#F_STATO=="")||(STATO==#F_STATO))
JOIN LF_CLIFO INTO TIPOCF==TIPOCF CODCF==CODCF
INPUT TIPOCF F_TIPOCF SELECT
INPUT CODCF F_CODCF
INPUT CODCF F_CODCF SELECT
INPUT PROVV F_PROVV
INPUT ANNO F_ANNO
INPUT ANNO F_ANNO
*/
USE LF_DOC SELECT (TIPOCF==#F_TIPOCF)&&((#F_CODCF="")||(CODCF==#F_CODCF))&&((#F_STATO=="")||(STATO==#F_STATO))
BY LF_CLIFO->CODCF NDOC
JOIN LF_CLIFO INTO TIPOCF==TIPOCF CODCF==CODCF
INPUT PROVV F_PROVV SELECT
INPUT ANNO F_ANNO SELECT
INPUT CODNUM F_CODNUM SELECT
DISPLAY "Codice" CODCF
DISPLAY "Ragione Sociale@50" LF_CLIFO->RAGSOC
DISPLAY "Partita IVA@12" LF_CLIFO->PAIV
@ -174,10 +185,9 @@ BEGIN
DISPLAY "Tipo" TIPODOC
DISPLAY "N.Doc. " NDOC
DISPLAY "Stato@R" STATO
DISPLAY "Data\ndocumento" DATADOC
DISPLAY "Data\ndocumento@10" DATADOC
DISPLAY "Valuta" CODVAL
DISPLAY "Totale\ndocumento@18V" G1:TOTDOC
DISPLAY "Stato" STATO
COPY OUTPUT F_NDOC
OUTPUT F_CODCF CODCF
CHECKTYPE NORMAL
@ -193,7 +203,16 @@ END
STRING F_RAGSOCSEARCH 50
BEGIN
PROMPT 2 9 "Ragione Sociale "
FLAGS "B"
USE LF_DOC SELECT (TIPOCF==#F_TIPOCF)&&(LF_CLIFO->RAGSOC?=(#F_RAGSOCSEARCH+"*"))&&((#F_STATO=="")||(STATO==#F_STATO))
BY LF_CLIFO->RAGSOC NDOC
JOIN LF_CLIFO INTO TIPOCF==TIPOCF CODCF==CODCF
INPUT PROVV F_PROVV SELECT
INPUT ANNO F_ANNO SELECT
INPUT CODNUM F_CODNUM SELECT
COPY DISPLAY F_CODCF
COPY OUTPUT F_NDOC
OUTPUT F_CODCF CODCF
CHECKTYPE NORMAL
END
ENDPAGE

View File

@ -48,4 +48,8 @@
: MESSAGE_LV_DOT ( s1 -- )
DOC_LV_DOT \ user defined word in ve1.exe
;
: MESSAGE_ADD_ROW ( s1 s2 s3 -- )
DOC_ADD_ROW \ user defined word in ve1.exe
;

View File

@ -48,10 +48,13 @@ public:
TRiga_documento& TDoc_recordset::riga_doc(int n) const
{
if (n < 0 || n > _doc->rows()) // Non dovrebbe succedere mai
{
n = _doc->new_row("05").numero(); // Crea una riga descrizione fittizia
((TDoc_recordset*)this)->_lastpos++;
}
if (n <= 0)
n = _mypos+1;
if (n > _doc->rows()) // Non dovrebbe succedere mai
n = _doc->new_row("05").get_int(RDOC_NRIGA); // Crea ua riga descrizione fittizia
if (n <= 0)
n = 1;
return _doc->row(n);
@ -282,6 +285,8 @@ protected:
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);
TVariant eval_rdoc(const TRiga_documento& rdoc, const TString& formula, TFieldtypes ft) const;
TDocumentoEsteso& doc();
TRiga_documento& riga_doc(int n = 0);
@ -295,7 +300,8 @@ protected:
bool msg_scadenze(TVariant_stack& stack);
bool msg_tot_imponibili(TVariant_stack& stack);
bool msg_lv_dot(TVariant_stack& stack);
bool msg_add_row(TVariant_stack& stack);
int set_printed_status(TDocumento& doc) const;
public:
@ -796,6 +802,104 @@ bool TReport_doc::msg_lv_dot(TVariant_stack& stack)
return true;
}
TVariant TReport_doc::eval_rdoc(const TRiga_documento& rdoc, const TString& formula, TFieldtypes ft) const
{
TExpr_documento expr(formula, _strexpr, &rdoc.doc(), &rdoc);
for (int v = expr.numvar()-1; v >= 0; v--)
{
const TFixed_string fld = expr.varname(v);
if (rdoc.TRectype::exist(fld))
expr.setvar(fld, rdoc.get(fld));
else
{
TVariant var;
if (get_usr_val(fld, var))
expr.setvar(fld, var.as_string());
}
}
TVariant tmp;
switch (ft)
{
case _boolfld: tmp.set(expr.as_bool()); break;
case _realfld: tmp.set(expr.as_real()); break;
default : tmp.set(expr.as_string()); break;
}
return tmp;
}
bool TReport_doc::msg_add_row(TVariant_stack& stack)
{
TString4 row_type;
TString codart_expr;
TString descr_expr;
TToken_string sum_fields;
for (int v = 0; !stack.empty(); v++)
{
const TString& riga = stack.pop().as_string();
switch (v)
{
case 0: row_type.strncpy(riga, 2); break;
case 1: codart_expr = riga; break;
case 2: descr_expr = riga; break;
default: sum_fields.add(riga); break;
}
}
TRiga_documento& curr_rdoc = riga_doc(0);
if (curr_rdoc.get(RDOC_TIPORIGA) == row_type)
return false; // Riga generata
const TCodice_articolo codart = eval_rdoc(curr_rdoc, codart_expr, _alfafld).as_string();
const int curr_riga = curr_rdoc.numero();
const int last_riga = doc().physical_rows();
int good_riga = 0;
for (int i = last_riga; i > curr_riga; i--)
{
const TRiga_documento& rdoc = riga_doc(i);
if (rdoc.get(RDOC_TIPORIGA) == row_type && rdoc.get(RDOC_CODART) == codart)
{
good_riga = i;
break;
}
}
if (good_riga <= curr_riga) // Nessuna riga compatibile
{
// Aggiungi riga vuota, se necessario
const TRiga_documento& urdoc = riga_doc(last_riga);
if (urdoc.get(RDOC_TIPORIGA) != row_type)
{
TRiga_documento& empty_rdoc = riga_doc(-1);
empty_rdoc.put(RDOC_TIPORIGA, row_type);
}
// Crea nuova riga ragggruppamento
TRiga_documento& new_rdoc = riga_doc(-1);
new_rdoc.put(RDOC_TIPORIGA, row_type);
new_rdoc.put(RDOC_CODART, codart);
good_riga = new_rdoc.numero();
}
TRiga_documento& good_rdoc = riga_doc(good_riga);
FOR_EACH_TOKEN(sum_fields, fld)
good_rdoc.add(fld, curr_rdoc.get_real(fld));
int open_brace = 0;
while ((open_brace = descr_expr.find('{')) >=0)
{
const int close_brace = descr_expr.find('}', open_brace);
if (close_brace < 0) break;
const TString& varname = descr_expr.sub(open_brace+1, close_brace);
TFieldtypes ft = curr_rdoc.type(varname); if (ft == _nullfld) ft = _alfafld;
TVariant var = eval_rdoc(good_rdoc, varname, ft);
const TString& after = descr_expr.mid(close_brace+1);
descr_expr.cut(open_brace)<< var.as_string() << after;
}
good_rdoc.set_descr(descr_expr);
return true;
}
size_t TReport_doc::get_usr_words(TString_array& words) const
{
TReport::get_usr_words(words);
@ -808,6 +912,7 @@ size_t TReport_doc::get_usr_words(TString_array& words) const
"DOC_SCADENZE",
"DOC_TOT_IMPONIBILI",
"DOC_LV_DOT",
"DOC_ADD_ROW",
NULL
};
@ -834,6 +939,7 @@ bool TReport_doc::execute_usr_word(unsigned int opcode, TVariant_stack& stack)
case 4: msg_scadenze(stack); break;
case 5: msg_tot_imponibili(stack); break;
case 6: msg_lv_dot(stack); break;
case 7: msg_add_row(stack); break;
default: ok = false; break;
}
stack.reset(); // Svuota eventuali parametri variabili inutilizzati
@ -923,6 +1029,20 @@ bool TReport_doc_mask::on_field_event(TOperable_field& o, TField_event e, long j
set(F_A_NDOC, dal);
}
break;
case DLG_CONFIG:
if (e == fe_button)
{
TMask m("ba0100m");
TConfig cfg(CONFIG_USER, "Mail");
FOR_EACH_MASK_FIELD(m, i, f) if (f->field())
f->set(f->field()->read(cfg, "Mail"));
if (m.run() == K_ENTER)
{
FOR_EACH_MASK_FIELD(m, i, f) if (f->field())
f->field()->write(cfg, "Mail", f->get());
}
}
break;
default:
break;
}
@ -937,8 +1057,11 @@ TReport_doc_mask::TReport_doc_mask() : TAutomask("ve1300a")
TApplication& a = main_app();
const bool can_pdf = a.has_module(RSAUT);
const bool can_sign = can_pdf && a.has_module(FDAUT);
enable(DLG_EMAIL, can_pdf);
enable(DLG_SIGNMAIL, can_sign);
const int mail_client = xvt_mail_installed();
const bool can_mail = can_pdf && mail_client != 0;
enable(DLG_EMAIL, can_mail);
enable(DLG_SIGNMAIL, can_mail && can_sign);
enable(DLG_CONFIG, can_mail && (mail_client & 0x2) != 0);
enable(DLG_PDF, can_pdf);
enable(DLG_SIGNPDF, can_sign);
}
@ -1079,7 +1202,7 @@ bool TReport_doc_app::get_next_mail(TToken_string& to, TToken_string& cc, TToken
ok = get_mail_address(to, cc);
if (ok)
{
TDocumento doc('D', _anno, _codnum, _ndoc);
const TDocumento doc('D', _anno, _codnum, _ndoc);
doc.riferimento(subj);
if (subj.blank())
{
@ -1087,7 +1210,26 @@ bool TReport_doc_app::get_next_mail(TToken_string& to, TToken_string& cc, TToken
subj << ' ' << _ndoc << TR(" del ") << doc.get(DOC_DATADOC)
<< ' ' << prefix().firm().ragione_sociale();
}
text << TR("Invio documento ") << subj;
TString saluti = esc(ini_get_string(CONFIG_USER, "Mail", "Signature"));
if (saluti.full())
{
if (saluti.find('\n')<0 && fexist(saluti))
{
TScanner s(saluti);
while (!s.eof())
text << s.line() << '\n';
}
else
text << saluti << '\n';
}
else
{
text << TR("Cordiali Saluti");
if (user() != dongle().administrator())
text << " " << cache().get(LF_USER, user(), "USERDESC");
text << ' ' << prefix().firm().ragione_sociale();
}
text.trim();
if (to.full())
ui &= ~0x1; // No user interface
ui |= 0x2; // Query receipt
@ -1196,7 +1338,7 @@ bool TReport_doc_app::nome_report(const TRecordset& doc, int quale, TFilename& p
}
bool TReport_doc_app::print_loop(TRecordset& doc, TOutput_mode mode, bool is_definitive)
bool TReport_doc_app::print_loop(TRecordset& doc, TOutput_mode mode, bool final_print)
{
const int docs = doc.items();
if (docs <= 0)
@ -1226,154 +1368,161 @@ bool TReport_doc_app::print_loop(TRecordset& doc, TOutput_mode mode, bool is_def
yesno_box
#endif
(TR("Si desidera spedire veramente i documenti via mail?\n"
"Rispondendo NO verranno solo salvati gli allegati."));
"Rispondendo NO verranno solo salvati gli allegati."));
}
const bool mail_requested = (mode == out_mail || mode == out_signed_mail);
if (docs > 0)
{
const bool mail_requested = (mode == out_mail || mode == out_signed_mail);
TProgress_monitor pi(docs, TR("Elaborazione documenti..."));
for (short loop = mail_requested ? 0 : 1; loop < 2; loop++)
{
const bool mail_loop = (loop == 0);
const bool print_loop = !mail_loop;
TProgress_monitor pi(docs, TR("Elaborazione documenti..."));
for (short loop = mail_requested ? 0 : 1; loop < 2; loop++)
{
const bool mail_loop = (loop == 0);
const bool print_loop = !mail_loop;
for (int i = 0; i < docs; i++)
{
if (!pi.add_status())
break;
for (int i = 0; i < docs; i++)
{
if (!pi.add_status())
break;
doc.move_to(i);
doc.move_to(i);
const TString4 tipodoc = doc.get(DOC_TIPODOC).as_string();
const TTipo_documento& tipo = cached_tipodoc(tipodoc);
const TString4 tipodoc = doc.get(DOC_TIPODOC).as_string();
const TTipo_documento& tipo = cached_tipodoc(tipodoc);
const bool final_doc = doc.get(DOC_STATO).as_string()[0] >= tipo.stato_finale_stampa();
if (final_print && final_doc)
continue; // Evita lavoro inutile!
bool arc = false;
if (is_definitive)
{
if (doc.get(DOC_STATO).as_string()[0] == tipo.stato_finale_stampa())
continue; // Evita lavoro inutile!
bool arc = false;
if (final_print || final_doc)
{
const TString4 codnum = doc.get(DOC_CODNUM).as_string();
const TCodice_numerazione& cn = cached_numerazione(codnum);
arc = cn.auto_archive();
}
set_next_pdf(&doc);
const TString4 codnum = doc.get(DOC_CODNUM).as_string();
const TCodice_numerazione& cn = cached_numerazione(codnum);
arc = cn.auto_archive();
}
set_next_pdf(&doc);
TToken_string to, cc;
const bool send_mail = mail_requested && get_mail_address(to, cc);
const bool paperless = send_mail || mode == out_pdf || mode == out_signed_pdf;
TToken_string to, cc;
const bool send_mail = mail_requested && get_mail_address(to, cc);
const bool paperless = send_mail || mode == out_pdf || mode == out_signed_pdf;
// Tenta di costruirsi il nome del report: se non stampo su carta cerco di usare un profilo con sfondo
TFilename profilo;
const bool ok = nome_report(doc, paperless ? 2 : 0, profilo);
// Tenta di costruirsi il nome del report: se non stampo su carta cerco di usare un profilo con sfondo
TFilename profilo;
const bool ok = nome_report(doc, paperless ? 2 : 0, profilo);
if (ok)
{
int copies = 1;
if (!paperless)
{
copies = _msk->get_int(F_NCOPIE);
if (copies <= 0 && is_definitive)
copies = tipo.ncopie();
if (copies <= 0)
copies = 1;
}
if (ok)
{
int copies = 1;
if (!paperless)
{
copies = _msk->get_int(F_NCOPIE);
if (copies <= 0 && final_print)
copies = tipo.ncopie();
if (copies <= 0)
copies = 1;
}
TReport_doc& report = reports.get(profilo);
if (send_mail)
{
if (mail_loop)
{
mail_book = new TDoc_book;
if (!report.print(doc, *mail_book, is_definitive, 1, true, false, false)) // Non archiviare per ora...
break;
if (arc) // ... eventualemte archivia direttamente il book senza passare per uno temporaneo
mail_book->archive(NULL, signature);
TReport_doc& report = reports.get(profilo);
if (send_mail)
{
if (mail_loop)
{
mail_book = new TDoc_book;
if (!report.print(doc, *mail_book, final_print, 1, true, false, false)) // Non archiviare per ora...
break;
if (arc) // ... eventualemte archivia direttamente il book senza passare per uno temporaneo
mail_book->archive(NULL, signature);
TString mesg;
TToken_string to, cc; get_mail_address(to, cc);
mesg << tipo.descrizione() << TR(" n. ") << doc.get(DOC_NDOC)
<< TR(" del ") << doc.get(DOC_DATADOC) << TR(" a ") << to;
mail_log.log(0, mesg);
}
}
else
{
if (print_loop)
{
if (!report.print(doc, book, is_definitive, copies, true, arc, signature))
break;
if (!paperless)
print_extra_copies(report, doc, book, copies);
}
}
} //if(profilo.custom_path()...
else
{
TString msg; msg << TR("Report inesistente: ") << profilo;
xvtil_popup_error(msg);
continue;
}
TString mesg;
TToken_string to, cc; get_mail_address(to, cc);
mesg << tipo.descrizione() << TR(" n. ") << doc.get(DOC_NDOC)
<< TR(" del ") << doc.get(DOC_DATADOC) << TR(" a ") << to;
mail_log.log(0, mesg);
}
}
else
{
if (print_loop)
{
if (!report.print(doc, book, final_print, copies, true, arc, signature))
break;
if (!paperless)
print_extra_copies(report, doc, book, copies);
}
}
} //if(profilo.custom_path()...
else
{
TString msg; msg << TR("Report inesistente: ") << profilo;
xvtil_popup_error(msg);
continue;
}
// Stampa eventuali allegati
if (nome_report(doc, 1, profilo))
{
int copies = tipo.additional_ncopie();
if (copies <= 0) copies = 1;
// Stampa eventuali allegati
if (nome_report(doc, 1, profilo))
{
int copies = tipo.additional_ncopie();
if (copies <= 0) copies = 1;
TReport_doc& allegato = reports.get(profilo);
// Cambio _codnum per non sovrascrivere il pdf precedente
if (arc)
{
_codnum = profilo.name();
_codnum = _codnum.before(".");
}
// Il flag di definitivo deve essere false altrimenti riaggiorna lo stato e ristampa i documenti allegati
if (send_mail)
{
if (mail_loop)
allegato.print(doc, *mail_book, false, 1, false, false, false); // Non archivio gli allegati alla mail
}
else
{
if (print_loop)
{
allegato.print(doc, book, false, copies, false, arc, signature);
if (!paperless)
print_extra_copies(allegato, doc, book, copies);
}
}
}
TReport_doc& allegato = reports.get(profilo);
// Cambio _codnum per non sovrascrivere il pdf precedente
if (arc)
{
_codnum = profilo.name();
_codnum = _codnum.before(".");
}
// Il flag di definitivo deve essere false altrimenti riaggiorna lo stato e ristampa i documenti allegati
if (send_mail)
{
if (mail_loop)
allegato.print(doc, *mail_book, false, 1, false, false, false); // Non archivio gli allegati alla mail
}
else
{
if (print_loop)
{
allegato.print(doc, book, false, copies, false, arc, signature);
if (!paperless)
print_extra_copies(allegato, doc, book, copies);
}
}
}
if (mail_book != NULL)
{
if (mail_book->pages() > 0)
{
TFilename attachment;
bool is_tmp = false;
if (mail_book != NULL)
{
if (mail_book->pages() > 0)
{
TFilename attachment;
bool is_tmp = false;
// Se ho archiviato (arc==true) allora il file di attachment e' gia' pronto!
bool ok = arc && get_next_pdf(_anno, -1, _codnum, _ndoc, _codcf, attachment);
if (!ok || !attachment.exist()) // Altrimenti ne creo uno temporaneo
{
attachment.tempdir();
attachment << SLASH << _anno <<'_' << _codnum << '_' << _ndoc;
attachment.ext("pdf");
ok = mail_book->export_pdf(attachment, mode == out_signed_mail);
is_tmp = ok;
}
if (ok && attach_mail) // Ho chiesto la spedizione vera e propria
{
ok = spotlite_send_mail(attachment);
if (is_tmp)
attachment.fremove();
}
}
delete mail_book;
mail_book = NULL;
}
}
}
// Se ho archiviato (arc==true) allora il file di attachment e' gia' pronto!
bool ok = arc && get_next_pdf(_anno, -1, _codnum, _ndoc, _codcf, attachment);
if (!ok || !attachment.exist()) // Altrimenti ne creo uno temporaneo
{
attachment.tempdir();
attachment << SLASH << _anno <<'_' << _codnum << '_' << _ndoc;
attachment.ext("pdf");
ok = mail_book->export_pdf(attachment, mode == out_signed_mail);
is_tmp = ok;
}
if (ok && attach_mail) // Ho chiesto la spedizione vera e propria
{
ok = spotlite_send_mail(attachment);
// Per ora non cancellare allegati mailsend.exe potrebbe non aver finito di scriverli 14/07/2015
// if (is_tmp) attachment.fremove();
TString mesg; mesg << "Invio allegato " << attachment;
if (!ok) mesg << " NON";
mesg << " riuscito";
mail_log.log(0, mesg);
}
}
delete mail_book;
mail_book = NULL;
}
}
}
} // if docs > 0
if (book.pages() > 0)
{
@ -1464,7 +1613,7 @@ void TReport_doc_app::print_trans(const char* ininame)
TConfig ini(ininame, "Transaction");
a = ini.get("Action")[0]; // Stampa, Anteprima, Pdf, ...
m = ini.get("Mode")[0]; // Definitivo o Provvisori
_no_print_dlg = ini.get_bool("NoPrintDlg");
_no_print_dlg = ini.get_bool("NoPrintDlg"); // Nascondi GUI di stampa
}
const TOutput_mode mode = key2mode(a);
const bool is_definitive = m == 'D';
@ -1499,7 +1648,7 @@ TReport_doc_app::TOutput_mode TReport_doc_app::key2mode(KEY k) const
void TReport_doc_app::main_loop()
{
_no_print_dlg = false;
_no_print_dlg = false; // Normalmente mostra la GUI di stampa
const int a = argc();
if (a > 2)
{

View File

@ -42,6 +42,12 @@ BEGIN
FLAGS "D"
END
BUTTON DLG_CONFIG 10 2
BEGIN
PROMPT 7 1 "~Imposta"
PICTURE TOOL_CONFIG
END
BUTTON DLG_NULL 10 2
BEGIN
PROMPT 7 1 ""
@ -131,8 +137,10 @@ BEGIN
INPUT NDOC F_DA_NDOC
DISPLAY "Data@10" DATADOC
DISPLAY "Numero@7" NDOC
DISPLAY "Stato" STATO
DISPLAY "Cliente/Fornitore@40" 20->RAGSOC
DISPLAY "Comune@20" 13->DENCOM
DISPLAY "E-Mail per fatture@40" 20->DOCMAIL
OUTPUT F_DA_NDOC NDOC
GROUP 1
ADD RUN ve0 -0
@ -274,6 +282,13 @@ BEGIN
FLAG "P"
END
STRING DLG_PROFILE 260
BEGIN
PROMPT 1 -1 "Profilo "
PSELECT
FLAGS "H"
END
ENDPAGE
ENDMASK

View File

@ -1,5 +1,3 @@
#include <applicat.h>
#include "velib07.h"
#include "../ba/ba8500.h"

View File

@ -478,6 +478,6 @@ bool TTabelle_sconti::remove()
int ve2100(int argc, char* argv[]) {
TTabelle_sconti a;
a.run(argc, argv, "Tabella sconti ");
a.run(argc, argv, TR("Tabella sconti "));
return 0;
}

View File

@ -646,6 +646,6 @@ bool TCondizioni_vendita::handle_copy(TMask_field &b, KEY k)
int ve2200(int argc, char* argv[])
{
TCondizioni_vendita a;
a.run(argc, argv, "Condizioni di vendita");
a.run(argc, argv, TR("Condizioni di vendita"));
return 0;
}

View File

@ -20,7 +20,6 @@ class TMask_anamag: public TMask
int last_annogiac, last_annosto;
int _disabled_user_page;
int _type_cod, _altype_cod;
TString4 _ean8_pref;
TString8 _ean13_pref;
@ -49,7 +48,6 @@ class TMask_anamag: public TMask
static bool handle_sheet_giac_valgiac(TMask_field &, KEY); // handler
static bool handle_sheet_stomag_stoval(TMask_field &, KEY); // handler
static bool handle_autoinsert_livgiac(TMask_field &, KEY); // handler del campo
static bool handle_classdog2(TMask_field&, KEY); // handler del secondo sottocampo della classe doganale
static void sheetgiac_get(TSheet_field &fld_righe, int item);
static void sheetgiac_put(TSheet_field &fld_righe, int item);
@ -326,9 +324,7 @@ void TMask_anamag::set_parametered_fields()
set_handler(F_STOANNO, handle_stoanno);
}
set_handler(F_CLASSDOG2, handle_classdog2);
// setta i campi della maschera per la pagina giacenze
TSheet_field &fld_stomag = sfield(F_SHEETSTOMAG);
TSheet_field &fld_giac = sfield(F_SHEETGIAC);
@ -1191,18 +1187,6 @@ bool TMask_anamag::handle_sheetgiac(TMask_field &fld, KEY k)
return TRUE;
}
bool TMask_anamag::handle_classdog2(TMask_field& f, KEY k)
{
if (f.to_check(k))
{
TString8 str; str << atoi(f.get());
if (str.len() < f.size())
str.right_just(f.size(), '0');
f.set(str);
}
return true;
}
int TMask_anamag::add_totali_storico(TString & codmag)
{
TSheet_field &s =(TSheet_field &)field(F_SHEETSTOMAG);
@ -1851,6 +1835,7 @@ bool TAnagrafica_magazzino::user_create()
open_files(LF_TAB, LF_TABCOM, LF_ANAMAG, LF_MAG, LF_STOMAG,
LF_UMART, LF_CODCORR, LF_DESLIN, LF_DIST, LF_RDIST, LF_RMOVMAG,
LF_CLIFO, LF_PCON, 0);
// crea l'oggetto per i parametri di livello giacenza
// apre la maschera e dispone gli sheet
_rel= new TRelation(LF_ANAMAG);

View File

@ -29,7 +29,7 @@
#define F_DESCRV 138
#define F_UMP 139
#define F_PESO 140
#define F_CLASSDOG1 141
#define F_CLASSDOG 141
#define F_CLASSDOGD 142
#define F_UBICAZIONE 143
#define F_UBICAZIONE1 144
@ -143,8 +143,6 @@
#define F_CONVET 286
#define F_VALSTATUN 287
#define F_PAESEOR 288
#define F_CLASSDOG2 289
#define F_CLASSDOG3 290
#define F_NUMREGULC1 300
#define F_NUMRIGULC1 301

View File

@ -487,7 +487,7 @@ END
ENDPAGE
PAGE "Unita'" 0 2 0 0
PAGE "Unità" 0 2 0 0
GROUPBOX DLG_NULL 78 3
BEGIN
@ -509,12 +509,12 @@ END
TEXT DLG_NULL
BEGIN
PROMPT 1 3 "@bUnita' di misura"
PROMPT 1 3 "@bUnità di misura"
END
SPREADSHEET F_SHEETUM 76 4
BEGIN
PROMPT 1 4 "Unita' di misura "
PROMPT 1 4 "Unità di misura "
FLAGS "A"
USE LF_UMART KEY NRIGA
INPUT CODART F_CODART
@ -839,63 +839,38 @@ BEGIN
CHECKTYPE NORMAL
END
NUMBER F_CLASSDOG1 4
NUMBER F_CLASSDOG 8
BEGIN
PROMPT 1 8 "Nomenclatura combin. "
FIELD CLASSDOG[1,4]
FLAG "Z"
PROMPT 1 8 "Nomenclatura combinata "
FIELD CLASSDOG
USE %NOC
INPUT CODTAB[1,4] F_CLASSDOG1
INPUT CODTAB[5,6] F_CLASSDOG2
INPUT CODTAB[7,8] F_CLASSDOG3
DISPLAY "Codice 1" CODTAB[1,4]
DISPLAY "@3" CODTAB[5,6]
DISPLAY "@3" CODTAB[7,8]
INPUT CODTAB F_CLASSDOG
DISPLAY "Codice@4" CODTAB[1,4]
DISPLAY " @2" CODTAB[5,6]
DISPLAY " @2" CODTAB[7,8]
DISPLAY "Descrizione@50" S0
OUTPUT F_CLASSDOG1 CODTAB[1,4]
OUTPUT F_CLASSDOG2 CODTAB[5,6]
OUTPUT F_CLASSDOG3 CODTAB[7,8]
OUTPUT F_CLASSDOG CODTAB
OUTPUT F_CLASSDOGD S0
VALIDATE REQIF_FUNC 1 F_CLASSDOG2
MESSAGE DIRTY,F_CLASSDOG3
WARNING "Nomenclatura combinata assente"
END
STRING F_CLASSDOG2 2
BEGIN
PROMPT 30 8 ""
FIELD CLASSDOG[5,6]
COPY ALL F_CLASSDOG1
VALIDATE REQIF_FUNC 1 F_CLASSDOG2
MESSAGE DIRTY,F_CLASSDOG3
WARNING "Nomenclatura combinata assente"
END
NUMBER F_CLASSDOG3 2
BEGIN
PROMPT 35 8 ""
FIELD CLASSDOG[7,8]
FLAG "Z"
COPY ALL F_CLASSDOG1
CHECKTYPE NORMAL
VALIDATE FIXLEN_FUNC 8
WARNING "Nomenclatura combinata assente"
END
STRING F_CLASSDOGD 37
STRING F_CLASSDOGD 50 41
BEGIN
PROMPT 40 8 ""
PROMPT 35 8 ""
FLAG "D"
END
STRING F_PROVOR 2
BEGIN
PROMPT 1 9 "Provincia di origine "
PROMPT 1 9 "Provincia di origine (INTRA) "
FIELD LF_ANAMAG->PROV
END
STRING F_PAESEOR 2
BEGIN
PROMPT 50 9 "Paese di origine "
PROMPT 49 9 "Paese di origine (INTRA) "
FIELD LF_ANAMAG->PAESE
END

View File

@ -25,7 +25,7 @@ END
STRING FS_CODUMCORR 2
BEGIN
PROMPT 2 6 "Unita' di misura "
PROMPT 2 6 "Unità di misura "
FIELD UM
FLAG "U"
USE %UMS
@ -40,7 +40,7 @@ END
//Livelli giacenza
STRING FS_LIV1 10
BEGIN
// Non mettere FLAGS "D" perchè disabiliterebbe tutta la colonna
// Non mettere FLAGS "D" perché disabiliterebbe tutta la colonna
FLAGS "U"
PROMPT 2 8 "Livello 1 "
USE GCG

View File

@ -1102,11 +1102,6 @@ void TGestione_listini_semplice::init_modify_mode(TMask& m)
bool TGestione_listini_semplice::user_create()
{
/* Controlla se la chiave ha l'autorizzazione a questo programma
Tdninst dninst;
if (!dninst.can_I_run(true))
return error_box(TR("Programma non autorizzato!")); */
//decide il tipo di condizione di vendita: 'L'istino, 'C'ontratto, 'O'fferta
_tipo = 'L';
_codice = 0L;
@ -1135,11 +1130,10 @@ bool TGestione_listini_semplice::user_create()
}
}
if (_codice > 0 && _tipo < 'C')
_tipo = 'C';
_tipo = 'C'; // Se c'è il cliente deve essere un contratto
else
_tipo = toupper(_tipo);
}
_rel = new TRelation(LF_CONDV);
//attenzione!! questo è il parametro per avere la lunghezza del numero riga sullo sheet

View File

@ -64,9 +64,6 @@ void TRicarico_listini_mask::save()
TProgind pi(s.items(), TR("Salvataggio modifiche"), false, true);
FOR_EACH_SHEET_ROW(s, r, row) if (_dirty[r])
{
if (!pi.setstatus(r))
break;
const TString80 codart = row->get(s.cid2index(F_CODART));
const real sconto = row->get(s.cid2index(F_SCONTO));
const real costo = row->get(s.cid2index(F_COSTO));
@ -104,6 +101,51 @@ void TRicarico_listini_mask::save()
rcondv.rewrite();
}
}
const char* cod = "FGDI";
TLocalisamfile deslin(LF_DESLIN); deslin.setkey(2);
for (int lingua = 0; cod[lingua]; lingua++)
{
TString desc = row->get(s.cid2index(F_DESCFRA+lingua));
if (desc.full())
{
desc.trim();
deslin.zero();
deslin.put("CODART", codart);
deslin.put("CODLIN", cod[lingua]);
if (deslin.read() == NOERR)
{
if (deslin.get("DESCR") != desc)
{
deslin.put("DESCR", desc);
deslin.rewrite();
}
}
else
{
TISAM_recordset rsdeslin("USE DESLIN\nFROM CODART=#ART\nTO CODART=#ART");
rsdeslin.set_var("#ART", codart);
int nriga = 1;
if (rsdeslin.move_last())
nriga += rsdeslin.get("NRIGA").as_int();
deslin.zero();
deslin.put("CODART", codart);
deslin.put("NRIGA", nriga);
deslin.put("CODLIN", cod[lingua]);
deslin.put("DESCR", desc);
const int err = deslin.write();
if (err != NOERR)
{
TString msg;
msg << TR("Descrizione in lingua ") << cod[lingua] << TR(" articolo ") << codart;
cantwrite_box(msg);
}
}
}
}
if (!pi.setstatus(r+1))
break;
}
_dirty.reset();
disable(DLG_SAVEREC);
@ -198,21 +240,24 @@ void TRicarico_listini_mask::load()
}
const TString& codart = sm.get(F_CODART);
const char cod[4] = "FGD";
for (int lingua = 0; lingua < 3; lingua++)
const char* cod = "FGDI";
for (int lingua = 0; cod[lingua]; lingua++)
{
deslin.zero();
deslin.put("CODART", codart);
deslin.put("CODLIN", cod[lingua]);
if (deslin.read() == NOERR)
sm.set(F_DESCFRA+lingua, deslin.get("DESCR"));
else
sm.reset(F_DESCFRA+lingua);
}
TToken_string& r = s.row(-1);
if (r.empty()) // Dummy test
if (r.empty_items()) // Dummy test
{
sm.field(F_RICARICO).on_hit();
sm.field(F_OLDPRICE).on_hit();
sm.field(F_NEWPRICE).on_hit();
sm.efield(F_RICARICO).on_hit();
sm.efield(F_OLDPRICE).on_hit();
sm.efield(F_NEWPRICE).on_hit();
FOR_EACH_MASK_FIELD(sm, i, f)
{
const short id = f->dlg();
@ -541,12 +586,10 @@ class TRicarico_listini : public TSkeleton_application
{
protected:
virtual bool create();
public:
virtual void main_loop();
};
void TRicarico_listini::main_loop()
{
TRicarico_listini_mask mask;
@ -555,9 +598,11 @@ void TRicarico_listini::main_loop()
bool TRicarico_listini::create()
{
#ifndef DBG
Tdninst dninst;
if (!dninst.can_I_run(true))
return error_box(TR("Programma personalizzato non autorizzato!"));
return cantaccess_box(title());
#endif
TSheet_field::set_line_number_width(4);
return TSkeleton_application::create();
}

View File

@ -25,4 +25,5 @@
#define F_DESCFRA 112
#define F_DESCENG 113
#define F_DESCDEU 114
#define F_CODARTALT 115
#define F_DESCITA 115
#define F_CODARTALT 116

View File

@ -175,6 +175,7 @@ BEGIN
ITEM "Descrizione\nFrancese@30"
ITEM "Descrizione\nInglese@30"
ITEM "Descrizione\nTedesco@30"
ITEM "Descrizione\nItaliano@30"
ITEM "Replaced by@20"
END
@ -183,7 +184,7 @@ ENDPAGE
ENDMASK
// maschera di riga sheet
PAGE "Riga aggiornamento listini" -1 -1 66 12
PAGE "Riga aggiornamento listini" -1 -1 66 13
STRING F_CODART 20
BEGIN
@ -293,20 +294,22 @@ END
STRING F_DESCFRA 50
BEGIN
PROMPT 1 9 "Descr. FRA "
FLAGS "D"
END
STRING F_DESCENG 50
BEGIN
PROMPT 1 10 "Descr. ENG "
FLAGS "D"
END
STRING F_DESCDEU 50
BEGIN
PROMPT 1 11 "Descr. DEU "
FLAGS "D"
EN
END
STRING F_DESCITA 50
BEGIN
PROMPT 1 12 "Descr. ITA "
END
ENDPAGE

View File

@ -606,15 +606,15 @@ void TStatistiche_ve::elabora(const TMask& mask) const
if (righe_items > 0)
{
//E crea pure la progind..
TProgind pi(righe_items, TR("Generazione file statistiche..."), true, true);
TProgress_monitor pi(righe_items, TR("Generazione file statistiche..."));
//Scansione del recordset trovato
for (bool ok = righe.move_first(); ok; ok = righe.move_next())
{
if (!pi.addstatus(1))
break;
//scrive sul CSV i campi che servono al file di excel e al report
csv->aggiungi_riga(righe, tipo_dati, tipo_stat, tipo_dettaglio);
if (!pi.add_status())
break;
}
//aggiorna le colonne delle percentuali
@ -696,16 +696,13 @@ void TStatistiche_ve::elabora(const TMask& mask) const
void TStatistiche_ve::main_loop()
{
TStatistiche_ve_mask mask;
while (mask.run() == K_ENTER)
{
elabora(mask);
}
}
bool TStatistiche_ve::create()
{
//controlla se la chiave ha l'autorizzazione a questo programma
//controlla se la chiave ha l'autorizzazione per questo programma
Tdninst dninst;
if (!dninst.can_I_run(true))
return error_box(TR("Programma non autorizzato!"));

View File

@ -1,8 +1,5 @@
#include <applicat.h>
#include <dongle.h>
#include <utility.h>
#include "velib07.h"
#include "../ba/ba8500.h"
///////////////////////////////////////////////////////////

View File

@ -971,7 +971,7 @@ bool TRicalcolo_mask::elabora()
}
TToken_string& key_expr = get_key_expr(cur.key());
TLog_report vw(TR("Ricalcolo valori"));
TLog_report vw(main_app().title());
TTable_expression::set_relation(cur.relation());
TTable_expression::set_window(&vw);

View File

@ -107,7 +107,7 @@ void TStatus_change::main_loop()
msg.add_plural(total, TR("documento"));
if (yesno_box(msg))
{
TProgress_monitor pi(total, name());
TProgress_monitor pi(total, title());
const TString& finale = m.get(F_FINALE);
TDocumento* doc = new TDocumento;
rel.lfile().set_curr(doc);

View File

@ -107,16 +107,17 @@ BEGIN
PROMPT 2 10 "Da "
USE LF_DOC SELECT STATO==#F_INIZIALE
JOIN LF_CLIFO INTO TIPOCF==TIPOCF CODCF==CODCF
INPUT ANNO F_ANNO SELECT
INPUT PROVV F_PROVVIS SELECT
INPUT ANNO F_ANNO SELECT
INPUT CODNUM F_CODNUM SELECT
INPUT NDOC F_DANUMERO
DISPLAY "Num." CODNUM
DISPLAY "Anno" ANNO
DISPLAY "Provv" PROVV
DISPLAY "Anno" ANNO
DISPLAY "Num." CODNUM
DISPLAY "Tipo" TIPODOC
DISPLAY "N.Doc. " NDOC
DISPLAY "Data Doc. " DATADOC
DISPLAY "Stato" STATO
DISPLAY "Ragione Sociale@50" LF_CLIFO->RAGSOC
OUTPUT F_DANUMERO NDOC
CHECKTYPE SEARCH

View File

@ -23,7 +23,7 @@ public:
TArchive_mask::TArchive_mask() : TMask("ve5400")
{
TList_field& lf = (TList_field&)field(F_DRIVE);
TList_field& lf = lfield(F_DRIVE);
TToken_string codes, values;
TString4 str;
int k = 0;
@ -51,7 +51,6 @@ TArchive_mask::TArchive_mask() : TMask("ve5400")
//-------APPLICAZIONE-----------------------------
class TArchive_doc : public TSkeleton_application
{
TArray _file;
TIsamtempfile *_tdoc; //dichiaro un puntatore al file documenti (non posso dichiarare un file)
TIsamtempfile *_trdoc; // righe documenti
TIsamtempfile *_trcf; // clienti/ fornitori
@ -63,12 +62,11 @@ class TArchive_doc : public TSkeleton_application
protected: // TSkeleton_application
virtual void main_loop();
void open_files(int logicnum, ...);
virtual bool create();
void create_tmp_files(bool create);
void delete_tmp_files(bool remove);
void archivia(const TMask& m);
void ripristina(const TMask& m);
bool ripristina(const TMask& m);
bool restore_file(TIsamtempfile& src, bool update);
bool restore_clifo(bool update);
@ -76,26 +74,13 @@ protected: // T
public:
TArchive_doc() { }
virtual ~TArchive_doc() { }
};
void TArchive_doc::open_files(int logicnum, ...)
{
va_list marker;
va_start(marker, logicnum);
while (logicnum > 0)
{
CHECKD(_file.objptr(logicnum) == NULL, "File gia' aperto: ", logicnum);
_file.add(new TLocalisamfile(logicnum), logicnum);
logicnum = va_arg(marker, int);
}
}
bool TArchive_doc::create()
{
open_files(LF_TABCOM, LF_TAB, LF_CLIFO, LF_OCCAS, LF_INDSP, LF_CFVEN,
/* open_files(LF_TABCOM, LF_TAB, LF_CLIFO, LF_OCCAS, LF_INDSP, LF_CFVEN,
LF_DOC, LF_RIGHEDOC, LF_ANAMAG, LF_MOVMAG, LF_RMOVMAG, LF_CONDV,
LF_SVRIEP, LF_AGENTI, LF_PERCPROV, LF_CESS, 0);
LF_SVRIEP, LF_AGENTI, LF_PERCPROV, LF_CESS, 0);*/
_tmp_dir.temp();
_tmp_dir = _tmp_dir.path();
_tmp_dir << "VE";
@ -217,7 +202,8 @@ void TArchive_doc::archivia(const TMask& m)
delete_tmp_files(false); //chiude i files temp in modo da risparmiare memoria
const char * dir = &_tmp_dir[1]; //fa puntare dir alla directory temp
const char* dir = _tmp_dir; //fa puntare dir alla directory temp
if (*dir == '%') dir++;
bool rt = _arc.backup(dir,_unit,_desc, TRUE); //esegue la compressione ed il salvataggio sul device scelto
create_tmp_files(false); //apre i files temp, riallocandoli (NON li crea effettvam.)
delete_tmp_files(true); //cancella fisicamente i files temp
@ -250,16 +236,10 @@ bool TArchive_doc::restore_file(TIsamtempfile& src, bool update)
TProgress_monitor pi(src.items(), msg);
for (int err = src.first(); err == NOERR; err = src.next())
{
err = src.curr().write(dst);
if (err == _isreinsert)
{
if (update)
err = src.curr().rewrite(dst);
else
err = NOERR;
}
dst.curr() = src.curr();
err = dst.write_rewrite();
if (err != NOERR)
return cantwrite_box(src.description());
return cantwrite_box(dst.description());
if (!pi.add_status(1))
break;
}
@ -283,7 +263,7 @@ bool TArchive_doc::restore_docs()
return ok;
}
void TArchive_doc::ripristina(const TMask& m)
bool TArchive_doc::ripristina(const TMask& m)
{
_unit = m.get(F_DRIVE)[0];
_path = m.get(F_PATH);
@ -293,12 +273,15 @@ void TArchive_doc::ripristina(const TMask& m)
if (!xvt_fsys_is_removable_drive(src) && _path.full())
src.add(_path);
src.add("ve.z00");
if (!src.exist())
return cantread_box(src);
const char* dst = _tmp_dir;
if (*dst == '%') dst++;
const char* dst = & _tmp_dir[1];
if (::aga_unzip(src, dst))
{
create_tmp_files(FALSE); // In realta' ci sono gia'
{
create_tmp_files(false); // In realta' ci sono gia'
if (m.get_bool(F_WITHCLI))
restore_clifo(m.get_bool(F_UPDATE));
restore_docs();
@ -306,7 +289,8 @@ void TArchive_doc::ripristina(const TMask& m)
delete_tmp_files(true); // Removes temp files!
}
else
error_box(TR("Errore nella scompattazione dei file. Nessun documento ricevuto."));
return error_box(TR("Errore nella scompattazione dei file. Nessun documento ricevuto."));
return true;
}

View File

@ -68,16 +68,16 @@ void TFatturazione_bolle_app::process_by_cli(const TMask& m)
const long dn = m.get_long(F_NUMERO_DOCUMENTO_DA);
const long an = m.get_long(F_NUMERO_DOCUMENTO_A);
TElaborazione * e = elab(m.get(F_CODICE_ELAB));
TElaborazione & eld = *e;
TElaborazione& eld = *elab(m.get(F_CODICE_ELAB));
TToken_string tipidoc(24), statidoc(10);
eld.tipi_stati_iniziali(tipidoc, statidoc);
TTipo_documento t(eld.tipo_iniziale(0));
char tipocf(t.tipocf());
TLista_cf clienti(tipocf);
const int tot_cli = clienti.leggi(dc, ac, da, aa, dz, az);
const int tot_cli = clienti.leggi_doc(eld, dd, ad, dc, ac, da, aa, dz, az);
TString msg(80);
iw.set_max(tot_cli);
for (int c = 0; c < tot_cli; c++)
@ -102,7 +102,7 @@ void TFatturazione_bolle_app::process_by_cli(const TMask& m)
if (!iw.add_status())
break;
}
delete e;
delete &eld;
}
void TFatturazione_bolle_app::process_by_ragsoc(const TMask& m)

View File

@ -230,7 +230,7 @@ class TTipo_documento : public TRectype // velib03
char _tipocf;
char _tipocr;
char _check_qta;
bool _cnt_prezzi, _show_evaded_lines, _load_cont, _non_evadere, _hca_req, _check_double_art;
bool _cnt_prezzi, _show_evaded_lines, _load_cont, _non_evadere, _hca_req, _check_double_art, _ignora_anticipi_fatturazione;
protected:
void add_formula_if_needed(TConfig& profile, TString& variable, const char* varname, const char* formula);
@ -341,12 +341,11 @@ public:
bool da_evadere() const { return !_non_evadere; }
bool head_ca_required() const { return _hca_req; }
bool check_double_art() const { return _check_double_art; }
bool ignora_anticipi_fatturazione() const { return _ignora_anticipi_fatturazione; }
TTipo_documento(const char* tipodoc = NULL);
TTipo_documento(const TRectype& rec);
virtual ~TTipo_documento();
};
const TTipo_documento& cached_tipodoc(const char* tipodoc);
@ -484,7 +483,7 @@ public:
bool formfeed() const { return get_bool("B0"); }
TFormula_documento* first_formula() { return succ_formula(true); }
TFormula_documento* succ_formula(bool restart = FALSE);
TFormula_documento* succ_formula(bool restart = false);
int read(const char* tiporig);
void set_defaults(TSheet_field& s, int row) const;
@ -539,13 +538,13 @@ protected:
virtual TRiga_documento & copy(const TRiga_documento & r);
TObject* dup() const { return new TRiga_documento(*this); }
virtual void set_variables(TExpression * e) const ;
virtual void set_variables(TExpression* e) const ;
bool has_doc() const { return _doc != NULL;}
static void test_firm();
public:
void dirty_fields(bool dirty_document = true);
void dirty_fields(bool dirty_document = true);
bool doc_dependent() const;
int numero() const { return get_int(RDOC_NRIGA); }
void set_numero(int numero) { put(RDOC_NRIGA, numero);}
@ -566,7 +565,7 @@ public:
(is_spese() && !spesa().is_percentuale()) || is_prestazione(); }
bool is_evasa() const; // Ritorna vero se la riga è evasa
void checked(bool on = true) { put(RDOC_CHECKED, (bool)on); }
void unchecked() { checked(FALSE); }
void unchecked() { checked(false); }
bool linked() const { return get(RDOC_DACODNUM).full(); }
// @cmember Assegna il documento corrente
void set_doc(TDocumento * doc) { _doc = doc; }
@ -619,9 +618,9 @@ public:
real prezzo(bool scontato, bool lordo, int ndec = AUTO_DECIMALS) const ;
real importo(bool scontato , bool lordo, int ndec = AUTO_DECIMALS) const ;
real sconto() const { return importo(FALSE,FALSE) - importo(true,FALSE); }
real sconto() const { return importo(false,false) - importo(true,false); }
real iva(int ndec) const;
real imponibile(bool lordo = FALSE) const;
real imponibile(bool lordo = false) const;
real imponibile_omaggio(int iva_calc_mode = 1) const;
real iva_omaggio(int ndec, int iva_calc_mode = 1) const;
real imposta(bool round = true) const;
@ -701,7 +700,8 @@ public:
~TRiepilogo_iva() {};
};
class TAgente ;
class TAgente;
class TDoc_key;
class TDocumento : public TMultiple_rectype // velib03
{
@ -770,7 +770,7 @@ public:
const TString& codiva_spese() const ;
const TString& codiva_bolli() const ;
TCodgiac_livelli & livelli() const ;
TCodgiac_livelli& livelli() const ;
void dirty_fields();
TAssoc_array& tabella_iva(bool solo_imponibili = false) { update_tabella_iva(solo_imponibili); return _tabella_iva; }
@ -783,9 +783,9 @@ public:
const TString& riferimento(TString& rif) const { return tipo().riferimento(*this, rif); }
virtual TRecord_array& body(int logicnum = 0) const;
virtual TDocumento & operator =(const TDocumento & d) {return copy(d);}
virtual TRectype & operator =(const TRectype & r);
virtual TRectype & operator =(const char * r);
virtual TDocumento& operator =(const TDocumento & d) { return copy(d); }
virtual TRectype& operator =(const TRectype & r);
virtual TRectype& operator =(const char * r);
virtual void zero(const char * fieldname);
virtual void zero(char c = '\0') { TMultiple_rectype::zero(c); }
void sort_rows(const char * key);
@ -810,15 +810,14 @@ public:
int read(const TRectype& rec, word op = _isequal, word lockop = _nolock) { *this = rec; return read(op, lockop); }
int read(word op = _isequal, word lockop = _nolock) { TLocalisamfile f(LF_DOC); return read(f, op, lockop);}
int write(bool re = FALSE) const { TLocalisamfile f(LF_DOC); return write_rewrite(f, re);}
int write(bool re = false) const { TLocalisamfile f(LF_DOC); return write_rewrite(f, re);}
int rewrite() const { return write(true); }
int remove() const { TLocalisamfile f(LF_DOC); return remove(f);}
int decimals(bool price = FALSE) const;
int decimals(bool price = false) const;
void flush_rows();
void calc_provvigione(TProvvigioni_agente & provv, const TString & key, bool first = true, bool generata = true);
char tipo_numerazione() const { return get_char(DOC_PROVV); }
int anno() const { return get_int(DOC_ANNO); }
const TString& numerazione() const { return get(DOC_CODNUM); }
@ -869,8 +868,8 @@ public:
real spese_incasso(real &imp, int ndec, TTipo_importo netto = _lordo) const ;
real bolli(real & imp, int ndec, TTipo_importo netto = _lordo) const ;
real imponibile(bool spese = FALSE, int ndec = AUTO_DECIMALS) const;
real imposta(bool spese = FALSE, int ndec = AUTO_DECIMALS) const;
real imponibile(bool spese = false, int ndec = AUTO_DECIMALS) const;
real imposta(bool spese = false, int ndec = AUTO_DECIMALS) const;
real totale_doc() const;
real totale_netto() const;
real basesconto() const;
@ -881,7 +880,7 @@ public:
TPagamento& pagamento();
void update_spese_aut(TString_array & spese, bool preserve_old = FALSE, TSheet_field * sh = NULL);
void update_spese_aut(TString_array & spese, bool preserve_old = false, TSheet_field * sh = NULL);
real calc_conai_qta(TCONAI_class type);
void update_conai();
@ -895,12 +894,12 @@ public:
const TString & codesiva() const;
void get_protocolli_esenzione(TString & esenzione, TString & data_esenzione,
TString & registrazione, TString & data_registrazione) const;
void cli2doc() { clifor().cli2doc(*this); }
TDocumento ();
TDocumento (const TDocumento & d);
TDocumento (const TDocumento& d);
TDocumento(char provv, int anno, const char* codnum, long numdoc);
TDocumento(const TRectype& doc);
TDocumento(const TDoc_key& key);
virtual ~TDocumento();
};
@ -928,7 +927,7 @@ public:
TCurrency_documento(const TCurrency& cur) { copy(cur); }
TCurrency_documento(const TCurrency_documento& cur) { copy(cur); }
TCurrency_documento(const real& num, const TDocumento &doc, bool price = FALSE);
TCurrency_documento(const real& num, const TDocumento &doc, bool price = false);
virtual ~TCurrency_documento() { }
};
@ -1066,7 +1065,7 @@ public:
static bool anno_handler( TMask_field& f, KEY key);
static bool num_handler( TMask_field& f, KEY key );
static bool numdocrif_search_handler( TMask_field& f, KEY key );
static bool ragsoc_search_handler( TMask_field& f, KEY key );
//static bool ragsoc_search_handler( TMask_field& f, KEY key );
static bool datadocrif_handler(TMask_field& f, KEY key);
static bool liqdiff_handler( TMask_field& f, KEY key );

View File

@ -72,6 +72,7 @@ int TCodice_numerazione::read(const char* codnum)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// trova le numerazioni documenti in base ai tipi richiesti (ca3800,ca3900,ps1001,ha3800)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int numerazioni_documenti(TString_array& num_doc, const TString& tipo_doc)
{
//e adesso cerca le numerazioni che contengono tipi ordine

View File

@ -945,14 +945,15 @@ real TRiga_documento::calc_conai_qta(TCONAI_class type) const
real qta = quantita(); // Quantita' merce
if (peso > ZERO && !qta.is_zero()) // Verifica se ha un peso valido
{
const TString4 um = get(RDOC_UMQTA);
TArticolo& art = articolo();
qta = art.convert_to_um(qta, NULL, um); // Converte la quantita nell'unita' base
// A volte CODARTMAG è vuoto per cui converte erroneamente la qta in 0 :-(
if (is_articolo())
{
const TString4 um = get(RDOC_UMQTA);
TArticolo& art = articolo();
qta = art.convert_to_um(qta, NULL, um); // Converte la quantita nell'unita' base
}
kg = qta * peso; // Calcola peso dell'imballo
kg.round(5);
/* TString s = kg.string();
s.trim(); */
}
}
}
@ -990,19 +991,19 @@ real TRiga_documento::valore(bool totale, bool lordo, int ndec) const
return val;
}
const TString & TRiga_documento::codice_costo() const
const TString& TRiga_documento::codice_costo() const
{
const TString& cod_cos = get(RDOC_CODCOSTO);
return cod_cos.empty() ? doc().get(DOC_CODCOSTO) : cod_cos;
}
const TString & TRiga_documento::codice_commessa() const
const TString& TRiga_documento::codice_commessa() const
{
const TString& cod_cms = get(RDOC_CODCMS);
return cod_cms.empty() ? doc().get(DOC_CODCMS) : cod_cms;
}
const TString & TRiga_documento::fase_commessa() const
const TString& TRiga_documento::fase_commessa() const
{
const TString & fas_cms = get(RDOC_FASCMS);
return fas_cms.empty() ? doc().get(DOC_FASCMS) : fas_cms;
@ -1010,8 +1011,8 @@ const TString & TRiga_documento::fase_commessa() const
void TRiga_documento::dirty_fields(bool dirty_document)
{
for (TDocumento_variable_field * f = (TDocumento_variable_field *) first_variable_field();
f != NULL; f = (TDocumento_variable_field *) succ_variable_field())
for (TDocumento_variable_field* f = (TDocumento_variable_field*)first_variable_field();
f != NULL; f = (TDocumento_variable_field*)succ_variable_field())
f->set_dirty();
if (dirty_document)
((TDocumento &)doc()).dirty_fields();
@ -1029,14 +1030,14 @@ bool TRiga_documento::doc_dependent() const
if (tipor == RIGA_SCONTI)
return get(RDOC_SCONTO).not_empty();
}
return FALSE;
return false;
}
void TRiga_documento::put_str(const char* fieldname, const char* val)
{
if (strcmp(fieldname, RDOC_TIPORIGA) == 0)
if (xvt_str_same(fieldname, RDOC_TIPORIGA))
{
const TString4 v(val);
const TString4 v = val;
if (TRectype::get(RDOC_TIPORIGA) != v)
{
TAuto_variable_rectype::put_str(fieldname, v);
@ -1059,9 +1060,9 @@ bool TRiga_documento::is_articolo() const
return (t == RIGA_MERCE || t == RIGA_OMAGGI) && get(RDOC_CODARTMAG).full();
}
void TRiga_documento::zero(const char * fieldname)
void TRiga_documento::zero(const char* fieldname)
{
if (strcmp(fieldname, RDOC_TIPORIGA) == 0)
if (xvt_str_same(fieldname, RDOC_TIPORIGA))
reset_fields(*this);
TAuto_variable_rectype::zero(fieldname);
dirty_fields();
@ -1079,7 +1080,7 @@ void TRiga_documento::cms2tipodet()
{
TString4 cms_tipodet;
const TString4 tipodet = get(RDOC_TIPODET);
TString codcms = codice_commessa();
const TString20 codcms = codice_commessa();
if (codcms.full() && get(RDOC_CODIVA).full())
{
@ -1127,12 +1128,10 @@ void TRiga_documento::autosave(TSheet_field& f)
if (num >= 0 && num < f.items())
{
TMask& m = f.sheet_row_mask(num);
TToken_string & row = f.row(num);
TToken_string& row = f.row(num);
put( RDOC_TIPORIGA, row.get( f.cid2index(FR_TIPORIGA )) );
TString8 codmag(row.get(f.cid2index(FR_CODMAG)));
put( RDOC_TIPORIGA, row.get(f.cid2index(FR_TIPORIGA)));
TString8 codmag = row.get(f.cid2index(FR_CODMAG));
codmag.left_just(3);
codmag << row.get( f.cid2index(FR_CODDEP ));
put( RDOC_CODMAG, codmag);

View File

@ -8,9 +8,12 @@
#include "../cg/cg2103.h"
#include "../db/dblib.h"
#include "../pr/prlib.h"
#include "../sv/svlib01.h"
#include "../li/letint.h"
#ifdef LIVE_STATISTICS
#include "../sv/svlib01.h"
#endif
#include "veini.h"
#include "velib.h"
#include "sconti.h"
@ -226,11 +229,13 @@ long TDocumento::_firm = -1;
TString4 TDocumento::_codiva_spese;
TString4 TDocumento::_codiva_bolli;
short TDocumento::_has_mag = 3;
short TDocumento::_has_stat_ven = 3;
short TDocumento::_has_provv = 3;
#ifdef LIVE_STATISTICS
short TDocumento::_has_stat_ven = 3;
#endif
TCodgiac_livelli * TDocumento::_livelli=NULL;
// HIDDEN TStats_agg _st_agg;
HIDDEN TAssoc_array _docs_to_agg;
void TDocumento::init()
@ -265,15 +270,24 @@ TDocumento::TDocumento(char provv, int anno, const char* codnum, long numdoc)
: TMultiple_rectype(LF_DOC)
{
init();
if (numdoc <= 0)
{
numdoc = 0;
set_key(*this, provv, anno, codnum, numdoc);
}
else
if (numdoc > 0)
read(provv, anno, codnum, numdoc);
else
set_key(*this, provv, anno, codnum, 0L);
}
TDocumento::TDocumento(const TDoc_key& key)
: TMultiple_rectype(LF_DOC)
{
init();
const long ndoc = key.ndoc();
if (ndoc > 0)
read(key.provv(), key.anno(), key.codnum(), ndoc);
else
set_key(*this, key.provv(), key.anno(), key.codnum(), 0L);
}
TDocumento::TDocumento(const TRectype& rec)
: TMultiple_rectype(LF_DOC)
{
@ -299,12 +313,14 @@ const TString& TDocumento::codiva_bolli() const
void TDocumento::check_modules()
{
if (_has_mag == 3)
if (_has_mag < 0 || _has_mag > 1)
{
const TDongle& din = dongle();
_has_mag = din.active(MGAUT);
_has_stat_ven = din.active(SVAUT);
_has_provv = din.active(PRAUT);
#ifdef LIVE_STATISTICS
_has_stat_ven = din.active(SVAUT);
#endif
}
}
@ -606,26 +622,53 @@ const TString & TDocumento::commessa_principale() const
return codice_commessa();
}
bool TDocumento::modificabile() const
{
const char stato_attuale = stato();
// Controlla se un documento è incluso nelle statistiche definitive
static bool doc_invalidating_stats(const TDocumento& doc)
{
bool inv = false;
if (dongle().active(SVAUT) && doc.tipo().statistiche())
{
const TDate datadoc = doc.get(DOC_DATADOC);
if (datadoc.ok())
{
const TDate datalast = ini_get_string(CONFIG_DITTA, "sv", "UltimoCalcolo");
inv = datadoc <= datalast;
}
}
return inv;
}
if (stato_attuale <= ' ')
return true;
const TString& stati_modifica = tipo().stati_iniziali_modifica();
return stati_modifica.blank() || stati_modifica.find(stato_attuale) >= 0;
bool TDocumento::modificabile() const
{
bool maybe = true;
const char stato_attuale = stato();
if (stato_attuale > ' ')
{
const TString& stati_modifica = tipo().stati_iniziali_modifica();
maybe = stati_modifica.blank() || stati_modifica.find(stato_attuale) >= 0;
if (maybe && doc_invalidating_stats(*this))
maybe = false;
}
return maybe;
}
bool TDocumento::cancellabile() const
{
const char stato_attuale = stato();
bool maybe = true;
if (stato_attuale <= ' ')
return true;
const TString& stati_cancellazione = tipo().stati_iniziali_cancellazione();
return stati_cancellazione.blank() || stati_cancellazione.find(stato_attuale) >= 0;
const char stato_attuale = stato();
if (stato_attuale > ' ')
{
const TString& stati_cancellazione = tipo().stati_iniziali_cancellazione();
maybe = stati_cancellazione.blank() || stati_cancellazione.find(stato_attuale) >= 0;
if (maybe && doc_invalidating_stats(*this))
maybe = false;
}
return maybe;
}
bool TDocumento::stampabile() const
@ -644,12 +687,13 @@ bool TDocumento::stampabile() const
bool TDocumento::bloccato() const
{
const char stato_attuale = stato();
if (stato_attuale <= ' ')
return false;
if (doc_invalidating_stats(*this))
return true;
char stato_bloccato = tipo().stato_bloccato();
if (stato_bloccato <= ' ')
return false;
@ -662,12 +706,10 @@ bool TDocumento::chiuso() const
return false;
const char stato_attuale = stato();
if (stato_attuale <= ' ')
return false;
char stato_chiuso = tipo().stato_chiuso();
if (stato_chiuso <= ' ')
return false;
@ -711,11 +753,11 @@ void TDocumento::copy_data(TRectype& dst, const TRectype& src)
dst.put(RDOC_NRIGA, nriga);
dst.put(RDOC_IDRIGA, idriga);
dst.zero(RDOC_MOVMAG);
const TString memo = src.get(RDOC_DESCEST);
const TString& memo = src.get(RDOC_DESCEST);
dst.put(RDOC_DESCEST, memo);
const TString g1 = src.get(RDOC_RG1);
const TString& g1 = src.get(RDOC_RG1);
dst.put(RDOC_RG1, g1);
((TRiga_documento & )dst).load_memo();
((TRiga_documento&)dst).load_memo();
}
else
{
@ -778,6 +820,7 @@ void TDocumento::on_read(int err, word lockop)
set_riga_esenzione();
_stato_originale = stato();
#ifdef LIVE_STATISTICS
if (err == NOERR && _has_stat_ven && tipo_valido() && tipo().statistiche() )
{
const TDoc_key key(head());
@ -803,6 +846,7 @@ void TDocumento::on_read(int err, word lockop)
_docs_to_agg.remove(key);
}
}
#endif
_old_agente.cut(0);
_old_agente1.cut(0);
@ -1026,7 +1070,7 @@ void TDocumento::dirty_fields()
for (int i = righe.last_row(); i > 0; i = righe.pred_row(i))
{
TRiga_documento& r = (TRiga_documento&)righe[i];
r.dirty_fields(FALSE);
r.dirty_fields(false);
}
}
_dirty_deny = true;
@ -1512,6 +1556,8 @@ int TDocumento::write_rewrite(TBaseisamfile & f, bool re) const
}
if (_has_provv && tipo().provvigioni() && tipo().stato_provvigioni() <= stato())
myself.update_provvigioni(false);
#ifdef LIVE_STATISTICS
if (_has_stat_ven && tipo().statistiche())
{
const TDoc_key key(myself.head());
@ -1540,13 +1586,16 @@ int TDocumento::write_rewrite(TBaseisamfile & f, bool re) const
st_agg->sub(myself.row(i));
}
}
#endif
}
return err;
}
// eliminare anche il mov di mag. ??????
// eliminare anche il mov di mag. ??????
int TDocumento::remove(TBaseisamfile& f) const
{
if (!cancellabile() && !yesno_box("Documento non cancellabile,\nContinuare ugualmente"))
if (!cancellabile() && !delete_box("Documento non cancellabile.\nSi desidera continuare ugualmente?"))
return NOERR;
const bool check_movmag = _has_mag && tipo().mov_mag();
const bool doc_bloccato = bloccato();
@ -1565,7 +1614,6 @@ int TDocumento::remove(TBaseisamfile& f) const
if (doc_bloccato)
{
const int rows = mov.rows();
for (int i= 1; i <= rows; i++)
mov.body()[i].zero(RMOVMAG_TIPORIGA);
mov.rewrite(m);
@ -1576,6 +1624,7 @@ int TDocumento::remove(TBaseisamfile& f) const
}
if (!doc_bloccato)
{
#ifdef LIVE_STATISTICS
if (_has_stat_ven && tipo().statistiche())
{
const TDoc_key key(head());
@ -1586,6 +1635,7 @@ int TDocumento::remove(TBaseisamfile& f) const
_docs_to_agg.remove(key);
}
}
#endif
if (_has_provv && tipo().provvigioni())
{
TDocumento& myself = *((TDocumento *)this);
@ -3018,18 +3068,21 @@ bool TDocumento::is_nota_credito() const
swap = true;
else
{
const TString4 codcaus(tipo().causale());
if (codcaus.full())
if (tipo().is_fattura())
{
TCausale c(codcaus, data().year());
const char sez = c.sezione_clifo();
//controllo ulteriore sull'iva
TipoIVA tiva = c.reg().iva();
const char tcf = tipocf();
if (tiva == nessuna_iva && tcf > ' ')
tiva = tcf == 'C' ? iva_vendite : iva_acquisti;
if (tiva != nessuna_iva)
swap = ((tiva == iva_vendite) ^ (sez == 'D'));
const TString4 codcaus(tipo().causale());
if (codcaus.full())
{
TCausale c(codcaus, data().year());
const char sez = c.sezione_clifo();
//controllo ulteriore sull'iva
TipoIVA tiva = c.reg().iva();
const char tcf = tipocf();
if (tiva == nessuna_iva && tcf > ' ')
tiva = tcf == 'C' ? iva_vendite : iva_acquisti;
if (tiva != nessuna_iva)
swap = ((tiva == iva_vendite) ^ (sez == 'D'));
}
}
}
return swap;

View File

@ -452,6 +452,7 @@ void TTipo_documento::read_formule()
_module = prof.get("MODULE", NULL, -1, "ve").left(2);
_hca_req = !prof.get_bool("HEAD_CA_OPT");
_check_double_art = prof.get_bool("CHECK_DOUBLE_ART");
_ignora_anticipi_fatturazione = prof.get_bool("IGNORA_ANTICIPI_FATTURAZIONE");
}
bool TTipo_documento::movimento_interno() const
@ -992,8 +993,8 @@ void TExpr_documento::evaluate_user_func(int index, int nparms, TEval_stack & st
{
for (int i = comp.first(); !found && i < items; i = comp.succ(i))
{
TRiga_esplosione & r = (TRiga_esplosione &) comp[i];
const TString c(r.articolo());
TRiga_esplosione& r = (TRiga_esplosione &) comp[i];
const TCodice_articolo c = r.articolo();
if (c.find(substr, pos) > 0)
{

View File

@ -250,7 +250,7 @@ bool TLista_clifo::TClifo::read(char tipo, long cod)
TLista_clifo::TClifo::TClifo(const TRectype& rec)
{
CHECK(rec.num() == LF_CLIFO, "Record non clienti");
CHECK(rec.num() == LF_CLIFO || rec.num() == LF_DOC, "Record senza TIPOCF e CODCF");
const char tipo = rec.get_char(CLI_TIPOCF);
const long codice = rec.get_long(CLI_CODCF);
read(tipo, codice);
@ -313,6 +313,87 @@ int TLista_clifo::leggi(long dc, long ac, long da, long aa, const char * dz, con
return _clifo.items();
}
static bool add_filter(TString& filter, const char* name, long da, long al)
{
if (!(da > 0 || al > da))
return false;
if (filter.full()) filter << "&&";
TString16 field = name;
if (xvt_str_compare_ignoring_case(name, DOC_CODCF) != 0)
field.insert("17->");
if (da == al)
filter << "(" << field << "==" << da << ")"; else
if (da <= 0 && al > 0)
filter << "(" << field << "<=" << al << ")"; else
if (da > 0 && al < da)
filter << "(" << field << ">=" << da << ")";
else
filter << "(BETWEEN(" << field << ',' << da << ',' << al << "))";
return true;
}
int TLista_clifo::leggi_doc(const TElaborazione& eld, const TDate& dd, const TDate& ad,
long dc, long ac, long da, long aa, const char* dz, const char* az)
{
if (!dd.ok())
return leggi(dc, ac, da, aa, dz, az);
TRelation doc(LF_DOC);
doc.add(LF_CFVEN, "TIPOCF==TIPOCF|CODCF==CODCF");
const TRectype& rec = doc.curr();
TRectype start(rec), stop(rec);
start.put(DOC_DATADOC, dd);
stop.put (DOC_DATADOC, ad);
TString filter(127);
add_filter(filter, DOC_CODCF, dc, ac);
add_filter(filter, CLI_CODAG, da, aa);
if (dz && (*dz !='\0'))
{
if (filter.not_empty()) filter << "&&";
filter << '(' << LF_CFVEN << "->" << CLI_CODZONA << ">=\"" << dz << "\")";
}
if (az && (*az !='\0'))
{
if (filter.not_empty()) filter << "&&";
filter << '(' << LF_CFVEN << "->" << CLI_CODZONA << "<=\"" << az << "\")";
}
TCursor cur(&doc, filter, 3, &start, &stop);
TBit_array buoni;
for (cur = 0; cur.ok(); ++cur)
{
const char tipocf = rec.get_char(DOC_TIPOCF);
const long codcf = rec.get_long(DOC_CODCF);
if (tipocf == tipo() && !buoni[codcf])
{
if (eld.is_document_ok(rec))
{
TClifo* c = new TClifo(tipocf, codcf);
_clifo.add(c, codcf);
buoni.set(codcf);
}
}
}
if (da > 0 || aa > 0)
ordina_per_agente();
else
{
if ((dz && (*dz !='\0')) || (az && (*dz !='\0')))
ordina_per_zona();
else
ordina_per_codice();
}
return _clifo.items();
}
int TLista_clifo::leggi_ragsoc(const char *dr, const char * ar, long da, long aa, const char * dz, const char * az)
{
TRelation clifo(LF_CLIFO);

View File

@ -48,6 +48,8 @@ public:
// Lista Cliente/Fornitore per vendite
///////////////////////////////////////////////////////////
class TElaborazione;
class TLista_clifo : public TObject // velib04
{
class TClifo : public TObject
@ -92,6 +94,8 @@ public:
int ordina_per_zona();
int leggi(long dc, long ac, long da = 0, long aa = 0, const char * dz = "", const char * az = "");
int leggi_doc(const TElaborazione& eld, const TDate& dd, const TDate& ad,
long dc, long ac, long da=0, long aa=0, const char * dz="", const char * az="");
int leggi_ragsoc(const char *dr, const char * ar, long da = 0, long aa = 0, const char * dz = "", const char * az = "");
long operator[] (int n) const { return clifo(n).codice(); }
@ -260,7 +264,7 @@ protected:
virtual const TString& get_tipo_out(const TDocumento& doc_out) const { return get("S8"); }
virtual bool da_raggruppare(const TRiga_documento & rin) { return true; }
virtual void elabora_riga(TRiga_documento& r, TDocumento& doc_out, bool usa_dcons, bool ragg_rig, bool ignora_desc,
TToken_string & campi_riga, const TDate & dcons, const TDate & ddoc);
TToken_string& campi_riga, const TDate& dcons, const TDate& ddoc);
void init();
public:
@ -446,7 +450,7 @@ protected:
// Funzione per aggiungere la riga iva al TAssoc_array _righe_iva
// error_type add_iva_row(const TBill&, const TRiga_documento&, const int ndec, const real p = 1.0);
// Funzione atomica per aggiungere le righe di spese d'incasso e bolli al TAssoc_array _righe_iva
void calculate_spese(real&, real&, int, bool, bool, const TString &, const TDocumento & );
void calculate_spese(const real&, real&, int, bool, const TString &, const TDocumento & );
// Funzione per aggiungere le righe di spese d'incasso e bolli al TAssoc_array _righe_iva (chiama calculate_spese())
error_type add_spese_inbo(TDocumento&, const int);
// Aggiorna le righe di sconto importo o percentuale

View File

@ -1,7 +1,5 @@
#include "velib04.h"
#include <dongle.h>
///////////////////////////////////////////////////////////
// TFatturazione bolle
///////////////////////////////////////////////////////////
@ -141,7 +139,7 @@ void TFatturazione_bolle::elabora_riga(TRiga_documento& r, TDocumento& doc_out,
r.put(RDOC_RIGAEVASA, true);
}
bool elaborata = false;
int sommata = 0;
// Raggruppo le righe se e' settato il flag di raggruppamento e
// se la riga non contiene solo una descrizione
@ -156,17 +154,27 @@ void TFatturazione_bolle::elabora_riga(TRiga_documento& r, TDocumento& doc_out,
{
add_rows(*rout, rin);
r.set_final_rdoc_key(*rout);
elaborata = true; // Ricorda di averla gia' elaborata
sommata = nr; // Ricorda di averla gia' elaborata
break;
}
}
}
if (!elaborata) // Se la riga non e' stata gia' sommata ...
if (sommata <= 0) // Se la riga non e' stata gia' sommata ...
{
create_row(doc_out, rin);
// Aggiorna collegamento alla riga di destinazione, cioè l'ultima del docuemnto di output
TRiga_documento& riga_fatt = doc_out[doc_out.physical_rows()];
r.update_rdoc_links(riga_fatt);
// Aggiorna collegamento alla riga di destinazione, cioè l'ultima del documento di output
const int last_row = doc_out.physical_rows();
if (last_row > 0)
{
TRiga_documento& riga_fatt = doc_out[last_row];
if (rin.get(RDOC_CODART) == riga_fatt.get(RDOC_CODART))
r.update_rdoc_links(riga_fatt);
}
}
else
{
TRiga_documento& riga_fatt = doc_out[sommata];
r.set_final_rdoc_key(riga_fatt);
}
}
@ -204,7 +212,7 @@ bool TFatturazione_bolle::raggruppa(TDocumento& doc_in, TDocumento& doc_out)
da_elaborare = ddoc >= data_cons && !rin->get_bool(RDOC_RIGAEVASA);
}
if (!da_elaborare)
return FALSE;
return false;
}
if (gestione_riferimenti())
@ -307,6 +315,13 @@ bool TFatturazione_bolle::raggruppa(TDocumento& doc_in, TDocumento& doc_out)
FOR_EACH_PHYSICAL_RDOC(doc_in, r, rin)
elabora_riga(*rin, doc_out, usa_dcons, ragg_rig, ignora_desc, campi_riga, dcons, ddoc);
// 30 Luglio 2015. Hardy non somma gli anticipi da bolla in quanto già contabilizzati, mentre gli altri li sommano tutti (forse)
if (!doc_in.tipo().ignora_anticipi_fatturazione())
{
const real anticipo = doc_in.get_real(DOC_IMPPAGATO);
doc_out.add(DOC_IMPPAGATO, anticipo); // Somma tutti gli anticipi versati in bolla
}
//cambio stato documento
bool cambia_stato_doc_in = true;
if (usa_dcons)
@ -340,20 +355,25 @@ bool TFatturazione_bolle::get_num_tip_out(const TDocumento& doc, TString& codnum
codnum = codice_numerazione_finale();
tipodoc = get_tipo_out(doc);
const TRectype& cfven = doc.clifor().vendite();
const TString& tipo_cfv = cfven.get(CFV_TIPODOCFAT);
if (tipo_cfv.full())
tipodoc = tipo_cfv;
// Nel caso di fatture controlla il tipo documento preferito dal cliente
const TCodice_numerazione& cn_std = cached_numerazione(codnum);
if (cn_std.tipo() == 2)
{
const TRectype& cfven = doc.clifor().vendite();
const TString& tipo_cfv = cfven.get(CFV_TIPODOCFAT);
if (tipo_cfv.full())
tipodoc = tipo_cfv;
}
bool ok = cn_std.find_tipo_doc(tipodoc) >= 0;
if (!ok)
{
TISAM_recordset num_recset("USE %NUM SELECT I1=2");
const TRectype& rec = num_recset.cursor()->curr();
for (ok = num_recset.move_first(); ok; ok = num_recset.move_next()) // giro sui vari tipi fattura
{
const TCodice_numerazione cn_alt(num_recset.cursor()->curr());
const TCodice_numerazione cn_alt(rec);
if (cn_alt.find_tipo_doc(tipodoc) >= 0)
{
codnum = cn_alt.codice();
@ -524,9 +544,9 @@ bool TFatturazione_bolle::elabora(TLista_documenti& doc_in, TLista_documenti& do
TDocumento::copy_data(new_doc->head(), campione.head()); // Copio la testata
// td = old_tipo_in; // Ripristino il vecchio
new_doc->zero(DOC_SPESEUPD); // Senno' non aggiorna le spese automatiche
new_doc->zero(DOC_SPESEUPD); // Senno' non aggiorna le spese automatiche
new_doc->put(DOC_DATADOC, data_elab);
new_doc->zero(DOC_IMPPAGATO); // 30 Luglio 2015 per Hardy
// Aggiungilo alla lista dei documenti in uscita
od = doc_out.add(new_doc);
@ -578,7 +598,7 @@ bool TFatturazione_bolle::elabora(TLista_documenti& doc_in, TLista_documenti& do
if (change_clifo())
{
const TString4 tipodoc(d.tipo().codice());
const TString4 tipodoc= d.tipo().codice();
TDocumento_mask m(tipodoc);
if (reload_prices())

File diff suppressed because it is too large Load Diff

View File

@ -141,7 +141,7 @@ error_type TGenerazione_effetti::change_group_status(TDocumento& doc, TAssoc_arr
const int items = group_array.items();
if (items > 0)
{
TProgind pi(items, "Cambio stato documenti", false);
TProgress_monitor pi(items, "Cambio stato documenti", false);
_error = no_error;
TToken_string * group_element;
int i=0;
@ -152,7 +152,7 @@ error_type TGenerazione_effetti::change_group_status(TDocumento& doc, TAssoc_arr
// Ciclo sugli elementi dell'assoc_array
for (group_element = (TToken_string *) group_array.first_item(); group_element != NULL && i < items; i++,group_element = (TToken_string*)group_array.succ_item())
{
if (!pi.addstatus(1))
if (!pi.add_status())
break;
group_element->restart();

View File

@ -115,19 +115,22 @@ bool TConsegna_mask::on_field_event(class TOperable_field& f, TField_event e, lo
if (!e.is_zero())
{
TToken_string key(32, ' ');
key.add(row->get(s.cid2index(S_CODART)));
key.add(row->get(s.cid2index(S_LIVGIAC1)));
key.add(row->get(s.cid2index(S_LIVGIAC2)));
key.add(row->get(s.cid2index(S_LIVGIAC3)));
key.add(row->get(s.cid2index(S_LIVGIAC4)));
key.trim();
real* g = (real*)giacenze.objptr(key);
if (g == NULL)
key = row->get(s.cid2index(S_CODART));
if (!cache().get(LF_ANAMAG, key).empty()) // Controlla solo articoli a magazzino
{
g = new real(row->get(s.cid2index(S_GIACENZA)));
giacenze.add(key, g);
key.add(row->get(s.cid2index(S_LIVGIAC1)));
key.add(row->get(s.cid2index(S_LIVGIAC2)));
key.add(row->get(s.cid2index(S_LIVGIAC3)));
key.add(row->get(s.cid2index(S_LIVGIAC4)));
key.trim();
real* g = (real*)giacenze.objptr(key);
if (g == NULL)
{
g = new real(row->get(s.cid2index(S_GIACENZA)));
giacenze.add(key, g);
}
*g -= e;
}
*g -= e;
}
}
}
@ -249,7 +252,7 @@ void TConsegna_mask::doc2mask(const TDocumento& indoc, const TDocumento& outdoc,
if (rec.is_descrizione())
show_line = !_ignora_descrizioni;
if ( show_line && (articolo.blank() || articolo == rec.get(RDOC_CODART)) )
if ( show_line && (articolo.blank() || articolo == rec.get(RDOC_CODARTMAG)) )
{
TToken_string& r = s.row(-1);
r = " ";
@ -273,10 +276,10 @@ void TConsegna_mask::doc2mask(const TDocumento& indoc, const TDocumento& outdoc,
for (int l = 1; l <= 4; l++)
r.add(livelli_giacenza().unpack_grpcode(livello, l));
if (!evasa)
if (!evasa && rec.is_articolo())
{
TArticolo_giacenza ag(rec.get(RDOC_CODART));
const real giac = ag.giacenza_anno(rec.get(RDOC_CODMAG), livello, codes);
const TArticolo_giacenza ag(rec.get(RDOC_CODARTMAG));
const real giac = ag.empty()? ZERO : ag.giacenza_anno(rec.get(RDOC_CODMAG), livello, codes);
r.add(giac.string(), s.cid2index(S_GIACENZA));
}
@ -366,15 +369,19 @@ bool TConsegna_ordini::calcola_ncolli_tara_pnetto(const TString& codart, const r
bool TConsegna_ordini::aggiorna_ncolli_tara_pnetto(TRiga_documento& r) const
{
const TString& codart = r.get(RDOC_CODARTMAG);
TArticolo& articolo = cached_article(codart);
const real qta = articolo.convert_to_um(r.quantita(), NULL, r.get(RDOC_UMQTA));
real ncolli, tara, pnetto;
const bool ok = calcola_ncolli_tara_pnetto(codart, qta, ncolli, tara, pnetto);
bool ok = codart.full();
if (ok)
{
r.put(RDOC_NCOLLI, ncolli);
r.put(RDOC_TARA, tara);
r.put(RDOC_PNETTO, pnetto);
TArticolo& articolo = cached_article(codart);
const real qta = articolo.convert_to_um(r.quantita(), NULL, r.get(RDOC_UMQTA));
real ncolli, tara, pnetto;
ok = calcola_ncolli_tara_pnetto(codart, qta, ncolli, tara, pnetto);
if (ok)
{
r.put(RDOC_NCOLLI, ncolli);
r.put(RDOC_TARA, tara);
r.put(RDOC_PNETTO, pnetto);
}
}
return ok;
}

View File

@ -4,7 +4,7 @@
#include <multirel.h>
#include <postman.h>
#include <recset.h>
// #include <smartcard.h> // Cassato il macchinaro
#include <sheet.h>
#include <treectrl.h>
#include <toolfld.h>
#include <urldefid.h>
@ -1781,7 +1781,7 @@ void TDocumento_mask::update_giacenza()
TSheet_field& sf = sfield(F_SHEET);
TToken_string& row = sf.row(sf.selected());
TString80 codart = row.get(sf.cid2index(FR_CODARTMAG));
TCodice_articolo codart = row.get(sf.cid2index(FR_CODARTMAG));
if (codart.blank())
{
reset(F_CURGIAC);
@ -2940,7 +2940,7 @@ bool TDocument_tree::get_description(TString& str) const
const TRectype& rec = riga();
const TRectype& testata = _relation->curr();
const TString80 codart = rec.get(RDOC_CODART);
const TCodice_articolo codart = rec.get(RDOC_CODART);
str = codart;
str.left_just(21);
str << rec.get(RDOC_DESCR).left(30);
@ -4393,12 +4393,12 @@ static int row_compare(const TObject** obj1, const TObject** obj2)
if (doc[i].get(RDOC_CODART).blank())
return -1;
const TString80 c1 = row1.get(RDOC_CODART);
const TString & c2 = row2.get(RDOC_CODART);
const TString& c1 = row1.get(RDOC_CODART);
const TString& c2 = row2.get(RDOC_CODART);
if (c1.full() && c2.full())
return strcmp((const char *) c1, (const char *) c2);
return r1 - r2;
return c1.compare(c2);
return r1 - r2;
}
bool TDocumento_mask::sort_row_handler( TMask_field& f, KEY key )

View File

@ -2604,6 +2604,7 @@ bool TDocumento_mask::numdocrif_search_handler(TMask_field& f, KEY key)
return true;
}
/*
bool TDocumento_mask::ragsoc_search_handler(TMask_field& f, KEY key)
{
if (key == K_F9)
@ -2650,7 +2651,7 @@ bool TDocumento_mask::ragsoc_search_handler(TMask_field& f, KEY key)
}
return true;
}
*/
bool TDocumento_mask::datadocrif_handler(TMask_field& f, KEY key)
{

View File

@ -493,7 +493,7 @@ bool TDocument_report::msg_parent_doc(TVariant_stack& stack)
int level = stack.pop().as_int();
for (; rdoc != NULL && level > 0; level--)
rdoc = (const TRiga_documento *)(rdoc->find_original_rdoc());
rdoc = (const TRiga_documento*)(rdoc->find_original_rdoc());
const TString& values = stack.pop().as_string();
const bool is_full = stack.peek().as_bool();