Patch level :

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :


git-svn-id: svn://10.65.10.50/trunk@16208 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
luca 2008-02-21 15:25:25 +00:00
parent 723838ddbc
commit 8af73fbed4
5 changed files with 353 additions and 53 deletions

BIN
tp/conaica.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -6,9 +6,11 @@
#include <progind.h>
#include <recarray.h>
#include <relation.h>
#include <reprint.h>
#include <reputils.h>
#include <textset.h>
#include <clifo.h>
#include <doc.h>
#include <rdoc.h>
@ -44,6 +46,14 @@ bool TDichiarazione_CONAI_mask::on_field_event(TOperable_field& o, TField_event
return true;
}
/////////////////////////////////////////////////////////////
// REPORT
/////////////////////////////////////////////////////////////
class TDichiarazione_CONAI_report : public TReport
{
public:
TDichiarazione_CONAI_report() {}
};
/////////////////////////////////////////////////////////////
// CSV RECORDSET
@ -92,12 +102,24 @@ void TDichiarazione_CONAI::scrivi_csv(const TRectype& riga_generata, TDichiarazi
const real totale_qta_assogg = riga_generata.get_real(RDOC_QTA); //questo ci serve per le quantita' assoggetate o no
TGeneric_distrib agip(totale_qta_assogg, 5); //distrib per ridistribuire le % dei quantitativi assoggetati
TArray qta_AB_conai; //array
TArray qta_AB_conai; //array con le quantita' conai totali (A+B)
//documento della riga generata, e quindi anche di tutte le altre righe conai
TDocumento doc('D', anno, codnum, numdoc);
//scopre se il doc e' una NAC
const bool is_nac = doc.is_nota_credito();
//prende la data del documento
const TDate& datadoc = doc.data();
//prende il cliente ed i suoi dati
TCli_for clifo = doc.clifor();
const long clifo_cod = clifo.codice();
TString16 clifo_cofi = clifo.get(CLI_COFI);
if (clifo_cofi.empty())
clifo_cofi = clifo.get(CLI_PAIV);
const int nrighe = doc.rows();
//ciclo di creazione del distrib con le quote conai
@ -134,43 +156,78 @@ void TDichiarazione_CONAI::scrivi_csv(const TRectype& riga_generata, TDichiarazi
//creazione di un nuovo record da esportare
csv.new_rec("");
//riempie i campi del record del csv
//codnum-anno-ndoc-datadoc-codcli-cofi-nriga-codagg1-codagg2-prezzo-um-conai(AB)-conai(B)-conai(A)
//parte chiave della riga
csv.set(0, TVariant(rdoc.get(RDOC_CODNUM)));
csv.set(1, TVariant(rdoc.get(RDOC_ANNO)));
csv.set(2, TVariant(rdoc.get(RDOC_NDOC)));
csv.set(3, TVariant(rdoc.get(RDOC_NRIGA)));
csv.set(3, TVariant(datadoc));
csv.set(4, TVariant(clifo_cod));
csv.set(5, TVariant(clifo_cofi));
csv.set(6, TVariant(rdoc.get(RDOC_NRIGA)));
//codici conai
csv.set(4, TVariant(codagg1)); //codice materiale conai (es. carta, legno...)
csv.set(5, TVariant(codagg2)); //sottocodice materiale (es. carta imballo, busta...)
csv.set(7, TVariant(codagg1)); //codice materiale conai (es. carta, legno...)
csv.set(8, TVariant(codagg2)); //sottocodice materiale (es. carta imballo, busta...)
//prezzo
const real prezzo = riga_generata.get_real(RDOC_PREZZO); //va preso dalla riga generata
csv.set(6, TVariant(prezzo));
csv.set(9, TVariant(prezzo));
//um conai
const TString4 umqta = cache().get("SPP", conai_codart, "S7"); //unita' di misura dalla tabella SPP
csv.set(7, TVariant(umqta));
csv.set(10, TVariant(umqta));
//quantita' totale conai (A + B) sul report (le NAC hanno segno rovesciato)
real qta_tot_conai = (real&)qta_AB_conai[i];
if (is_nac)
qta_tot_conai = -qta_tot_conai;
csv.set(8, TVariant(qta_tot_conai));
csv.set(11, TVariant(qta_tot_conai));
//quantita' assoggettata (B) sul report (le NAC hanno segno rovesciato)
real qta_assoggettata_conai = agip.get();
if (is_nac)
qta_assoggettata_conai = -qta_assoggettata_conai;
csv.set(9, TVariant(qta_assoggettata_conai));
csv.set(12, TVariant(qta_assoggettata_conai));
//quantita' esente conai (A) sul report
const real qta_esente_conai = qta_tot_conai - qta_assoggettata_conai;
csv.set(10, TVariant(qta_esente_conai));
csv.set(13, TVariant(qta_esente_conai));
}
}
}
static int compare_csv_rows(const TObject** o1, const TObject** o2)
{
TToken_string& s1 = *(TToken_string*)*o1;
TToken_string& s2 = *(TToken_string*)*o2;
//deve ordinare sul campo 8 (codagg2 = codice specie conai)
const TString& c1 = s1.get(8);
const TString& c2 = s2.get(8);
int cmp = c1.compare(c2);
// sotto ordinamento per codice cliente (campo 4)
if (cmp == 0)
{
const TString& c1 = s1.get(4);
const TString& c2 = s2.get(4);
cmp = c1.compare(c2);
// sotto-sotto ordinamento per ndoc (campo 2)
if (cmp == 0)
{
const TString& c1 = s1.get(2);
const TString& c2 = s2.get(2);
cmp = c1.compare(c2);
}
}
return cmp;
}
//metodo di base per la ricerca delle righe documento che soddisfano i parametri dell'utonto
void TDichiarazione_CONAI::elabora(const TMask& mask) const
{
@ -210,38 +267,43 @@ void TDichiarazione_CONAI::elabora(const TMask& mask) const
TConfig ditta_ini(CONFIG_DITTA, "ve");
TVariant codart;
TString esenzione;
TString nome_report; //report di tipo 6.1 scelto in base alla specie conai
switch (specie_conai)
{
case 0:
codart = ditta_ini.get("CODACC"); //acciaio
esenzione = "ESACC";
nome_report = "tp0900ac.rep";
break;
case 1:
codart = ditta_ini.get("CODALL"); //alluminio
esenzione = "ESALL";
nome_report = "tp0900al.rep";
break;
case 2:
codart = ditta_ini.get("CODCAR"); //carta
esenzione = "ESCAR";
nome_report = "tp0900ca.rep";
break;
case 3:
codart = ditta_ini.get("CODPLA"); //plastica
esenzione = "ESPLA";
nome_report = "tp0900pl.rep";
break;
case 4:
codart = ditta_ini.get("CODLEG"); //legno
esenzione = "ESLEG";
nome_report = "tp0900le.rep";
break;
case 5:
codart = ditta_ini.get("CODVET"); //vetro
esenzione = "ESVET";
nome_report = "tp0900ve.rep";
break;
default:
break;
}
//In caso il tipo stampa NON sia con il modello 6.1 basato sulla specie conai ma di tipo 6.3 basato sui..
//fornitori e le loro esenzioni, il report va rinominato perche' e' unico
if (mask.get_int(F_TIPOSTAMPA) == 2)
nome_report = "tp0900es.rep";
//Adesso prende le numerazioni e i tipi documento
TSheet_field& sf = mask.sfield(F_TIPI);
@ -265,8 +327,7 @@ void TDichiarazione_CONAI::elabora(const TMask& mask) const
rdoc.set_var("#CODART", codart);
//creazione del csv recordset che verra' riempito dai record del recordset rdoc
TDichiarazione_CONAI_csv_recordset csv;
const TString path = "C:/temp/cazzone.xls";
TDichiarazione_CONAI_csv_recordset* csv = new TDichiarazione_CONAI_csv_recordset;
//quante righe dello sheet processa?
const long tot_items = sf.items();
@ -280,9 +341,9 @@ void TDichiarazione_CONAI::elabora(const TMask& mask) const
//quanti record validi ha trovato?
const long items = rdoc.items();
#ifdef DBG
/*#ifdef DBG
warning_box("Hai trovato %ld righe di %s! Ti sembrano abbastanza?", items, row->get(0));
#endif
#endif*/
//E crea pure la progind..
TProgind pi(tot_items, TR("Generazione righe..."), true, true);
@ -293,17 +354,40 @@ void TDichiarazione_CONAI::elabora(const TMask& mask) const
if (!pi.addstatus(1))
break;
scrivi_csv(rdoc.cursor()->curr(), csv, specie_conai);
scrivi_csv(rdoc.cursor()->curr(), *csv, specie_conai);
} //for(bool ok = rdoc.move_first(..
} //FOR_EACH...
csv.save_as(path, fmt_text);
//riordinamento del file secondo: specie conai, codice cliente, numero documento
csv->sort(compare_csv_rows);
//se richiesto il file in formato excel...
if (mask.get_bool(F_EXCEL))
{
const TString path = mask.get(F_PATH);
csv->save_as(path, fmt_text);
/*#ifdef DBG
xvt_sys_goto_url(path, "open");
#endif*/
}
//creazione del report di stampa
TDichiarazione_CONAI_report rep;
bool ok = rep.load(nome_report);
rep.mask2report(mask);
rep.set_recordset(csv);
if (ok)
{
TReport_book book;
ok = book.add(rep);
if (ok)
book.print_or_preview();
}
#ifdef DBG
xvt_sys_goto_url(path, "open");
#endif
}

