Patch level : 3.0 nopatch

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :

Documentazione modulo vendita al dettaglio


git-svn-id: svn://10.65.10.50/trunk@14149 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2006-07-11 13:12:41 +00:00
parent c434cad322
commit cd80466f09
22 changed files with 1556 additions and 133 deletions

View File

@ -1,3 +1,3 @@
34 34
0 0
$rdoc|||513|31|Righe documenti di vendita|NDOC*3|| $rdoc|||520|31|Righe documenti di vendita|NDOC*3||

View File

@ -1,5 +1,5 @@
34 34
55 56
CODNUM|1|4|0|Codice Numeriazione CODNUM|1|4|0|Codice Numeriazione
ANNO|2|4|0|Anno ANNO|2|4|0|Anno
PROVV|1|1|0|Tipo numerazione <P>rovvisoria <D>efinitiva PROVV|1|1|0|Tipo numerazione <P>rovvisoria <D>efinitiva
@ -55,6 +55,7 @@ FASCMS|1|10|0|Fase Commessa
CODCOSTO|1|20|0|Centro di costo CODCOSTO|1|20|0|Centro di costo
CODAGG1|1|20|0|Codice aggiuntivo 1 CODAGG1|1|20|0|Codice aggiuntivo 1
CODAGG2|1|20|0|Codice aggiuntivo 2 CODAGG2|1|20|0|Codice aggiuntivo 2
PRIORITY|3|7|0|Priorita' MSP
7 7
CODNUM+ANNO+PROVV+NDOC+NRIGA| CODNUM+ANNO+PROVV+NDOC+NRIGA|
CODNUM+ANNO+PROVV+CODART+LIVELLO+CODMAG|X CODNUM+ANNO+PROVV+CODART+LIVELLO+CODMAG|X

View File

@ -2,7 +2,7 @@
18 18
CODDITTA|3|5|0|CODICE DITTA CODDITTA|3|5|0|CODICE DITTA
TIPO|1|1|0|TIPOLOGIA DOCUMENTO F fattura/R nota di credito/O ordine TIPO|1|1|0|TIPOLOGIA DOCUMENTO F fattura/R nota di credito/O ordine
DATADOC|5|8|0|DATA DOCUMENTO DATADOC|1|10|0|DATA DOCUMENTO
CODDEP|1|5|0|CODICE DEPOSITO CODDEP|1|5|0|CODICE DEPOSITO
CODMAG|1|3|0|CODICE MAGAZZINO CODMAG|1|3|0|CODICE MAGAZZINO
GRUPPO|1|5|0|GRUPPO GRUPPO|1|5|0|GRUPPO

View File

@ -4,4 +4,4 @@ TIPO|1|3|0|TIPO TABELLA
CODICE|1|25|0|CODICE CODICE|1|25|0|CODICE
DESCRI|1|70|0|DESCRIZIONE DESCRI|1|70|0|DESCRIZIONE
1 1
TIPO+CODICE|X TIPO+CODICE|

View File

@ -188,6 +188,8 @@ Col(25) = FR_TIPORIGA
[RIGHE] [RIGHE]
[DEFAULT]
[HANDLERS] [HANDLERS]
[PROFILOGRUPPO] [PROFILOGRUPPO]

View File

@ -168,18 +168,29 @@ TDocumento_form::TDocumento_form(TRectype& doc, TRelation& rel, bool definitiva,
bool found = false; bool found = false;
TFilename nomeform; TFilename nomeform;
if (aggiuntivo) const TTipo_documento & tipo = __tipi.tipo(tipodoc);
found = tipo.additional_print_profile(nomeform);
else if (tipo.empty())
found = tipo.main_print_profile(nomeform); {
found &= nomeform.ends_with(".frm"); error_box(FR("Tipo di documento non valido: '%s'"), (const char*)tipodoc);
if (!found)
{
error_box(FR("Nome form di stampa '%s' non valido per il tipo documento %s"), (const char*)nomeform, (const char*)tipodoc);
return; return;
} }
if (tipo.printable())
{ // se non ci sono errori procede con la stampa
nomeform = aggiuntivo ? tipo.additional_print_profile() : tipo.main_print_profile(); // legge il nome del form di stampa
nomeform.trim();
_valid = true; TFilename test(nomeform); test.ext("frm");
if (!test.custom_path())
{
error_box(FR("Nome form di stampa '%s' non valido per il tipo documento %s"), (const char*)nomeform, (const char*)tipodoc);
return;
}
}
else
return;
_valid = TRUE;
read(nomeform); read(nomeform);
_cli_loaded= FALSE; _cli_loaded= FALSE;
set_doc_ext(&doc); // istanzia TDocumentoEsteso set_doc_ext(&doc); // istanzia TDocumentoEsteso
@ -1422,25 +1433,22 @@ void TStampaDoc_application::print_selected()
extdoc.scadenze_reset(); extdoc.scadenze_reset();
// Stampa eventuali documenti allegati // Stampa eventuali documenti allegati
TFilename formagg; const TFilename formagg = extdoc.tipo().additional_print_profile();
if (extdoc.tipo().additional_print_profile(formagg)) const int ncopie2 = extdoc.tipo().get_int("I2");
{
const int ncopie2 = extdoc.tipo().get_int("I2");
if (ncopie2 > 0) // Se esiste un tipo documento da accodare if (!formagg.blank() && ncopie2 > 0) // Se esiste un tipo documento da accodare
{ {
TDocumento_form* secform = new TDocumento_form(cur.curr(), *_firmrel, _definitiva, _interattivo, true); TDocumento_form* secform = new TDocumento_form(cur.curr(), *_firmrel, _definitiva, _interattivo, TRUE);
if (secform->valid()) if (secform->valid())
{ {
for (int i = 0; i < ncopie2; i++) for (int i = 0; i < ncopie2; i++)
{ {
print_documento(*secform); print_documento(*secform);
extdoc.summary_reset(); extdoc.summary_reset();
extdoc.scadenze_reset(); extdoc.scadenze_reset();
} }
} }
delete secform; delete secform;
}
} }
} }

View File

@ -158,7 +158,6 @@ class TReport_doc : public TReport
{ {
size_t _first_msg; size_t _first_msg;
protected: protected:
virtual void include_libraries(bool reload); virtual void include_libraries(bool reload);
virtual size_t get_usr_words(TString_array& words) const; virtual size_t get_usr_words(TString_array& words) const;
@ -686,7 +685,6 @@ void TReport_doc::include_libraries(bool reload)
} }
TReport_doc::TReport_doc(const char* name) TReport_doc::TReport_doc(const char* name)
{ {
// istanziamento e impostazione della relazione di gestione della ditta corrente // istanziamento e impostazione della relazione di gestione della ditta corrente
load(name); // Faccio la load altrimenti non include la libreria 1300.alx load(name); // Faccio la load altrimenti non include la libreria 1300.alx
@ -907,8 +905,30 @@ bool TReport_doc_app::print_loop(const TString& query)
TString msg; msg << TR("Report allegato inesistente") << " : " << profilo; TString msg; msg << TR("Report allegato inesistente") << " : " << profilo;
statbar_set_title(TASK_WIN, msg); statbar_set_title(TASK_WIN, msg);
} }
}
// Stampa eventuali allegati
TString16 codalleg = tipo.additional_print_profile();
codalleg.trim();
if (codalleg.not_empty())
{
TFilename profilo(codalleg); profilo.ext("rep");
if (profilo.custom_path())
{
int copies = tipo.additional_ncopie();
if (copies <= 0) copies = 1;
TReport_doc& allegato = reports.get(profilo);
// Il flag di definitvo deve essere false altrimenti riaggiorna lo stato e ristampa i documenti allegati
allegato.print(doc, book, false, copies, false);
}
else
{
TString msg; msg << TR("Report allegato inesistente") << " : " << codalleg;
statbar_set_title(TASK_WIN, msg);
}
}
}
if (book.pages() > 0) if (book.pages() > 0)
book.print_or_preview(); book.print_or_preview();

