From 6c857aa0177350d0bac338f504c527009b11d7bd Mon Sep 17 00:00:00 2001 From: villa Date: Fri, 11 Nov 1994 11:26:28 +0000 Subject: [PATCH] Corretti (o sputtanati) errori liquidazione MI2031 2011 0047 2009 1060 2097(da correggere in Printer) 2098 2099 2100 2108 git-svn-id: svn://10.65.10.50/trunk@600 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg4300.cpp | 124 ++++++++++++++++++++++++++++++++++++++------------ cg/cg4300.h | 5 +- cg/cg4301.cpp | 24 +++++++--- cg/cg4302.cpp | 6 --- cg/cg4304.cpp | 48 ++++++++++--------- cg/cg4400.cpp | 10 ++-- cg/cg4400.h | 4 +- 7 files changed, 151 insertions(+), 70 deletions(-) diff --git a/cg/cg4300.cpp b/cg/cg4300.cpp index fedb7a8e9..0fe0e4683 100755 --- a/cg/cg4300.cpp +++ b/cg/cg4300.cpp @@ -7,16 +7,34 @@ #include "cg4300.h" #include "cg4300a.h" #include +#include real CG4300_App::CENTO(100.0); inline CG4300_App& app() { return (CG4300_App&)main_app(); } -void CG4300_App::user_create() -{ - TProgind pnd(3,"Preparazione archivi\nPrego attendere", - FALSE, TRUE, 30); +bool CG4300_App::user_create() +{ + // vediamo se c'e' il messaggio per calcolare in batch + TMailbox m; + TProgind* pnd = NULL; + TMessage* msg = m.next_s("RCL"); + TToken_string subj(36); + bool is_interactive = msg == NULL; + bool recalc_only = FALSE; + bool is_header = TRUE; + TDate printdate; + TString filename; + long ditta; + + _prind = NULL; + + if (msg != NULL) subj = msg->body(); + + if (is_interactive) + pnd = new TProgind (3,"Preparazione archivi\nPrego attendere", + FALSE, TRUE, 30); _nditte = new TRelation(LF_NDITTE); _nditte->add(LF_ATTIV,"CODDITTA=CODDITTA"); @@ -28,17 +46,31 @@ void CG4300_App::user_create() _n_ditte = 0l; // prevediamo la data che usera'; se calcola la liq. di un altro anno - // si fottera' la frequenza versamenti - TDate oggi(TODAY); - _year.format("%d",oggi.year()); + // si fottera' la frequenza versamenti + + if (is_interactive) + { + TDate oggi(TODAY); + _year.format("%d",oggi.year()); + } + else // parse messaggio + { + _year = subj.get(0); + _month = subj.get_int(1); + ditta = subj.get_long(2); + recalc_only = *(subj.get(3)) == 'C'; + printdate = subj.get(4); + filename = subj.get(5); + is_header = subj.items() == 6; + + } - pnd.addstatus(1); + if(pnd) pnd->addstatus(1); _rel = new TRelation(LF_MOV); _rel->add(LF_RMOVIVA,"NUMREG=NUMREG"); _cur = new TCursor(_rel, "", 2); - // (*_cur) = 0; _pim = new TTable("PIM"); _ppa = new TTable("PPA"); @@ -66,7 +98,6 @@ void CG4300_App::user_create() _rmoviva_r = &(_cur->curr(LF_RMOVIVA)); _mov_r = &(_mov->curr()); - // ACHTUNG: tutti i _codatt (codici attivita') sono // in realta' composti dal codice attivita' piu' il // tipo attivita' (1 o 2) @@ -98,32 +129,65 @@ void CG4300_App::user_create() __firm = TApplication::get_firm(); - pnd.addstatus(1); + if (pnd) pnd->addstatus(1); - - for (_nditte->first(); !_nditte->eof(); _nditte->next()) + if (is_interactive) { - if (!(TApplication::set_firm(_nditte_r->get_long("CODDITTA")))) - continue; - - _n_ditte++; - - TToken_string* d = new TToken_string(64); - - // add record - d->add(_nditte_r->get("CODDITTA")); - d->add(_nditte_r->get("RAGSOC")); - d->add(look_lia() ? _lia->get("S7") : _nditte_r->get("FREQVIVA")); - _nomiditte.add(d); + for (_nditte->first(); !_nditte->eof(); _nditte->next()) + { + if (!(TApplication::set_firm(_nditte_r->get_long("CODDITTA")))) + continue; + _n_ditte++; + + TToken_string* d = new TToken_string(64); + + // add record + d->add(_nditte_r->get("CODDITTA")); + d->add(_nditte_r->get("RAGSOC")); + d->add(look_lia() ? _lia->get("S7") : _nditte_r->get("FREQVIVA")); + _nomiditte.add(d); + } } - pnd.addstatus(1); + if (pnd) pnd->addstatus(1); TApplication::set_firm(__firm); - set_real_picture(REAL_PICTURE); + set_real_picture(REAL_PICTURE); + + if (!is_interactive) + { + TTemp_window w(TASK_WIN); + w.iconize(); + if (recalc_only) _isprint = FALSE; + else printer().set_export_file(filename, is_header); + // calcola liquidazione + printer().setdate(printdate); + _recalc = one; + TApplication::set_firm(ditta); + + _nditte->zero(); _nditte_r->put("CODDITTA", ditta); _nditte->read(); + _freqviva = (look_lia() ? _lia->get("S7") : _nditte_r->get("FREQVIVA")); + + TRectype& mov = _cur->curr(); + TRectype from(_cur->curr()); from.zero(); + TRectype to(from); + TDate f(1, 1, atoi(_year)); + TDate t(1, _month, atoi(_year)); + t.set_end_month(); + from.put(MOV_DATAREG, f); + to.put(MOV_DATAREG, t); + _cur->setregion(from, to); + + if (is_month_ok(_month)) update_firm(_month); + if (_isprint) print(); + TApplication::set_firm(__firm); + } + else delete pnd; + + return is_interactive; } -void CG4300_App::user_destroy() +bool CG4300_App::user_destroy() { delete _ditte; @@ -162,7 +226,9 @@ void CG4300_App::user_destroy() delete _nditte; delete _rel; - delete _cur; + delete _cur; + + return TRUE; } bool CG4300_App::set_print(int n) diff --git a/cg/cg4300.h b/cg/cg4300.h index 23e3e7969..2f7b27843 100755 --- a/cg/cg4300.h +++ b/cg/cg4300.h @@ -44,6 +44,7 @@ // ------------------------------------------------------------------ // Fine parametri modificabili // do not change below this line if you want me to work +// and you to keep your fucking ass healty // ------------------------------------------------------------------ // per il campo I0 di pim @@ -257,8 +258,8 @@ protected: public: - virtual void user_create(); - virtual void user_destroy(); + virtual bool user_create(); + virtual bool user_destroy(); virtual bool set_print(int i); bool set_liquidazione(); diff --git a/cg/cg4301.cpp b/cg/cg4301.cpp index 47f2c8acb..e3c0ee80b 100755 --- a/cg/cg4301.cpp +++ b/cg/cg4301.cpp @@ -40,7 +40,7 @@ bool CG4300_App::recalc_all() { if (!is_month_ok(m)) continue; if (!look_lim(m)) need_refresh = TRUE; - else need_refresh |= !(_lim->get_bool("B0")); + else if (!(_lim->get_bool("B0"))) need_refresh = TRUE; } if (need_refresh) if (yesno_box("Alcuni mesi precedenti non risultano ricalcolati. E' " @@ -69,7 +69,7 @@ bool CG4300_App::recalc_all() } if (!_prind->iscancelled()) _prind->addstatus(1); TApplication::set_firm(__firm); - delete _prind; + delete _prind; _prind = NULL; return TRUE; } @@ -115,7 +115,7 @@ bool CG4300_App::update_firm(int month, bool recalc) month, (const char*)_nditte_r->get("RAGSOC"), (const char*)desatt); - _prind->set_text(buf); + if (_prind) _prind->set_text(buf); _vend_arr.destroy(); _corr_arr.destroy(); @@ -293,7 +293,8 @@ void CG4300_App::recalc_att(int month, const char* codatt) real cred_cost = 0.0; real for_rimb = 0.0; real acq_ies = 0.0; - real acq_ies_iva = 0.0; + real acq_ies_iva = 0.0; + real ult_detr = 0.0; *_cur = 0; long items = _cur->items(); @@ -385,6 +386,7 @@ void CG4300_App::recalc_att(int month, const char* codatt) { ammort_6 += imponibile; ammort_6_iva += imposta; + ult_detr += imposta * real(DETRAZIONE_6PERCENTO); } else if (tipomov == vendita && tipocr == 4) // Vendite strum. art 17 (cess. amm.???) @@ -638,6 +640,13 @@ void CG4300_App::recalc_att(int month, const char* codatt) _ptm->put("S2", acquisti.string()); _ptm->put("S3", vendite.string()); _ptm->rewrite(); + + // somma le ulteriori detrazioni + look_lim(month, TRUE); + real dt = _lim->get_real("R6"); + dt += ult_detr; + _lim->put("R6", dt); + _lim->rewrite(); } void CG4300_App::write_liq(int month, const char* codatts) @@ -692,11 +701,14 @@ void CG4300_App::write_liq(int month, const char* codatts) look_lim(month,TRUE); + // scorpora ulteriori detrazioni + real dt = _lim->get_real("R6"); + risultato -= dt; + _lim->put("R0",risultato); _lim->put("B0","X"); - if (_isfinal) - _lim->put("B1","X"); + if (_isfinal) _lim->put("B1","X"); _lim->rewrite(); if (month == 12) diff --git a/cg/cg4302.cpp b/cg/cg4302.cpp index 2284da796..0012813da 100755 --- a/cg/cg4302.cpp +++ b/cg/cg4302.cpp @@ -344,12 +344,6 @@ real CG4300_App::credito_prec(int month) { real c(0.0); - // se c'e' un credito nei parametri ditta, si usa quello e vaffanculo -// TConfig cnf(CONFIG_DITTA); - -// c = (const char*)cnf.get("CrIvAp"); -// if (!c.is_zero()) return c; - if (is_first_month(month)) { look_lia(); diff --git a/cg/cg4304.cpp b/cg/cg4304.cpp index 5df8c6f04..803409836 100755 --- a/cg/cg4304.cpp +++ b/cg/cg4304.cpp @@ -404,8 +404,10 @@ void CG4300_App::describe_pims(int month, const char* codatt) t->_r11 += _plm->get_real("R2"); // pro-rata indetraibile t->_s0 = (_plm->get_real("R12")).string(); // % pro-rata - t->_s1 = _plm->get("S2"); // acq. inded. su ricavi esenti - t->_s2 = _plm->get("S3"); // IVA acq. inded. su ricavi esenti + real aie(_plm->get("S2")); // acq. inded. su ricavi esenti + real aiev(_plm->get("S3")); // IVA acq. inded. su ricavi esenti + d->_r9 += aie; + d->_r10 += aiev; } } // annual follows in _arr @@ -485,6 +487,9 @@ void CG4300_App::describe_liq(int month, const char* codatts, _DescrItem* di) // r7 = credito precedente d->_r7 = credito_prec(month); + + // r11 = ulteriori detrazioni + d->_r11 = _lim->get_real("R6"); // vedi se c'era un debito precedente e schiaffa in r10 if (!is_first_month(month)) @@ -710,7 +715,7 @@ void CG4300_App::set_pim(_DescrItem& d) "@82gImposta@96gImponibile@115gImposta"); set_row(3,""); } - set_row(d._f0 ? 4 : 1,"%4s %-20s@25g%r %r@58g%r %r@91g%r %r", + set_row(d._f0 ? 4 : 1,"%4s %-20s@25g%r@41g%r@58g%r@74g%r@91g%r@107g%r", (const char*)d._s1, (const char*)d._s2, &(d._r0), @@ -724,7 +729,7 @@ void CG4300_App::set_pim(_DescrItem& d) void CG4300_App::set_plm(_DescrItem& d) { set_row(1,""); set_row(2,""); - set_row(3,"Totale@25g%r %r@58g%r %r@91g%r %r", + set_row(3,"Totale@25g%r@41g%r@58g%r@74g%r@91g%r@107g%r", &(d._r0), &(d._r1), &(d._r2), @@ -734,14 +739,23 @@ void CG4300_App::set_plm(_DescrItem& d) // totalazzi parziali e generali set_row(4,"di cui per acquisti intracomunitari@107g%r", &(d._r6)); set_row(5,""); - set_row(6,"Totali acquisti indeducibili per art.19@91g%r %r", + set_row(6,"Totali acquisti indeducibili per art.19@91g%r@107g%r", &(d._r7), &(d._r8)); - set_row(7,""); + set_row(7,""); + int rw = 8; + if (! (d._r9.is_zero() && d._r10.is_zero())) + { + set_row(rw++, "Totale acquisti indeducibili su ricavi esenti@91g%r@107g%r", + &(d._r9), + &(d._r10)); + set_row(rw++,""); + } + real tot1 = d._r7 + d._r4; real tot2 = d._r8 + d._r5; - set_row(8,"Totale Generale IVA@25g%r %r@58g%r %r@91g%r %r", + set_row(rw++,"Totale Generale IVA@25g%r@41g%r@58g%r@74g%r@91g%r@107g%r", &(d._r0), &(d._r1), &(d._r2), @@ -752,9 +766,6 @@ void CG4300_App::set_plm(_DescrItem& d) void CG4300_App::set_ptm(_DescrItem& d) { - real iesi(d._s1); - real iesv(d._s2); - if (d._r0.is_zero() && // acq. ammortizz. d._r1.is_zero() && // IVA acq. ammort. d._r2.is_zero() && // ammort. detr. 6% @@ -767,8 +778,6 @@ void CG4300_App::set_ptm(_DescrItem& d) d._r9.is_zero() && // IVA su cessioni ammort. d._r10.is_zero() && // tot. esenti IVA d._r11.is_zero() && // pro_rata - iesi.is_zero() && // indeducibili su ricavi esenti - iesv.is_zero() && // IVA indeducibili su ricavi esenti d._arr.items() == 0) { set_row(1,""); @@ -800,17 +809,11 @@ void CG4300_App::set_ptm(_DescrItem& d) set_row(row++, "Altri beni strumentali acquisiti in leasing@50g%r@69g%r", &(d._r6), &(d._r7)); - if (! (iesi.is_zero() && iesv.is_zero())) - { - set_row(row++, "Totale acquisti indeducibili su ricavi esenti@50g%r@69g%r", - &iesi, - &iesv); - } if (! (d._r2.is_zero() && d._r3.is_zero())) { - real rn = d._r2 * real(DETRAZIONE_6PERCENTO); + real rn = d._r3 * real(DETRAZIONE_6PERCENTO); set_row(row++, "Acquisto beni soggetti a detrazione (6%%)" - "@50g%r@69g%r@88g%r", + "@50g%r@69g%r@86g%r", &(d._r2), &(d._r3), &rn); @@ -868,8 +871,11 @@ void CG4300_App::set_grand(_DescrItem& d) if (!(d._r8.is_zero())) set_row(rw++,"@11gVersamento acconto dicembre@58g%r", &(d._r8)); + if (!(d._r11.is_zero())) + set_row(rw++,"@11gUlteriori detrazioni@58g%r", &(d._r11)); + set_row(rw++,"@11gRettifiche IVA a credito@58g%r", &(d._r6)); - real rc = d._r1 + d._r7 + d._r8 + d._r6; + real rc = d._r1 + d._r7 + d._r8 + d._r6 -d._r11; // conguaglio prorata if (d._r9.sign() < 0) rc -= d._r9; diff --git a/cg/cg4400.cpp b/cg/cg4400.cpp index b08c012cd..c6f83ec22 100755 --- a/cg/cg4400.cpp +++ b/cg/cg4400.cpp @@ -376,7 +376,7 @@ const char * CG4400_application::ricerca_occ(const char * occ) return TMP; } -void CG4400_application::user_create() +bool CG4400_application::user_create() { _nditte = new TLocalisamfile(LF_NDITTE); _ditte = new TArray_sheet(-1, -1, 0, 0, "Selezione Ditte", @@ -411,10 +411,11 @@ void CG4400_application::user_create() add_cursor(_cur); add_file(LF_MOV); - add_file(LF_RMOVIVA); + add_file(LF_RMOVIVA); + return TRUE; } -void CG4400_application::user_destroy() +bool CG4400_application::user_destroy() { delete _ditte; delete _nditte; @@ -422,7 +423,8 @@ void CG4400_application::user_destroy() delete _tabcom; delete _cur; delete _rel; - delete _clifo; + delete _clifo; + return TRUE; } diff --git a/cg/cg4400.h b/cg/cg4400.h index 289d9d211..978a714d0 100755 --- a/cg/cg4400.h +++ b/cg/cg4400.h @@ -71,8 +71,8 @@ protected: void aggiorna_reg(); void aggiorna_lib(); void calcola_progressivi(real&, real&, const char*, const int); - void user_create(); - void user_destroy(); + bool user_create(); + bool user_destroy(); bool preprocess_page(int, int); int stampa_intestazione(); int stampa_prospetto();