Revert "Rimosso"

This reverts commit c3c7ab12b34231aaa774a2c1e9b3980d90d28667.
This commit is contained in:
Alessandro Bonazzi 2021-03-04 21:08:56 +01:00
parent 54c98a85b9
commit 14bf82f83e

497
src/cg/cg2102.h Executable file
View File

@ -0,0 +1,497 @@
#ifndef __CG2102_H
#define __CG2102_H
#ifndef __RELAPP_H
#include <relapp.h>
#endif
#ifndef __CGPAGAME_H
#include "cgpagame.h"
#endif
#ifndef __MOV_H
#include "mov.h"
#endif
#ifndef __CGSALDAC_H
#include "cgsaldac.h"
#endif
#ifndef __CGLIB_H
#include "cglib.h"
#endif
#ifndef __CG2100_H
#include "cg2100.h"
#endif
#include <automask.h>
#include "../f1/f1lib.h"
#include <vector>
#define K_ELIMMAS 0 // Key per eliminazione massima
class TPro_msk;
class TDati_mov_auto;
enum CGMaskType { _query = 0, _no_iva = 1, _iva = 2, _occas = 3};
class TPrimanota_application : public TRelation_application
{
TMovimentoPN* _rel; // Relazione principale
TPagamento* _pag;
bool _ges_val, _ges_sal; // Gestione valuta e saldaconto
bool _num_cli, _num_for; // Riferimento partita allineato a destra
bool _liqdiff; // Liquidazione differita
bool _npart_is_prot; // Riferimento partita = n. prot. IVA anziche' doc
bool _npart_is_month; // Riferimento partita = mese
bool _skip_giornale_check; // Ignora controllo data stampa libro giornale
bool _skip_bollato_check; // Ignora controllo data stampa bollato
bool _savenew; // Registra e nuovo
short _firstfocus; // Primo campo della maschera a prendere il focus
bool _sheet_shown; // Lo sheet e' gia' stato visualizzato una volta?
bool _swap_mask;
bool _is_saldaconto; // saldaconto si/no (vede parametri e causale)
bool _scad_free; // posso variare liberamente le rate della fattura
bool _easy_sal; // Nuovo saldaconto semplificato
bool _quadratura; // Bottone quadratura automatica per ATS
TString _perc_attesa_fld; // Percentuale del fornitore/cliente
TSaldo_agg _saldi; // Saldi da aggiornare
TPartite_array _partite; // Partite coinvolte
TMask* _msk[4]; // Maschere di query, cg, iva, occasionali
int _mode; // Modo maschera corrente
bool _as400; // Movimento trasferito da as400?
bool _sal_dirty; // Il saldaconto e' stato "toccato"?
TipoIVA _iva; // Tipo di IVA corrente
TCausale * _causale; // Causale corrente
TLibro_giornale* _giornale; // Libro giornale corrente
long _lastreg; // Numero ultima registrazione
TDate _last_dreg; // Ultima data registrazione inserita
TDate _last_dcom; // Ultima data competenza inserita
TDati_mov_auto* _automatico;// Dati per gestire incasso immediato
TBill _conto_ricavo; // Conto di ricavo del clifo
TToken_string _tmp; // Stringa temporanea da ritornare
TString_array _pag_rows; // Copia dello sheet delle rate
TEsercizi_contabili _esercizi; // Tabella degli esercizi contabili
TAssoc_array _colori; // Colori delle righe
bool _isf1;
shared_ptr<TPro_msk> _pro_mask;
bool _is_set_fpcheck;
int _last_date;
bool _f1_ini;
bool _f1_liq;
friend class TPro_msk;
static bool showpartite_handler(TMask_field& f, KEY k);
static bool speserimb_handler(TMask_field& f, KEY k);
static bool altrespese_handler(TMask_field& f, KEY k);
static bool abbatt_handler(TMask_field& f, KEY k);
static bool abbpass_handler(TMask_field& f, KEY k);
static bool ritprof_handler(TMask_field& f, KEY k);
static bool diffcamb_handler(TMask_field& f, KEY k);
static bool suspended_handler(TMask_field& f, KEY k);
static bool num_handler(TMask_field& f, KEY key);
static bool caus_query_handler(TMask_field& f, KEY key);
static void check_fppro_fields(TMask& m);
static bool caus_modify_handler(TMask_field& f, KEY key);
static bool datareg_handler(TMask_field& f, KEY key);
static bool datacomp_handler(TMask_field& f, KEY key);
static bool datacompcr_handler(TMask_field& f, KEY key);
static bool data74ter_handler(TMask_field& f, KEY key);
static bool datadoc_handler(TMask_field& f, KEY key);
static bool numdoc_handler(TMask_field& f, KEY key);
static bool ndocext_handler(TMask_field& f, KEY key);
static bool annorif_handler(TMask_field& f, KEY key);
static bool numrif_handler(TMask_field& f, KEY key);
static bool protiva_handler(TMask_field& f, KEY key);
static bool clifo_handler(TMask_field& f, KEY key);
static bool totdoc_handler(TMask_field& f, KEY key);
static bool totdocval_handler(TMask_field& f, KEY key);
static bool ritfis_handler(TMask_field& f, KEY key);
static bool ritsoc_handler(TMask_field& f, KEY key);
static bool revcharge_handler(TMask_field& f, KEY key);
static bool main_codiva_handler(TMask_field& f, KEY key);
static bool liqdiff_handler(TMask_field& f, KEY key);
static bool ivaxcassa_handler(TMask_field& f, KEY key);
static bool dataintra_handler(TMask_field& f, KEY key);
static bool corrlire_handler(TMask_field& f, KEY key);
static bool corrvaluta_handler(TMask_field& f, KEY key);
static bool occas_code_handler(TMask_field& f, KEY key);
static bool occas_cfpi_handler(TMask_field& f, KEY key);
static bool occas_handler(TMask_field& f, KEY key);
static bool solaiva_handler(TMask_field& f, KEY key);
static bool descr_handler(TMask_field& f, KEY k);
static bool sheet_clifo_handler(TMask_field& f, KEY k);
static bool sheet_mastrino_handler(TMask_field& f, KEY k);
static bool sheet_rateo_handler(TMask_field& f, KEY k);
static bool sheet_risconto_handler(TMask_field& f, KEY k);
static bool iva_sottoconto_handler(TMask_field& f, KEY k);
static bool imponibile_handler(TMask_field& f, KEY key);
static bool detrazione_handler(TMask_field& f, KEY key);
static bool codiva_handler(TMask_field& f, KEY key);
static bool imposta_handler(TMask_field& f, KEY key);
static bool dareavere_handler(TMask_field& f, KEY k);
static bool fase_handler(TMask_field& f, KEY key);
static bool cg_tipo_handler(TMask_field& f, KEY key);
static bool cg_gruppo_handler(TMask_field& f, KEY key);
static bool cg_conto_handler(TMask_field& f, KEY key);
static bool cg_sottoconto_handler(TMask_field& f, KEY key);
static bool codpag_handler(TMask_field& f, KEY key);
static bool valuta_handler(TMask_field& f, KEY key);
static bool datacambio_handler(TMask_field& f, KEY key);
static bool cambio_handler(TMask_field& f, KEY key);
static bool reset_handler(TMask_field& f, KEY key);
static bool nrate_handler(TMask_field& f, KEY key);
static bool recalc_handler(TMask_field& f, KEY key);
static bool codcab_handler(TMask_field& f, KEY key);
static bool tipopag_handler(TMask_field& f, KEY key);
static bool linkdoc_handler(TMask_field& f, KEY k);
static bool mastrino_handler(TMask_field& f, KEY k);
static bool rataeur_handler(TMask_field& f, KEY key);
static bool rataval_handler(TMask_field& f, KEY key);
static bool iva_handler(TMask_field& f, KEY key);
static bool cg_handler(TMask_field& f, KEY key);
static bool pag_notify(TSheet_field& s, int r, KEY key);
static bool pag_sheet_handler(TMask_field& f, KEY key);
static bool colors_handler(TMask_field& f, KEY k);
static bool quadratura_handler(TMask_field& f, KEY k); // Bottone quadratura per ATS
// Gestione F1
static void write_righe_iva_f1(TMask& cg_msk, const shared_ptr<TPro_msk>& msk);
static bool write_scad_f1(const TMask& cg_msk, const shared_ptr<TPro_msk>& msk);
static void write_clifo(TMask& cg_msk, const shared_ptr<TPro_msk>& msk);
static void set_totale(TMask& cg_msk, const shared_ptr<TPro_msk>& msk);
static void riporta_dati_f1(TMask& cg_msk, const shared_ptr<TPro_msk>& msk);
void insert_part_scad(TConfig& ini);
// Handlers per aggancio FPPRO
// Bottone per maschera FPPRO
static bool fppro_mask(TMask_field& f, KEY key);
static bool scollega_handler(TMask_field& f, KEY key);
static bool is_collegato(TMask_field& f);
static void fppromask_set_handl(TMask* msk);
static void load_list(TMask* msk, KEY k);
static void f1_init_modify(TMask& m, const TRectype& mov);
void reset_sheet_row(TSheet_field& s, int n);
int crea_somma_spese(TImporto& imp);
void update_saldo_riga(int r);
void link_mastrino(const TBill& bill) const;
protected: // TApplication
virtual void on_firm_change();
virtual void on_config_change();
virtual void print();
void dump_rec(TConfig & ini, const TRectype & rec, int row = 0, int pref = 0);
void dump_fatt(TConfig& ini, TPartita & game, int rigafatt, int pref = 0);
void set_scad_f1(TMask& m);
virtual void ini2mask(TConfig& ini, TMask& msk, bool query);
virtual void mask2ini(const TMask& msk, TConfig& ini);
// Metodi per aggancio FPPRO (solo su operazioni di Fattura di Acquisto)
// Metodo chiamato dalla write e rewrite per salvare su db fatt.
void write_fppro();
static bool has_tot_doc(TToken_string& fppro_keys);
// Salvo dati fornitore e registrazione contabile sul db FPPRO
int save_fppro();
// Salva sul movimento il riferimento al documento in FPPRO (keys)
bool save_dbmov(bool clean = false) const;
static bool scollega(bool set = false);
// Pulisce il mov e db dai firerimenti FPPRO (in MODE_MOD per edit/delete)
void clean_fppro();
// setta variabili prima del controllo has_f1_db
void set_has_f1_db(TMask* m);
bool has_f1_db(TMask* m);
// Controlli prima di write e rewrite
int controlli_f1(const TMask& m);
virtual bool save(bool check_dirty);
bool get_mask_swap_file(TFilename& name) const;
bool force_mask_swap(const TCausale& old_caus, const TCausale& new_caus);
protected: // TRelation_application
void check_f1_ini(); // setto variabili se ho f1 o liq nei parametri (ini da fp)
virtual bool user_create();
virtual bool user_destroy();
bool iva_mask(const TMask & m) const { return m.source_file() == "cg2100c.msk"; }
virtual bool changing_mask(int mode);
virtual TMask* get_mask(int mode);
virtual TRelation* get_relation() const { return _rel; }
virtual void init_query_mode(TMask& m);
virtual void init_insert_mode(TMask& m);
virtual void init_modify_mode(TMask& m);
virtual bool save_and_new() const;
virtual bool save_and_quit() const;
virtual bool is_transaction() const;
virtual bool get_next_key(TToken_string& key);
virtual int read(TMask& m);
void find_movcoll(const long numreg);
void set_movcoll(const long movcoll, const long numreg);
virtual int write(const TMask& m);
virtual int rewrite(const TMask& m);
virtual bool remove();
virtual void write_enable(bool) {}
virtual bool protected_record(TRectype& rec);
virtual bool can_I_write(const TRelation* rel) const;
virtual const char* record_description(const TRelation& rel) const;
protected:
void check_saldi();
void genera_automatico(int tipo, const char* causimm); // 0=nessuno, 1=incasso, 2=regolarizzazione 3= ?? 4 = rilevazione fatture da emettere/ricevere
void gioca_cambi(int force = 0x00);
TMask* load_mask(int n);
TMask& occas_mask() { return *load_mask(3); }
void mask2rel(const TMask& m);
TipoIVA iva() const { return _iva; }
const TString & clifo() const;
bool gestione_valuta() const { return _ges_val; }
bool gestione_saldaconto() const { return _ges_sal; }
bool npart_is_month() const { return _npart_is_month; }
bool npart_is_prot() const { return _npart_is_prot; }
bool is_saldaconto() const { return _is_saldaconto; }
bool is_fattura() const { return is_saldaconto() && causale().tipomov() == tm_fattura; }
bool is_nota_credito() const { return is_saldaconto() && causale().tipomov() == tm_nota_credito; }
bool is_pagamento() const { return is_saldaconto() && causale().tipomov() >= tm_pagamento; }
bool activate_split_payment(TMask& m);
bool is_split_payment() const;
bool is_fattura_split() const;
bool activate_numrif(TMask& m, bool set_pag);
void fill_sheet(TMask& m) const;
void init_mask(TMask& m);
static TipoIVA reg2IVA(const char* registro, int anno);
static const real& cod2IVA(const TMask& m);
static real scorpora(real& imponibile, const real& percentuale);
static int get_importi_iva(TToken_string & row, real& imp_det, real& iva_det, real& imp_ind, real& iva_ind);
static int bill2pos(const TBill& conto, char tipo);
TipoIVA cau2IVA(const char* causale, int anno);
bool IVA2bill(const TCodiceIVA& iva, TBill& bill);
int bill2contr(const TBill& c, char sezione) const;
int bill_used(const TBill& conto) const;
TBill& ivas_bill(TBill& tc);
void load_colors();
void save_colors();
COLOR type2color(char tipor, char tipoc);
void set_type_color(char tipor, char tipoc, COLOR col);
void set_colors();
bool read_caus(const char* cod = nullptr, int year = 0);
TLibro_giornale& giornale() { return *_giornale; }
bool test_swap(bool ritsoc);
TImporto real2imp(const real& r, char tipo);
real totale_documento();
void ivas_pack();
void cgs_pack();
bool ci_sono_importi(const TSheet_field& cgs) const;
real calcola_imp() const;
void add_cgs_tot(TMask& m);
int set_cgs_row(int n, const TImporto& importo, const TBill& conto, const char* desc, char tipo,
const char* cms = nullptr, const char* fas = nullptr);
void set_cgs_imp(int n, const TImporto& importo);
bool add_cgs_imp(int n, const TImporto& importo);
bool sub_cgs_imp(int n, const TImporto& importo);
void disable_cgs_cells(int n, char tipo);
void add_cup_or_cig(short id, const TRectype& rec, TToken_string& riga) const;
void add_cup_or_cig(short id, TConfig& ini, TToken_string& riga) const;
void add_cgs_ritenute(char fsr); // Fiscali, Sociali, Reverse Charge
void generazione_righe_cg(int r);
void reset_cgs_row(int n) { reset_sheet_row(cgs(), n); }
void reset_ivas_row(int n) { reset_sheet_row(ivas(), n); }
TPagamento& pagamento() const;
void set_pagamento(const char* c, const char* d);
void set_totale_pagamento(bool update);
void reset_pagamento();
void set_scadenze(TMask& m);
void set_banche(TMask& m);
bool read_scadenze(TMask& m);
void write_scadenze(const TMask& m);
void remove_scadenze(const TMask& m, const char* rif);
void renumber_partita(TMask& m, const char* oldp, const char* newp);
void recalc_scadenze(const TDate& d);
#ifdef PRORATA100
static bool prorata_handler(TMask_field& f, KEY k);
bool test_prorata();
bool aggiusta_prorata();
#endif
int cerca_conto_cf(TBill& bill) const;
bool edit_partite(const TMask& m, int riga);
bool crea_partita(const TBill& bill, int anno, const TString& numero, int numrig, const TImporto& importo);
bool notify_cgline_deletion(TPartita& partita, long nreg, int numrig);
bool notify_cgline_deletion(int numrig);
bool is_percipient(long forn, char& tipper, long& codper) const;
long calcola_m770(int tipo_coll, real& spese, real& compenso, real& iva, real& ritfis);
bool link_m770();
bool link_cesp (const TMask& msk, const char* action);
bool link_intra(const TMask& msk, const char* action);
bool link_anal (const TMask& msk, const char* action);
public:
static int type2pos(char tipo);
static char row_type(const TToken_string& s);
void add2cg_row(TSheet_field& s, TToken_string & row, TString_array & saved_desc, const bool add = true);
void sub2cg_row(TSheet_field& s, TToken_string & row, TString_array & saved_desc) { add2cg_row(s, row, saved_desc, false) ; }
static bool iva_notify(TSheet_field& s, int r, KEY k);
static bool cg_notify(TSheet_field& s, int r, KEY key);
bool get_isf1() const { return _isf1; }
int get_lastdate() { return _last_date; }
TMask * mask(CGMaskType type) { return _msk[type]; }
void type2colors(char tipor, COLOR& back, COLOR& fore);
void set_type_colors(char tipor, COLOR back, COLOR fore);
void reset_colors();
real calcola_saldo() const;
TCausale& causale() const { return * _causale; }
TPartite_array& partite() { return _partite; } // Partite editate
bool edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp);
bool notify_edit_pagamento(TPartita& partita, TRectype& new_pag,
const TValuta& valuta, int deleting = 0);
TSheet_field& cgs() const;
TSheet_field& ivas() const;
TSheet_field& pags() const;
TString_array& pag_rows() { return _pag_rows; }
TImporto get_cgs_imp(int n) const;
TPrimanota_application();
virtual ~TPrimanota_application() { }
};
class TPro_msk : public TAutomask
{
public:
struct riga_iva_s;
struct scadenza_s;
private:
TString _numero;
TDate _datadoc;
real _totdoc;
real _ritenute;
TProtocollo _protfppro;
TString _fpprokeys;
TString _piva;
TString _codforn;
vector<riga_iva_s> _righe_iva;
vector<scadenza_s> _scadenze;
bool _riporta;
// Handlers per aggancio FPPRO
// Bottone carica documenti in maschera FPPRO
static bool fppro_handler(TMask_field& f, KEY k);
// Bottone riporta doc FPPRO in testata Prima Nota
static bool riporta_handler(TMask_field& f, KEY k);
static bool collega_handler(TMask_field& f, KEY k);
static bool piva_handler(TMask_field& f, KEY k);
static bool date_handler(TMask_field& f, KEY k);
// Non permette la selezione multipla
void fppro_selfatt() const;
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
public:
struct riga_iva_s
{
real imponibile;
real imposta;
real aliquota;
TString4 natura;
char esigibilita;
};
struct scadenza_s
{
TDate data;
real importo;
};
bool should_bring_back() const { return _riporta; }
bool is_doc_split();
void set_righeiva(const char* fpprokeys);
void set_scadenze(const char* fpprokeys);
void set_doc(const char* numero, const char* datadoc, const char* totdoc, const char* ritenute, const char* protfppro, const char* fpprokeys, const char* codforn, const char* piva);
TString get_numdoc() const { return _numero; }
TDate get_datadoc() const { return _datadoc; }
real get_totdoc() const { return _totdoc; }
real get_ritenute() const { return _ritenute; }
TString get_fpprokeys() const { return _fpprokeys; }
TString get_codforn() const { return _codforn; }
TString get_piva() const { return _piva; }
const vector<riga_iva_s>& get_righeiva() const { return _righe_iva; }
TProtocollo& get_protocollo() { return _protfppro; }
vector<scadenza_s>& get_scadenze() { return _scadenze; }
real get_tot_imp_riva();
void add_rigaiva(const real& imponibile, const real& imposta, const real& aliquota, const TString4& natura, char esigib);
void add_scad(const TDate& date, const real& importo);
static TString& query_fppro(const TString& codforn, const TString& date);
static TString& query_fppro(const TString& stato_piva, const TString& piva, const TString& date);
static TString& query_fppro(const TString& codforn, const TString& stato_piva, const TString& piva, const TString& where_str, const TString& date, const TString& keyprginvio, const TString& keyheaderfatt, const TString& keybodyfatt, bool order = true, bool piva_research = false);
static TString& query_string();
static void abilita_piva(TMask* msk);
// Carica documenti FPPRO sulla maschera
static bool load_fppro_mask(TMask* msk, KEY k = 32);
TPro_msk() = delete;
TPro_msk(TMask& cg_msk);
};
bool& is_f1();
TString& num_doc_rif();
#ifndef __EXTRA__
inline TPrimanota_application& app()
{ return (TPrimanota_application&)main_app(); }
#endif
#endif