View File

@ -294,6 +294,7 @@ int TLista_clifo::add(long cod)
return pos; return pos;
} }
///////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TFatturazione_bolle_app // TFatturazione_bolle_app
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////

View File

@ -280,7 +280,7 @@ bool TIndustriosa_app::call_mci(TDocumento& doc, const TRectype& movimento)
ini.set_paragraph(para.row(0)); ini.set_paragraph(para.row(0));
const TTipo_documento& td = doc.tipo(); const TTipo_documento& td = doc.tipo();
const TString4 codcaus = td.causale(); const TString16 codcaus = td.causale();
TCausale causale(codcaus); TCausale causale(codcaus);
FOR_EACH_ASSOC_STRING(hvar, obj, key, field) FOR_EACH_ASSOC_STRING(hvar, obj, key, field)

View File

@ -3,8 +3,6 @@
#include <printer.h> #include <printer.h>
#include <progind.h> #include <progind.h>
#include <sort.h> #include <sort.h>
#include "velib05.h"
#include "ve7.h" #include "ve7.h"
#include "ve7200.h" #include "ve7200.h"
#include "ve7200a.h" #include "ve7200a.h"

View File

@ -15,7 +15,6 @@ Item_09 = "Configurazione", [ACQVEN_020]
Item_10 = "Importazione documenti STORE", <dtmenu.men> Item_10 = "Importazione documenti STORE", <dtmenu.men>
Item_11 = "Trasferimento PACK", <tpmenu.men> Item_11 = "Trasferimento PACK", <tpmenu.men>
[ACQVEN_001] [ACQVEN_001]
Caption = "Archivi e tabelle di base" Caption = "Archivi e tabelle di base"
Picture = <ve00> Picture = <ve00>

View File

@ -12,7 +12,6 @@ JOIN %ABE TO 33 ALIAS 206 INTO CODTAB==ASPBENI1
JOIN %CTR TO 33 ALIAS 207 INTO CODTAB==CAUSTRASP JOIN %CTR TO 33 ALIAS 207 INTO CODTAB==CAUSTRASP
JOIN %BAN TO 33 ALIAS 208 INTO CODTAB==CODABIA JOIN %BAN TO 33 ALIAS 208 INTO CODTAB==CODABIA
END
DESCRIPTION DESCRIPTION
BEGIN BEGIN
33->* "Documenti di vendita" 33->* "Documenti di vendita"
@ -33,7 +32,7 @@ GENERAL
BEGIN BEGIN
OFFSET 0 0 OFFSET 0 0
FONT "Courier New" FONT "Courier New"
SIZE 11 SIZE 10
MODULE "BOLLA STANDARD AGA" MODULE "BOLLA STANDARD AGA"
PRI_DECIMALS 0 3 PRI_DECIMALS 0 3
QTA_DECIMALS 3 3 QTA_DECIMALS 3 3
@ -41,9 +40,7 @@ BEGIN
EXCLUDE "08," EXCLUDE "08,"
END END
SECTION GRAPHICS ODD SECTION GRAPHICS ODD
FIGURA 99 84 63 FIGURA 99 84 63
BEGIN BEGIN
PROMPT 1 2 "bolla.bmp" PROMPT 1 2 "bolla.bmp"
@ -52,7 +49,6 @@ END
END END
SECTION HEADER ODD 32 SECTION HEADER ODD 32
STRINGA 200 1 STRINGA 200 1
BEGIN BEGIN
KEY "abilita/disabilita stampa intestazione ditta " KEY "abilita/disabilita stampa intestazione ditta "

File diff suppressed because it is too large Load Diff

View File

