Patch level : 12.0 1048

Files correlati     : f20.trr f20.dir
Commento        :

Invio Certificazione unica per email
This commit is contained in:
Alessandro Bonazzi 2021-03-29 22:33:38 +02:00
parent 9a13b24bc8
commit 8dcee11556
5 changed files with 235 additions and 28 deletions

View File

@ -8,6 +8,7 @@
#include "777.h"
#include "777lib.h"
#include "777200a.h"
#include "777200c.h"
#include "777200.h"
#include "../cg/cglib.h"
@ -49,7 +50,7 @@ const TString& get_telephone(const TRectype& rec, const char* pref, const char*
// TTracciatoCU
///////////////////////////////////////////////////////////
#define CU_DEFAULT_NAME "MODCUR" THIS_YEAR
class TTracciatoCU : public TTracciato770
{
@ -531,9 +532,12 @@ TRecnotype TTrasferimentoCU::conta_certificazioni() const
anno = LAST_YEARN;
TString query;
query.format("USE %d SELECT (ANNO=%d)&&(CODANAGR>0)\nFROM CODDITTA=%ld\nTO CODDITTA=%ld",
LF_QUALA, anno, _cod_ditta, _cod_ditta);
LF_QUALA, anno, _cod_ditta, _cod_ditta);
TISAM_recordset recset(query);
return recset.items();
}
@ -780,8 +784,8 @@ bool TTrasferimentoCU::append_record_d(const TRectype& qla, TLog_report& log)
bool TTrasferimentoCU::append_record_h(const TRectype& qla, int modulo, TLog_report& log)
{
const char tipoanag = qla.get_char("TIPOA");
const long codanagr = qla.get_long("CODANAGR");
const char tipoanag = qla.get_char(QUD_TIPOA);
const long codanagr = qla.get_long(QUD_CODANAGR);
if (tipoanag < 'F' && codanagr <= 0)
{
@ -804,23 +808,23 @@ bool TTrasferimentoCU::append_record_h(const TRectype& qla, int modulo, TLog_rep
rec.set(4, perc.codice_fiscale()); // Codice fiscale del percipiente
rec.set(5, _certificazione); // Progressivo certificazione
const TString4 causale = qla.get("CAUSALE");
const TString4 causale = qla.get(QUD_CAUSALE);
rec.np_put("AU001001", causale);
if ((causale >= "G" && causale <= "I")&& (qla.get_long("ANNO") < 2019L))
rec.np_put("AU001002", qla.get_long("ANNO")); // Potrebbe essere anche l'anno precedente
if ((causale >= "G" && causale <= "I")&& (qla.get_long(QUD_ANNO) < 2019L))
rec.np_put("AU001002", qla.get_long(QUD_ANNO)); // Potrebbe essere anche l'anno precedente
// rec.np_put("AU001003", "");
rec.np_put("AU001004", qla.get_real("TOTALE"));
rec.np_put("AU001004", qla.get_real(QUD_TOTALE));
if (perc.estero())
rec.np_put("AU001005", qla.get_real("SOMREGCONV"));
rec.np_put("AU001005", qla.get_real(QUD_SOMREGCONV));
real imponibile = qla.get_real(QUD_IMPONIBILE);
const TString4 codcaus = qla.get(QUD_CODCAUS);
long codice = atol(cache().get("%CA7", codcaus, "I1")); // 1, 2, 5, 6, 7 // EDIT 2020: aggiunti 8, 9, 10, 11 // Edit 2021 aggiunti 12,13
real altre_somme = qla.get_real("SOMME");
real altre_somme = qla.get_real(QUD_SOMME);
if (altre_somme > -0.02 && altre_somme < 0.02)
{
altre_somme = ZERO;
@ -840,25 +844,25 @@ bool TTrasferimentoCU::append_record_h(const TRectype& qla, int modulo, TLog_rep
rec.np_put("AU001007", altre_somme);
}
rec.np_put("AU001008", imponibile); // 004 - 005 - 007
rec.np_put("AU001009", qla.get_real("IMPORTO")); // ritenute a titolo di acconto
rec.np_put("AU001009", qla.get_real(QUD_IMPORTO)); // ritenute a titolo di acconto
//rec.np_put("AU001010", ZERO); // ritenute a titolo di imposta
rec.np_put("AU001011", qla.get_real("RITSOSPESE")); // ritenute sospese
rec.np_put("AU001011", qla.get_real(QUD_RITSOSPESE)); // ritenute sospese
if (causale == "N")
rec.np_put("AU001012", qla.get_real("ADDREG")); // addizionale regionale
rec.np_put("AU001012", qla.get_real(QUD_ADDREG)); // addizionale regionale
rec.np_put("AU001018", qla.get_real("IMPANNIPRE")); // imponibile anni precedenti
rec.np_put("AU001019", qla.get_real("RITANNIPRE")); // ritenute anni precedenti
rec.np_put("AU001018", qla.get_real(QUD_IMPANNIPRE)); // imponibile anni precedenti
rec.np_put("AU001019", qla.get_real(QUD_RITANNIPRE)); // ritenute anni precedenti
rec.np_put("AU001020", qla.get_real(QUD_SPESERIMB)); // spese rimborsate
rec.np_put("AU001021", qla.get_real(QUD_RITRIMB)); // ritenute rimborsate
rec.np_put("AU001022", qla.get_real(QUD_SRNETRIT)); // somme restituite al netto della ritenuta subita
const real cce = qla.get_real(QUD_CTINPSEROG);
const real ccp = qla.get_real(QUD_CTINPSPERC);
const real cal = qla.get_real("ALTRICONTR");
const real cdo = qla.get_real("CONTRDOV");
const real cve = qla.get_real("CONTRVER");
TString8 entprev = qla.get("ENTEPREV");
TString4 cat = qla.get("CATEGORIA");
const real cal = qla.get_real(QUD_ALTRICONTR);
const real cdo = qla.get_real(QUD_CONTRDOV);
const real cve = qla.get_real(QUD_CONTRVER);
TString8 entprev = qla.get(QUD_ENTEPREV);
TString4 cat = qla.get(QUD_CATEGORIA);
TString cfep;
if (entprev.blank())
@ -995,7 +999,8 @@ void TTrasferimentoCU::remove()
}
TTrasferimentoCU::TTrasferimentoCU(const char* path, char mode)
: _save_headers(true), _data_imp(TODAY), _data_tra(TODAY), _tipo_operazione(' ')
: _save_headers(true), _data_imp(TODAY), _data_tra(TODAY),
_tipo_operazione(' ')
{
if (mode == 'r')
load(path);
@ -1015,15 +1020,75 @@ TTrasferimentoCU::~TTrasferimentoCU()
// TCU_mask
///////////////////////////////////////////////////////////
class TCU_mask : public TAutomask
class TInvio_CU_mask : public TAutomask
{
protected:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
public:
TInvio_CU_mask() : TAutomask("777200c") {}
};
bool TInvio_CU_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
{
switch (o.dlg())
{
case DLG_ALL:
if (e == fe_button)
{
TSheet_field & sh = sfield(F_SHEET);
FOR_EACH_SHEET_ITEM(sh, nrow)
if (*sh.get_str_row_cell(nrow, S_EMAIL) > ' ')
sh.set_row_cell(S_SELECTED, !sh.get_bool_row_cell(nrow, S_SELECTED), nrow);
sh.force_update();
}
break;
default: break;
}
return true;
}
class TCU_mask : public TAutomask
{
protected:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
void fill_row(TMask & m, const char * tipoa, long percip);
public:
TCU_mask() : TAutomask("777200a") {}
};
void TCU_mask::fill_row(TMask & m, const char * tipoa, long percip)
{
TSheet_field & sh = m.sfield(F_SHEET);
const int nrow = sh.set_row_cell(S_SELECTED, !ini_get_bool(CONFIG_DITTA, "CU", format("%1s%6ld", tipoa, percip)));
sh.set_row_cell(S_TIPOA, tipoa, nrow);
sh.set_row_cell(S_CODANAGR, percip, nrow);
TToken_string key(tipoa);
TString email;
key.add(percip);
const TRectype & cli = cache().get(LF_CLIFO, key, 7);
email = cli.get(CLI_PEC);
if (email.blank())
email = cli.get(CLI_MAIL);
if (email.blank())
email = cli.get(CLI_DOCMAIL);
if (email.blank())
sh.set_row_cell(S_SELECTED, false, nrow);
sh.set_row_cell(S_EMAIL, email, nrow);
TString ragsoc = cache().get(LF_ANAG, key, ANA_RAGSOC);
ragsoc.strip_double_spaces();
sh.set_row_cell(S_RAGSOC, ragsoc, nrow);
}
bool TCU_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
{
switch (o.dlg())
@ -1047,6 +1112,7 @@ bool TCU_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
if (e == fe_button)
{
TFilename tmp = get(F_PATH);
tmp.add(CU_DEFAULT_NAME);
if (tmp.exist())
{
@ -1059,6 +1125,80 @@ bool TCU_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
return false; // don't close mask
}
break;
case DLG_EMAIL:
if (e == fe_button)
{
TFilename tmp = get(F_PATH);
TLog_report log("Invio certificazione unica");
tmp.add(CU_DEFAULT_NAME);
if (tmp.exist())
{
const int quality = get_bool(F_QUALITY) ? 2 : 1;
const bool simple = get_bool(F_SIMPLE);
const int anno = get_int(F_ANNO);
const long daditta = get_long(F_DADITTA);
const long aditta = get_long(F_ADITTA);
TInvio_CU_mask m;
TSheet_field & sh = m.sfield(F_SHEET);
TString email;
TString4 tipoa;
long percip;
for (long codditta = daditta; codditta <= aditta; codditta++)
{
TString query;
query.format("USE %d SELECT (ANNO=%d)\nBY TIPOA CODANAGR CAUSALE\nFROM CODDITTA=%ld\nTO CODDITTA=%ld",
LF_QUALA, anno, codditta, codditta);
TISAM_recordset recset(query);
TString last_tipoa;
long last_percip = -1;
sh.reset();
for (bool ok = recset.move_first(); ok; ok = recset.move_next())
{
tipoa = recset.get(QUD_TIPOA).as_string();
percip = recset.get(QUD_CODANAGR).as_int();
if (last_tipoa != tipoa || last_percip != percip)
{
last_tipoa = tipoa;
last_percip = percip;
fill_row(m, tipoa, percip);
}
}
if (tipoa.full())
fill_row(m, tipoa, percip);
if (m.run() == K_ENTER)
{
FOR_EACH_SHEET_ITEM(sh, r)
{
if (sh.get_bool_row_cell(r, S_SELECTED))
{
tipoa = sh.get_str_row_cell(r, S_TIPOA);
percip = sh.get_long_row_cell(r, S_CODANAGR);
email = sh.get_str_row_cell(r, S_EMAIL);
TString query;
query.format("USE %d SELECT (ANNO=%d)&&(TIPOA==\"%s\")&&(CODANAGR==%ld)\nBY TIPOA CODANAGR CAUSALE\nFROM CODDITTA=%ld\nTO CODDITTA=%ld",
LF_QUALA, anno, (const char *) tipoa, percip, codditta, codditta);
TISAM_recordset perc(query);
TString ragsoc = sh.get_str_row_cell(r, S_RAGSOC);
send_cu(perc, quality, simple, anno, tipoa, percip, email, ragsoc, log);
}
}
}
}
}
else
cantread_box(tmp);
log.print_or_preview();
return false; // don't close mask
}
break;
case DLG_EDIT:
if (e == fe_button)
{
@ -1135,6 +1275,7 @@ void TCU_app::main_loop()
TProgress_monitor pp(nperc, TR("Generazione record percipienti"));
const TRectype& rec = perc.cursor()->curr();
const int modulo = 1; // In realtà non accetta modulo != 1 per cui separa causali diverse in due comunicazioni
for (bool ok = perc.move_first(); ok; ok = perc.move_next())
{
t.append_record_d(rec, log);

View File

@ -10,6 +10,7 @@
#define THIS_YEARN 2021
#define LAST_YEAR "2020"
#define LAST_YEARN 2020
#define CU_DEFAULT_NAME "MODCUR" THIS_YEAR
class TRecordCU;
@ -85,6 +86,7 @@ public:
};
void print_cu(const TFilename& datafile, int quality, bool simple);
void send_cu(TISAM_recordset& perc, int quality, bool syntetic, int anno, const char * tipoa, long percip, const char * email, const char * ragsoc, TLog_report & log);
void edit_cu(const TFilename& datafile, int quality, bool simple);
#endif

View File

@ -14,9 +14,15 @@ BEGIN
PICTURE TOOL_PREVIEW
END
BUTTON DLG_EMAIL 2 2
BEGIN
PROMPT 3 1 "Invia"
PICTURE TOOL_EMAIL
END
BUTTON DLG_EDIT 2 2
BEGIN
PROMPT 3 1 "Modifica"
PROMPT 4 1 "Modifica"
PICTURE TOOL_EDIT
END

View File

@ -1,4 +1,7 @@
#include "777200.h"
#include <automask.h>
#include <config.h>
#include <reprint.h>
#include <colors.h>
#include <isam.h>
@ -47,7 +50,7 @@ class TCU_report : public TReport
TReport_font _fnt_rep, _fnt_prm, _fnt_lbl, _fnt_sub, _fnt_prg;
int _quality; // 0=text only; 1=borders only; 2=filled bars
bool _syntetic;
private:
const TReport_field& last_field() const;
void set_field_pos(int row, int col, int width, TReport_field& fld) const;
@ -82,7 +85,7 @@ protected:
void create_H();
public:
TCU_report(int quality, bool syntetic);
TCU_report(int quality, bool syntetic, bool single);
};
#define CU_FORM_WIDTH 7800
@ -896,7 +899,7 @@ void TCU_report::create_H()
end_paragraph(body);
}
TCU_report::TCU_report(int quality, bool syntetic) : _quality(quality), _syntetic(syntetic)
TCU_report::TCU_report(int quality, bool syntetic, bool single) : _quality(quality), _syntetic(syntetic)
{
set_lpi(6);
set_cpi(10);
@ -907,7 +910,7 @@ TCU_report::TCU_report(int quality, bool syntetic) : _quality(quality), _synteti
_fnt_prg.create(_fnt_lbl.name(), _fnt_rep.size()/2+1, XVT_FS_BOLD);
_fnt_prm.create(_fnt_lbl.name(), 2*_fnt_rep.size()/3, 0);
if (!_syntetic)
if (!single && !_syntetic)
create_B();
create_D();
create_H();
@ -915,8 +918,52 @@ TCU_report::TCU_report(int quality, bool syntetic) : _quality(quality), _synteti
void print_cu(const TFilename& datafile, int quality, bool syntetic)
{
TCU_report cur(quality, syntetic);
TCU_report cur(quality, syntetic, false);
cur.set_recordset(new TTrasferimentoCU(datafile, 'r'));
cur.preview();
xvtil_statbar_set(NULL);
}
void send_cu(TISAM_recordset& perc, int quality, bool syntetic, int anno, const char * tipoa, long percip, const char * email, const char * ragsoc, TLog_report & log)
{
TCU_report cur(quality, syntetic, true);
TFilename datafile;
TReport_book b;
TFilename pdf;
const TRecnotype nperc = perc.items();
const TRectype& rec = perc.cursor()->curr();
const int modulo = 1; // In realtà non accetta modulo != 1 per cui separa causali diverse in due comunicazioni
datafile.temp(CU_DEFAULT_NAME);
pdf.temp("cu", "pdf");
{
TTrasferimentoCU t(datafile, 'w');
for (bool ok = perc.move_first(); ok; ok = perc.move_next())
{
t.append_record_d(rec, log);
t.append_record_h(rec, modulo, log);
}
t.save();
}
cur.set_recordset(new TTrasferimentoCU(datafile, 'r'));
b.add(cur);
b.export_pdf(pdf, false);
TToken_string to(email, ';'), cc("", ';'), ccn("", ';'), attachment(pdf, ';');
TString msg("Invio a ");
TString subj("Certificazione unica anno ");
TString message("Certificazione anno ");
subj << anno + 1;
message << anno + 1 << " di " << ragsoc;
msg << email;
if (!send_mail(to, cc, ccn, subj, message, attachment))
msg << " non ";
else
ini_set_bool(CONFIG_DITTA, "CU", format("%1s%6ld", (const char *)tipoa, percip), true);
msg << " riuscito";
log.log(0, msg);
xvtil_statbar_set(NULL);
}

View File

@ -3,11 +3,13 @@
#ifndef __QUADROD_H
#define __QUADROD_H
#define QUD_ANNO "ANNO"
#define QUD_CODDITTA "CODDITTA"
#define QUD_TIPOA "TIPOA"
#define QUD_CODANAGR "CODANAGR"
#define QUD_NPROG "NPROG"
#define QUD_CODCAUS "CODCAUS"
#define QUD_CAUSALE "CAUSALE"
#define QUD_TOTALE "TOTALE"
#define QUD_SOMME "SOMME"
#define QUD_IMPONIBILE "IMPONIBILE"
@ -18,8 +20,17 @@
#define QUD_CTINPSEROG "CTINPSEROG"
#define QUD_CTINPSPERC "CTINPSPERC"
#define QUD_SPESERIMB "SPESERIMB"
#define QUD_RITSOSPESE "RITSOSPESE"
#define QUD_ADDREG "ADDREG"
#define QUD_IMPANNIPRE "IMPANNIPRE"
#define QUD_RITANNIPRE "RITANNIPRE"
#define QUD_RITRIMB "RITRIMB"
#define QUD_SRNETRIT "SRNETRIT"
#define QUD_GENERATA "GENERATA"
#define QUD_ALTRICONTR "ALTRICONTR"
#define QUD_CONTRDOV "CONTRDOV"
#define QUD_CONTRVER "CONTRVER"
#define QUD_ENTEPREV "ENTEPREV"
#define QUD_CATEGORIA "CATEGORIA"
#endif