From 428d4216bd08bf6965119e38ebd7cba6514627bd Mon Sep 17 00:00:00 2001 From: villa Date: Fri, 18 Nov 1994 11:40:45 +0000 Subject: [PATCH] Parametri liquidazione e ditte: aggiunto/corretto controllo registri Liquidazione: corretto controllo esistenza archivi git-svn-id: svn://10.65.10.50/trunk@660 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg2104.cpp | 177 +++++++++++++++++++++++++++++++++++++++++++++++--- cg/cg4300.cpp | 9 ++- cg/cg4301.cpp | 8 +-- cg/cg5100.cpp | 89 ++++++++++++++++++++++++- cg/cg5300.cpp | 79 ++++++++++++---------- 5 files changed, 308 insertions(+), 54 deletions(-) diff --git a/cg/cg2104.cpp b/cg/cg2104.cpp index 30dde64fb..319fc0023 100755 --- a/cg/cg2104.cpp +++ b/cg/cg2104.cpp @@ -186,11 +186,102 @@ void TPrimanota_application::aggiorna_scadenzario(const TMask& m) pag.set_total(imponibile, imposta, spese); - // TBI TBI TBI TBI TBI TBI TBI TBI TBI - // controllare se c'e' una rateazione non standard gia' registrata - // in tal caso occorre zappare e settare le rate a mano - pag.set_rate_auto(); + // se c'e' una rateazione gia' registrata + // zappettare e settare le rate a mano + bool new_part = FALSE; + + // should never happen but it doesn't hurt + if (_rel->cg(0).empty()) return; + + TLocalisamfile partita (LF_PARTITE); + TLocalisamfile scadenza(LF_SCADENZE); + + TString nreg(_rel->lfile().get("NUMREG")); + TString ndoc(_rel->lfile().get("NUMDOC")); + TString tmov(_rel->lfile().get("TIPOMOV")); + TDate ddoc(_rel->lfile().get_date("DATADOC")); + TDate dreg(_rel->lfile().get_date("DATAREG")); + TString reg (_rel->lfile().get("REG")); + TString protiva(_rel->lfile().get("PROTIVA")); + TString codcaus(_rel->lfile().get("CODCAUS")); + TString codval (_rel->lfile().get("CODVAL")); + TString cambio (_rel->lfile().get("CAMBIO")); + + TString numpart = m.get(F_NUMRIF); + TString anno = m.get(F_ANNORIF); + + char sezione = _rel->cg(0).get_char("SEZIONE"); // Dare/Avere + char tipocf = _rel->cg(0).get_char("TIPOC"); // Cliente || Fornitore || Uncazzo + int gruppo = (tipocf == 'C' || tipocf == 'F') ? 0 : + _rel->cg(0).get_char("GRUPPO"); + int conto = (tipocf == 'C' || tipocf == 'F') ? 0 : + _rel->cg(0).get_char("fCONTO"); + int sottoconto = _rel->cg(0).get_char("SOTTOCONTO"); + int nriga = 1; + int numrig = 1; + + partita.put("TIPOCF", tipocf); + partita.put("GRUPPO", gruppo); + partita.put("CONTO", conto); + partita.put("SOTTOCONTO", sottoconto); + partita.put("ANNO", anno); + partita.put("NUMPART", numpart); + partita.put("NRIGA", nriga); + + if (partita.read() == NOERR) + { + // se la maschera contiene importi diversi da quelli + // registrati, o se il codice pagamento e' diverso, + // si riparte da zero usando la modalita' indicata + if (imponibile != partita.get_real("IMPORTO") || + imposta != partita.get_real("IMPOSTA") || + spese != partita.get_real("SPESE") || + pag.code() != partita.get("CODPAG")) + pag.set_rate_auto(); + else + { + pag.zap_rate(); + + for (int rata = 1; ; i++) + { + // cerca rata + scadenza.zero(); + scadenza.put("TIPOCF", tipocf); + scadenza.put("GRUPPO", gruppo); + scadenza.put("CONTO", conto); + scadenza.put("SOTTOCONTO", sottoconto); + scadenza.put("ANNO", anno); + scadenza.put("NUMPART", numpart); + scadenza.put("NRIGA", nriga); + scadenza.put("NRATA", i+1); + + if (scadenza.read() == NOERR) + { + // TBI setta rate + real importo = scadenza.get("IMPORTOVAL"); + TDate scad = scadenza.get("DATASCAD"); + int tipop = scadenza.get_int("TIPOPAG"); + bool paid = scadenza.get_bool("PAGATA"); + TString ucl(scadenza.get("ULTCLASS")); + + // disable rows if paid + // pag.set_rata(i, importo, scad, tipop, ucl, paid); + } + else break; + } + } + } + else + { + pag.set_rate_auto(); + new_part = TRUE; + } + + // prepara lo sheet + pag.set_sheet(ps); + TArray rows(ps.rows_array()); + // se la prima rata e' fissa non si tocca if (pag.tipo_prima_rata() > 0) { @@ -200,9 +291,6 @@ void TPrimanota_application::aggiorna_scadenzario(const TMask& m) ps.disable_cell(0,3); } - // prepara lo sheet - pag.set_sheet(ps); - TArray rows(ps.rows_array()); shuttle sh; @@ -215,6 +303,77 @@ void TPrimanota_application::aggiorna_scadenzario(const TMask& m) ms.run(); // TBI se modificato riaggiustare i files - // chiamando la write del caso - // ------------------------------------------------- + // partite e scadenze + // ---------------------------------------- + if (pag.dirty() || new_part) + { + if (new_part) + { + partita.zero(); + partita.put("TIPOCF", tipocf); + partita.put("GRUPPO", gruppo); + partita.put("CONTO", conto); + partita.put("SOTTOCONTO", sottoconto); + partita.put("ANNO", anno); + partita.put("NUMPART", numpart); + partita.put("NRIGA", nriga); + } + // TBI put data on partita + + if (new_part) partita.write(); + else partita.rewrite(); + + bool new_scad = FALSE; + + for (int i = 0; i < pag.n_rate(); i++) + { + new_scad = FALSE; + scadenza.zero(); + scadenza.put("TIPOCF", tipocf); + scadenza.put("GRUPPO", gruppo); + scadenza.put("CONTO", conto); + scadenza.put("SOTTOCONTO", sottoconto); + scadenza.put("ANNO", anno); + scadenza.put("NUMPART", numpart); + scadenza.put("NRIGA", nriga); + scadenza.put("NRATA", i+1); + + if (scadenza.read() != NOERR) + { + new_scad = TRUE; + scadenza.zero(); + scadenza.put("TIPOCF", tipocf); + scadenza.put("GRUPPO", gruppo); + scadenza.put("CONTO", conto); + scadenza.put("SOTTOCONTO", sottoconto); + scadenza.put("ANNO", anno); + scadenza.put("NUMPART", numpart); + scadenza.put("NRIGA", nriga); + scadenza.put("NRATA", i+1); + } + // TBI set everything + + + if (new_scad) scadenza.write(); + else scadenza.rewrite(); + } + // elimina eventuali altre scadenze + // oltre l'ultima registrata + for (; !new_scad ; i++) + { + scadenza.zero(); + scadenza.put("TIPOCF", tipocf); + scadenza.put("GRUPPO", gruppo); + scadenza.put("CONTO", conto); + scadenza.put("SOTTOCONTO", sottoconto); + scadenza.put("ANNO", anno); + scadenza.put("NUMPART", numpart); + scadenza.put("NRIGA", nriga); + scadenza.put("NRATA", i+1); + + if (scadenza.read() == NOERR) + scadenza.remove(); + else new_scad = TRUE; + } + } } diff --git a/cg/cg4300.cpp b/cg/cg4300.cpp index 196087a60..813b86621 100755 --- a/cg/cg4300.cpp +++ b/cg/cg4300.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "cg4300.h" #include "cg4300a.h" @@ -149,9 +150,11 @@ bool TLiquidazione_app::user_create() if (is_interactive) { for (_nditte->first(); !_nditte->eof(); _nditte->next()) - { - if (!(TApplication::set_firm(_nditte_r->get_long("CODDITTA")))) - continue; + { + if (!prefhndl->exist(_nditte_r->get_long("CODDITTA"))) + continue; + + TApplication::set_firm(_nditte_r->get_long("CODDITTA")); _n_ditte++; TToken_string* d = new TToken_string(64); diff --git a/cg/cg4301.cpp b/cg/cg4301.cpp index b929b62c8..16e5dacd2 100755 --- a/cg/cg4301.cpp +++ b/cg/cg4301.cpp @@ -5,7 +5,6 @@ // ------------------------------------------------------------ #include - #include "cg4300.h" // -------------------- QUI comincia l'avventura -------------------------- @@ -152,7 +151,9 @@ bool TLiquidazione_app::update_firm(int month, bool recalc) _isannual = (_month == 12 && !mens && !_isbenzinaro) || (_month == 13 && (mens || _isbenzinaro)); _isriepilogo = _month == 13; - + + _isvent = FALSE; + for (_reg->first(); !_isvent && _reg->good(); _reg->next()) { if (codatt == _reg->get("S8") && _reg->get_int("I0") == 2) @@ -163,8 +164,7 @@ bool TLiquidazione_app::update_firm(int month, bool recalc) if ((month != 13 || _isannual) && (calc || !recalc)) if (!update_att(month, cattiv)) describe_error("Attivita' non ricalcolate: possibili errori", - codatt); - + codatt); // vediamo se c'e' qualcosa da raccontare gheravergot = _isannual || _isriepilogo; diff --git a/cg/cg5100.cpp b/cg/cg5100.cpp index 5192e0038..e7842c0b9 100755 --- a/cg/cg5100.cpp +++ b/cg/cg5100.cpp @@ -2,26 +2,107 @@ #include #include #include +#include +#include #include "cg5100a.h" class CG51_App : public TConfig_application { - bool _change_pcon; + bool _change_pcon; TString16 _val; + TArray _atts; void swap_file(int logicnum, bool tocom); + void check_registers(int year); + public: virtual bool preprocess_config (TMask& mask, TConfig& config); virtual bool postprocess_config (TMask& mask, TConfig& config); virtual bool postprocess_config_changed(const char* par, const char* var, const char* oldv, const char* newv); - virtual bool user_create() { _change_pcon = FALSE; return TRUE;} + virtual bool user_create(); virtual bool user_destroy(); CG51_App() : TConfig_application(CONFIG_DITTA) {} virtual ~CG51_App() {} }; +bool CG51_App::user_create() +{ + _change_pcon = FALSE; + + TLocalisamfile attiv(LF_ATTIV); + attiv.zero(); + + attiv.put(ATT_CODDITTA, get_firm()); + TRectype r(attiv.curr()); + + for(attiv.read(_isgteq); attiv.status() == NOERR && attiv.curr() == r; + attiv.next()) + // istanzia array _atts on le attivita' della ditta corrente + _atts.add(new TString(attiv.get(ATT_CODATT))); + + return TRUE; +} + + +void CG51_App::check_registers(int year) +{ + // controlla che per ogni data attivita' esistano almeno un registro + // acquisti, vendite e giornale; warning appropriato in caso negativo + TTable reg("REG"); + TRecfield reg_year(reg.curr(), "CODTAB", 0,3); + + const byte R_ACQ = 0x01; + const byte R_VEN = 0x02; + const byte R_ALL = R_ACQ | R_VEN; + + bool is_giornale = FALSE; + + byte flags = 0x00; + + for (int i = 0; i < _atts.items(); i++) + { + TString& att = (TString&)_atts[i]; + for (reg.first(); !reg.eof(); reg.next()) + { + if (atoi(reg_year) == year && reg.get_int("I0") == 5) + { + is_giornale = TRUE; + continue; + } + if (atoi(reg_year) != year || att != reg.get("S8")) + continue; + + switch (reg.get_int("I0")) + { + case 1: // vendite + flags |= R_VEN; + break; + case 2: // acquisti + flags |= R_ACQ; + break; + } + if (flags == R_ALL && is_giornale) break; + } + if (flags < R_ALL) + { + TString wrn("I seguenti registri non esistono per l'attivita' "); + wrn << att << "(" << year << "):"; + if ((flags & R_VEN) == 0x00) wrn << "\n\tregistro vendite"; + if ((flags & R_ACQ) == 0x00) wrn << "\n\tregistro acquisti"; + warning_box(wrn); + } + } + + // libro giornale non si controlla per attivita' + if(!is_giornale) + warning_box("Non esiste probabilmente nessun " + "libro giornale per l'anno %d", year); +} + + + void CG51_App::swap_file(int logicnum, bool tocom) { TDir dir; @@ -99,6 +180,10 @@ bool CG51_App::postprocess_config_changed(const char* par, const char* var, else return FALSE; } + else if (v == "AnLiIv") + { + check_registers(atoi(newv)); + } return TRUE; } diff --git a/cg/cg5300.cpp b/cg/cg5300.cpp index da1086d20..489d34b03 100755 --- a/cg/cg5300.cpp +++ b/cg/cg5300.cpp @@ -71,45 +71,50 @@ void CG5300_App::check_registers(int year) const byte R_ACQ = 0x01; const byte R_VEN = 0x02; - const byte R_GIO = 0x04; - const byte R_ALL = R_ACQ | R_VEN | R_GIO; + const byte R_ALL = R_ACQ | R_VEN; + + bool is_giornale = FALSE; + byte flags = 0x00; + for (int i = 0; i < _atts.items(); i++) { - byte flags = 0x00; - TString& att = (TString&)_atts[i]; - - for (reg.first(); !reg.eof(); reg.next()) - { - if (atoi(reg_year) != year || att != reg.get("S8")) - continue; + TString& att = (TString&)_atts[i]; + for (reg.first(); !reg.eof(); reg.next()) + { + if (atoi(reg_year) == year && reg.get_int("I0") == 5) + { + is_giornale = TRUE; + continue; + } + if (atoi(reg_year) != year || att != reg.get("S8")) + continue; - switch ((int)reg.get_long("I0")) - { - case 1: // vendite - flags |= R_VEN; - break; - case 2: // acquisti - flags |= R_ACQ; - break; - case 5: // giornale - flags |= R_GIO; - break; - } - if (flags == R_ALL) break; - } - if (flags < R_ALL) - { - TString att = (TString&)_atts[i]; - TString wrn("I seguenti registri probabilmente non esistono per l'attivita' "); - wrn << att << ":"; - if ((flags & R_VEN) == 0x00) wrn << "\n\tregistro vendite"; - if ((flags & R_ACQ) == 0x00) wrn << "\n\tregistro acquisti"; - if ((flags & R_GIO) == 0x00) wrn << "\n\tlibro giornale"; - warning_box(wrn); - } - } - + switch (reg.get_int("I0")) + { + case 1: // vendite + flags |= R_VEN; + break; + case 2: // acquisti + flags |= R_ACQ; + break; + } + if (flags == R_ALL && is_giornale) break; + } + if (flags < R_ALL) + { + TString wrn("I seguenti registri non esistono per l'attivita' "); + wrn << att << "(" << year << "):"; + if ((flags & R_VEN) == 0x00) wrn << "\n\tregistro vendite"; + if ((flags & R_ACQ) == 0x00) wrn << "\n\tregistro acquisti"; + warning_box(wrn); + } + } + + // libro giornale non si controlla per attivita' + if(!is_giornale) + warning_box("Non esiste probabilmente nessun " + "libro giornale per l'anno %d", year); } @@ -248,7 +253,8 @@ int CG5300_App::rewrite(const TMask& m) if (prorata != _pla->get_real("R8") || es_a8 != _pla->get_real("R5") || es_a8b != _pla->get_real("R6") || - es_a9 != _pla->get_real("R7")) + es_a9 != _pla->get_real("R7") || + m.field(F_CRED_PREC).dirty()) { // invalida la prima liquidazione calcolata se ce n'e' TTable lim("LIM"); @@ -361,3 +367,4 @@ int cg5300(int argc, char* argv[]) + \ No newline at end of file