Patch level :10.0
Files correlati : Ricompilazione Demo : [ ] Commento : iniziata personalizzazione habilita git-svn-id: svn://10.65.10.50/trunk@20336 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
c6e7c5df0b
commit
44c062708a
15
ps/pd6342.cpp
Executable file
15
ps/pd6342.cpp
Executable file
@ -0,0 +1,15 @@
|
||||
#include <xvt.h>
|
||||
|
||||
#include "pd6342.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int n = argc > 1 ? atoi(argv[1]+1) : 0;
|
||||
switch(n)
|
||||
{
|
||||
case 0:
|
||||
default:
|
||||
pd6342100(argc, argv); break; //stampa costi/ricavi mensili per Habilita
|
||||
}
|
||||
return 0;
|
||||
}
|
2
ps/pd6342.h
Executable file
2
ps/pd6342.h
Executable file
@ -0,0 +1,2 @@
|
||||
int pd6342100(int argc, char* argv[]);
|
||||
|
350
ps/pd6342100.cpp
Executable file
350
ps/pd6342100.cpp
Executable file
@ -0,0 +1,350 @@
|
||||
#include <applicat.h>
|
||||
#include <defmask.h>
|
||||
#include <dongle.h>
|
||||
#include <modaut.h>
|
||||
#include <progind.h>
|
||||
#include <recset.h>
|
||||
#include <reprint.h>
|
||||
#include <textset.h>
|
||||
|
||||
#include "pd6342.h"
|
||||
#include "pd6342100a.h"
|
||||
|
||||
#include "../ca/movana.h"
|
||||
#include "../ca/rmovana.h"
|
||||
#include "../ca/calib01.h"
|
||||
#include "../ca/calib02.h"
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// MASCHERA
|
||||
///////////////////////////////////////////////////////////
|
||||
class TPrint_cosric_month_mask : public TAutomask
|
||||
{
|
||||
protected:
|
||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||
|
||||
public:
|
||||
TPrint_cosric_month_mask();
|
||||
virtual ~TPrint_cosric_month_mask() {}
|
||||
};
|
||||
|
||||
TPrint_cosric_month_mask::TPrint_cosric_month_mask() : TAutomask("pd6342100a")
|
||||
{
|
||||
int nfields = ca_create_fields(*this, 0, LF_COMMESSE, 2, 4, F_CMS, F_CMS + 100, 0x0, "#CMS");
|
||||
for (int i = 0; i < nfields; i++)
|
||||
{
|
||||
TMask_field& dacms = field(F_CMS + i);
|
||||
dacms.set_group(1);
|
||||
dacms.check_type(CHECK_NORMAL);
|
||||
}
|
||||
//conti
|
||||
ca_create_fields(*this, 0, LF_PCONANA, 2, 7, F_DACONTO, F_DACONTO + 100, 0x0, "#DACONTO");
|
||||
nfields = ca_create_fields(*this, 0, LF_PCONANA, 2, 11, F_ACONTO, F_ACONTO + 100, 0x0, "#ACONTO");
|
||||
for (int i = 0; i < nfields; i++)
|
||||
{
|
||||
TMask_field& daconto = field(F_DACONTO + i);
|
||||
daconto.set_group(1);
|
||||
daconto.check_type(CHECK_NORMAL);
|
||||
TMask_field& aconto = field(F_ACONTO + i);
|
||||
aconto.set_group(2);
|
||||
aconto.check_type(CHECK_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
bool TPrint_cosric_month_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
{
|
||||
switch(o.dlg())
|
||||
{
|
||||
case DLG_PRINT:
|
||||
if (e == fe_button)
|
||||
{
|
||||
main_app().print();
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case DLG_PREVIEW:
|
||||
if (e == fe_button)
|
||||
{
|
||||
main_app().preview();
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// REPORT
|
||||
////////////////////////////////////////////////////////
|
||||
class TPrint_cosric_month_report : public TAnal_report
|
||||
{
|
||||
protected:
|
||||
virtual bool use_mask() { return false; }
|
||||
public:
|
||||
TPrint_cosric_month_report() {}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// RECORDSET
|
||||
////////////////////////////////////////////////////////
|
||||
class TPrint_cosric_month_recordset : public TAS400_recordset
|
||||
{
|
||||
public:
|
||||
bool crea_nuova_riga(const TString& codcms, const TString& codfase, const TString& codconto, TArray& importi);
|
||||
TPrint_cosric_month_recordset();
|
||||
};
|
||||
|
||||
|
||||
TPrint_cosric_month_recordset::TPrint_cosric_month_recordset()
|
||||
: TAS400_recordset("AS400(280)")
|
||||
{
|
||||
create_field(RMOVANA_CODCMS, -1, 20, _alfafld, true);
|
||||
create_field(RMOVANA_CODFASE, -1, 10, _alfafld);
|
||||
create_field(RMOVANA_CODCONTO, -1, 20, _alfafld, true);
|
||||
TString16 month_string;
|
||||
for (int i = 1; i <= 12; i++)
|
||||
{
|
||||
month_string.format("IMPORTO_%02d", i);
|
||||
create_field(month_string, -1, 18, _realfld);
|
||||
month_string.format("SEZIONE_%02d", i);
|
||||
create_field(month_string, -1, 1, _alfafld);
|
||||
}
|
||||
}
|
||||
|
||||
bool TPrint_cosric_month_recordset::crea_nuova_riga(const TString& codcms, const TString& codfase,
|
||||
const TString& codconto, TArray& importi)
|
||||
{
|
||||
new_rec("");
|
||||
set(RMOVANA_CODCMS, codcms);
|
||||
set(RMOVANA_CODFASE, codfase);
|
||||
set(RMOVANA_CODCONTO, codconto);
|
||||
TString16 month_string;
|
||||
for (int i = 1; i <= 12; i++)
|
||||
{
|
||||
const TImporto& importo = (const TImporto&)importi[i - 1];
|
||||
if (!importo.is_zero())
|
||||
{
|
||||
month_string.format("IMPORTO_%02d", i);
|
||||
real imp = importo.valore();
|
||||
imp.round(2);
|
||||
set(month_string, imp);
|
||||
month_string.format("SEZIONE_%02d", i);
|
||||
TString4 sez;
|
||||
sez << importo.sezione();
|
||||
set(month_string, sez);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// APPLICAZIONE
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TPrint_cosric_month : public TSkeleton_application
|
||||
{
|
||||
TPrint_cosric_month_mask* _mask;
|
||||
bool _has_ca;
|
||||
|
||||
protected:
|
||||
virtual bool check_autorization() const {return false;}
|
||||
virtual const char * extra_modules() const {return "ca";}
|
||||
|
||||
virtual bool create();
|
||||
virtual void print();
|
||||
virtual void preview();
|
||||
virtual void print_or_preview(const bool stampa);
|
||||
|
||||
TPrint_cosric_month_recordset* elabora() const;
|
||||
|
||||
public:
|
||||
virtual void main_loop();
|
||||
|
||||
};
|
||||
|
||||
|
||||
TPrint_cosric_month_recordset* TPrint_cosric_month::elabora() const
|
||||
{
|
||||
//creazione dell'as400 recordset che verra' riempito dai record del recordset righe
|
||||
TPrint_cosric_month_recordset* printset = new TPrint_cosric_month_recordset();
|
||||
|
||||
//creazione della query per la creazione del recordset
|
||||
TString query;
|
||||
query << "USE RMOVANA KEY 4\n";
|
||||
query << "SELECT (ANNOES=#ANNOES)&&(BETWEEN(CODCONTO,#DACONTO,#ACONTO))\n";
|
||||
query << "JOIN MOVANA INTO NUMREG==NUMREG\n";
|
||||
query << "FROM CODCMS=#CMS\n";
|
||||
query << "TO CODCMS=#CMS";
|
||||
|
||||
TISAM_recordset recset(query);
|
||||
|
||||
recset.set_var("#CMS", TVariant(_mask->get(F_CMS)));
|
||||
recset.set_var("#ANNOES", TVariant(_mask->get(F_ANNO)));
|
||||
TString80 dacontone, acontone;
|
||||
//c'e' un range di conti da considerare?
|
||||
const short dlg_da = F_DACONTO;
|
||||
const short dlg_al = F_ACONTO;
|
||||
for (int i = 0; _mask->id2pos(dlg_da + i) > 0; i++)
|
||||
{
|
||||
dacontone << _mask->get(dlg_da + i);
|
||||
acontone << _mask->get(dlg_al + i);
|
||||
}
|
||||
recset.set_var("#DACONTO", TVariant(dacontone));
|
||||
recset.set_var("#ACONTO", TVariant(acontone));
|
||||
|
||||
const long recset_items = recset.items();
|
||||
if (recset_items > 0)
|
||||
{
|
||||
TAssoc_array commesse_fasi; //assoc_array con chiave cms-fase-conto e un simpatico array dei 12 importi dei mesi per quella chiave
|
||||
TToken_string key; //chiave assoc_array
|
||||
|
||||
TProgind pi(recset_items, TR("Elaborazione dati per la stampa..."), true, true);
|
||||
|
||||
//Scansione delle righe analitiche filtrate...
|
||||
const TRectype& rmovana = recset.cursor()->curr();
|
||||
const TRectype& movana = recset.cursor()->curr(LF_MOVANA);
|
||||
for (bool ok = recset.move_first(); ok; ok = recset.move_next())
|
||||
{
|
||||
if (!pi.addstatus(1))
|
||||
break;
|
||||
//questo per adesso non serve, ma non si sa mai che chiedano la spaccatura tra costi e ricavi...
|
||||
const TAnal_bill uncle(rmovana);
|
||||
const TIndbil indbil = uncle.indicatore_bilancio();
|
||||
|
||||
key = rmovana.get(RMOVANA_CODCMS);
|
||||
key.add(rmovana.get(RMOVANA_CODFASE));
|
||||
key.add(rmovana.get(RMOVANA_CODCONTO));
|
||||
|
||||
//importo
|
||||
const real valore = rmovana.get_real(RMOVANA_IMPORTO);
|
||||
const char sezione = rmovana.get_char(RMOVANA_SEZIONE);
|
||||
|
||||
//durata del movana che contiene la riga in oggetto
|
||||
const TDate datacomp = movana.get_date(MOVANA_DATACOMP);
|
||||
TDate datafcomp = movana.get_date(MOVANA_DATAFCOMP);
|
||||
if (!datafcomp.ok())
|
||||
datafcomp = datacomp;
|
||||
const long durata_totale = datafcomp - datacomp + 1;
|
||||
|
||||
//giro sulle durate per il riproporzionamento
|
||||
int first_month = datacomp.month();
|
||||
int last_month = datafcomp.month();
|
||||
if (datafcomp.year() > datacomp.year())
|
||||
last_month = 12;
|
||||
|
||||
const int year = _mask->get_int(F_ANNO);
|
||||
for (int m = first_month; m <= last_month; m++)
|
||||
{
|
||||
TDate data_ini(1, m, year);
|
||||
TDate data_fin(1, m, year); data_fin.set_end_month();
|
||||
if (data_ini < datacomp)
|
||||
data_ini = datacomp;
|
||||
if (data_fin > datafcomp)
|
||||
data_fin = datafcomp;
|
||||
const int durata_month = data_fin - data_ini + 1;
|
||||
real valore_mese = valore * durata_month / durata_totale;
|
||||
const TImporto importo_mese(sezione, valore_mese);
|
||||
|
||||
//cerca se l'importo in questione va aggiunto ad un elemento già esistente dell'assoc_array o se..
|
||||
//..l'elemento con questa chiave non esiste e quindi deve aggiungerlo
|
||||
TArray* cms_fas = (TArray*)commesse_fasi.objptr(key);
|
||||
if (cms_fas == NULL)
|
||||
{
|
||||
cms_fas = new TArray(12);
|
||||
const TImporto importo_nullo;
|
||||
for (int j = 0; j < 12; j++)
|
||||
cms_fas->add(importo_nullo);
|
||||
|
||||
commesse_fasi.add(key, cms_fas);
|
||||
}
|
||||
TImporto& imp_cms_fas = (TImporto&)(*cms_fas)[m - 1];
|
||||
imp_cms_fas += importo_mese;
|
||||
}
|
||||
} //for(int m = first_month...
|
||||
|
||||
|
||||
FOR_EACH_ASSOC_OBJECT(commesse_fasi, obj, chiave, arr)
|
||||
{
|
||||
key = chiave;
|
||||
const TString& codcms = key.get(0);
|
||||
const TString& codfase = key.get(1);
|
||||
const TString& codconto = key.get(2);
|
||||
|
||||
TArray& importi = *(TArray*)arr;
|
||||
printset->crea_nuova_riga(codcms, codfase, codconto, importi);
|
||||
}
|
||||
printset->sort();
|
||||
}
|
||||
|
||||
return printset;
|
||||
}
|
||||
|
||||
|
||||
void TPrint_cosric_month::print_or_preview(const bool stampa)
|
||||
{
|
||||
if (_mask->check_fields())
|
||||
{
|
||||
TPrint_cosric_month_report rep;
|
||||
rep.load("pd6342100a.rep");
|
||||
|
||||
TPrint_cosric_month_recordset* printset = elabora();
|
||||
rep.set_recordset(printset);
|
||||
|
||||
//setta i valori della maschera sul report (dopo la set_recordset, sennò..
|
||||
//..sarebbero sovrascritti dalla set_recordset)
|
||||
rep.mask2report(*_mask);
|
||||
|
||||
TReport_book book;
|
||||
book.add(rep);
|
||||
|
||||
if (stampa)
|
||||
book.print();
|
||||
else
|
||||
book.preview();
|
||||
}
|
||||
}
|
||||
|
||||
void TPrint_cosric_month::print()
|
||||
{
|
||||
print_or_preview(true);
|
||||
}
|
||||
|
||||
void TPrint_cosric_month::preview()
|
||||
{
|
||||
print_or_preview(false);
|
||||
}
|
||||
|
||||
void TPrint_cosric_month::main_loop()
|
||||
{
|
||||
_mask = new TPrint_cosric_month_mask;
|
||||
_mask->run();
|
||||
delete _mask;
|
||||
_mask = NULL;
|
||||
}
|
||||
|
||||
bool TPrint_cosric_month::create()
|
||||
{
|
||||
//controlla se la chiave ha il modulo CA (e non solo CM) NON è ammesso CA E CM
|
||||
_has_ca = dongle().active(CAAUT);
|
||||
//in tal caso il programma è utilizzabile solo se si ha il piano dei conti contabile..
|
||||
if (_has_ca)
|
||||
{
|
||||
//le commesse devono essere state configurate
|
||||
const TMultilevel_code_info& mci = ca_multilevel_code_info(LF_COMMESSE);
|
||||
if (mci.levels() != 1)
|
||||
return error_box(TR("Il programma funziona solo con le commesse configurate come primo livello di CA"));
|
||||
}
|
||||
|
||||
return TSkeleton_application::create();
|
||||
}
|
||||
|
||||
int pd6342100(int argc, char* argv[])
|
||||
{
|
||||
TPrint_cosric_month stat_anal;
|
||||
stat_anal.run(argc, argv, TR("Stampa costi per mese"));
|
||||
return 0;
|
||||
}
|
4
ps/pd6342100a.h
Executable file
4
ps/pd6342100a.h
Executable file
@ -0,0 +1,4 @@
|
||||
#define F_ANNO 100
|
||||
#define F_CMS 101
|
||||
#define F_DACONTO 151
|
||||
#define F_ACONTO 160
|
97
ps/pd6342100a.rep
Executable file
97
ps/pd6342100a.rep
Executable file
@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<report name="pd6342100a" orientation="2" lpi="6">
|
||||
<description>Stampa costi-ricavi mensili CA</description>
|
||||
<font face="Arial" size="8" />
|
||||
<section type="Head">
|
||||
<font face="Arial" bold="1" size="8" />
|
||||
</section>
|
||||
<section type="Head" level="1">
|
||||
<field border="1" radius="100" x="30" y="0.5" type="Testo" valign="center" align="center" width="100" height="3" pattern="2" text="COSTI - RICAVI MENSILI PER SEDE E UNITA' OPERATIVA">
|
||||
<font face="Times New Roman" bold="1" size="16" />
|
||||
</field>
|
||||
<field x="10" y="4" type="Testo" width="6" text="Anno:">
|
||||
<font face="Arial" size="9" />
|
||||
</field>
|
||||
<field x="16" y="4" type="Numero" align="right" width="6">
|
||||
<font face="Arial" bold="1" size="9" />
|
||||
<source>ANNO</source>
|
||||
</field>
|
||||
<field x="30" y="4" type="Testo" width="15" text="Data di stampa:">
|
||||
<font face="Arial" size="9" />
|
||||
</field>
|
||||
<field x="44" y="4" type="Data" width="12">
|
||||
<font face="Arial" bold="1" size="9" />
|
||||
<source>#SYSTEM.DATE</source>
|
||||
</field>
|
||||
<field border="1" y="5" type="Linea" width="170" height="0" />
|
||||
</section>
|
||||
<section type="Head" level="2">
|
||||
<groupby>CODCMS</groupby>
|
||||
<font face="Arial" bold="1" size="9" />
|
||||
<prescript description="H2 PRESCRIPT">MESSAGE RESET,F2</prescript>
|
||||
<field x="1" y="0.5" type="Stringa" width="10" id="98" pattern="2">
|
||||
<source>CODCMS</source>
|
||||
<prescript description="H2.98 PRESCRIPT">MESSAGE COPY,F2.98</prescript>
|
||||
</field>
|
||||
<field x="12" y="0.5" type="Stringa" width="50" id="99" pattern="2">
|
||||
<prescript description="H2.99 PRESCRIPT">MESSAGE ISAMREAD,COMMESSE,CODCMS=CODCMS,DESCRIZ</prescript>
|
||||
<postscript description="H2.99 POSTSCRIPT">MESSAGE COPY,F2.99</postscript>
|
||||
</field>
|
||||
</section>
|
||||
<section type="Head" level="3">
|
||||
<groupby>CODFASE</groupby>
|
||||
<font italic="1" face="Arial" bold="1" size="8" />
|
||||
<prescript description="H3 PRESCRIPT">MESSAGE RESET,F3</prescript>
|
||||
<field x="2" type="Stringa" width="5" id="98" pattern="2">
|
||||
<source>CODFASE</source>
|
||||
<prescript description="H3.98 PRESCRIPT">MESSAGE COPY,F3.98</prescript>
|
||||
</field>
|
||||
<field x="8" type="Stringa" width="50" id="99" pattern="2">
|
||||
<prescript description="H3.99 PRESCRIPT">MESSAGE ISAMREAD,FASI,CODCMSFAS=CODCMS!CODFASE=CODFASE,DESCRIZ</prescript>
|
||||
<postscript description="H3.99 POSTSCRIPT">MESSAGE COPY,F3.99</postscript>
|
||||
</field>
|
||||
</section>
|
||||
<section type="Body" />
|
||||
<section type="Body" level="1">
|
||||
<field x="3" type="Stringa" width="8" id="98" pattern="2">
|
||||
<source>CODCONTO</source>
|
||||
</field>
|
||||
<field x="11" type="Stringa" width="20" id="99" pattern="2">
|
||||
<font face="Arial Narrow" size="8" />
|
||||
<prescript description="B1.99 PRESCRIPT">MESSAGE ISAMREAD,PCONANA,CODCONTO=#98,DESCR</prescript>
|
||||
</field>
|
||||
<field x="32" type="Valuta" align="right" width="10" id="101" pattern="2" text="#########,@@">
|
||||
<source>IMPORTO_01</source>
|
||||
<postscript description="B1.101 POSTSCRIPT">"F3.102" "F3.101" 102 @ 101 @
|
||||
REP_ADD_IMPORTO
|
||||
</postscript>
|
||||
</field>
|
||||
<field x="42.5" type="Stringa" width="1" id="102" pattern="2">
|
||||
<source>SEZIONE_01</source>
|
||||
</field>
|
||||
</section>
|
||||
<section type="Foot" />
|
||||
<section type="Foot" level="1" />
|
||||
<section type="Foot" level="2">
|
||||
<font face="Arial" bold="1" size="9" />
|
||||
<field border="1" x="1" y="0.25" type="Linea" width="169" height="0" pattern="2" />
|
||||
<field x="1" y="0.5" type="Testo" width="6" pattern="2" text="Totale" />
|
||||
<field x="8" y="0.5" type="Stringa" width="8" id="98" pattern="2" />
|
||||
<field x="16" y="0.5" type="Stringa" width="20" id="99" pattern="2">
|
||||
<font face="Arial Narrow" bold="1" size="8" />
|
||||
</field>
|
||||
</section>
|
||||
<section type="Foot" level="3">
|
||||
<font italic="1" face="Arial Narrow" bold="1" size="8" />
|
||||
<field border="1" x="1" y="0.25" type="Linea" width="168" height="0" pattern="2" />
|
||||
<field x="2" y="0.5" type="Testo" width="6" pattern="2" text="Totale" />
|
||||
<field x="8" y="0.5" type="Stringa" width="6" id="98" pattern="2" />
|
||||
<field x="14" y="0.5" type="Stringa" width="15" id="99" pattern="2" />
|
||||
<field x="32" y="0.5" type="Valuta" align="right" width="10" id="101" pattern="2" text="#########,@@">
|
||||
<font italic="1" face="Arial" bold="1" size="8" />
|
||||
</field>
|
||||
<field x="42.5" y="0.5" type="Stringa" width="1" id="102" pattern="2">
|
||||
<font italic="1" face="Arial" bold="1" size="8" />
|
||||
</field>
|
||||
</section>
|
||||
</report>
|
48
ps/pd6342100a.uml
Executable file
48
ps/pd6342100a.uml
Executable file
@ -0,0 +1,48 @@
|
||||
#include "pd6342100a.h"
|
||||
|
||||
TOOLBAR "topbar" 0 0 0 2
|
||||
|
||||
BUTTON DLG_PREVIEW 2 2
|
||||
BEGIN
|
||||
PROMPT 1 1 "~Anteprima"
|
||||
PICTURE TOOL_PREVIEW
|
||||
END
|
||||
|
||||
#include <printbar.h>
|
||||
|
||||
ENDPAGE
|
||||
|
||||
PAGE "Stampa costi per mese" 0 2 0 0
|
||||
|
||||
NUMBER F_ANNO 4
|
||||
BEGIN
|
||||
PROMPT 1 1 "Anno "
|
||||
USE ESC
|
||||
INPUT CODTAB F_ANNO
|
||||
DISPLAY "Codice Esercizio" CODTAB
|
||||
DISPLAY "Data inizio esercizio" D0
|
||||
DISPLAY "Data fine esercizio " D1
|
||||
OUTPUT F_ANNO CODTAB
|
||||
CHECKTYPE REQUIRED
|
||||
FLAGS "RZ"
|
||||
FIELD ANNO
|
||||
END
|
||||
|
||||
GROUPBOX DLG_NULL 77 13
|
||||
BEGIN
|
||||
PROMPT 1 3 "@bParametri"
|
||||
END
|
||||
|
||||
TEXT DLG_NULL
|
||||
BEGIN
|
||||
PROMPT 2 6 "@bDa Conto"
|
||||
END
|
||||
|
||||
TEXT DLG_NULL
|
||||
BEGIN
|
||||
PROMPT 2 10 "@bA Conto"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
Loading…
x
Reference in New Issue
Block a user