View File

@ -3,6 +3,11 @@
#define F_FIRM 101
#define F_RAGSOC 102
#define F_PAIV 103
#define F_COFI 104
#define F_DENCOM 105
#define F_INDRES 106
#define F_CIVRES 107
#define F_PERIODO 111
#define F_ANNO 112
@ -12,9 +17,9 @@
#define F_SPECIECONAI 116
#define F_TIPOSTAMPA 117
#define F_EMAIL 118
#define F_TEL 119
#define F_SOCIO 120
#define F_UFFADD 121
#define F_SOCIO 121
#define F_RESP 122
#define F_PRODUT 123
#define F_EXCEL 124

View File

@ -47,23 +47,38 @@ BEGIN
FIELD #RAGSOC
END
GROUPBOX DLG_NULL 78 5
STRING F_PAIV 16
BEGIN
PROMPT 2 2 "iva"
FLAGS "D"
FIELD #PAIV
END
STRING F_COFI 16
BEGIN
PROMPT 45 2 "cofi"
FLAGS "D"
FIELD #COFI
END
GROUPBOX DLG_NULL 78 3
BEGIN
PROMPT 1 3 "@bPeriodo da considerare"
END
RADIOBUTTON F_PERIODO 16
RADIOBUTTON F_PERIODO 38
BEGIN
PROMPT 2 3 ""
ITEM "1|Annuale" MESSAGE HIDE,F_TRIMESTRE|HIDE,F_MESE
ITEM "2|Trimestrale" MESSAGE SHOW,F_TRIMESTRE|HIDE,F_MESE
ITEM "3|Mensile" MESSAGE HIDE,F_TRIMESTRE|SHOW,F_MESE
FIELD #PERIODO
FLAGS "Z"
END
NUMBER F_ANNO 4
BEGIN
PROMPT 28 4 "Anno "
PROMPT 40 4 "Anno "
HELP "Anno per cui effettuare la dichiarazione"
CHECKTYPE REQUIRED
FIELD #ANNO
@ -71,7 +86,7 @@ END
LIST F_MESE 15
BEGIN
PROMPT 28 5 "Periodo "
PROMPT 52 4 "Periodo "
HELP "Mese per cui effettuare la dichiarazione"
FLAGS "AM"
FIELD #MESE
@ -79,7 +94,7 @@ END
LIST F_TRIMESTRE 15
BEGIN
PROMPT 28 5 "Periodo "
PROMPT 52 4 "Periodo "
HELP "Trimestre di cui effettuare la dichiarazione"
ITEM "3|1 Trimestre "
ITEM "6|2 Trimestre "
@ -90,12 +105,12 @@ END
TEXT DLG_NULL
BEGIN
PROMPT 1 8 "@bNumerazioni e tipi documento da considerare"
PROMPT 1 6 "@bNumerazioni e tipi documento da considerare"
END
SPREADSHEET F_TIPI 78 4
BEGIN
PROMPT 1 9 ""
PROMPT 1 7 ""
ITEM "Numerazione"
ITEM "Descrizione@50"
ITEM "Tipo"
@ -104,7 +119,7 @@ END
LIST F_SPECIECONAI 12
BEGIN
PROMPT 1 14 "@bSpecie CONAI da considerare"
PROMPT 1 12 "@bSpecie CONAI da considerare"
ITEM "0|Acciaio "
ITEM "1|Alluminio "
ITEM "2|Carta "
@ -116,48 +131,48 @@ END
RADIOBUTTON F_TIPOSTAMPA 34
BEGIN
PROMPT 45 14 "@bTipo stampa"
PROMPT 45 12 "@bTipo stampa"
ITEM "1|Mod.6.1"
ITEM "2|Mod.6.3"
FLAGS "Z"
END
GROUPBOX DLG_NULL 78 5
GROUPBOX DLG_NULL 78 6
BEGIN
PROMPT 1 15 "@bDati Dichiarante"
PROMPT 1 14 "@bDati Dichiarante"
END
STRING F_SOCIO 6
STRING F_SOCIO 30 6
BEGIN
PROMPT 2 16 "Cod.Socio "
PROMPT 2 15 "Cod.Socio "
FIELD #SOCIO
END
STRING F_UFFADD 12
STRING F_RESP 18 12
BEGIN
PROMPT 20 16 "Uff.Addetto "
FIELD #UFFADD
END
STRING F_RESP 12
BEGIN
PROMPT 48 16 "Responsabile "
PROMPT 20 15 "Responsabile "
FIELD #RESP
END
RADIOBUTTON F_PRODUT 28
RADIOBUTTON F_PRODUT 27
BEGIN
PROMPT 2 17 ""
PROMPT 51 15 "Iscritto in quanto:"
ITEM "1|Produttore"
ITEM "2|Utilizzatore"
FLAGS "Z"
FIELD #PRODUT
END
STRING F_EMAIL 256 36
STRING F_EMAIL 256 30
BEGIN
PROMPT 34 18 "E-Mail "
FIELD #EMAIL
PROMPT 2 18 "E-Mail "
FIELD EMAIL
END
STRING F_TEL 26
BEGIN
PROMPT 46 18 "Tel. "
FIELD TEL
END
BOOLEAN F_EXCEL

