diff --git a/cg/cg3900.cpp b/cg/cg3900.cpp
index 28bd795f4..7fd693c74 100755
--- a/cg/cg3900.cpp
+++ b/cg/cg3900.cpp
@@ -56,6 +56,8 @@ class TAllegato_info : public TObject
public:
bool occasionale() const { return _tipo == 'C' && _occas.full(); }
char tipo() const { return _tipo; }
+ long codice() const { return _codice; }
+ const TString & occas_code() const { return _occas;}
TVariant get(const TString& field) const;
void key(TString& str) const;
@@ -63,6 +65,7 @@ public:
const TAllegato_importi& importi(bool prec) const { return prec ? _prec : _curr; }
bool is_not_null(bool strict) const { return _curr.is_not_null(strict) || _prec.is_not_null(strict); }
+ void set_codice(long codice, const char* occas) { _codice = codice; _occas = occas; }
TAllegato_info(const TRecordset& mov);
};
@@ -612,34 +615,60 @@ const TCausale& TCausali_cache::causale(const char* codice, int annoiva)
class TAlleg_report : public TReport
{
- int _anno;
+ TAssoc_array _vars;
protected:
virtual bool use_mask() { return false; }
+ virtual bool set_usr_val(const TString& name, const TVariant& var);
virtual bool get_usr_val(const TString& name, TVariant& var) const;
public:
- TAlleg_report(TRecordset* rs, int anno);
+ TAlleg_report(TRecordset* rs, const TMask& am, bool hide_not_alleg = false);
};
+bool TAlleg_report::set_usr_val(const TString& name, const TVariant& var)
+{
+ if (!TReport::set_usr_val(name, var))
+ _vars.add(name, new TVariant(var));
+ return true;
+}
+
bool TAlleg_report::get_usr_val(const TString& name, TVariant& var) const
{
- if (name == "ANNO")
+ if (name[0] == '#')
{
- var.set(_anno);
- return true;
- }
- if (name == "PREC")
- {
- var.set(_anno-1);
- return true;
+ TVariant* v = (TVariant*)_vars.objptr(name);
+ if (v != NULL)
+ {
+ var = *v;
+ return true;
+ }
}
return TReport::get_usr_val(name, var);
}
-TAlleg_report::TAlleg_report(TRecordset* rs, int anno) : _anno(anno)
+TAlleg_report::TAlleg_report(TRecordset* rs, const TMask& am, bool hide_not_alleg)
{
load("cg3900a");
+ mask2report(am);
+ TString4 filtro;
+
+ if (!hide_not_alleg)
+ filtro = am.get(F_FILTRO);
+ set_usr_val("#FILTRO", TVariant(filtro));
+
+
+ if (hide_not_alleg)
+ {
+ const char* const fields[] = { "H0.107", "B1.107", "B1.207", "F1.107", "F1.207", NULL };
+ for (int i = 0; fields[i]; i++)
+ {
+ TReport_field* rf = field(fields[i]);
+ if (rf != NULL)
+ rf->deactivate();
+ }
+ }
+
set_recordset(rs);
}
@@ -725,13 +754,18 @@ int TAlleg_mask::imp_iva(char tipocf, bool non_esposti, const TRecordset& riga,
return allegato;
}
-bool TAlleg_mask::scan_iva_rows(const TRecordset& mov, TAssoc_array& clifi, bool strict)
+bool TAlleg_mask::scan_iva_rows(const TRecordset& mov, TAssoc_array& clifi, bool invio)
{
// Informazioni base sul cliente in testata: vengono ignorati gli importi
const TAllegato_info clifo(mov);
+ const int tipalleg = clifo.get(CLI_ALLEG).as_int();
- if (strict)
+ if (invio)
{
+ // Ignoro da subito chi non va in allegato
+ if (tipalleg != 0 && tipalleg != 4)
+ return false;
+
// Gli occasionali meritano solo di essere ignorati
if (clifo.occasionale())
return false;
@@ -739,12 +773,14 @@ bool TAlleg_mask::scan_iva_rows(const TRecordset& mov, TAssoc_array& clifi, bool
const TVariant stato = clifo.get(CLI_STATOPAIV);
if (!stato.is_empty() && stato.as_string() != "IT") // Scarto gli esteri
return false;
-
- // Ignoro da subito chi non va in allegato
- const int tipalleg = clifo.get(CLI_ALLEG).as_int();
- if (tipalleg != 0 && tipalleg != 4)
- return false;
}
+ else
+ {
+ // Per efficienza andrebbe nella funzione chiamante
+ const int filtro = get_int(F_FILTRO);
+ if (filtro >= 0 && tipalleg != filtro)
+ return false;
+ }
TString80 clifo_key; clifo.key(clifo_key);
TAllegato_info* ai = (TAllegato_info*)clifi.objptr(clifo_key);
@@ -753,6 +789,17 @@ bool TAlleg_mask::scan_iva_rows(const TRecordset& mov, TAssoc_array& clifi, bool
ai = new TAllegato_info(mov);
clifi.add(clifo_key, ai);
}
+ else
+ {
+ // Se questa partita IVA esiste gia' deve prevalere la ragione sociale con tipalleg=0
+ if (tipalleg == 0)
+ {
+ const long codcf = clifo.codice(); // Codice corrente
+ const long old_codcf = ai->codice(); // Codice su fornitura
+ if (codcf != old_codcf)
+ ai->set_codice(codcf, clifo.occas_code());
+ }
+ }
const TDate datareg = mov.get(MOV_DATAREG).as_date();
const TDate datadoc = mov.get(MOV_DATADOC).as_date();
@@ -766,7 +813,10 @@ bool TAlleg_mask::scan_iva_rows(const TRecordset& mov, TAssoc_array& clifi, bool
const bool non_esposti = movintra || reverse_charge;
const bool prorata100 = caus.reg().prorata100(annoiva);
- const bool anno_prec = datadoc.year() == anno-1;
+ bool anno_prec = false; // In attesa di modifiche a prima nota
+ if (get(F_ALGO) == "R")
+ anno_prec = datadoc.year() == anno-1; // Serve per quadrature
+
TAllegato_importi& allimp = ai->importi(anno_prec);
TISAM_recordset righe_iva("USE RMOVIVA\nFROM NUMREG=#NR\nTO NUMREG=#NR");
@@ -792,34 +842,37 @@ bool TAlleg_mask::scan_iva_rows(const TRecordset& mov, TAssoc_array& clifi, bool
return true;
}
-// algo: 0=AGA; 1=Sirio/Benetti
-TRecordset* TAlleg_mask::new_recordset(char tipocf, bool strict)
+// algo: R=data Registrazione; D=data Documento
+TRecordset* TAlleg_mask::new_recordset(char tipocf, bool invio)
{
- const int algo_dick = get_int(F_ALGO);
+ const int algo_dick = get(F_ALGO) == "D";
// Compito: tradurre in ISAM la seguente query:
// SELECT * FROM MOV
- // WHERE TIPO=#TYPE AND ANNOIVA=#YEAR
+ // WHERE TIPO=#TYPE AND ANNOIVA=#ANNO
// ORDER BY TIPO,CODCF;
- TString query = "USE MOV KEY 3"; // La chiave 3 e' TIPO+CODCF+DATAREG+NUMREG
- query << "\nSELECT (ANNOIVA=#YEAR)"; // Seleziona solo l'anno desiderato
-
+ TString query = "USE MOV KEY 3"; // La chiave 3 e' TIPO+CODCF+DATAREG+NUMREG
+ query << "\nSELECT ";
if (algo_dick)
- query << "||(ANNOIVA=(#YEAR+1))";
+ query << "(ANNOIVA>=#ANNO)"; // Seleziona dall'anno desiderato in poi
+ else
+ query << "(ANNOIVA==#ANNO)"; // Seleziona solo l'anno desiderato
query << "\nFROM TIPO=#TYPE CODCF=1"; // Salta tutti movimenti senza CODCF
query << "\nTO TIPO=#TYPE"; // Inutile dire CODCF=999999
TISAM_recordset mov(query);
if (tipocf <= ' ') tipocf = get(F_TIPO)[0];
- const char tipo[2] = { tipocf, '\0' };
+
+ const char tipo[2] = { tipocf, '\0' };
const int anno = get_int(F_ANNO);
- mov.set_var("#YEAR", TVariant(long(anno)));
+
+ mov.set_var("#ANNO", TVariant(long(anno)));
mov.set_var("#TYPE", TVariant(tipo));
const TRecnotype movs = mov.items();
TString msg;
- msg << movs << ' ' << TR("Movimenti") << ' '
+ msg << TR("Elaborazione") << ' ' << movs << ' ' << TR("Movimenti") << ' '
<< (tipocf == 'C' ? TR("Clienti") : TR("Fornitori"));
TProgind pi(movs, msg, true, true);
@@ -838,7 +891,7 @@ TRecordset* TAlleg_mask::new_recordset(char tipocf, bool strict)
continue;
// Scarta trasferimento movimenti intra prima del 2008
- if (strict && anno < 2008 && caus.intra())
+ if (invio && anno < 2008 && caus.intra())
continue;
// Controllo inutilmente anche il tipo documento
@@ -861,20 +914,20 @@ TRecordset* TAlleg_mask::new_recordset(char tipocf, bool strict)
{
const int annodoc = mov.get(MOV_DATADOC).as_date().year();
const bool is_nota = (tipodoc=="NC") || (tipodoc=="ND");
- keep = (annodoc == anno) || (is_nota && (annodoc == anno-1));
+ keep = (annodoc == anno) ; // || (is_nota && (annodoc == anno-1));
}
if (!keep)
continue;
- scan_iva_rows(mov, clifi, strict);
+ scan_iva_rows(mov, clifi, invio);
}
TAllegati_set* hullygully = new TAllegati_set;
FOR_EACH_ASSOC_OBJECT(clifi, h, k, o)
{
const TAllegato_info& ai = *(TAllegato_info*)o;
- if (ai.is_not_null(strict))
+ if (ai.is_not_null(invio))
hullygully->add(ai);
}
hullygully->sort();
@@ -899,21 +952,27 @@ void TAlleg_mask::add_0_9(int trc, TPadoaSchioppa_set& pss, TLog_report& log)
const TRectype& anag = contribuente();
const char tipoa = anag.get_char(ANA_TIPOA);
const long codanagr = anag.get_long(ANA_CODANAGR);
+ const TString ragsoc = anag.get(ANA_RAGSOC); // Non fidarsi ad usare TString&
TString16 pariva = anag.get(ANA_PAIV); pariva.right_just(11, '0');
if (!pi_check("", pariva))
- log_error(anag.get(ANA_RAGSOC), TR("*** Ditta con partita IVA errata"), pariva, log, 2);
+ log_error(ragsoc, TR("*** Ditta con partita IVA errata"), pariva, log, 2);
+ else
+ {
+ if (pariva[0] == '8' || pariva[0] == '9')
+ log_error(ragsoc, TR("** Verificare esenzione dall'invio degli elenchi"), pariva, log, 2);
+ }
const TString16 codfis = anag.get(ANA_COFI);
if (!cf_check("", codfis))
- log_error(anag.get(ANA_RAGSOC), TR("** Ditta con codice fiscale errato"), codfis, log, 2);
+ log_error(ragsoc, TR("** Ditta con codice fiscale errato"), codfis, log, 2);
pss.set("CodiceFiscale", codfis.full() ? codfis : pariva);
pss.set("PartitaIVA", pariva.full() ? pariva : codfis);
if (tipoa == 'F')
{
- pss.set("Cognome", anag.get(ANA_RAGSOC).left(30));
- pss.set("Nome", anag.get(ANA_RAGSOC).mid(30));
+ pss.set("Cognome", ragsoc.left(30));
+ pss.set("Nome", ragsoc.mid(30));
const TRectype& anafis = cache().get(LF_ANAGFIS, codanagr);
pss.set("Sesso", anafis.get(ANF_SESSO));
@@ -937,7 +996,7 @@ void TAlleg_mask::add_0_9(int trc, TPadoaSchioppa_set& pss, TLog_report& log)
TString8 key; key << stato << '|' << comun;
const TRectype& comres = cache().get(LF_COMUNI, key);
- pss.set("Denominazione", anag.get(ANA_RAGSOC));
+ pss.set("Denominazione", ragsoc);
pss.set("ComuneSedeLegale", comres.get(COM_DENCOM));
pss.set("ProvinciaSedeLegale", comres.get(COM_PROVCOM));
}
@@ -1036,7 +1095,8 @@ void TAlleg_mask::log_error(const TRecordset& clifo, const char* msg1, const cha
TLog_report& errlog, int severity)
{
TString str;
- str << clifo.get(CLI_TIPOCF) << clifo.get(CLI_CODCF)
+ str << clifo.get("#RECORD.NUMBER") << ". "
+ << clifo.get(CLI_TIPOCF) << clifo.get(CLI_CODCF)
<< ' ' << clifo.get(CLI_RAGSOC);
str.strip_double_spaces();
log_error(str, msg1, msg2, errlog, severity);
@@ -1099,6 +1159,12 @@ void TAlleg_mask::add_1_2(int trc, TRecordset& clifo, TPadoaSchioppa_set& pss, T
{
if (!pi_check("", paiv))
log_error(clifo, TR("** Partita IVA errata"), paiv, log, 1);
+ else
+ {
+ if (paiv[0] == '8' || paiv[0] == '9')
+ log_error(clifo, TR("** Verificare esclusione della Parita IVA"), paiv, log, 1);
+ }
+
pss.set(3001, paiv); // Partita IVA (obbligatoria dal 2006)
}
@@ -1141,11 +1207,10 @@ void TAlleg_mask::add_1_2(int trc, TRecordset& clifo, TPadoaSchioppa_set& pss, T
void TAlleg_mask::generazione()
{
- TReport_book book;
-
_red_alert = false;
TLog_report log(TR("Errori riscontrati"));
+ TReport_book book;
TPadoaSchioppa_set pss;
add_0_9(0, pss, log); // Testa
@@ -1157,7 +1222,7 @@ void TAlleg_mask::generazione()
log.log(0, TR("CLIENTI"));
add_1_2(1, *cli, pss, log); // Clienti
- TAlleg_report rep(cli, get_int(F_ANNO));
+ TAlleg_report rep(cli, *this, true);
book.add(rep);
}
@@ -1167,7 +1232,7 @@ void TAlleg_mask::generazione()
log.log(0, TR("FORNITORI"));
add_1_2(2, *ven, pss, log); // Fornitori
- TAlleg_report rep(ven, get_int(F_ANNO));
+ TAlleg_report rep(ven, *this, true);
book.add(rep);
}
@@ -1250,6 +1315,7 @@ bool TAlleg_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
const TRectype& anag = contribuente();
o.set(anag.get(ANA_COFI));
o.disable();
+ set(F_PIVA, anag.get(ANA_PAIV));
}
break;
case F_INTR:
@@ -1304,7 +1370,7 @@ bool TAlleg_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
if (e == fe_button)
{
TRecordset* rs = new_recordset();
- TAlleg_report rep(rs, get_int(F_ANNO));
+ TAlleg_report rep(rs, *this);
TReport_book book;
book.add(rep);
book.print_or_preview();
diff --git a/cg/cg3900a.h b/cg/cg3900a.h
index 44aaeebd4..3e90e32b4 100755
--- a/cg/cg3900a.h
+++ b/cg/cg3900a.h
@@ -1,13 +1,15 @@
-#define F_TIPO 101
-#define F_ANNO 102
-#define F_ALGO 103
-#define F_DIR 104
-#define F_NAME 105
-#define F_COFI 106
+#define F_TIPO 101
+#define F_ANNO 102
+#define F_ALGO 103
+#define F_DIR 104
+#define F_NAME 105
+#define F_COFI 106
+#define F_PIVA 107
-#define F_CONT 109
-#define F_SOGG 110
-#define F_INTR 111
-#define F_CAF 112
-#define F_COMP 113
-#define F_DATA 114
+#define F_CONT 109
+#define F_SOGG 110
+#define F_INTR 111
+#define F_CAF 112
+#define F_COMP 113
+#define F_DATA 114
+#define F_FILTRO 115
diff --git a/cg/cg3900a.rep b/cg/cg3900a.rep
index ccc7c5387..5d4481246 100755
--- a/cg/cg3900a.rep
+++ b/cg/cg3900a.rep
@@ -5,27 +5,82 @@
-
+
MESSAGE RESET,F1
- IF(TIPOCF=="C";"Clienti";"Fornitori") + " movimentati nel " + ANNO
+ IF(TIPOCF=="C";"Clienti";"Fornitori") + " movimentati nel " + #ANNO
+
+ MESSAGE _PAGENO
+
+
+
+ #FILTRO
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ #PIVA
+
+
+
+ #SOGGETTO
+
+
+
+ #ALGO
+
+
+
+
+
+
+
+ #INTERMEDIARIO
+
+
+
+ #CAF
+
+
+
+ #IMPEGNO
+
+
+
+ #COMPILATORE
+
+
+
+
+
+
- CODCF
+ #RECORD.NUMBER
@@ -36,7 +91,7 @@
PAIV
- ANNO
+ #ANNO
C_IMP
@@ -62,19 +117,15 @@
C_NE
MESSAGE ADD,#F1.106
-
- C_NA
- MESSAGE ADD,#F1.107
-
TRIM(INDCF) + " " + CIVCF
-
+
COFI
- PREC
+ #ANNO-1
P_IMP
@@ -100,20 +151,24 @@
P_NE
MESSAGE ADD,#F1.206
-
- P_NA
- MESSAGE ADD,#F1.207
-
CAPCF
DENCOM
-
+
PROVCOM
+
+
+ CODCF
+
+
+ C_NA
+ MESSAGE ADD,#F1.107
+
@@ -122,10 +177,10 @@
- ANNO
+ #ANNO
- PREC
+ #ANNO-1
diff --git a/cg/cg3900a.uml b/cg/cg3900a.uml
index 8e848555c..a7116261a 100755
--- a/cg/cg3900a.uml
+++ b/cg/cg3900a.uml
@@ -28,13 +28,15 @@ BEGIN
CHECKTYPE REQUIRED
NUM_EXPR #F_ANNO>=2006
WARNING "L'anno non puo' essere antecedente al 2006"
+ FIELD ANNO
END
LISTBOX F_ALGO 1 13
BEGIN
PROMPT 34 1 "Scansione per data "
- ITEM "0|registrazione"
- ITEM "1|documento"
+ ITEM "D|documento"
+ ITEM "R|registrazione"
+ FIELD ALGO
END
BOOLEAN F_COFI
@@ -66,16 +68,24 @@ END
STRING F_CONT 16
BEGIN
- PROMPT 2 9 "Codice fiscale contribuente "
+ PROMPT 2 9 "Cod. fisc. contribuente "
FLAGS "U"
END
+STRING F_PIVA 11
+BEGIN
+ PROMPT 52 9 "Partita IVA "
+ FLAGS "UD"
+ FIELD PIVA
+END
+
STRING F_SOGG 16
BEGIN
- PROMPT 2 10 "Codice fiscale soggetto obbligato "
+ PROMPT 2 10 "Cod. fisc. soggetto obbligato "
STR_EXPR #F_SOGG!=#F_CONT
WARNING "Il codice del soggetto deve essere diverso da quello del contribuente"
FLAGS "U"
+ FIELD SOGGETTO
END
GROUPBOX DLG_NULL 78 5
@@ -89,12 +99,14 @@ BEGIN
STR_EXPR #F_INTR!=#F_CONT
WARNING "Il codice dell'intermediario deve essere diverso da quello del contribuente"
FLAGS "U"
+ FIELD INTERMEDIARIO
END
NUMBER F_CAF 5
BEGIN
PROMPT 42 13 "Iscrizione C.A.F. "
FLAGS "U"
+ FIELD CAF
END
LISTBOX F_COMP 1 20
@@ -102,6 +114,7 @@ BEGIN
PROMPT 2 14 "Comunicazione predisposta da "
ITEM "1|contribuente"
ITEM "2|chi effettua l'invio"
+ FIELD COMPILATORE
END
DATE F_DATA
@@ -109,6 +122,7 @@ BEGIN
PROMPT 2 15 "Data dell'impegno alla trasmimssione "
VALIDATE REQIF_FUNC 1 F_INTR
WARNING "Data obbligatoria in presenza di un intermediario"
+ FIELD IMPEGNO
END
GROUPBOX DLG_NULL 78 5
@@ -123,6 +137,19 @@ BEGIN
ITEM "F|Fornitori"
END
+LIST F_FILTRO 2 42
+BEGIN
+ PROMPT 26 18 "Filtro "
+ ITEM "-1|Tutti"
+ ITEM "0|Validi per allegato IVA"
+ ITEM "1|Non validi per allegato IVA"
+ ITEM "2|Occasionali"
+ ITEM "3|Documenti riepilogativi"
+ ITEM "4|Con partita IVA gia' inserita"
+ ITEM "5|Esteri"
+ ITEM "6|Privati"
+END
+
BUTTON DLG_SELECT 10 2
BEGIN
PROMPT -25 19 ""