diff --git a/ca/ca3700.cpp b/ca/ca3700.cpp
index 1250fe2e6..e9d35a7de 100755
--- a/ca/ca3700.cpp
+++ b/ca/ca3700.cpp
@@ -73,6 +73,20 @@ bool TPrint_rendiconto_ca_mask::on_field_event(TOperable_field& o, TField_event
{
switch (o.dlg())
{
+ case F_DATAINI:
+ case F_DATAFIN:
+ if (e == fe_close)
+ {
+ const int anno = get_int(F_ANNO);
+ if (anno > 0) //se viene selezionato un esercizio..
+ {
+ TEsercizi_contabili esc; //..le date devono essere incluse nell'esercizio selezionato!
+ const TDate data = o.get();
+ if (esc.date2esc(data) != anno)
+ return error_box(TR("La data deve appartenere all'anno selezionato"));
+ }
+ }
+ break;
case F_REPORT:
if (e == fe_button)
{
@@ -88,7 +102,7 @@ bool TPrint_rendiconto_ca_mask::on_field_event(TOperable_field& o, TField_event
if (e == fe_close)
{
if (!test_compatible_report())
- return error_box("Impossibile trovare un report compatibile");
+ return error_box(TR("Impossibile trovare un report compatibile"));
}
break;
case F_PRE1:
@@ -501,19 +515,12 @@ const TVariant& TPrint_rendiconto_ca_recordset::get(const char* column_name) con
void TPrint_rendiconto_ca_recordset::salva_rmovana(const TRectype& rmovana, const TRectype& movana, const TDocumento* doc)
{
- //serve un documento da cui ricavare i parametri di stampa
- const bool dadoc = doc != NULL;
- TDocumento* newdoc = (TDocumento*)doc;
- if (newdoc == NULL && movana.get(MOVANA_DNDOC).not_empty())
- {
- const TString16 dacodnum = movana.get(MOVANA_DCODNUM);
- newdoc = new TDocumento('D', movana.get_int(MOVANA_DANNO), dacodnum, movana.get_long(MOVANA_DNDOC));
- }
-
//tipo movimento CONSUNTIVO
const char tipomov = movana.get_char(MOVANA_TIPOMOV);
if (tipomov <= ' ' || tipomov == 'T')
{
+ TRectype& tmpcurr = _tmp->curr();
+ tmpcurr.zero();
//compila i campi da stampare
// il conto puo' essere analitico o contabile...
@@ -553,19 +560,19 @@ void TPrint_rendiconto_ca_recordset::salva_rmovana(const TRectype& rmovana, cons
if (current_conto == 0 && current_sottoconto == 0)
{
conto_riclassificato = rec_panapdc.get(PANAPDC_CODCONTO);
- _tmp->curr().put("CONTO", conto_riclassificato);
+ tmpcurr.put("CONTO", conto_riclassificato);
break; //esce dal casino e passa ai campi successivi
}
else if (conto == current_conto && current_sottoconto == 0)
{
conto_riclassificato = rec_panapdc.get(PANAPDC_CODCONTO);
- _tmp->curr().put("CONTO", conto_riclassificato);
+ tmpcurr.put("CONTO", conto_riclassificato);
break; //esce dal casino e passa ai campi successivi
}
else if (conto == current_conto && sottoconto == current_sottoconto)
{
conto_riclassificato = rec_panapdc.get(PANAPDC_CODCONTO);
- _tmp->curr().put("CONTO", conto_riclassificato);
+ tmpcurr.put("CONTO", conto_riclassificato);
break; //esce dal casino e passa ai campi successivi
}
} //for sugli elementi del cursore
@@ -580,32 +587,43 @@ void TPrint_rendiconto_ca_recordset::salva_rmovana(const TRectype& rmovana, cons
}
else //...sennò si usa il normale piano dei conti analitico (cioè tutti tranne che il CRPA)
- _tmp->curr().put("CONTO", rmovana.get(RMOVANA_CODCONTO)); //conto
+ tmpcurr.put("CONTO", rmovana.get(RMOVANA_CODCONTO)); //conto
//in ogni caso riempio il campo conto_cg
- _tmp->curr().put("CONTOCG", rmovana.get(RMOVANA_CODCONTO)); //conto_cg
+ tmpcurr.put("CONTOCG", rmovana.get(RMOVANA_CODCONTO)); //conto_cg
+
+ //serve un documento da cui ricavare i parametri di stampa
+ TDocumento* newdoc = (TDocumento*)doc;
+ bool should_delete = false;
+ if (newdoc == NULL && movana.get(MOVANA_DNDOC).not_empty())
+ {
+ const TString16 dacodnum = movana.get(MOVANA_DCODNUM);
+ newdoc = new TDocumento('D', movana.get_int(MOVANA_DANNO), dacodnum, movana.get_long(MOVANA_DNDOC));
+ should_delete = true;
+ }
+ const bool dadoc = newdoc != NULL;
//i movimenti possono essere normali o generati da documento...
if (dadoc) //movimento generato da documento
{
- _tmp->curr().put("CODNUM", movana.get(MOVANA_DCODNUM)); //codnum del documento che origina il movana
- _tmp->curr().put("ANNO", movana.get(MOVANA_DANNO)); //anno del doc di origine
- _tmp->curr().put("NUMRD", movana.get(MOVANA_DNDOC)); //numreg del movana
- _tmp->curr().put("DATA", movana.get(MOVANA_DATADOC)); //data del documento che genera movana
- }
- else //movimento normale
+ tmpcurr.put("CODNUM", movana.get(MOVANA_DCODNUM)); //codnum del documento che origina il movana
+ tmpcurr.put("ANNO", movana.get(MOVANA_DANNO)); //anno del doc di origine
+ tmpcurr.put("NUMRD", movana.get(MOVANA_DNDOC)); //
+ tmpcurr.put("DATA", newdoc->get(DOC_DATADOC)); //data del documento che genera movana..
+ } //..non esiste il campo in movana
+ else //movimento normale (senza documento)
{
- _tmp->curr().put("CODNUM", movana.get(MOVANA_NUMDOC));
- _tmp->curr().put("ANNO", movana.get(MOVANA_ANNOES)); //anno del movimento
- _tmp->curr().put("NUMRD", movana.get(MOVANA_NUMREG)); //numreg del movana
- _tmp->curr().put("DATA", movana.get(MOVANA_DATACOMP)); //data del movana
+ tmpcurr.put("CODNUM", movana.get(MOVANA_NUMDOC));
+ tmpcurr.put("ANNO", movana.get(MOVANA_ANNOES)); //anno del movimento
+ tmpcurr.put("NUMRD", movana.get(MOVANA_NUMREG)); //numreg del movana
+ tmpcurr.put("DATA", movana.get(MOVANA_DATACOMP)); //data del movana
}
int selettore = 0;
if (newdoc != NULL)
{
- _tmp->curr().put("NUMDOCRIF", newdoc->get(DOC_NUMDOCRIF)); //docrif del documento originante il movana
- _tmp->curr().put("DATADOCRIF", newdoc->get(DOC_DATADOCRIF)); //datadocrif del documento originante il movana
+ tmpcurr.put("NUMDOCRIF", newdoc->get(DOC_NUMDOCRIF)); //docrif del documento originante il movana
+ tmpcurr.put("DATADOCRIF", newdoc->get(DOC_DATADOCRIF)); //datadocrif del documento originante il movana
const int tipo_documento = newdoc->tipo().tipo();
int tipo_babbo = 0;
@@ -648,14 +666,14 @@ void TPrint_rendiconto_ca_recordset::salva_rmovana(const TRectype& rmovana, cons
default:
break;
}
- _tmp->curr().put("DOCORIG", riferimento);
+ tmpcurr.put("DOCORIG", riferimento);
}
//campi comuni
- _tmp->curr().put("DESC", movana.get(MOVANA_DESCR)); //descrizione movana
- _tmp->curr().put("NRIGA", rmovana.get(RMOVANA_NUMRIG));
- _tmp->curr().put("DESCRIGA", rmovana.get(RMOVANA_DESCR)); //descrizione rmovana
+ tmpcurr.put("DESC", movana.get(MOVANA_DESCR)); //descrizione movana
+ tmpcurr.put("NRIGA", rmovana.get(RMOVANA_NUMRIG));
+ tmpcurr.put("DESCRIGA", rmovana.get(RMOVANA_DESCR)); //descrizione rmovana
/*[Tipo documento]
O=I**
@@ -684,16 +702,17 @@ F=IMF*/
imp.normalize(sezione_normale);
if (selettore & FATTURATO)
- _tmp->curr().put("FATTURATO", imp.valore());
+ tmpcurr.put("FATTURATO", imp.valore());
if (selettore & MATURATO)
- _tmp->curr().put("MATURATO", imp.valore());
+ tmpcurr.put("MATURATO", imp.valore());
if (selettore & IMPEGNATO)
- _tmp->curr().put("IMPEGNATO", imp.valore());
+ tmpcurr.put("IMPEGNATO", imp.valore());
_tmp->write(); // aggiunge i record al file temporaneo
+
+ if (should_delete)
+ delete newdoc;
}
- if (!dadoc && newdoc != NULL)
- delete newdoc;
}
diff --git a/ca/ca3700a.rep b/ca/ca3700a.rep
index 0465446e3..5ea3fcb0d 100755
--- a/ca/ca3700a.rep
+++ b/ca/ca3700a.rep
@@ -40,15 +40,15 @@
-
+
-
-
-
+
+
+
@@ -116,15 +116,15 @@ MESSAGE RESET,F2.103
DOCORIG
-
+
FATTURATO
MESSAGE ADD,F2.101
-
+
MATURATO
MESSAGE ADD,F2.102
-
+
IMPEGNATO
MESSAGE ADD,F2.103
diff --git a/ve/velib04f.cpp b/ve/velib04f.cpp
index cc9d716ed..c1268c0c0 100755
--- a/ve/velib04f.cpp
+++ b/ve/velib04f.cpp
@@ -80,9 +80,9 @@ bool TContabilizzazione_analitica::search_costo_ricavo(const TRiga_documento& r,
clifo_key.format("%c|%ld", r.doc().get_char(DOC_TIPOCF), r.doc().get_long(DOC_CODCF));
const TRectype& cli_file = cache().get(LF_CLIFO, clifo_key);
- const bool is_cli = cli_file.get(CLI_TIPOCF) != 'F';
+ const bool is_cli = cli_file.get_char(CLI_TIPOCF) != 'F';
bool skip_art_related = false;
- bool skip_clifo = !cli_file.empty();
+ bool skip_clifo = cli_file.empty();
const TCodiceIVA codiva(r.get(RDOC_CODIVA));
const char t = r.tipo().tipo();
@@ -109,7 +109,8 @@ bool TContabilizzazione_analitica::search_costo_ricavo(const TRiga_documento& r,
const int co = cli_file.get_int(CLI_CONTORIC);
const long so = cli_file.get_long(CLI_SOTTOCRIC);
conto.set(gr,co,so);
- if (conto.ok()) break; // se lo trova esce (tutti != 0)
+ if (conto.ok())
+ break; // se lo trova esce (tutti != 0)
}
else
if (tok == "CA")
@@ -139,7 +140,8 @@ bool TContabilizzazione_analitica::search_costo_ricavo(const TRiga_documento& r,
conto.set(gr,co,so);
}
}
- if (conto.ok()) break;
+ if (conto.ok())
+ break;
}
else
if (tok == "GM" || tok == "SM" || tok == "RF")
@@ -194,7 +196,8 @@ bool TContabilizzazione_analitica::search_costo_ricavo(const TRiga_documento& r,
case 'P': // righe prestazione
case 'S': // righe spese
{
- const TRectype& tab = cache().get('P' ? "PRS" : "SPP", r.get(RDOC_CODART));
+ const TString80 codspesa = r.get(RDOC_CODART);
+ const TRectype& tab = cache().get(t == 'P' ? "PRS" : "SPP", codspesa);
if (!tab.empty())
{
int gr = tab.get_int(is_cli ? "I0" : "I3");
@@ -448,7 +451,9 @@ bool TContabilizzazione_analitica::elabora(TDocumento& doc, long numreg_cg, TVis
continue;
// salto valori nulli
- const real valore = riga.valore(true, decimals);
+ const real qta = riga.get(RDOC_QTA);
+ // const real valore = riga.valore(true, decimals);
+ const real valore = riga.importo(true, false);
if (valore.is_zero())
continue;