diff --git a/ca/ca1100.cpp b/ca/ca1100.cpp
index f5cdaaa66..b4a873934 100755
--- a/ca/ca1100.cpp
+++ b/ca/ca1100.cpp
@@ -5,30 +5,50 @@
#include "ca1.h"
#include "calib02.h"
+class TEthero_rep : public TAnal_report
+{
+protected:
+ virtual bool use_mask() { return true; }
+};
class TPrint_ca : public TSkeleton_application
{
+protected:
+ void print_rep(const TFilename& n) const;
+
public:
virtual void main_loop();
};
+void TPrint_ca::print_rep(const TFilename& n) const
+{
+ TEthero_rep rep;
+ if (rep.load(n))
+ rep.print_or_preview();
+}
+
void TPrint_ca::main_loop()
{
TFilename path;
- while (select_custom_file(path, "rep", "ca1100"))
+
+ if (argc() > 2)
{
- TReport_book book;
- TAnal_report rep;
- rep.load(path);
- book.add(rep);
- book.print_or_preview();
+ path = argv(2);
+ path.ext("rep");
+ if (path.custom_path())
+ {
+ print_rep(path);
+ return;
+ }
}
+ while (select_custom_file(path, "rep", "ca1100"))
+ print_rep(path);
}
int ca1100(int argc, char* argv[])
{
TPrint_ca a;
- a.run(argc, argv, TR("Stampa anagrafiche"));
+ a.run(argc, argv, TR("Stampa analitica"));
return 0;
}
diff --git a/ca/ca1100a.rep b/ca/ca1100a.rep
new file mode 100644
index 000000000..c41848446
--- /dev/null
+++ b/ca/ca1100a.rep
@@ -0,0 +1,284 @@
+
+
+
+
+
+
+
+
+
+
+
+ CODCCOSTO
+
+
+
+
+
+
+
+ MESSAGE ISAMREAD,CDC,CODCOSTO=CODCCOSTO,DESCRIZ
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ CODCONTO
+ MESSAGE RESET,F3
+
+
+
+
+
+
+
+
+ #THIS @
+EMPTY=
+IF
+ELSE
+ #THIS GET_ID_NEXT @ \ Legge la sezione dal campo successivo
+ "A" = IF \ Se vale Avere
+ #THIS @ -1 * \ Cambia segno
+ #THIS ! \ al campo corrente
+ THEN
+ #THIS @ \ Prende il valore attuale con segno
+ "F3." #THIS GET_ID + \ Costruisce la stringa F3.101
+ +! \ Somma il campo corrente al corrispondente in F3
+THEN
+
+
+
+
+
+
+
+ #THIS @
+EMPTY=
+IF
+ELSE
+ #THIS GET_ID_NEXT @ \ Legge la sezione dal campo successivo
+ "A" = IF \ Se vale Avere
+ #THIS @ -1 * \ Cambia segno
+ #THIS ! \ al campo corrente
+ THEN
+ #THIS @ \ Prende il valore attuale con segno
+ "F3." #THIS GET_ID + \ Costruisce la stringa F3.101
+ +! \ Somma il campo corrente al corrispondente in F3
+THEN
+
+
+
+
+
+
+
+ #THIS @
+EMPTY=
+IF
+ELSE
+ #THIS GET_ID_NEXT @ \ Legge la sezione dal campo successivo
+ "A" = IF \ Se vale Avere
+ #THIS @ -1 * \ Cambia segno
+ #THIS ! \ al campo corrente
+ THEN
+ #THIS @ \ Prende il valore attuale con segno
+ "F3." #THIS GET_ID + \ Costruisce la stringa F3.101
+ +! \ Somma il campo corrente al corrispondente in F3
+THEN
+
+
+
+
+
+
+
+ #THIS @
+EMPTY=
+IF
+ELSE
+ #THIS GET_ID_NEXT @ \ Legge la sezione dal campo successivo
+ "A" = IF \ Se vale Avere
+ #THIS @ -1 * \ Cambia segno
+ #THIS ! \ al campo corrente
+ THEN
+ #THIS @ \ Prende il valore attuale con segno
+ "F3." #THIS GET_ID + \ Costruisce la stringa F3.101
+ +! \ Somma il campo corrente al corrispondente in F3
+THEN
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ MESSAGE ISAMREAD,PCONANA,CODCONTO=#H3.101,DESCR
+
+
+ #THIS @ 0 C; IF
+ #THIS @
+ -1 *
+ #THIS !
+ #THIS GET_ID_NEXT
+ "A"
+ELSE
+ #THIS @
+ 0 = IF
+ ""
+ ELSE
+ "D"
+ THEN
+THEN
+ #THIS GET_ID_NEXT !
+
+
+
+
+ #THIS @ 0 C; IF
+ #THIS @
+ -1 *
+ #THIS !
+ #THIS GET_ID_NEXT
+ "A"
+ELSE
+ #THIS @
+ 0 = IF
+ ""
+ ELSE
+ "D"
+ THEN
+THEN
+ #THIS GET_ID_NEXT !
+
+
+
+
+ 104 @
+102 @
+- .
+
+
+ 102 @
+0 = IF
+ 0
+ELSE
+ 106 @
+ 102 @
+ F; 100 *
+ 0 ROUND
+THEN
+.
+
+
+
+ #THIS @ 0 C; IF
+ #THIS @
+ -1 *
+ #THIS !
+ #THIS GET_ID_NEXT
+ "A"
+ELSE
+ #THIS @
+ 0 = IF
+ ""
+ ELSE
+ "D"
+ THEN
+THEN
+ #THIS GET_ID_NEXT !
+
+
+
+
+ #THIS @ 0 C; IF
+ #THIS @
+ -1 *
+ #THIS !
+ #THIS GET_ID_NEXT
+ "A"
+ELSE
+ #THIS @
+ 0 = IF
+ ""
+ ELSE
+ "D"
+ THEN
+THEN
+ #THIS GET_ID_NEXT !
+
+
+
+
+ 104 @
+102 @
+- .
+
+
+ 102 @
+0 = IF
+ 0
+ELSE
+ 106 @
+ 102 @
+ F; 100 *
+ 0 ROUND
+THEN
+.
+
+
+
+ USE RMOVANA KEY 3 SELECT BETWEEN(CODCCOSTO,#CODCOSTO,#CODCOSTO)
+BY CODCCOSTO CODCONTO DATACOMP
+JOIN MOVANA INTO NUMREG==NUMREG
+FROM DATACOMP=#DATAINI
+TO DATACOMP=#DATAFIN
+ : ADD_T0_F3 ( -- )
+#THIS @
+EMPTY=
+IF
+ELSE
+ MON
+ #THIS GET_ID_NEXT @ \ Legge la sezione dal campo successivo
+ "A" = IF \ Se vale Avere
+ #THIS @ -1 * \ Cambia segno
+ #THIS ! \ al campo corrente
+ THEN
+ #THIS @ \ Prende il valore attuale con segno
+ "F3." #THIS GET_ID + \ Costruisce la stringa F3.101
+ +! \ Somma il campo corrente al corrispondente in F3
+THEN
+;
+
\ No newline at end of file
diff --git a/ca/ca1100a.uml b/ca/ca1100a.uml
new file mode 100644
index 000000000..9cb15cc4a
--- /dev/null
+++ b/ca/ca1100a.uml
@@ -0,0 +1,66 @@
+PAGE "Bilancio di Budget" -1 -1 52 9
+
+NUMBER 101 4
+BEGIN
+ PROMPT 1 1 "Esercizio "
+ USE ESC
+ INPUT CODTAB 101
+ DISPLAY "Codice Esercizio" CODTAB
+ DISPLAY "Inizio Esercizio" D0
+ DISPLAY "Fine Esercizio " D1
+ OUTPUT 102 D0
+ OUTPUT 103 D1
+ CHEKCTYPE REQUIRED
+END
+
+DATE 102
+BEGIN
+ PROMPT 27 1 ""
+ FLAGS "D"
+ FIELD DATAINI
+END
+
+DATE 103
+BEGIN
+ PROMPT 39 1 ""
+ FLAGS "D"
+ FIELD DATAFIN
+END
+
+DATE 104
+BEGIN
+ PROMPT 1 2 "Data stampa "
+ FIELD DATASTA
+ CHECKTYPE REQUIRED
+ STR_EXPR BETWEEN(#104,#102,#103)
+ WARNING "Data non compresa nell'anno selezionato"
+END
+
+STRING 105 20
+BEGIN
+ PROMPT 1 3 "Centro di Costo "
+ USE 146
+ INPUT CODCOSTO 105
+ DISPLAY "Centro di Costo@20" CODCOSTO
+ DISPLAY "Descrizione@50" DESCRIZ
+ OUTPUT 105 CODCOSTO
+ CHECKTYPE NORMAL
+ FIELD CODCOSTO
+END
+
+
+BUTTON 1 10 2
+BEGIN
+ PROMPT -12 -1 ""
+END
+
+BUTTON 2 10 2
+BEGIN
+ PROMPT -22 -1 ""
+END
+
+ENDPAGE
+
+ENDMASK
+
+
diff --git a/ca/ca3.cpp b/ca/ca3.cpp
index 6e0ff1105..4254d470d 100755
--- a/ca/ca3.cpp
+++ b/ca/ca3.cpp
@@ -7,16 +7,15 @@ int main(int argc, char** argv)
const int r = (argc > 1) ? argv[1][1] - '0' : 0;
switch (r)
{
- case 1: ca3200(argc, argv); break; // stampa mastrini
- case 2: ca3300(argc, argv); break; // stampa bilancio
- case 3: ca3400(argc, argv); break; // generazione movimenti perfetti ma casuali
- case 4: ca3500(argc, argv); break; // stampatore generico di report di CA
- case 5: ca3600(argc, argv); break; // stampa pagato per CdC/Commessa/Fase
- case 6: ca3700(argc, argv); break; //stampa rendiconto
- case 7: ca3800(argc, argv); break; //stampa bilancio di commessa per esercizio
- case 8: ca3900(argc, argv); break; // stampa stima ricavi
- default: ca3100(argc, argv); break; // stampa movimenti
+ case 1: ca3200(argc, argv); break; // stampa mastrini
+ case 2: ca3300(argc, argv); break; // stampa bilancio
+ case 3: ca3400(argc, argv); break; // generazione movimenti perfetti ma casuali
+ case 4: ca3500(argc, argv); break; // stampatore generico di report di CA
+ case 5: ca3600(argc, argv); break; // stampa pagato per CdC/Commessa/Fase
+ case 6: ca3700(argc, argv); break; // stampa rendiconto
+ case 7: ca3800(argc, argv); break; // stampa bilancio di commessa per esercizio
+ case 8: ca3900(argc, argv); break; // stampa stima ricavi
+ default:ca3100(argc, argv); break; // stampa movimenti
}
- exit(0);
return 0;
}
diff --git a/ca/ca3300.cpp b/ca/ca3300.cpp
index e667057f9..149bc8a0b 100755
--- a/ca/ca3300.cpp
+++ b/ca/ca3300.cpp
@@ -4,6 +4,8 @@
#include
#include
+#include "cdc.h"
+#include "commesse.h"
#include "movana.h"
#include "pconana.h"
#include "rmovana.h"
@@ -28,7 +30,6 @@ protected:
public:
TPrint_bilancio_ca_mask();
- virtual ~TPrint_bilancio_ca_mask() {}
};
const TString& TPrint_bilancio_ca_mask::get_report_class() const
@@ -50,7 +51,7 @@ bool TPrint_bilancio_ca_mask::test_compatible_report()
{
const TString& cls = get_report_class();
const TString& name = get(F_REPORT);
- bool ok = name.not_empty();
+ bool ok = name.full();
if (ok && name != cls)
{
TReport rep;
@@ -188,7 +189,6 @@ bool TPrint_bilancio_ca_mask::on_field_event(TOperable_field& o, TField_event e,
return TAnal_report_mask::on_field_event(o, e, jolly);
}
-
TPrint_bilancio_ca_mask::TPrint_bilancio_ca_mask()
:TAnal_report_mask("ca3300")
{
@@ -269,7 +269,12 @@ TPrint_bilancio_ca_mask::TPrint_bilancio_ca_mask()
// creazione dei campi della seconda pagina della maschera
create_sheet(F_RIGHE);
- set_handlers(); // Setta l'andler universale a tutti i nuovi campi
+ // Crea gli elementi della lista della stampa completa
+ const bool per_cms = cfg.get("Level", NULL, 1) == "CMS";
+ TList_field& sc = lfield(F_COMPLETA);
+ sc.replace_items("0|1", per_cms ? " |commesse" : " |centri di costo");
+
+ set_handlers(); // Setta l'handler universale a tutti i nuovi campi
}
////////////////////////////////////////////////////////
@@ -536,7 +541,7 @@ void TRecordset_sezioni_contrapposte::add_conto(int indbil, const TString& b)
if ((_tipimov & _saldanal_qualsiasi) == _saldanal_qualsiasi) // Bilancio a sezioni contrapposte di raffronto
{
- const TSaldanal& sp = ca_saldo(bill, _da_data, _a_data, _saldanal_preventivi);
+ const TSaldanal& sp = ca_sldo(bill, _da_data, _a_data, _saldanal_preventivi);
const TSaldanal& sc = ca_saldo(bill, _da_data, _a_data, _saldanal_consuntivo);
if (!sp._fin.is_zero() || !sc._fin.is_zero())
{
@@ -963,8 +968,11 @@ class TPrint_bilancio_ca : public TSkeleton_application
TPrint_bilancio_ca_mask* _mask;
protected:
- virtual const char * extra_modules() const {return "cm";} //funziona anche con autorizzazione CM
+ virtual const char * extra_modules() const { return "cm"; } // funziona anche con autorizzazione CM
+ bool commessa_buona(const TRectype& cms, const TDate& dadata, const TDate& adata) const;
+ bool buon_cdc(const TRectype& cdc, const TDate& dadata, const TDate& adata) const;
+ void fill_sheet(int livello);
void bilancio_a_sezioni_contrapposte(const bool stampa);
void bilancio_di_verifica(const bool stampa);
@@ -980,13 +988,17 @@ void TPrint_bilancio_ca::bilancio_a_sezioni_contrapposte(const bool stampa)
TReport_bilancio_sezioni_contrapposte rep(_mask->get(F_REPORT));
const int rows = _mask->sfield(F_RIGHE).items();
+ TProgind* pi = rows > 1 ? new TProgind(rows, TR("Bilancio a sezioni contrapposte")) : NULL;
TReport_book book;
for (int i = 0; i < rows; i++)
{
+ if (pi && !pi->addstatus(1))
+ break;
rep.set_filter(*_mask, i);
book.add(rep);
}
+ if (pi) delete pi;
if (stampa)
book.print(); //stampa il book dei report
@@ -999,13 +1011,17 @@ void TPrint_bilancio_ca::bilancio_di_verifica(const bool stampa)
TReport_bilancio_verifica rep(_mask->get(F_REPORT));
const int rows = _mask->sfield(F_RIGHE).items();
+ TProgind* pi = rows > 1 ? new TProgind(rows, TR("Bilancio di verifica")) : NULL;
TReport_book book;
for (int i = 0; i < rows; i++)
{
+ if (pi && !pi->addstatus(1))
+ break;
rep.set_filter(*_mask, i);
book.add(rep);
}
+ if (pi) delete pi;
if (stampa)
book.print(); //stampa il book dei report
@@ -1023,16 +1039,129 @@ void TPrint_bilancio_ca::preview()
print_or_preview(false);
}
+// Anche l'occhio vuole la sua parte
+bool TPrint_bilancio_ca::commessa_buona(const TRectype& cms, const TDate& dadata, const TDate& adata) const
+{
+ if (dadata.ok() || adata.ok())
+ {
+ TDate dataini, datafine;
+ ca_durata_commessa(cms, dataini, datafine);
+
+ if (dadata.ok() && datafine.ok() && datafine < dadata)
+ return false; // Commessa finita prima dell'inizio della stampa
+
+ if (adata.ok() && dataini.ok() && dataini > adata)
+ return false; // Commessa iniziata dopo la fine della stampa
+
+ TString query;
+ query = "USE RMOVANA KEY 4\nBY CODCMS DATACOMP\n";
+ query << "FROM CODCMS=#CMS\nTO CODCMS=#CMS";
+ TISAM_recordset rmovana(query);
+ rmovana.set_var("#CMS", cms.get(COMMESSE_CODCMS));
+
+ if (!rmovana.move_first())
+ return false; // Ignora commesse non movimentate
+
+ TDate datacomp = rmovana.get(RMOVANA_DATACOMP).as_date();
+ if (adata.ok() && datacomp > adata)
+ return false; // la data del primo movimento è troppo grande
+
+ rmovana.move_last(); // deve riuscire per forza, avendo avuto successo la move_first
+ datacomp = rmovana.get(RMOVANA_DATACOMP).as_date();
+ if (datacomp < dadata)
+ return false; // la data dell'ultimo movimento è troppo piccola
+ }
+ return true;
+}
+
+// Non sempre si fanno le cose alla cdc
+bool TPrint_bilancio_ca::buon_cdc(const TRectype& cdc, const TDate& dadata, const TDate& adata) const
+{
+ if (dadata.ok() || adata.ok())
+ {
+ TString query;
+ query = "USE RMOVANA KEY 5\nBY CODCCOSTO DATACOMP\n";
+ query << "FROM CODCCOSTO=#COSTO\nTO CODCCOSTO=#COSTO";
+ TISAM_recordset rmovana(query);
+ rmovana.set_var("#COSTO", cdc.get(CDC_CODCOSTO));
+ if (!rmovana.move_first())
+ return false; // Ignora centri non movimentati ... come quello di Isernia
+
+ TDate datacomp = rmovana.get(RMOVANA_DATACOMP).as_date();
+ if (adata.ok() && datacomp > adata)
+ return false; // la data del primo movimento è troppo grande
+
+ rmovana.move_last();
+ datacomp = rmovana.get(RMOVANA_DATACOMP).as_date();
+ if (datacomp < dadata)
+ return false; // la data dell'ultimo movimento è troppo piccola
+ }
+ return true;
+}
+
+void TPrint_bilancio_ca::fill_sheet(int livello)
+{
+ TSheet_field& sf = _mask->sfield(F_RIGHE);
+ sf.destroy();
+ if (livello <= 0)
+ {
+ sf.row(-1);
+ return;
+ }
+ const bool per_cms = ca_config().get("Level", NULL, 1) == "CMS";
+ const int annoes = _mask->get_int(F_ANNO);
+ TDate dadata, adata;
+ if (annoes > 0)
+ {
+ TEsercizi_contabili ese;
+ ese.code2range(annoes, dadata, adata);
+ }
+ if (!_mask->efield(F_DATADA).empty())
+ dadata = _mask->get(F_DATADA);
+ if (!_mask->efield(F_DATAA).empty())
+ adata = _mask->get(F_DATAA);
+
+ TString query;
+ query << "USE " << (per_cms ? LF_COMMESSE : LF_CDC);
+ TISAM_recordset recset(query);
+ const TRectype& rec = recset.cursor()->curr();
+ for (bool ok = recset.move_first(); ok; ok = recset.move_next())
+ {
+ if (per_cms)
+ {
+ if (commessa_buona(rec, dadata, adata))
+ sf.row(-1) = rec.get(COMMESSE_CODCMS);
+ }
+ else
+ {
+ if (buon_cdc(rec, dadata, adata))
+ sf.row(-1) = rec.get(CDC_CODCOSTO);
+ }
+ }
+}
+
void TPrint_bilancio_ca::print_or_preview(const bool stampa)
{
TSheet_field& sf = _mask->sfield(F_RIGHE);
- if (sf.empty())
- sf.row(-1); // Aggiungo riga vuota
+
+ bool empty_sheet = true;
+ const int completa = _mask->get_int(F_COMPLETA);
+ if (completa <= 0)
+ {
+ empty_sheet = sf.empty();
+ if (empty_sheet)
+ sf.row(-1); // Aggiungo riga vuota
+ }
+ else
+ fill_sheet(completa);
if (_mask->get(F_BILANCIO) == "C")
bilancio_a_sezioni_contrapposte(stampa);
else
bilancio_di_verifica(stampa);
+
+ if (empty_sheet)
+ sf.destroy();
}
void TPrint_bilancio_ca::main_loop()
@@ -1049,3 +1178,4 @@ int ca3300(int argc, char* argv[])
a.run(argc, argv, TR("Stampa bilancio"));
return 0;
}
+
diff --git a/ca/ca3300.h b/ca/ca3300.h
index 5a9ee6349..807a4c5fb 100755
--- a/ca/ca3300.h
+++ b/ca/ca3300.h
@@ -14,6 +14,7 @@
#define F_DATAA 313
#define F_TIPOSTAMPA 314
#define F_PRINT_CONTO_ECON 315
+#define F_COMPLETA 316
//campi generati dai piani dei conti
#define F_PIANO 319
diff --git a/ca/ca3300.uml b/ca/ca3300.uml
index aef9219c1..62f6e6bb7 100755
--- a/ca/ca3300.uml
+++ b/ca/ca3300.uml
@@ -108,7 +108,7 @@ BEGIN
PROMPT 59 6 "Al "
END
-LIST F_STAMPAV 20
+LIST F_STAMPAV 1 20
BEGIN
PROMPT 2 8 "Selezione conti "
ITEM "1|Movimentati"
@@ -117,6 +117,16 @@ BEGIN
GROUP 4
END
+LIST F_COMPLETA 1 16
+BEGIN
+ PROMPT 42 8 "Stampa completa "
+ ITEM "0| " MESSAGE SHOW,F_RIGHE
+ ITEM "1|Primo livello " MEGGASE HIDE,F_RIGHE
+ ITEM "2|Secondo livello" MESSAGE HIDE,F_RIGHE
+ ITEM "3|Terzo livello " MEGGASE HIDE,F_RIGHE
+END
+
+
BOOLEAN F_PRINT_CONTO_ECON
BEGIN
PROMPT 2 9 "Stampa situazione conto economico"
diff --git a/ca/calib01.cpp b/ca/calib01.cpp
index 1105a3a18..1d941f1cf 100755
--- a/ca/calib01.cpp
+++ b/ca/calib01.cpp
@@ -47,8 +47,7 @@ TConfig_anal::TConfig_anal() : TConfig(CONFIG_DITTA, "ca"), _has_ca(dongle().act
const TString& TConfig_anal::get(const char* varname, const char* section, int index, const char* def)
{
if (_has_ca)
- return TConfig::get(varname, section, index, def);
-
+ return TConfig::get(varname, section, index, def);
if (_has_cm)
{
@@ -3115,7 +3114,8 @@ long ca_durata_commessa(const TRectype& rec_commesse, TDate& dataini, TDate& dat
}
}
- //se entrambe le date fossero vuote, visto che comunque adesso l'anno ce l'ha, le può ricavare..
+ //se entrambe le date fossero vuote, visto che comunque adesso l'anno ce l'ha, le può ricavare...
+ // Probabilmente le prossime 3 righe andrebbero cancellate: si assume una commessa per un anno
if (!dataini.ok() && !datafine.ok())
esc.code2range(anno, dataini, datafine);
else //solo una data o nessuna data non buona
diff --git a/ca/camenu.men b/ca/camenu.men
index d3cc1a962..a570c9dc3 100755
--- a/ca/camenu.men
+++ b/ca/camenu.men
@@ -74,6 +74,7 @@ Item_05 = "Rendiconto", "ca3 -6", "F"
Item_06 = "Bilancio di commessa", "ca3 -7", "F"
Item_07 = "Stima ricavi di competenza", "ca3 -8", "F"
Item_08 = "Conti per commessa", "ca1 -7", "F"
+Item_09 = "Bilancio per centro di costo", "ca1 -0 ca1100a", "F"
[CAMENU_050]
Caption = "Servizi"