196
tp/tp0900ca.rep Executable file
View File

@ -0,0 +1,196 @@
<?xml version="1.0" encoding="UTF-8" ?>
<report name="tp0900ca" orientation="1" lpi="6">
<description>Dichiarazione CONAI carta 6.1</description>
<font face="Courier New" size="8" />
<section type="Head">
<field x="60.5" y="9.75" type="Numero" align="right" width="5" pattern="1">
<source>#ANNO</source>
</field>
<field x="20.5" y="13.75" type="Stringa" width="30" pattern="1">
<source>#SOCIO</source>
</field>
<field x="22.5" y="14.75" type="Stringa" width="50" pattern="1">
<source>#RAGSOC</source>
</field>
<field x="18" y="15.75" type="Stringa" width="30" pattern="1">
<source>#INDRES</source>
</field>
<field x="20" y="16.75" type="Stringa" width="16" pattern="1">
<source>#PAIV</source>
</field>
<field x="62.25" y="16.75" type="Stringa" width="16" pattern="1">
<source>#COFI</source>
</field>
<field x="31.5" y="17.75" type="Stringa" width="18" pattern="1">
<source>#RESP</source>
</field>
<field x="54.25" y="17.75" type="Stringa" width="16" pattern="1">
<source>#TEL</source>
</field>
<field x="76" y="17.75" type="Stringa" width="16" pattern="1">
<source>#EMAIL</source>
</field>
</section>
<section type="Head" level="1" />
<section type="Body">
<field x="2" y="0.5" type="Immagine" width="90" height="55" pattern="1">
<source>"conaica.png"</source>
</field>
</section>
<section type="Body" level="1">
<field type="Stringa" hidden="1" align="right" width="5" pattern="1">
<source>I</source>
</field>
<field x="10" type="Numero" hidden="1" align="right" width="10" pattern="1">
<source>N</source>
<postscript description="B1.0 POSTSCRIPT">MESSAGE ADD,F0.104
MESSAGE ADD,F0.110</postscript>
</field>
<field x="30" type="Numero" hidden="1" align="right" width="10" pattern="1">
<source>M</source>
<postscript description="B1.0 POSTSCRIPT">MESSAGE ADD,F0.204
MESSAGE ADD,F0.210</postscript>
</field>
</section>
<section y="26" type="Foot">
<field x="26.5" y="20" type="Data" width="14" pattern="1">
<font face="Courier New" size="10" />
<source>#SYSTEM.DATE</source>
</field>
<field x="29.25" y="0.25" type="Numero" align="right" width="10" id="100" pattern="1">
<prescript description="F0.100 PRESCRIPT">#THIS @
1000 &#2F;
2 ROUND
#THIS !</prescript>
</field>
<field x="29.25" y="1.25" type="Numero" align="right" width="10" id="101" pattern="1">
<prescript description="F0.101 PRESCRIPT">#THIS @
1000 &#2F;
2 ROUND
#THIS !</prescript>
</field>
<field x="29.25" y="2.25" type="Numero" align="right" width="10" id="102" pattern="1">
<prescript description="F0.102 PRESCRIPT">#THIS @
1000 &#2F;
2 ROUND
#THIS !</prescript>
</field>
<field x="29.25" y="3.25" type="Numero" align="right" width="10" id="103" pattern="1">
<prescript description="F0.103 PRESCRIPT">#THIS @
1000 &#2F;
2 ROUND
#THIS !</prescript>
</field>
<field x="29.25" y="4.25" type="Numero" align="right" width="10" id="104" pattern="1">
<prescript description="F0.104 PRESCRIPT">#THIS @
1000 &#2F;
2 ROUND
#THIS !</prescript>
</field>
<field x="29.25" y="5.25" type="Numero" align="right" width="10" id="105" pattern="1">
<prescript description="F0.105 PRESCRIPT">#THIS @
1000 &#2F;
2 ROUND
#THIS !</prescript>
</field>
<field x="29.25" y="6.25" type="Numero" align="right" width="10" id="106" pattern="1">
<prescript description="F0.106 PRESCRIPT">#THIS @
1000 &#2F;
2 ROUND
#THIS !</prescript>
</field>
<field x="29.25" y="7.25" type="Numero" align="right" width="10" id="107" pattern="1">
<prescript description="F0.107 PRESCRIPT">#THIS @
1000 &#2F;
2 ROUND
#THIS !</prescript>
</field>
<field x="29.25" y="8.25" type="Numero" align="right" width="10" id="108" pattern="1">
<prescript description="F0.108 PRESCRIPT">#THIS @
1000 &#2F;
2 ROUND
#THIS !</prescript>
</field>
<field x="29.25" y="9.25" type="Numero" align="right" width="10" id="109" pattern="1">
<prescript description="F0.109 PRESCRIPT">#THIS @
1000 &#2F;
2 ROUND
#THIS !</prescript>
</field>
<field x="29.25" y="10.25" type="Numero" align="right" width="10" id="110" pattern="1">
<font face="Courier New" bold="1" size="8" />
<prescript description="F0.110 PRESCRIPT">#THIS @
1000 &#2F;
2 ROUND
#THIS !</prescript>
</field>
<field x="39.75" y="0.25" type="Numero" align="right" width="10" id="200" pattern="1">
<prescript description="F0.200 PRESCRIPT">#THIS @
1000 &#2F;
2 ROUND
#THIS !</prescript>
</field>
<field x="39.75" y="1.25" type="Numero" align="right" width="10" id="201" pattern="1">
<prescript description="F0.201 PRESCRIPT">#THIS @
1000 &#2F;
2 ROUND
#THIS !</prescript>
</field>
<field x="39.75" y="2.25" type="Numero" align="right" width="10" id="202" pattern="1">
<prescript description="F0.202 PRESCRIPT">#THIS @
1000 &#2F;
2 ROUND
#THIS !</prescript>
</field>
<field x="39.75" y="3.25" type="Numero" align="right" width="10" id="203" pattern="1">
<prescript description="F0.203 PRESCRIPT">#THIS @
1000 &#2F;
2 ROUND
#THIS !</prescript>
</field>
<field x="39.75" y="4.25" type="Numero" align="right" width="10" id="204" pattern="1">
<prescript description="F0.204 PRESCRIPT">#THIS @
1000 &#2F;
2 ROUND
#THIS !</prescript>
</field>
<field x="39.75" y="5.25" type="Numero" align="right" width="10" id="205" pattern="1">
<prescript description="F0.205 PRESCRIPT">#THIS @
1000 &#2F;
2 ROUND
#THIS !</prescript>
</field>
<field x="39.75" y="6.25" type="Numero" align="right" width="10" id="206" pattern="1">
<prescript description="F0.206 PRESCRIPT">#THIS @
1000 &#2F;
2 ROUND
#THIS !</prescript>
</field>
<field x="39.75" y="7.25" type="Numero" align="right" width="10" id="207" pattern="1">
<prescript description="F0.207 PRESCRIPT">#THIS @
1000 &#2F;
2 ROUND
#THIS !</prescript>
</field>
<field x="39.75" y="8.25" type="Numero" align="right" width="10" id="208" pattern="1">
<prescript description="F0.208 PRESCRIPT">#THIS @
1000 &#2F;
2 ROUND
#THIS !</prescript>
</field>
<field x="39.75" y="9.25" type="Numero" align="right" width="10" id="209" pattern="1">
<prescript description="F0.209 PRESCRIPT">#THIS @
1000 &#2F;
2 ROUND
#THIS !</prescript>
</field>
<field x="39.75" y="10.25" type="Numero" align="right" width="10" id="210" pattern="1">
<font face="Courier New" bold="1" size="8" />
<prescript description="F0.210 PRESCRIPT">#THIS @
1000 &#2F;
2 ROUND
#THIS !</prescript>
</field>
</section>
<section type="Foot" level="1" />
</report>