@ -119,6 +119,22 @@ TSpesa_prest::TSpesa_prest(const TRectype& rec)
{ {
} }
TSpesa_prest::genere() const
{
const TString & tipo = get("COD");
if (tipo == "SPP")
return RIGA_SPESEDOC:
else
if (tipo == "PRS")
return RIGA_PRESTAZIONI;
else
if (tipo == "RSS")
return RIGA_RISORSE;
else
if (tipo == "ATR")
return RIGA_ATTREZZATURE;
return ' ';
}
int TSpesa_prest::read(const char* codice) int TSpesa_prest::read(const char* codice)
{ {
const TString8 cod = get("COD"); const TString8 cod = get("COD");

View File

@ -14,6 +14,7 @@
#include "../cg/cg2103.h" #include "../cg/cg2103.h"
#include "../cg/cglib01.h" #include "../cg/cglib01.h"
#include "../mg/mglib.h" #include "../mg/mglib.h"
#include "../mg/anamag.h"
#include "../mg/movmag.h" #include "../mg/movmag.h"
#include "../pr/prlib.h" #include "../pr/prlib.h"
#include "../sv/svlib01.h" #include "../sv/svlib01.h"
@ -169,6 +170,8 @@ void TDocumento::init()
_dirty_deny = FALSE; _dirty_deny = FALSE;
check_modules(); check_modules();
TConfig c(CONFIG_DITTA, "ve");
} }
TDocumento::TDocumento() TDocumento::TDocumento()
@ -879,6 +882,7 @@ int TDocumento::write_rewrite(TBaseisamfile & f, bool re) const
myself.update_conai(); myself.update_conai();
myself.set_row_ids(); myself.set_row_ids();
// const int rows = physical_rows();
long num = get_long("MOVMAG"); long num = get_long("MOVMAG");
@ -969,9 +973,11 @@ int TDocumento::write_rewrite(TBaseisamfile & f, bool re) const
cambio = get_real(DOC_CAMBIO); cambio = get_real(DOC_CAMBIO);
if (cambio == ZERO) if (cambio == ZERO)
cambio = 1.0; cambio = 1.0;
const bool esplodente = TCausale_magazzino(mov.get(DOC_CAUSMAG)).esplodente(); const TString8 cod_caus(mov.get(MOVMAG_CODCAUS));
TString80 codice_riga; TCausale_magazzino caus(cod_caus);
TString16 caus_riga; const bool esplodente = caus.esplodente();
const bool scarica_alt = caus.scarica_alternativi();
TString16 cod_caus_riga;
TDistinta_tree dist; TDistinta_tree dist;
TString80 codart; TString80 codart;
@ -979,17 +985,18 @@ int TDocumento::write_rewrite(TBaseisamfile & f, bool re) const
{ {
TRiga_documento & r = myself.row(i); TRiga_documento & r = myself.row(i);
const bool articolo = r.is_articolo(); const bool articolo = r.is_articolo();
codart = r.get("CODARTMAG"); bool valid_row = articolo;
codice_riga = r.get("CODART");
if (codart.empty()) cod_caus_riga = r.get("CAUSMAG");
codart = codice_riga; if (articolo)
caus_riga = r.get("CAUSMAG"); codart = r.get("CODARTMAG");
bool distinta_da_esplodere = FALSE; else
if (!articolo && {
(codice_riga.not_empty() && codart = r.get("CODART");
(caus_riga.not_empty() ? TCausale_magazzino(caus_riga).esplodente() : esplodente))) if (codart.full() && (cod_caus_riga.full() ? TCausale_magazzino(cod_caus_riga).esplodente() : esplodente))
distinta_da_esplodere = dist.set_root(TCodice_articolo(codice_riga)); valid_row = dist.set_root(TCodice_articolo(codart));
if (articolo || distinta_da_esplodere) }
if (valid_row)
{ {
long r_num = r.get_long("MOVMAG"); long r_num = r.get_long("MOVMAG");
if (r_num == 0) if (r_num == 0)
@ -1009,6 +1016,14 @@ int TDocumento::write_rewrite(TBaseisamfile & f, bool re) const
rm.put(RMOVMAG_IMPIANTO, r.get("IMPIANTO"));; rm.put(RMOVMAG_IMPIANTO, r.get("IMPIANTO"));;
rm.put(RMOVMAG_LINEA, r.get("LINEA")); rm.put(RMOVMAG_LINEA, r.get("LINEA"));
rm.put(RMOVMAG_CODMAG, r.get("CODMAG")); rm.put(RMOVMAG_CODMAG, r.get("CODMAG"));
if (articolo && (cod_caus_riga.full() ? TCausale_magazzino(cod_caus_riga).scarica_alternativi() : scarica_alt))
{
const TRectype art = cache().get(LF_ANAMAG, codart);
const TString & alt = art.get(ANAMAG_CODARTALT);
if (alt.full())
codart = alt;
}
rm.put(RMOVMAG_CODART, codart); rm.put(RMOVMAG_CODART, codart);
rm.put(RMOVMAG_LIVGIAC, r.get("LIVELLO")); rm.put(RMOVMAG_LIVGIAC, r.get("LIVELLO"));
rm.put(RMOVMAG_UM, r.get("UMQTA")); rm.put(RMOVMAG_UM, r.get("UMQTA"));
@ -1019,7 +1034,7 @@ int TDocumento::write_rewrite(TBaseisamfile & f, bool re) const
prezzo.change_to_firm_val(); prezzo.change_to_firm_val();
rm.put(RMOVMAG_PREZZO, prezzo.get_num()); rm.put(RMOVMAG_PREZZO, prezzo.get_num());
rm.put(RMOVMAG_CODCAUS, caus_riga); rm.put(RMOVMAG_CODCAUS, cod_caus_riga);
rm.put(RMOVMAG_TIPORIGA, (char) riga_dadocumento); rm.put(RMOVMAG_TIPORIGA, (char) riga_dadocumento);
} }
} }
@ -1764,7 +1779,7 @@ void TDocumento::update_tabella_iva()
// Aggiorna o aggiunge l'elemento se non esiste // Aggiorna o aggiunge l'elemento se non esiste
const TCodiceIVA & iva = r.iva(); const TCodiceIVA & iva = r.iva();
const TString4 cod(iva.codice()); const TString4 cod(iva.codice());
if (cod.not_empty()) if (cod.full())
{ {
TRiepilogo_iva * aliquota = (TRiepilogo_iva *) table.objptr(cod); TRiepilogo_iva * aliquota = (TRiepilogo_iva *) table.objptr(cod);
if (aliquota == NULL) if (aliquota == NULL)
@ -1848,21 +1863,22 @@ void TDocumento::update_tabella_iva()
if (!val.is_zero()) if (!val.is_zero())
{ {
const TString4 codiva = codiva_es.not_empty() ? (const TString &) codiva_es : codiva_spese(); const TString& codiva = codiva_es.full() ? (const TString &) codiva_es : codiva_spese();
TRiepilogo_iva* ri = (TRiepilogo_iva*)table.objptr(codiva); TRiepilogo_iva* ri = (TRiepilogo_iva*)table.objptr(codiva);
if (ri == NULL) if (ri == NULL && codiva.full())
{ {
ri = new TRiepilogo_iva(TCodiceIVA(codiva)); ri = new TRiepilogo_iva(TCodiceIVA(codiva));
table.add(codiva, ri); table.add(codiva, ri);
} }
if (ri != NULL)
ri->imp_spese() += val; ri->imp_spese() += val;
tot_doc += val; tot_doc += val;
if (!doc_al_lordo) if (!doc_al_lordo)
{ {
val = spese_incasso(ALL_DECIMALS, _imposta); val = spese_incasso(ALL_DECIMALS, _imposta);
ri->iva_spese() += val; if (ri != NULL)
ri->iva_spese() += val;
tot_doc += val; tot_doc += val;
} }
} }
@ -1871,21 +1887,24 @@ void TDocumento::update_tabella_iva()
val = bolli(real(tot_doc - rit), ALL_DECIMALS, doc_al_lordo ? _lordo : _netto); val = bolli(real(tot_doc - rit), ALL_DECIMALS, doc_al_lordo ? _lordo : _netto);
if (val != ZERO) if (val != ZERO)
{ {
const TString16 codiva = codiva_bolli(); const TString& codiva = codiva_bolli();
TRiepilogo_iva* ri = (TRiepilogo_iva *) table.objptr(codiva); if (codiva.full())
{
TRiepilogo_iva* ri = (TRiepilogo_iva*)table.objptr(codiva);
if (ri == NULL)
{
ri = new TRiepilogo_iva(TCodiceIVA(codiva));
table.add(codiva, ri);
}
if (!doc_al_lordo)
{
real valiva = bolli(real(tot_doc - rit), ALL_DECIMALS, _imposta);
ri->iva_spese() += valiva;
tot_doc += valiva;
}
ri->imp_spese() += val;
}
if (ri == NULL)
{
ri = new TRiepilogo_iva(TCodiceIVA(codiva));
table.add(codiva, ri);
}
if (!doc_al_lordo)
{
real valiva = bolli(real(tot_doc - rit), ALL_DECIMALS, _imposta);
ri->iva_spese() += valiva;
tot_doc += valiva;
}
ri->imp_spese() += val;
tot_doc += val; tot_doc += val;
} }
@ -2188,7 +2207,6 @@ TRecord_array& TDocumento::body(int logicnum) const
const bool order = is_ordine(); const bool order = is_ordine();
for (int i = r.last_row(); i > 0; i = r.pred_row(i)) for (int i = r.last_row(); i > 0; i = r.pred_row(i))
{ {
TRectype& rec = r[i]; TRectype& rec = r[i];
TRecfield dcons(rec, RDOC_DATACONS); TRecfield dcons(rec, RDOC_DATACONS);
@ -2236,7 +2254,10 @@ void TDocumento::update_spese_aut(TString_array & spese_aut, bool preserve_old,
sh->destroy(i - 1); sh->destroy(i - 1);
} }
} }
TString4 cod_iva_cli;
const int nspese = spese_aut.items(); const int nspese = spese_aut.items();
if (nspese > 0) if (nspese > 0)
{ {
TString16 key; key.format("%c|%ld", get_char(DOC_TIPOCF), get_long(DOC_CODCF)); TString16 key; key.format("%c|%ld", get_char(DOC_TIPOCF), get_long(DOC_CODCF));
@ -2308,11 +2329,10 @@ void TDocumento::update_spese_aut(TString_array & spese_aut, bool preserve_old,
real TDocumento::calc_conai_qta(int type) real TDocumento::calc_conai_qta(int type)
{ {
const char * const __conai_art_names[] = {"CONACC", "CONALL", "CONCAR", "CONPLA", "CONLEG", "CONVET"}; const char * const __conai_art_names[] = {"CONACC", "CONALL", "CONCAR", "CONPLA", "CONLEG", "CONVET"};
const int nrows = physical_rows(); const int nrows = physical_rows();
real qta; real qta;
for (int i = nrows; i > 0; i--) for (int i = nrows; i > 0; i--)
{ {
const TRiga_documento& r = row(i); const TRiga_documento& r = row(i);
@ -2331,7 +2351,6 @@ real TDocumento::calc_conai_qta(int type)
qta += row_qta; qta += row_qta;
} }
} }
return qta; return qta;
} }

View File

@ -196,7 +196,9 @@ const TString_array& TTipo_documento::sheet_columns() const
{ {
TFilename pn; profile_name(pn); TFilename pn; profile_name(pn);
TConfig prof(pn, "SHEET"); TConfig prof(pn, "SHEET");
for (int i = 0; i < MAX_COLUMNS; i++) TString8 col;
const int ncols = prof.get_int("NCOLS");
for (int i = 1; i <= ncols; i++)
{ {
const TString& id = prof.get("Col", NULL, i); const TString& id = prof.get("Col", NULL, i);
if (atoi(id) <= 0) if (atoi(id) <= 0)
@ -834,6 +836,11 @@ TFormula_documento::TFormula_documento(const TRectype& rec)
_expr = new TExpr_documento(expr_string(), et); _expr = new TExpr_documento(expr_string(), et);
} }
TObject* TFormula_documento::dup() const
{
return new TFormula_documento(*this);
}
TFormula_documento::~TFormula_documento() TFormula_documento::~TFormula_documento()
{ {
if (_expr) if (_expr)

View File

@ -170,7 +170,6 @@ int TLista_documenti::write(bool re) const
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TParametri_elaborazione // TParametri_elaborazione
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////

View File

@ -265,7 +265,6 @@ bool TFatturazione_bolle::elabora(TLista_documenti& doc_in, TLista_documenti& do
const TDate& data_elab, bool interattivo) const TDate& data_elab, bool interattivo)
{ {
TWait_cursor hourglass; TWait_cursor hourglass;
TToken_string campi_doc(128); // Lista di campi che devono essere uguali TToken_string campi_doc(128); // Lista di campi che devono essere uguali
campi_doc = "TIPOCF|CODCF|CODVAL|CODLIN"; // Uguali sempre campi_doc = "TIPOCF|CODCF|CODVAL|CODLIN"; // Uguali sempre

View File

@ -9,6 +9,18 @@
#include "velib04.h" #include "velib04.h"
#include "../ca/calib01.h" #include "../ca/calib01.h"
#include <mov.h>
#include <rmov.h>
#include <rmoviva.h>
#include <clifo.h>
#include <cfven.h>
#include <nditte.h>
#include <occas.h>
#include <scadenze.h>
#include <doc.h>
#include <rdoc.h>
#include "velib.h"
#include "../cg/cg2103.h" #include "../cg/cg2103.h"
#include "../cg/cglib02.h" #include "../cg/cglib02.h"
#include "../cg/cgsaldac.h" #include "../cg/cgsaldac.h"
@ -973,6 +985,7 @@ bool TContabilizzazione::test_swap()
} }
const bool s = (t == iva_vendite) ^ (sez == 'D'); const bool s = (t == iva_vendite) ^ (sez == 'D');
return s; return s;
} }
@ -1174,8 +1187,8 @@ error_type TContabilizzazione::compile_head_mov(TDocumento& doc)
// Codice registro IVA // Codice registro IVA
TRegistro& registro = _caus->reg(); TRegistro& registro = _caus->reg();
const bool iva_mov = registro.ok(); const bool iva_mov = registro.ok();
long ult_prot = 0; long ult_prot = 0;
if (iva_mov) if (iva_mov)
{ {
if (recontabilizing) if (recontabilizing)
@ -1202,7 +1215,7 @@ error_type TContabilizzazione::compile_head_mov(TDocumento& doc)
// Reperisce la valuta // Reperisce la valuta
TDate datacam(doc.get_date(DOC_DATACAMBIO)); TDate datacam(doc.get_date(DOC_DATACAMBIO));
real cambio(doc.cambio()); real cambio(doc.cambio());
TString4 codval(doc.valuta()); codval.trim(); TString4 codval(doc.valuta());
codval.trim(); codval.trim();
@ -1263,7 +1276,6 @@ error_type TContabilizzazione::compile_head_mov(TDocumento& doc)
const TString4 codpag(doc.get(DOC_CODPAG)); const TString4 codpag(doc.get(DOC_CODPAG));
if (sc_enabled(data_reg) || codpag.not_empty()) // La condizione di pagamento va controllata if (sc_enabled(data_reg) || codpag.not_empty()) // La condizione di pagamento va controllata
{ // se e' abilitato il saldaconto o se e' stata inserita { // se e' abilitato il saldaconto o se e' stata inserita
_cpg->put("CODTAB",codpag); _cpg->put("CODTAB",codpag);
if (_cpg->read() != NOERR) if (_cpg->read() != NOERR)
{ {
@ -1847,8 +1859,6 @@ error_type TContabilizzazione::add_spese_inbo(TDocumento& doc, const int ndec)
if (!sp_bolli.is_zero()) if (!sp_bolli.is_zero())
calculate_spese(sp_bolli, iva_sp_bolli, ndec, false, is_cli, doc.codiva_bolli(), doc); calculate_spese(sp_bolli, iva_sp_bolli, ndec, false, is_cli, doc.codiva_bolli(), doc);
return _error; return _error;
} }
@ -2211,7 +2221,6 @@ error_type TContabilizzazione::compile_rows_mov(TDocumento& doc)
// Le righe omaggio senza addebito IVA vanno saltate // Le righe omaggio senza addebito IVA vanno saltate
const bool riga_omaggio = tipo == RIGA_OMAGGI && r.get_bool(RDOC_ADDIVA); const bool riga_omaggio = tipo == RIGA_OMAGGI && r.get_bool(RDOC_ADDIVA);
if ((tipo != RIGA_DESCRIZIONI && tipo != RIGA_SCONTI && tipo != RIGA_RETTIFICHE) || riga_omaggio) if ((tipo != RIGA_DESCRIZIONI && tipo != RIGA_SCONTI && tipo != RIGA_RETTIFICHE) || riga_omaggio)
{ {
const bool spesa = r.tipo().tipo() == RIGA_SPESEDOC; const bool spesa = r.tipo().tipo() == RIGA_SPESEDOC;
char tipo_rit = '\0'; char tipo_rit = '\0';
@ -2360,7 +2369,6 @@ error_type TContabilizzazione::compile_rows_mov(TDocumento& doc)
// Compila le righe // Compila le righe
error_type TContabilizzazione::compile_rows_mov_re(TDocumento& doc) error_type TContabilizzazione::compile_rows_mov_re(TDocumento& doc)
{ {
const int rows = doc.rows(); const int rows = doc.rows();
const int ndec = doc.decimals(); const int ndec = doc.decimals();
@ -2375,7 +2383,6 @@ error_type TContabilizzazione::compile_rows_mov_re(TDocumento& doc)
// Le righe omaggio senza addebito IVA vanno saltate // Le righe omaggio senza addebito IVA vanno saltate
const bool riga_omaggio = tipo == RIGA_OMAGGI && r.get_bool(RDOC_ADDIVA); const bool riga_omaggio = tipo == RIGA_OMAGGI && r.get_bool(RDOC_ADDIVA);
if ((tipo != RIGA_DESCRIZIONI && tipo != RIGA_SCONTI && tipo != RIGA_RETTIFICHE) && !riga_omaggio) if ((tipo != RIGA_DESCRIZIONI && tipo != RIGA_SCONTI && tipo != RIGA_RETTIFICHE) && !riga_omaggio)
{ {
TBill conto; TBill conto;
search_costo_ricavo(conto,r); // l'errore eventuale viene settato qui dentro search_costo_ricavo(conto,r); // l'errore eventuale viene settato qui dentro
@ -2775,7 +2782,6 @@ error_type TContabilizzazione::write_all(TDocumento& doc, TMovimentoPN_VE & movi
TSaldo_agg saldo; TSaldo_agg saldo;
int err = NOERR; int err = NOERR;
const long old_numreg = doc_contabilized(doc, false); const long old_numreg = doc_contabilized(doc, false);
if (old_numreg > 0) if (old_numreg > 0)
{ {
TMovimentoPN oldmov; TMovimentoPN oldmov;
@ -3787,8 +3793,8 @@ bool TContabilizzazione::prev_contabilized(const TDocumento& doc) const
const TString4 stato_doc = rec.get(DOC_STATO); const TString4 stato_doc = rec.get(DOC_STATO);
const TString4 stato_ok = stato_finale_doc_iniziale(); const TString4 stato_ok = stato_finale_doc_iniziale();
return stato_doc >= stato_ok;
return stato_doc >= stato_ok;
} }
static bool link_handler(int n, const char* nreg) static bool link_handler(int n, const char* nreg)
@ -3842,7 +3848,6 @@ bool TContabilizzazione::elabora(TLista_documenti& doc_in, TLista_documenti& doc
p.links().add("Movimento Analitico |r|w", 1); p.links().add("Movimento Analitico |r|w", 1);
p.setlinkhandler(link_handler); p.setlinkhandler(link_handler);
_viswin = new TViswin(NULL, TR("Contabilizzazione documenti"), false, true, true); _viswin = new TViswin(NULL, TR("Contabilizzazione documenti"), false, true, true);
_viswin->open_modal(); _viswin->open_modal();
const clock_t start_time = clock(); const clock_t start_time = clock();

View File

@ -95,7 +95,7 @@ void TDocumentoEsteso::summary_set_next()
TToken_string& codici = _order_array.row(_sum_filter-1); TToken_string& codici = _order_array.row(_sum_filter-1);
const TString4 codiva(codici.get()); // Reperisce il prossimo codice nella lista. (son gia' ordinati per codice) const TString4 codiva(codici.get()); // Reperisce il prossimo codice nella lista. (son gia' ordinati per codice)
if (codiva.not_empty() && _summary_table.is_key(codiva)) if (codiva.full() && _summary_table.is_key(codiva))
{ {
// Estrae da _summary_table i dati relativio al codice corrispondente. // Estrae da _summary_table i dati relativio al codice corrispondente.
const TRiepilogo_iva& riep= (const TRiepilogo_iva&) _summary_table[codiva]; const TRiepilogo_iva& riep= (const TRiepilogo_iva&) _summary_table[codiva];

View File

@ -47,6 +47,28 @@ bool TOriginal_row_mask::on_key(KEY key)
} }
class TOriginal_row_mask : public TAutomask
{
protected:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
virtual bool on_key(KEY key);
public:
TOriginal_row_mask() : TAutomask("ve0100c") { }
};
bool TOriginal_row_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
{
return true;
}
bool TOriginal_row_mask::on_key(KEY key)
{
if (key == K_SHIFT + K_F12)
enable(-1);
return TAutomask::on_key(key);
}
TDocumento_mask::TDocumento_mask(const char* td) TDocumento_mask::TDocumento_mask(const char* td)
: TVariable_mask(), _progs_page(-1), : TVariable_mask(), _progs_page(-1),
@ -926,6 +948,7 @@ void TDocumento_mask::spese2mask()
spese.add(s); spese.add(s);
} }
doc().put("SPESEUPD", false);
doc().put(DOC_CODVAL, get(F_CODVAL)); doc().put(DOC_CODVAL, get(F_CODVAL));
doc().put(DOC_CAMBIO, get(F_CAMBIO)); doc().put(DOC_CAMBIO, get(F_CAMBIO));
doc().put(DOC_CONTROEURO, get(F_CONTROEURO)); doc().put(DOC_CONTROEURO, get(F_CONTROEURO));
@ -992,7 +1015,6 @@ void TDocumento_mask::mask2doc()
if (fr) if (fr)
fr->write(f.get(), doc()); fr->write(f.get(), doc());
} }
} }
TVariable_mask* TDocumento_mask::riga_mask(int numriga) TVariable_mask* TDocumento_mask::riga_mask(int numriga)
@ -1043,6 +1065,9 @@ TVariable_mask* TDocumento_mask::riga_mask(int numriga)
const TCursor * cur = browse->cursor(); const TCursor * cur = browse->cursor();
if (cur) if (cur)
{ {
codmag = c.default_mag();
if (c.has_default_dep())
codmag << c.default_dep();
const int num = cur->file().num(); const int num = cur->file().num();
if (num == LF_ANAMAG || num == LF_CODCORR) if (num == LF_ANAMAG || num == LF_CODCORR)
{ {
@ -1185,7 +1210,7 @@ TVariable_mask* TDocumento_mask::riga_mask(int numriga)
void TDocumento_mask::update_giacenza() void TDocumento_mask::update_giacenza()
{ {
if (id2pos(F_CURGIAC)<0) if (id2pos(F_CURGIAC)<0 || !is_running())
return; return;
TSheet_field& sf = sfield(F_SHEET); TSheet_field& sf = sfield(F_SHEET);
@ -1236,25 +1261,13 @@ void TDocumento_mask::update_giacenza()
giac = art.disponibilita(annoes, codmag, livello, TRUE); giac = art.disponibilita(annoes, codmag, livello, TRUE);
disp = art.disponibilita(annoes, codmag, livello, FALSE); disp = art.disponibilita(annoes, codmag, livello, FALSE);
TLocalisamfile umart(LF_UMART); const TString4 um = row.get(sf.cid2index(FR_UMQTA));
umart.setkey(2); art.convert_to_um(giac, um);
umart.put(UMART_CODART, codart); art.convert_to_um(disp, um);
umart.put(UMART_UM, row.get(sf.cid2index(FR_UMQTA)));
if (umart.read() == NOERR)
{
real curr_fc = umart.get_real(UMART_FC);
if (curr_fc > ZERO)
{
giac /= curr_fc;
disp /= curr_fc;
}
}
} }
set(F_CURGIAC, giac.string()); set(F_CURGIAC, giac.string());
set(F_CURDISP, disp.string()); set(F_CURDISP, disp.string());
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -1362,7 +1375,6 @@ bool TDocumento_mask::ss_notify( TSheet_field& ss, int r, KEY key )
const bool on = rdoc.get(RDOC_DACODNUM).not_empty(); const bool on = rdoc.get(RDOC_DACODNUM).not_empty();
ss.sheet_mask().enable(DLG_USER, on); ss.sheet_mask().enable(DLG_USER, on);
} }
return TRUE; return TRUE;
} }
@ -2213,7 +2225,7 @@ bool TElabora_mask::on_field_event(TOperable_field& o, TField_event e, long joll
break; break;
case F_ROWS: case F_ROWS:
if (e == fe_modify) if (e == fe_modify && is_running())
{ {
TString id; TString id;
@ -2293,7 +2305,6 @@ bool TElabora_mask::on_field_event(TOperable_field& o, TField_event e, long joll
break; break;
} }
return TRUE; return TRUE;
} }
int TElabora_mask::update_list() int TElabora_mask::update_list()

View File

@ -81,6 +81,7 @@ bool numdocrif_hndl( TMask_field& field, KEY key )
} }
return true; return true;
} }
bool totdoc_hndl( TMask_field& field, KEY key ) bool totdoc_hndl( TMask_field& field, KEY key )
@ -102,7 +103,6 @@ bool totdoc_hndl( TMask_field& field, KEY key )
} }
} }
return true; return true;
} }
bool smart_hndl( TMask_field& field, KEY key ) bool smart_hndl( TMask_field& field, KEY key )
@ -152,7 +152,6 @@ bool smart_hndl( TMask_field& field, KEY key )
} }
return true; return true;
} }
bool ora_hndl( TMask_field& field, KEY key ) bool ora_hndl( TMask_field& field, KEY key )
@ -175,7 +174,6 @@ bool ora_hndl( TMask_field& field, KEY key )
ora = field.get(); ora = field.get();
if (ora.not_empty()) if (ora.not_empty())
{ {
if (!isdigit(ora[0]) || if (!isdigit(ora[0]) ||
!isdigit(ora[1]) || !isdigit(ora[1]) ||
!isdigit(ora[2]) || !isdigit(ora[2]) ||
@ -269,9 +267,11 @@ bool note_hndl( TMask_field& f, KEY key )
} }
} }
} }
return true; return true;
} }
// Handler per il calcolo delle date di pagamento // Handler per il calcolo delle date di pagamento
@ -296,11 +296,20 @@ bool data_hndl( TMask_field& field, KEY key )
if (!datadoc.ok()) if (!datadoc.ok())
return field.error_box("La data documento deve essere comunque indicata."); return field.error_box("La data documento deve essere comunque indicata.");
if (m.id2pos(F_DATACAMBIO1) >= 0 && !m.get(F_CODVAL).empty())
m.set(F_DATACAMBIO1, field.get(), TRUE);
}
if (key == K_ENTER || field.to_check(key))
{
const TDate datadoc(m.get(F_DATADOC));
if (!datadoc.ok())
return field.error_box("La data documento deve essere comunque indicata.");
const TCodice_numerazione codnum(m.get(F_CODNUM)); const TCodice_numerazione codnum(m.get(F_CODNUM));
if (codnum.test_eser()) if (codnum.test_eser())
{ {
TEsercizi_contabili esc; TEsercizi_contabili esc;
if (esc.date2esc(datadoc) <= 0) if (esc.date2esc(datadoc) <= 0)
return field.error_box("La data documento non appartiene ad un esercizio valido."); return field.error_box("La data documento non appartiene ad un esercizio valido.");
if (main_app().has_module(CGAUT)) if (main_app().has_module(CGAUT))
@ -321,7 +330,6 @@ bool data_hndl( TMask_field& field, KEY key )
} }
} }
} }
if (codnum.dont_test_datadoc()) if (codnum.dont_test_datadoc())
return true; // Non devo fare altri test return true; // Non devo fare altri test
@ -340,8 +348,8 @@ bool data_hndl( TMask_field& field, KEY key )
return field.error_box("Data documento inferiore alla data del documento precedente"); return field.error_box("Data documento inferiore alla data del documento precedente");
} }
} }
}
return true; return true;
} }
// handler delle righe // handler delle righe
@ -364,6 +372,7 @@ void row_set_handler( TMask& m, const int field, const int index )
yesnofatal_box( false, "Funzione di handler sulla riga non definita( %d ).", index ); yesnofatal_box( false, "Funzione di handler sulla riga non definita( %d ).", index );
} }
} }
HIDDEN TString16 curr_um; HIDDEN TString16 curr_um;
@ -558,6 +567,7 @@ bool tipo_riga_handler(TMask_field& f, KEY key)
} }
bool codmag_handler( TMask_field& f, KEY key ) bool codmag_handler( TMask_field& f, KEY key )
{ {
// if (f.to_check(key, true)) // if (f.to_check(key, true))
@ -618,6 +628,7 @@ bool codmag_coll_handler( TMask_field& f, KEY key )
} }
void upd_colli_peso_tara(TMask& m, const TRectype& a) void upd_colli_peso_tara(TMask& m, const TRectype& a)
{ {
// const real qta = m.get_real(FR_QTA) * curr_fc; // curr_fc puo' non essere inizializzata e vale -1 // const real qta = m.get_real(FR_QTA) * curr_fc; // curr_fc puo' non essere inizializzata e vale -1
@ -650,6 +661,7 @@ void upd_colli_peso_tara(TMask& m, const TRectype& a)
const real peso = qta * a.get_real(ANAMAG_PESO); const real peso = qta * a.get_real(ANAMAG_PESO);
m.fld(pos).set(peso.string()); m.fld(pos).set(peso.string());
} }
} }
@ -1032,6 +1044,340 @@ bool search_price_handler(TMask_field& f, KEY key )
} }
static bool __in_handler = false;
int sort_sheet(const TObject** a, const TObject** b)
{
TToken_string * t1 = (TToken_string *) *a;
TToken_string * t2 = (TToken_string *) *b;
const char * a1 = t1->get(1);
const char * a2 = t2->get(1);
int cmp = strcmp(a1, a2);
if (cmp == 0)
{
TDate d1(t1->get(2));
TDate d2(t2->get(2));
cmp = d2 - d1;
if (cmp == 0)
return t2->get_int(8) - t1->get_int(8);
}
return cmp;
}
void search_price(TMask_field& f, KEY key )
{
TMask& row_mask = f.mask();
TSheet_field& sh = *row_mask.get_sheet();
TDocumento_mask& mask = (TDocumento_mask &)sh.mask();
TArray_sheet sheet(0, 3, -1, 16, "Ricerca Prezzi",
"N.ro doc.|Codice articolo@20|Data@10|Prezzo@18P|Quantità|Sconto@10|Numerazione@18|Tipo Documento@18", 0, 1);
TString_array & el = sheet.rows_array();
TString form;
TRelation * rel = new TRelation(LF_DOC);
TRectype from(rel->curr());
TRectype to(rel->curr());
TDate datadoc = mask.get_date(F_DATADOC);
const long codcf = mask.get_long(F_CODCF);
const TString16 numdoc(mask.get(F_NDOC));
const int last_anno = mask.get_int(F_ANNO);
const int current_doc_row = sh.selected() + 1;
const int first_anno = last_anno - ((TTipo_riga_documento&)mask.doc()[current_doc_row].tipo()).search_years();
TToken_string nums(((TTipo_riga_documento&)mask.doc()[current_doc_row].tipo()).search_nums());
const TString& tipocf = mask.get(F_TIPOCF);
from.put(DOC_TIPOCF, tipocf);
to.put(DOC_TIPOCF, tipocf);
from.put(DOC_CODCF, codcf);
to.put(DOC_CODCF, codcf);
from.put(DOC_PROVV, "D");
to.put(DOC_PROVV, "D");
from.put(DOC_ANNO, first_anno);
to.put(DOC_ANNO, last_anno);
to.put(DOC_DATADOC, datadoc);
if (nums.empty())
nums = mask.get(F_CODNUM);
TString8 first_num(nums.get(0));
TString8 last_num(first_num);;
form << "((CODNUM==\"" << first_num << "\")";
for (const char * s = nums.get(); s && *s; s = nums.get())
{
if (first_num > s)
first_num = s;
if (last_num < s)
last_num = s;
form << "||(CODNUM==\"" << s << "\")";
}
form << ")";
TCursor cur(rel, form, 2, &from, &to);
const int items = cur.items();
cur.freeze();
TRecord_array r(LF_RIGHEDOC, RDOC_NRIGA);
TRectype rec(LF_RIGHEDOC);
for(cur = 0L; cur.pos() < items; ++cur)
{
const TString16 data(cur.curr().get(DOC_DATADOC));
const TString80 num(cache().get("%NUM", cur.curr().get(DOC_CODNUM), "S0"));
const TString80 tipo(cache().get("%TIP", cur.curr().get(DOC_TIPODOC), "S0"));
rec.zero();
rec.put(RDOC_PROVV, cur.curr().get(DOC_PROVV));
rec.put(RDOC_ANNO, cur.curr().get(DOC_ANNO));
rec.put(RDOC_CODNUM, cur.curr().get(DOC_CODNUM));
rec.put(RDOC_NDOC, cur.curr().get(DOC_NDOC));
r.read(rec);
int last_row = r.last_row();
for (int i = r.first_row(); i <= last_row; i = r.succ_row(i))
{
const TRectype & rdoc = r.row(i);
const TString & codart = rdoc.get(RDOC_CODART);
if (codart.not_empty())
{
TToken_string row;
row.add(rdoc.get(RDOC_NDOC));
row.add(codart);
row.add(data);
row.add(rdoc.get(RDOC_PREZZO));
row.add(rdoc.get(RDOC_QTA));
row.add(rdoc.get(RDOC_SCONTO));
row.add(num);
row.add(tipo);
row.add(rdoc.get(RDOC_NRIGA));
el.add(row);
}
}
}
el.TArray::sort(sort_sheet);
const int max_rows = ((TTipo_riga_documento&)mask.doc()[current_doc_row].tipo()).max_rows_art();
if (max_rows > 0)
{
const int items = el.items();
TString80 last_cod;
long last_doc = 0L;
real last_price(ZERO);
int count = 0;
for (int i = 0 ; i < items; i++)
{
const TString & codart = el.row(i).get(1);
long ndoc = el.row(i).get_long(0);
real price(el.row(i).get(3));
if (codart != last_cod)
{
last_cod = codart;
last_doc = ndoc;
last_price = price;
count = 1;
}
else
{
if (ndoc == last_doc && price == last_price)
{
el.destroy(i);
}
else
{
last_doc = ndoc;
last_price = price;
count++;
if (count > max_rows)
el.destroy(i);
}
}
}
el.pack();
}
if (sheet.run() == K_ENTER)
{
__in_handler = true;
const TString & xx = sheet.row(-1).get(3);
row_mask.set(FR_PREZZO, xx);
const TString & codart_sel = sheet.row(-1).get(1);
row_mask.set(FR_CODART, codart_sel, 3);
row_mask.field(FR_CODART).set_dirty(false);
const TString & prezzo = sheet.row(-1).get(3);
row_mask.set(FR_PREZZO, prezzo);
const TString & sconto = sheet.row(-1).get(5);
row_mask.set(FR_SCONTO, sconto);
__in_handler = false;
}
}
void search_price_article(TMask_field& f, KEY key )
{
TMask& row_mask = f.mask();
TSheet_field& sh = *row_mask.get_sheet();
TDocumento_mask& mask = (TDocumento_mask &)sh.mask();
const int current_doc_row = sh.selected() + 1;
const TString16 numdoc(mask.get(F_NDOC));
const TString80 codart(row_mask.get(FR_CODART));
TDate datadoc = mask.get_date(F_DATADOC);
const char tipocf = mask.get(F_TIPOCF)[0];
const TString16 codcf = mask.get(F_CODCF);
TToken_string nums(((TTipo_riga_documento&)mask.doc()[current_doc_row].tipo()).search_nums());
if (nums.empty())
nums = mask.get(F_CODNUM);
TString8 first_num(nums.get(0));
TString8 last_num(first_num);;
TString form;
form << "(33->TIPOCF==\"" << tipocf << "\")&&(33->CODCF==\"" << (const char *)codcf << "\")&&(ANSI(33->DATADOC)<=\"" << datadoc.string(ANSI) << "\")" << "&&((CODNUM==\"" << first_num << "\")";
for (const char * s = nums.get(); s && *s; s = nums.get())
{
if (first_num > s)
first_num = s;
if (last_num < s)
last_num = s;
form << "||(CODNUM==\"" << s << "\")";
}
form << ")";
TRelation rel(LF_RIGHEDOC);
TRectype from(rel.curr());
TRectype to(rel.curr());
rel.add(LF_DOC, "PROVV==PROVV|ANNO=ANNO|CODNUM==CODNUM|NDOC==NDOC");
const int last_anno = mask.get_int(F_ANNO);
const int first_anno = last_anno - ((TTipo_riga_documento&)mask.doc()[current_doc_row].tipo()).search_years();
from.put(RDOC_CODART, codart);
from.put(RDOC_CODNUM, first_num);
from.put(RDOC_ANNO, first_anno);
from.put(RDOC_PROVV, "D");
to.put(RDOC_CODART, codart);
to.put(RDOC_CODNUM, last_num);
to.put(RDOC_ANNO, last_anno);
to.put(RDOC_PROVV, "D");
TSorted_cursor cur(&rel, "33->DATADOC-|CODNUM|NDOC-", form, 5, &from, &to);
cur.items();
cur.freeze();
cur.relation()->add("%NUM", "CODTAB==CODNUM", 1, 0, 201);
cur.relation()->add("%TIP", "CODTAB==TIPODOC", 1, LF_DOC, 202);
TCursor_sheet sheet(&cur, "NDOC|CODART|33->DATADOC|PREZZO|QTA|SCONTO|-201->S0|-202->S0",
"Ricerca Prezzi",
"N.ro doc.|Codice articolo@20|Data@10|Prezzo@18P|Quantità|Sconto@10|Numerazione@18|Tipo Documento@18",
0, 4);
sheet.add_string (101, 0, "Codice Articolo ", 2, 1, 20, "D");
sheet.add_string (102, 0, "Descrizione ", 2, 3, 50, "D");
sheet.set(101, codart);
sheet.set(102, cache().get(LF_ANAMAG, codart, "DESCR"));
if (sheet.run() == K_ENTER)
{
__in_handler = true;
row_mask.set(FR_CODART, codart, 3);
row_mask.field(FR_CODART).set_dirty(false);
__in_handler = false;
const TString & prezzo = sheet.row(-1).get(3);
row_mask.set(FR_PREZZO, prezzo);
const TString & sconto = sheet.row(-1).get(5);
row_mask.set(FR_SCONTO, sconto);
}
}
bool search_price_handler(TMask_field& f, KEY key )
{
TMask& row_mask = f.mask();
TSheet_field& sh = *row_mask.get_sheet();
if (key == K_F8 && !sh.sheet_mask().is_running())
{
const TString & codart = row_mask.get(FR_CODART);
if (codart.empty())
search_price(f, key);
else
search_price_article(f,key);
return true;
}
else
if ((key == K_TAB && f.focusdirty()))
{
TDocumento_mask& mask = (TDocumento_mask &)sh.mask();
const TString80 codart(row_mask.get(FR_CODART));
if (!__in_handler && codart.not_empty() && row_mask.get(FR_PREZZO).empty())
{
TDate datadoc = mask.get_date(F_DATADOC);
const char tipocf = mask.get(F_TIPOCF)[0];
const TString16 codcf = mask.get(F_CODCF);
const int current_doc_row = sh.selected() + 1;
TToken_string nums(((TTipo_riga_documento&)mask.doc()[current_doc_row].tipo()).search_nums());
if (nums.empty())
nums = mask.get(F_CODNUM);
TString8 first_num(nums.get(0));
TString8 last_num(first_num);;
TString form;
form << "(33->TIPOCF==\"" << tipocf << "\")&&(33->CODCF==\"" << (const char *)codcf << "\")&&(ANSI(33->DATADOC)<=\"" << datadoc.string(ANSI) << "\")" << "&&((CODNUM==\"" << first_num << "\")";
for (const char * s = nums.get(); s && *s; s = nums.get())
{
if (first_num > s)
first_num = s;
if (last_num < s)
last_num = s;
form << "||(CODNUM==\"" << s << "\")";
}
form << ")";
TRelation rel(LF_RIGHEDOC);
TRectype from(rel.curr());
TRectype to(rel.curr());
rel.add(LF_DOC, "PROVV==PROVV|ANNO=ANNO|CODNUM==CODNUM|NDOC==NDOC");
const int last_anno = mask.get_int(F_ANNO);
const int first_anno = last_anno - ((TTipo_riga_documento&)mask.doc()[current_doc_row].tipo()).search_years();
from.put(RDOC_CODART, codart);
from.put(RDOC_CODNUM, first_num);
from.put(RDOC_ANNO, first_anno);
from.put(RDOC_PROVV, "D");
to.put(RDOC_CODART, codart);
to.put(RDOC_CODNUM, last_num);
to.put(RDOC_ANNO, last_anno);
to.put(RDOC_PROVV, "D");
TSorted_cursor cur(&rel, "33->DATADOC-|CODNUM|NDOC-", "", 5, &from, &to);
cur.setfilter(form, true);
if (cur.items() > 0L)
{
cur = 0L;
__in_handler = true;
row_mask.set(FR_CODART, codart, 3);
row_mask.field(FR_CODART).set_dirty(false);
__in_handler = false;
const TString & prezzo = cur.curr().get(RDOC_PREZZO);
row_mask.set(FR_PREZZO, prezzo);
const TString & sconto = cur.curr().get(RDOC_SCONTO);
row_mask.set(FR_SCONTO, sconto);
}
}
}
return codart_handler( f, key);
}
bool codart_handler(TMask_field& f, KEY key ) bool codart_handler(TMask_field& f, KEY key )
{ {
TMask& row_mask = f.mask(); TMask& row_mask = f.mask();
@ -1127,12 +1473,15 @@ bool codart_handler(TMask_field& f, KEY key )
} }
} }
const TString& descest = anamag.get("DESCRAGG"); const TString& descest = anamag.get("DESCRAGG");
if (descest.not_empty()) if (descest.not_empty())
desc << "\n" << descest; desc << "\n" << descest;
if (!mask.doc()[current_doc_row].tipo().no_desc())
row_mask.set(FR_DESCR, desc); row_mask.set(FR_DESCR, desc);
TString80 key; key << codart << "|1"; TString80 key; key << codart << "|1";
const TRectype& umart = cache().get(LF_UMART, key); const TRectype& umart = cache().get(LF_UMART, key);
if (!umart.empty()) if (!umart.empty())
@ -1164,14 +1513,17 @@ bool codart_handler(TMask_field& f, KEY key )
if (caus.empty()) if (caus.empty())
caus = mask.get(F_CAUSMAG); caus = mask.get(F_CAUSMAG);
if (caus.not_empty()) if (caus.not_empty())
{ {
const TCausale_magazzino c(caus); const TCausale_magazzino c(caus);
if (!c.movimenta_sospesi()) if (!c.movimenta_sospesi())
{ {
const TRectype & rec = cache().get(LF_ANAMAG, row_mask.get(FR_CODARTMAG)); const TRectype & rec = cache().get(LF_ANAMAG, row_mask.get(FR_CODARTMAG));
if (rec.get_bool("SOSPESO")) if (rec.get_bool("SOSPESO"))
return error_box(TR("Articolo %s sospeso, quindi non movimentabile"), (const char *)codart); return error_box(TR("Articolo %s sospeso, quindi non movimentabile"), (const char *)codart);
} }
@ -1271,9 +1623,11 @@ bool codart_handler(TMask_field& f, KEY key )
} }
mask.update_giacenza(); mask.update_giacenza();
} }
return true; return true;
} }
bool codartmag_handler( TMask_field& f, KEY key ) bool codartmag_handler( TMask_field& f, KEY key )
{ {
TMask & m = f.mask(); TMask & m = f.mask();
@ -1344,6 +1698,7 @@ bool liv_handler( TMask_field& f, KEY key )
r.put(MAG_LIVELLO, liv); r.put(MAG_LIVELLO, liv);
TRectype new_rec(r); TRectype new_rec(r);
if (fl.read() != NOERR) if (fl.read() != NOERR)
{ {
@ -1506,7 +1861,6 @@ bool um_handler( TMask_field& f, KEY key )
curr_fc = fc; curr_fc = fc;
} }
return true; return true;
} }
bool descr_handler( TMask_field& f, KEY key ) bool descr_handler( TMask_field& f, KEY key )
@ -1523,7 +1877,6 @@ bool descr_handler( TMask_field& f, KEY key )
} }
} }
return true; return true;
} }
bool qtaart_handler( TMask_field& f, KEY key ) bool qtaart_handler( TMask_field& f, KEY key )
@ -1563,6 +1916,7 @@ bool qtaart_handler( TMask_field& f, KEY key )
TToken_string& row = sf.row(sf.selected()); TToken_string& row = sf.row(sf.selected());
const TString codart = row.get(sf.cid2index(FR_CODARTMAG)); const TString codart = row.get(sf.cid2index(FR_CODARTMAG));
if (codart.not_empty()) if (codart.not_empty())
{ {
TString16 codmag = row.get(sf.cid2index(FR_CODMAG)); TString16 codmag = row.get(sf.cid2index(FR_CODMAG));
@ -1613,8 +1967,7 @@ bool qtaart_handler( TMask_field& f, KEY key )
} }
} }
return qta_handler(f, key); return qta_handler(f, key);
} }
bool qta_handler( TMask_field& f, KEY key ) bool qta_handler( TMask_field& f, KEY key )
{ {
@ -1635,7 +1988,6 @@ bool qta_handler( TMask_field& f, KEY key )
} }
return true; return true;
} }
bool qta_evasa_handler( TMask_field& f, KEY key ) bool qta_evasa_handler( TMask_field& f, KEY key )
@ -1661,7 +2013,6 @@ bool qta_evasa_handler( TMask_field& f, KEY key )
} }
} }
return true; return true;
} }
bool causmag_handler( TMask_field& f, KEY key ) bool causmag_handler( TMask_field& f, KEY key )
@ -1672,6 +2023,7 @@ bool causmag_handler( TMask_field& f, KEY key )
TDocumento_mask& mask = (TDocumento_mask &) row_mask.get_sheet()->mask(); TDocumento_mask& mask = (TDocumento_mask &) row_mask.get_sheet()->mask();
TString4 causmag(f.get()); TString4 causmag(f.get());
if (causmag.blank()) if (causmag.blank())
causmag = mask.get(F_CAUSMAG); causmag = mask.get(F_CAUSMAG);
if (causmag.full()) if (causmag.full())
{ {
@ -1720,7 +2072,6 @@ bool causmag_handler( TMask_field& f, KEY key )
} }
} }
return true; return true;
} }
bool sppr_handler( TMask_field& f, KEY key ) bool sppr_handler( TMask_field& f, KEY key )
@ -1815,7 +2166,6 @@ bool sppr_handler( TMask_field& f, KEY key )
} }
} }
return true; return true;
} }
bool TDocumento_mask::numdocrif_search_handler(TMask_field& f, KEY key) bool TDocumento_mask::numdocrif_search_handler(TMask_field& f, KEY key)
@ -1853,7 +2203,6 @@ bool TDocumento_mask::numdocrif_search_handler(TMask_field& f, KEY key)
} }
} }
return true; return true;
} }
bool TDocumento_mask::ragsoc_search_handler(TMask_field& f, KEY key) bool TDocumento_mask::ragsoc_search_handler(TMask_field& f, KEY key)
@ -1898,6 +2247,7 @@ bool TDocumento_mask::ragsoc_search_handler(TMask_field& f, KEY key)
return true; return true;
} }
bool TDocumento_mask::datadocrif_handler(TMask_field& f, KEY key) bool TDocumento_mask::datadocrif_handler(TMask_field& f, KEY key)
{ {
if (key == K_ENTER && f.empty()) if (key == K_ENTER && f.empty())
@ -1926,7 +2276,6 @@ bool link_handler( TMask_field& f, KEY key )
r.edit(LF_DOC, "DAPROVV|DAANNO|DACODNUM|DANDOC"); r.edit(LF_DOC, "DAPROVV|DAANNO|DACODNUM|DANDOC");
} }
return true; return true;
} }
bool ca_mag_handler(TMask_field& f, bool cdc = true) bool ca_mag_handler(TMask_field& f, bool cdc = true)