// ------------------------------------------------------------ // Calcolo liquidazioni // Part 5: stampa // fv 21-1-94 // ------------------------------------------------------------ #include #include #include #include #include "cg4300.h" #include #include #include // flags per annuale #define IS_PRORATA 0x0001 // minchietta per prospetto ventilazione class _vDesc : public TObject { public: TString4 _codiva; real _acq; real _vnd; real _viv; _vDesc() {} virtual ~_vDesc() {} }; const char* const sep = "------------------------------------------------------------------" "------------------------------------------------------------------"; void TLiquidazione_app::set_page(int file, int cnt) { _DescrItem& d = (_DescrItem&)_descr_arr[cnt]; set_auto_ff(FALSE); reset_print(); switch(d._flags) { case CHG_PARMS: set_att(d); break; case SET_FIRM: set_firm(d); break; case PIS_ROW: case PIM_ROW: case PIS_ROW_D: case PIM_ROW_D: case PIS_ROW_DI: case PIM_ROW_DI: set_pim(d); break; case PIS_HEAD: case PIM_HEAD: case PIS_HEAD_D: case PIM_HEAD_D: case PIS_HEAD_DI: case PIM_HEAD_DI: set_pim_head(d); break; case MISC_LIQ: set_pumpam(d); break; case TOT_ROW: set_plm(d); break; case TOT_ROW_D: case TOT_ROW_DI: set_plm_diff(d); break; case PLAFOND: set_plafond(d); break; case VENTILA: set_ventila(d); break; case REGAGR: set_regagr(d); break; case REGVIA: set_viaggio(d); break; case THE_END: set_grand(d); break; case LIQACC: /* Obsoleto if (atoi(_year) >= 2000) set_liqacc_2000(d); else set_liqacc_1999(d); */ set_liqacc_2000(d); break; case ACCONTO: set_acconto_p(d); break; case ACCHEAD: set_acchead_p(d); break; case DELDEB: set_deltab(d, false); break; case DELCRED: set_deltab(d, true); break; default: break; } } print_action TLiquidazione_app::postprocess_page(int file, int cnt) { if (_descr_arr.items() == 0 || cnt == _descr_arr.items()-1) return NEXT_PAGE; return REPEAT_PAGE; } bool TLiquidazione_app::preprocess_page(int file, int cnt) { return _descr_arr.items() != 0; } // ---------------------------------------------------------------- // Print description // ---------------------------------------------------------------- void TLiquidazione_app::describe_att(int month, const char* codatt, bool /*isresult*/, char flags) { if (_isprint && _canprint) { TToken_string atts(codatt); const bool single_att = atts.items() == 1; describe_name(month, atts, flags); if (single_att) { if (_isplafond) describe_plafond(month, codatt); if (_isvent) describe_ventilation(month, codatt); if (_isagricolo) describe_agricolo(month, codatt); if (_isviaggio) describe_viaggio(month, codatt); } describe_pims(month, codatt, false); // PIM describe_pims(month, codatt, true); // PIS if (single_att) describe_consistence(codatt); } } void TLiquidazione_app::describe_name(int month, const TToken_string& codatts, char flags) { const bool single_att = codatts.items() == 1; _DescrItem* d = new _DescrItem(CHG_PARMS); d->_s0 = _nditte->curr().get(NDT_CODDITTA); d->_s1 = _nditte->curr().get(NDT_RAGSOC); const TRectype& ndt_att = _nditte->curr(LF_ATTIV); d->_s2 = ndt_att.get(ATT_CODATECO); if (d->_s2.blank()) d->_s2 = ndt_att.get(ATT_CODATT); d->_s3 = single_att ? (const char*)ndt_att.get(ATT_DESCR) : ""; d->_s4 = _freqviva; d->_f1 = month; d->_f2 = _isbenzinaro; d->_f3 = (word)flags; d->_f0 = 0; if (_mixed && single_att) d->_f0 = atoi(codatts.mid(5)); _descr_arr.add(d); } void TLiquidazione_app::describe_firm(int month) { if (!_isprint || !_canprint) return; _DescrItem* d = new _DescrItem(SET_FIRM); d->_s0 = _nditte->curr().get("CODDITTA"); d->_s1 = _nditte->curr().get("RAGSOC"); d->_s2 = _freqviva; d->_f1 = month; _descr_arr.add(d); } void TLiquidazione_app::describe_liqacc() { if (!_isprint || !_canprint) return; if (!look_lia()) return; if (_lia->get("S8") != "A") return; _DescrItem* d = new _DescrItem(LIQACC); d->_r0 = _lia->get_real("R7"); d->_r1 = _lia->get_real("R13"); d->_r2 = _lia->get_real("R14"); d->_r3 = _lia->get_real("R9"); d->_r4 = _lia->get_real("R10"); d->_r5 = _lia->get_real("R8"); d->_r6 = _lia->get_real("R12"); d->_r7 = _lia->get_real("R11"); d->_r8 = _lia->get_real("R4"); d->_r29 = _lia->get_real("R29"); d->_r33 = _lia->get_real("R33"); TToken_string ff(_lia->get("S1"),'!'); real cre_pre (ff.get(0)); real acq_intr (ff.get(1)); d->_r9 = cre_pre; d->_r10 = acq_intr; _descr_arr.add(d); } void TLiquidazione_app::describe_plafond(int month, const char* codatt) { TString att(codatt); // prepara la descrizione del riepilogo da stampare e lo accoda real t1, t2, t3; _DescrItem* d = new _DescrItem(PLAFOND); if (month == 13) look_pla(codatt); for (int jj = 1; jj <= 3; jj++) // three types of plafond { t1 = 0.0; t2 = 0.0; t3 = 0.0; if (month < 13) { look_ppa(_freqviva == "M" ? month : next_trim(month) -2, codatt,jj); t3 = _ppa->get_real("R2"); } for (int m = 1; m <= month && m < 13; m++) { if (is_month_ok(m,month) && look_ppa(m,codatt,jj)) { t1 += _ppa->get_real("R0"); t2 += _ppa->get_real("R1"); } } switch (jj) { case 1: d->_r0 = t1; d->_r1 = t2; d->_r2 = month < 13 ? t3 : _pla->get_real("R5"); break; case 2: d->_r3 = t1; d->_r4 = t2; d->_r5 = month < 13 ? t3 : _pla->get_real("R6"); break; case 3: d->_r6 = t1; d->_r7 = t2; d->_r8 = month < 13 ? t3 : _pla->get_real("R7"); break; } } // for tipo esenzione plafond _descr_arr.add(d); // bookmark } void TLiquidazione_app::describe_ventilation(int month, const char* codatt) { if (!_isvent || _isagricolo || _isviaggio) return; _DescrItem* d = new _DescrItem(VENTILA); TString att(codatt); look_plm(month, att); for (_pim->first(); !_pim->eof(); _pim->next()) { if (strcmp(*_pim_codatt,att) != 0) continue; look_reg(*_pim_codreg); look_iva(*_pim_codiva); int tipocr = atoi(*_pim_tipocr); int tipodet = atoi(*_pim_tipodet); int mese = atoi(*_pim_mese); bool corrisp = _reg->get_bool("B0"); real imponibile = _pim->get_real("R0"); real imposta = _pim->get_real("R1"); tiporeg tipomov = (tiporeg)_reg->get_long("I0"); TString tipoiva = _iva->get("S1"); if (_year != *_pim_anno || (month == 13 && mese < 13)) continue; if (imponibile.is_zero() && imposta.is_zero()) continue; // questi non vanno in liquidazione, i totali sono // gia' calcolati altrove if (tipodet == 1 || (tipodet == 3 && tipocr == 5) || tipodet == 9) continue; // questi non si devono vedere perche' so' bbrutti if (tipoiva == "NS" || tipoiva == "ES" || tipoiva == "NI") continue; if (mese <= month) { if (tipocr == 1 && tipomov == acquisto) { // somma agli acquisti _vDesc* vd = NULL; for (int i = 0; i < d->_arr.items(); i++) { _vDesc* vv = (_vDesc*)&(d->_arr[i]); if (strcmp(vv->_codiva,*_pim_codiva) == 0) { vd = vv; break; } } if (vd == NULL) { vd = new _vDesc; } vd->_acq += (imponibile+imposta); d->_r0 += (imponibile+imposta); if (vd->_codiva.empty()) { vd->_codiva = *_pim_codiva; d->_arr.add(vd); } } else if ((is_month_ok(mese,month) || month == 13) && corrisp && _pim->get_bool("B1") && tipocr == 0 && tipomov == vendita) // non sono sicurissimo della above condition { // somma alle vendite _vDesc* vd = NULL; for (int i = 0; i < d->_arr.items(); i++) { _vDesc* vv = (_vDesc*)&(d->_arr[i]); if (strcmp(vv->_codiva,*_pim_codiva) == 0) { vd = vv; break; } } if (vd == NULL) { vd = new _vDesc; } vd->_vnd += imponibile; vd->_viv += imposta; d->_r1 += imponibile+imposta; if (vd->_codiva.empty()) { vd->_codiva = *_pim_codiva; d->_arr.add(vd); } } } } d->_r0 = _pam->get_real("R2"); // Totale acquisti d->_r1 = _pam->get_real("R3"); // Totale vendite if (d->_r1.is_zero() || d->_r0.is_zero()) delete d; else { // Questo e' il fantastico moltiplicatore d->_r2 = d->_r1 / d->_r0; _descr_arr.add(d); } } void TLiquidazione_app::describe_agricolo(int month, const char* codatt) { _DescrItem* d = new _DescrItem(REGAGR); if (_isagr98) // Setta l'array interno con tutti gli items relativi alla tabella PIA { TArray& agr_array = d->_arr; for (_pia->first(); !_pia->eof(); _pia->next()) // Scorre i progressivi agricoli { if (strcmp((const char*)*_pia_codatt, codatt) == 0 && is_month_plain(atoi(*_pia_mese)) && _year == *_pia_anno) // E sono gia' in ordine di codice... { _DescrItem* p = new _DescrItem(PROGAGR); p->_r0 = _pia->get_real("R0"); // Imponibile p->_r1 = _pia->get_real("R1"); // Imposta p->_s0 = *_pia_codord; // Codice iva ordinario p->_s1 = *_pia_codcom; // Codice iva compensazione if (p->_r0 != ZERO || p->_r1 != ZERO) agr_array.add(p); // Aggiunge il fottuto item agricolo } } } for (int mese = month == 13 ? 13 : 1; mese <= month; mese++) { if (!is_month_ok(mese,month)) continue; if (!look_plm(mese, codatt)) continue; d->_r0 += _plm->get_real("R5"); d->_r1 += _plm->get_real("R6"); d->_r2 += _plm->get_real("R7"); d->_r3 += _plm->get_real("R8"); d->_r4 += _plm->get_real("R9"); d->_r5 += _plm->get_real("R10"); d->_r6 += _plm->get_real("R11"); d->_r7 += _pum->get_real("R10"); d->_r8 += _pum->get_real("R11"); d->_r11 += _plm->get_real("R13"); } // Aggiungo anche questi per comodita' futura. // in caso di ditta a regime agricolo // alias: // _r9 mantiene la percentuale (gia' arrotondata!) // _r10 mantiene l'iva detraibile calcolata! d->_r9 = d->_r8 / (d->_r7 + d->_r8); round_al_centesimo(d->_r9); d->_r10 = d->_r6 * d->_r9; d->_r9 *= CENTO; round_al_centesimo(d->_r10); _descr_arr.add(d); } void TLiquidazione_app::describe_viaggio(int month, const char* codatt) { if (!look_lim(month)) return; _DescrItem* d = new _DescrItem(REGVIA); for (int mese = month == 13 ? 13 : 1; mese <= month; mese++) { if (!is_month_ok(mese,month) || !look_plm(mese, codatt)) continue; d->_r0 += _plm->get_real("R5"); // corrispettivi CEE d->_r1 += _plm->get_real("R9"); // corrispettivi misti CEE d->_r2 += _plm->get_real("R6"); // corrispettivi fuori CE d->_r3 += _plm->get_real("R7"); // acquisti CEE d->_r4 += _plm->get_real("R10"); // acquisti misti parte CEE d->_r5 += _plm->get_real("R8"); // acquisti fuori CEE d->_r6 += _plm->get_real("R11"); // acquisti misti parte fuori CEE } // credito di costo precedente (CHECK annuale) d->_r8 = credito_costo_prec(month); // Solita minchiatina dell'arrotondamento alle 1000 lirette se siamo in annuale if (month == 13 || atoi(_year) >= 2000) // CM500314 e CM500315 { round_imposta(d->_r0); round_imposta(d->_r1); round_imposta(d->_r2); round_imposta(d->_r3); round_imposta(d->_r4); round_imposta(d->_r5); round_imposta(d->_r6); round_imposta(d->_r8); } d->_r7 = d->_r4.is_zero() ? ZERO : (d->_r4 * CENTO)/(d->_r4 + d->_r6); d->_r7.round(2); // percentuale d->_r9 = (d->_r1 * d->_r7)/CENTO; if (month == 13) round_imposta(d->_r9); else round_al_centesimo(d->_r9); // Calcola l'iva a debito, visto che servira' anche nel calcolo liquidazione (solo annuale) const real aliva = aliquota_agvia(); const real alcnt = aliva + CENTO; d->_r10 = (d->_r0 + d->_r9) - (d->_r3 + d->_r4 + d->_r8); // base imponibile lorda if (d->_r10.sign() > 0) { // d->_r11 = (d->_r10/(alcnt/CENTO)) * (aliva/CENTO); // iva dovuta d->_r11 = d->_r10 * aliva / alcnt; // iva dovuta if (month == 13) round_imposta(d->_r11); else round_al_centesimo(d->_r11); } _descr_arr.add(d); } void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool describe_pis) // le si passa una tokenstring (o un codatt) e lei, da brava, calcola // cumulando per tutte le attività nominatele // ogni riga riguarda un codiva ma tutti i registri // se il mese e' 13 si guarda tutto l'anno // se si tratta di una sola attività in att. mista evidenziata o servizievole, // stampa solo vendite e corrispettivi // L'ultimo parametro serve per calcolare i PIS (progressivi del periodo successivo) { TToken_string atts(codatt); const TString8 ref(atts.items() == 1 ? codatt : "ALL"); int last = _descr_arr.last(); bool issosp = false; real t0, t1, t2, t3, t4, t5, t26, t27, t28, t29, t30, t31, t32, t33; real rt0, rt1, rt2, rt3, rt4, rt5; real autodafe, autodafe_iva, art40, art40_iva; real diffimp, diffiva, diffincimp, diffinciva; real diffimp_acq, diffiva_acq, diffincimp_acq, diffinciva_acq; bool skip_acq = atts.items() == 1 && _mixed; // descrittore riga autodafe' _DescrItem* ads = NULL; // descrittore riga iva dovuta ag. viaggio' _DescrItem* iads = NULL; // Seleziona la tabella corretta: PIM o PIS e l'identificatore TTable* tab = describe_pis ? _pis : _pim; const word PIM_PIS = describe_pis ? PIS_ROW : PIM_ROW; // questa cazzata serve per far apparire l'intestazione delle colonne // anche se le colonne non ci sono; in tal modo si ottiene una peggior // chiarezza, una peggiore efficienza, una gran rottura di coglioni, // ma risulta identico al dio Sistema. _DescrItem * hea = NULL; _DescrItem * head = NULL; _DescrItem * headi = NULL; _DescrItem * tot = NULL; _DescrItem * totd = NULL; _DescrItem * totdi = NULL; int totpos = 0; // Assoc array per memorizzare i corrispettivi da scorporare. Tali corrispettivi verranno // aggiunti alla fine del ciclo, scorrendo tutte le righe generate. TAssoc_array corr_ann; _CorrItem cx; bool is_key; FOR_EACH_TOKEN(atts, tmpatt) { const TString8 att(tmpatt); tab->zero(); tab->put("CODTAB", _year); // 24-02-2014 partiamo dall'anno giusto! for (int terr = tab->read(_isgteq); terr == NOERR; terr = tab->next()) { _DescrItem* d = NULL; // compute const TString80 codtab = tab->get("CODTAB"); const TString4 anno = codtab.mid(0,4); const TString8 activity= codtab.mid(4,6); const int mese = atoi(codtab.mid(13,2)); const int tipodet = atoi(codtab.mid(20,1)); const TString4 codreg = codtab.mid(10,3); if (!look_reg(codreg)) continue; TString4 codiva = codtab.mid(16,4); codiva.trim(); if (!look_iva(codiva)) continue; tiporeg tipomov = (tiporeg)_reg->get_int("I0"); bool corrisp = _reg->get_bool("B0"); const TString4 tipoiva = _iva->get("S1"); const TString4 other = tab->get("S4"); TToken_string s1(tab->get("S1"), '!'); // Imponibile/iva fatture in ritardo real rit_imp(s1.get(0)); real rit_iva(s1.get(1)); /* Perchè _pim invece di tab ? 17-10-2012 diffimp = _pim->get_real("R26"); diffiva = _pim->get_real("R27"); diffincimp = _pim->get_real("R28"); diffinciva = _pim->get_real("R29"); diffimp_acq = _pim->get_real("R30"); diffiva_acq = _pim->get_real("R31"); diffincimp_acq = _pim->get_real("R32"); diffinciva_acq = _pim->get_real("R33"); */ diffimp = tab->get_real("R26"); diffiva = tab->get_real("R27"); diffincimp = tab->get_real("R28"); diffinciva = tab->get_real("R29"); diffimp_acq = tab->get_real("R30"); diffiva_acq = tab->get_real("R31"); diffincimp_acq = tab->get_real("R32"); diffinciva_acq = tab->get_real("R33"); const bool is_rit= tipodet != 0 && month == 13 && rit_imp != 0.0; //Se fattura in ritardo con tipo detr. != 0 e si sta calcolando l'annuale const tipo_sospensione sosp_imp = _reg->get_bool("B1") ? (tipo_sospensione) _reg->get_int("I9") : nessuna; issosp |= (sosp_imp != nessuna); // Setta il flag di presenza registri in sospensione (qualsiasi tipo: normale, vol_affari, liquidazione) // ACHTUNG! Corrispettivi da ventileer possono ventilare // ad un altro codiva; in tal caso si scrive quello if (corrisp && other.full()) { look_iva(other); codiva = other; } // se e' corrispettivo da ventilare non // scrivo un cannolo ripieno visto che e' stato ventilato if (tipomov == vendita && tipoiva == "VE" && !describe_pis) continue; // se e' il dettaglio di una attivita' mista non stampa // gli acquisti, il perche' losalamadonna if (tipomov == acquisto && skip_acq) continue; // questi non vanno in liquidazione, i totali sono // gia' calcolati altrove if ((tipodet == 1 || tipodet == 3 || tipodet == 9) && !is_rit) continue; // se ha tutti gli importi nulli viene da un annullamento di // progressivi esistenti (achtung fatture con scontrino) if (tab->get_real("R0").is_zero() && tab->get_real("R1").is_zero() && tab->get_real("R2").is_zero() && tab->get_real("R5").is_zero() && tab->get_real("R6").is_zero() && tab->get_real("R26").is_zero() && tab->get_real("R27").is_zero() && tab->get_real("R28").is_zero() && tab->get_real("R29").is_zero() && tab->get_real("R30").is_zero() && tab->get_real("R31").is_zero() && tab->get_real("R32").is_zero() && tab->get_real("R33").is_zero()) continue; if (activity == att && is_month_plain(mese) && _year == anno) { // vedi se c'e' gia' un item corrispondente int i; for(i = last+1; i < _descr_arr.items(); i++) { _DescrItem* wd = (_DescrItem*)&_descr_arr[i]; if (wd->_flags == PIM_PIS && wd->_s0 == ref && wd->_s1 == codiva) { d = wd; break; } if (wd->_flags == TOT_ROW) break; if (wd->_flags == PIM_PIS && wd->_s0 == ref && wd->_s1 > codiva) break; } if (d == NULL) { const bool isfirst = (hea == NULL); if (isfirst) { hea = new _DescrItem(describe_pis ? PIS_HEAD : PIM_HEAD); hea->_f0 = skip_acq; // così non compare nemmeno la colonnina! contento? hea->_f1 = true; _descr_arr.insert(hea, i++); tot = new _DescrItem(TOT_ROW); totpos = _descr_arr.insert(tot, i); } else totpos++; d = new _DescrItem(PIM_PIS); d->_f0 = isfirst; d->_s0 = ref; d->_s1 = codiva; _descr_arr.insert(d, i); } if (tipomov == acquisto) { // Ci sono anche le fatture in ritardo (solo in annuale)! Con tipo detraibilita' 1,3,9 if (sosp_imp != vol_affari) { d->_r4 += is_rit ? rit_imp : tab->get_real("R0"); d->_r5 += is_rit ? rit_iva : tab->get_real("R1"); t4 += is_rit ? rit_imp : tab->get_real("R0"); t5 += is_rit ? rit_iva : tab->get_real("R1"); } // Totalizza anche quelli valevoli per vol. affari. if (sosp_imp != liquidazione) { rt4 += is_rit ? rit_imp : tab->get_real("R0"); rt5 += is_rit ? rit_iva : tab->get_real("R1"); } } else // vendita { is_key = corr_ann.is_key(codiva); cx._totale = 0; _CorrItem& ca = is_key ? (_CorrItem&) corr_ann[codiva] : cx; if (sosp_imp != vol_affari) ca._totale += tab->get_real(tipoiva == "VE" ? "R2" : "R3"); // Se e' codice IVA da Vent. stiamo scorrendo i PIS: va stampato il lordo dei progressivi successivi if (sosp_imp != liquidazione) ca._totale_vf += tab->get_real(tipoiva == "VE" ? "R2" : "R3"); if (!is_key) // se non c'e' lo aggiunge { ca._aliquota = _iva->get_real("R0")/CENTO; // Se e' nuovo setta l'aliquota corr_ann.add(codiva,ca); } // vedi corrispettivi veri e falsi real cvi = tab->get_real("R0"); // imp. totale real cvv = tab->get_real("R1"); // iva totale real cfi = tab->get_real("R13"); // imp. falsi corrispettivi real cfv = tab->get_real("R14"); // iva falsi corrispettivi // MI3404... // Giochiamo sopra la particolarita' che se non e' un registro di corrispettivi // allora se R5 o R6 sono <> 0 significa che trattasi di documento FS, // che pertanto va stornato dal totale corrispettivi. (Cosi' volle Vladimiro) const real ifs(tab->get_real("R5")); // imp. fatture con scontrino const real vfs(tab->get_real("R6")); // iva fatture con scontrino if (!corrisp) { if (sosp_imp != vol_affari) { d->_r2 -= ifs; // tolgo FS dai corrispettivi d->_r3 -= vfs; t2 -= ifs; // idem per i totali t3 -= vfs; } if (sosp_imp != liquidazione) { rt2 -= ifs; rt3 -= vfs; } } if (corrisp) { cvi -= cfi; cvv -= cfv; } if (corrisp) { // usa R0 e R1 visto che la ventilazione e' gia' // stata calcolata if (sosp_imp != vol_affari) { d->_r2 += (cvi /* - ifs */); // tolgo FS dai corrispettivi d->_r3 += (cvv /* - vfs */); d->_r0 += ifs; // aggiungo FS alle vendite d->_r1 += vfs; t2 += (cvi /* - ifs */); // idem per i totali t3 += (cvv /* - vfs */); // non sono molto convinto ma vogliono cio' t0 += ifs; // ...avevo ragione e infatti l'ho cambiato t1 += vfs; } if (sosp_imp != liquidazione) { rt2 += cvi; rt3 += cvv; rt0 += ifs; rt1 += vfs; } } if (!corrisp || (!cfv.is_zero() || !cfi.is_zero())) { real adf, adi; // autofatture non residenti art. 17 real va7i, va7v; // ammontare art 40 c. 5/6/8 real vendi = corrisp ? cfi : tab->get_real("R0"); real vendv = corrisp ? cfv : tab->get_real("R1"); // si scorporano solo per l'annuale, altrimenti // vengono normalmente considerati nelle vendite if (month == 13) { TToken_string kr(tab->get("S0"),'!'); va7i = kr.get(0); va7v = kr.get(1); adf = tab->get_real("R7"); adi = tab->get_real("R8"); } if (sosp_imp != vol_affari) { d->_r0 += vendi - adf - va7i; d->_r1 += vendv - adi - va7v; t0 += vendi /* - adf */; t1 += vendv /* - adi */; } if (sosp_imp != liquidazione) { rt0 += vendi; rt1 += vendv; } autodafe += adf; art40 += va7i; art40_iva += va7v; } } // if (tipomov == vendita) // ci sono anche gli acquisti per cassa! { /* Non voglio piu' il riepilogo delle fatture emesse IVA diff if (!diffimp.is_zero() || !diffiva.is_zero() || !diffimp_acq.is_zero() || !diffiva_acq.is_zero()) { const word id = describe_pis ? PIS_ROW_D : PIM_ROW_D; int j; d = NULL; for (j = totpos + 1; j < _descr_arr.items(); j++) { _DescrItem * wd = (_DescrItem*)&_descr_arr[j]; const bool found = wd->_flags == id && wd->_s0 == ref; if (found && wd->_s1 == codiva) { d = wd; break; } if (wd->_flags == TOT_ROW_D) break; if (found && wd->_s1 > codiva) break; } if (d == NULL) { const bool isfirst = head == NULL; if (isfirst) { head = new _DescrItem(describe_pis ? PIS_HEAD_D : PIM_HEAD_D); _descr_arr.insert(head, j++); head->_f0 = false; head->_f1 = true; head->_f2 = atoi(activity.right(1)); // Tipo attività = 1 (servizi) o 2 (mista) head->_f3 = tipomov; totd = new _DescrItem(TOT_ROW_D); _descr_arr.insert(totd, j); } d = new _DescrItem(id); _descr_arr.insert(d, j); d->_f0 = isfirst; d->_s0 = ref; d->_s1 = codiva; } d->_r26 += diffimp; d->_r27 += diffiva; t26 += diffimp; t27 += diffiva; d->_r30 += diffimp_acq; d->_r31 += diffiva_acq; t30 += diffimp_acq; t31 += diffiva_acq; } */ if (!diffincimp.is_zero() || !diffinciva.is_zero() || !diffincimp_acq.is_zero() || !diffinciva_acq.is_zero()) { const word id = describe_pis ? PIS_ROW_DI : PIM_ROW_DI; d = NULL; int j; for (j = totpos + 1; j < _descr_arr.items(); j++) { _DescrItem* wd = (_DescrItem*)&_descr_arr[j]; const bool found = wd->_flags == id && wd->_s0 == ref; if (found && wd->_s1 == codiva) { d = wd; break; } if (wd->_flags == TOT_ROW_DI) break; if (found && wd->_s1 > codiva) break; } if (d == NULL) { const bool isfirst = headi == NULL; if (isfirst) { headi = new _DescrItem(describe_pis ? PIS_HEAD_DI : PIM_HEAD_DI); _descr_arr.insert(headi, j++); headi->_f0 = false; headi->_f1 = true; headi->_f2 = atoi(activity.right(1)); // Tipo attività = 1 (servizi) o 2 (mista) headi->_f3 = tipomov; totdi = new _DescrItem(TOT_ROW_DI); _descr_arr.insert(totdi, j); } d = new _DescrItem(id); _descr_arr.insert(d, j); d->_f0 = isfirst; d->_s0 = ref; d->_s1 = codiva; } d->_r28 += diffincimp; d->_r29 += diffinciva; t28 += diffincimp; t29 += diffinciva; d->_r32 += diffincimp_acq; d->_r33 += diffinciva_acq; t32 += diffincimp_acq; t33 += diffinciva_acq; } } } } // End of _pim cycle real impc,ivac; // Aggiunge lo scorporo dei corrispettivi const int ditems = _descr_arr.items(); for (int i=last+1;iget_real("R13"); if (!describe_pis && iva74t > ZERO) { if(iads == NULL) iads = new _DescrItem(PIM_ROW); iads->_s0 = "74TER"; // cosi' vollero iads->_s1 = "IVA "; // cosi' vollero iads->_s2 = " dovuta - 74 ter"; // cosi' vollero iads->_r1 += iva74t; t1 += iva74t; rt1 += iva74t; iads->_f0 = false; } } // fine while (codatt) if (!describe_pis && (art40.sign() > 0 || art40_iva.sign() > 0)) { _DescrItem* ads = new _DescrItem(PIM_ROW); ads->_s0 = ref; ads->_s1 = "VA7"; ads->_r0 = art40; ads->_r1 = art40_iva; ads->_f0 = false; _descr_arr.insert(ads, totpos++); } if (!describe_pis && (autodafe.sign() > 0 || autodafe_iva.sign() > 0)) { _DescrItem* ads = new _DescrItem(PIM_ROW); ads->_s0 = ref; ads->_s1 = "AF"; // così vollero, inoltre non è più A35 ma AF, come sul dio sistema ads->_r0 = autodafe; ads->_r1 = autodafe_iva; ads->_f0 = false; _descr_arr.insert(ads, totpos++); } // ag. viaggio: iva dovuta 74 ter la vogliono in mezzo ai progressivi if (iads != NULL) _descr_arr.insert(iads, totpos++); // prepara una bella riga di totali if (tot != NULL) { tot->_r0 = t0; tot->_r1 = t1; tot->_r2 = t2; tot->_r3 = t3; tot->_r4 = t4; tot->_r5 = t5; } if (totd != NULL) { totd->_r26 = t26; totd->_r27 = t27; totd->_r30 = t30; totd->_r31 = t31; } if (totdi != NULL) { totdi->_r28 = t28; totdi->_r29 = t29; totdi->_r32 = t32; totdi->_r33 = t33; totdi->_diff_ven_ap = _diff_ven_ap; totdi->_diff_ven_ap_iva = _diff_ven_ap_iva; totdi->_diff_acq_ap = _diff_acq_ap; totdi->_diff_acq_ap_iva = _diff_acq_ap_iva; } // Totali progressivi da registri, comprensivi dei valori per calcolo vol affari. if (tot != NULL && issosp) // Setta i valori (e la conseguente stampa della riga) solo se presenti registri in sospensione { tot->_r11 = rt0; tot->_r12 = rt1; tot->_r13 = rt2; tot->_r14 = rt3; tot->_s2 = rt4.string(); tot->_s3 = rt5.string(); } // aggiunge dati ptm _DescrItem* t = new _DescrItem(MISC_LIQ); t->_f2 = atoi(_year) > 1997 ? describe_pis : TRUE; //isfirst; // per il form feed o meno alla fine if (!describe_pis) { TToken_string ttm("0|0|0"); const bool annual = month == 13; const int limit = annual ? 13 : month; int m = annual ? month : 1; for (; m <= limit; m++) { if (!is_month_ok(m,month)) continue; FOR_EACH_TOKEN (atts, tmpatt) { const TString8 att(tmpatt); look_plm(m, att); real ad1, ad2; if (tot == NULL) { tot = new _DescrItem(TOT_ROW); _descr_arr.insert(tot, -1); } tot->_r6 += _pom->get_real("R0"); // acq. intracomunitari tot->_r7 += _pom->get_real("R1"); // inded. art 19 tot->_r8 += _pom->get_real("R2"); // IVA su inded. art. 19 t->_r0 += _pom->get_real("R3"); // acq. ammortizz. detr t->_r1 += _pom->get_real("R4"); // IVA acq. ammort. detr t->_r2 += _pum->get_real("R2"); // ammort. detr. 6% t->_r3 += _pum->get_real("R3"); // IVA ammort detr. 6% t->_r4 += _pom->get_real("R5"); // acq. beni rivendita t->_r5 += _pom->get_real("R6"); // IVA acq. beni rivendita t->_r6 += _pom->get_real("R7"); // acq. leasing t->_r7 += _pom->get_real("R8"); // IVA acq. leasing t->_r8 += _pum->get_real("R0"); // cessioni beni ammort. t->_r9 += _pum->get_real("R1"); // IVA su cessioni ammort. t->_r10 += _pum->get_real("R4"); // tot. esenti IVA if (!annual) // Se non siamo in annuale prende il prorata su doc. acq. anno precedente { t->_r12 += _plm->get_real("R14"); t->_r13 = _plm->get_real("R4"); // percentuale prorata anno precedente t->_r14 += _plm->get_real("R15"); t->_r15 = _plm->get_real("R16"); // percentuale prorata 2 anni addietro } t->_r11 += _plm->get_real("R2") - _plm->get_real("R14") - _plm->get_real("R15"); // pro-rata indetraibile sui doc. acq. anno attuale // in caso di liq. annuale prende il totale (tutto R2) ad1 = real(ttm.get(1)); ad2 = real(ttm.get(2)); ad1 += _pom->get_real("R11"); ad2 += _pom->get_real("R12"); ttm.add(_plm->get("R12"), 0); // % pro-rata anno corrente ttm.add(ad1.string(),1); // imp. acq. amm. indetr. ttm.add(ad2.string(),2); // IVA acq. amm. indetr t->_s0 = ttm; t->_f0 = _prorata.percentuale(_year)!=INVALID_PRORATA && (month != 13); // flag per segnalare l'esistenza tot->_r9 += _pom->get_real("R9"); // acq. inded. su ricavi esenti tot->_r10 += _pom->get_real("R10"); // IVA acq. inded. su ricavi esenti // passaggi interni real aipip(tot->_s0); // progressivo ... real aipivp(tot->_s1); // ... (che mazzata sulle palle...) aipip += _pum->get_real("R8"); // acq. inded. per pass. int aipivp += _pum->get_real("R9"); // IVA acq. inded. per pass. int tot->_s0 = aipip.string(); // risbatto ... tot->_s1 = aipivp.string(); // .. // spese generali. real spgnp(t->_s2); // progressivo ... real spgnvp(t->_s3); // ... (che doppia mazzata sulle palle...) spgnp += _pam->get_real("R10"); // spese generali. spgnvp += _pam->get_real("R11"); // IVA spese generali. t->_s2 = spgnp.string(); // risbatto ... t->_s3 = spgnvp.string(); // .. // sospensione imposta: non piu' due palle, ma QUATTRO... // caro Ferdinando... ora son divenute ben OTTO... // grazie all'iva ad esigibilita' differita da pagare/de"TRARRE" TToken_string tt(t->_s4); real aqsi(tt.get(0)); real aqsv(tt.get(1)); real vnsi(tt.get(2)); real vnsv(tt.get(3)); real aqli(tt.get(4)); real aqlv(tt.get(5)); real vnli(tt.get(6)); real vnlv(tt.get(7)); aqsi += _pam->get_real("R6"); aqsv += _pam->get_real("R7"); vnsi += _pam->get_real("R8"); vnsv += _pam->get_real("R9"); aqli += _pam->get_real("R12"); aqlv += _pam->get_real("R13"); vnli += _pam->get_real("R14"); vnlv += _pam->get_real("R15"); tt = ""; tt.add(aqsi.string()); tt.add(aqsv.string()); tt.add(vnsi.string()); tt.add(vnsv.string()); tt.add(aqli.string()); tt.add(aqlv.string()); tt.add(vnli.string()); tt.add(vnlv.string()); t->_s4 = tt; } // while (attivita') } // for (mese ok) // Cazzata orrenda ma necessaria CM500308 if (tot != NULL && issosp) { rt4 += tot->_r7; rt5 += tot->_r8; // Det 1 rt4 += tot->_r9; rt5 += tot->_r10; // Det 3 rt4 += real(tot->_s0); rt5 += real(tot->_s1); // Det 9 tot->_s2 = rt4.string(); tot->_s3 = rt5.string(); } // annual follows in _arr if (month == 13 && ref != "ALL") { // tutte quelle cose che vanno alla liquidazione annuale, come il // calcolo del prorata o del nuovo plafond o .... if (look_pla(codatt)) { real v1 = _pla->get_real("R14"); // Totale imponibile vendite real v2 = _pla->get_real("S1"); // Volume d'affari II attività real ris = v1 + v2; real e1 = _pla->get_real("R1"); // Totale vendite esenti C1 real e2 = _pla->get_real("R2"); // Totale vendite esenti C2 real e3 = _pla->get_real("R3"); // Totale vendite esenti C3 real e4 = _pla->get_real("R15"); // Totale vendite esenti C1A real e5 = _pla->get_real("R16"); // Totale vendite beni ammortizzabili esenti C3 real e6 = _pla->get_real("R17"); // Totale vendite beni ammortizzabili esenti C1A real bam = _pla->get_real("R4"); // Cessione beni ammortizzabili real iaq = _pla->get_real("R11"); // IVA acquisti real ppg = _pla->get_real("R12"); // pro-rata pagato // calcola nuovo prorata per ogni attivita' (miste: 1+2) real pr; if (atoi(_year) > 1997) // Calcolo dal 1998 in poi { const real rsa = ris - (e3-e5) - (e4-e6); const real rsn = rsa - e1; if (!rsa.is_zero()) pr = CENTO - (rsn * CENTO / rsa); // Percentuale di indetraibilita: reciproco della percentuale di detraibilita' } else { if (!ris.is_zero()) pr = e1 * CENTO / ris; } pr.round(0); real co = 0.0; real topay = 0.0; //if (pr != _prorata.current()) { // calcolo conguaglio -- se positivo e' a debito if (pr > ZERO) { topay = (iaq + ppg) * pr / CENTO; round_imposta(topay); } co = topay - ppg; round_imposta(co); } _DescrItem* dd = new _DescrItem(ANNUAL); // MonsterFish: arrotonda alle 1000 LIRE C1,C2,C3,C1A round_imposta(e1); round_imposta(e2); round_imposta(e3); round_imposta(e4); round_imposta(e5); round_imposta(e6); round_imposta(bam); round_imposta(ris); // segna flag prorata if ((e1+e2+e3+e4) > ZERO) dd->_f0 |= IS_PRORATA; dd->_r0 = ris; dd->_r1 = e1; dd->_r2 = pr > ZERO ? pr : ZERO; dd->_r3 = co; dd->_r4 = e2; dd->_r5 = e3; dd->_r6 = topay; dd->_r7 = e4; dd->_r8 = e5; dd->_r9 = e6; t->_arr.add(dd); } } } _descr_arr.add(t); } void TLiquidazione_app::describe_liq(int month, const char* codatts, _DescrItem* di) { if (!_isprint || !_canprint) return; if (!look_lim(month)) return; _DescrItem* d = new _DescrItem(THE_END); // gli diamo la stessa struttura di LIM d->_r0 = _lim->get_real("R0"); // Risultato d->_r1 = _lim->get_real("R1"); // Rimborso d->_r2 = _lim->get_real("R2"); d->_r3 = _lim->get_real("R3"); d->_r4 = _lim->get_real("R4"); d->_r5 = _lim->get_real("R5"); // rettifiche d->_r6 = _lim->get_real("R6"); d->_r7 = _lim->get_real("R14"); d->_r9 = _lim->get_real("R9"); d->_r29 = _lim->get_real("R29"); // fdiffinc_iva_ven d->_r33 = _lim->get_real("R33"); // fdiffinc_iva_acq /* Dal 1998 in poi il conguaglio prorata non va stampato, ma conglobato nell'iva acquisti if (atoi(_year) <= 1997) d->_r10 = _lim->get_real("R7"); // totale conguaglio prorata */ TToken_string tt(80); tt.add(_lam->get_real("R0").string()); // IVA Vendite tt.add(_lam->get_real("R1").string()); // IVA Acquisti tt.add(_lam->get_real("R2").string()); // Credito precedente tt.add(_lam->get_real("R3").string()); // Debito precedente tt.add(_lam->get_real("R4").string()); d->_s0 = tt; d->_s1 = _lim->get_real("R11").string(); // Acc. dec. d->_s2 = _lim->get_real("R12").string(); d->_s3 = _lim->get_real("R13").string(); // descrizione rettifiche if (month < 13) { d->_s4 = _lim->get("S0"); d->_s5 = _lim->get("S1"); d->_s6 = _lim->get("S2"); } d->_r11 = _lim->get_real("R10"); // tasso di interesse (Non arrotondare!) d->_r15 = _lim->get_real("R15"); // Credito utilizzato IVA d->_r16 = _lim->get_real("R16"); // Credito utilizzato F24 d->_r17 = _lim->get_real("R17"); // Variazioni d'imposta d->_r18 = _lim->get_real("R18"); // Imposta non versata d->_r19 = _lim->get_real("R19"); // Crediti speciali d->_f1 = is_first_month(month); // rispettiamo tutte le casistiche per i versamenti se non siamo in visualizzazione // analogamente in Visualizzazione ma solo nel caso dell'annuale. // In tutti gli altri casi va a cercare la delega d->_r8 = (_month == 13 || !_is_visliq) ? _lim->get_real("R8") : versamenti_IVA(_month, "1"); if (_month == 13) { const int anno_prossimo = atoi(_year)+1; if (look_lia(0l, FALSE, anno_prossimo)) d->_r20 = _lia->get_real("R0"); // Credito da riportare all'anno prossimo } // aggiunge eventuale satellite per rimborso infraannuale if (di != NULL) { if (d->_r0.sign() < 0) d->_arr.add(di); else delete di; } if (!_is_visliq) { _DescrItem* dv = describe_deleghe(month); if (dv != NULL) d->_arr.add(dv); } _descr_arr.add(d); } _DescrItem* TLiquidazione_app::describe_deleghe(int month) { _stampa_vers = _stampa_acc = FALSE; if (_lim->get_real("R0") > ZERO) { real iva = _lim->get_real("R0") + _lim->get_real("R14"); if (month == 13) round_imposta(iva); if (iva >= iva_da_riportare(_month)) _stampa_vers = TRUE; } _stampa_acc = (month == 12 && (_freqviva == "M" || (_isbenzinaro && _gest4))) ||(month == 13 && _freqviva == "T" && !(_isbenzinaro && _gest4)); if (!_stampa_vers && !(_stampa_acc && look_del(12,7))) return NULL; _DescrItem* d = new _DescrItem(DELEGA); d->_f0 = 0; //prospettino versamento if (_stampa_vers) //solo se sono a debito if (look_del(month,month == 13 ? 2 : 1)) { if (_del->get_bool("B0")) { //_del->S2 descr. ufficio iva/concessione //_del->S1 descrizione banca d->_s0 = _del->get("S9"); // Cod Ufficio concessione d->_s1 = _del->get("S7"); // Cod ABI d->_s2 = _del->get("S8"); // Cod CAB d->_r0 = _del->get_real("R0"); d->_d0 = _del->get_date("D0"); } // altrimenti lascia tutto in bianco e ci scriveranno i dati a mano } //prospettino acconto if ( (month == 12 && (_freqviva == "M" || (_isbenzinaro && _gest4))) || (month == 13 && _freqviva == "T" && !(_isbenzinaro && _gest4)) ) if (look_del(12,7)) //sia che sia a debito che a credito { d->_s4 = "ACC"; TToken_string t; if (_del->get_bool("B0")) { //_del->S2 descr. ufficio iva/concessione //_del->S1 descrizione banca t.add(_del->get("S9")); // Cod Conc t.add(_del->get("S7")); // Cod ABI t.add(_del->get("S8")); // Cod CAB t.add(_del->get_real("R0").string()); t.add(_del->get("D0")); } d->_s5 = t; } return d; } void TLiquidazione_app::describe_consistence(const char* codatt) { // controlla eventuali condizioni di conflitto con le normative // per la ditta e crea i messaggi appropriati // tutte le condizioni sono valutate sull'esercizio precedente int pryear = atoi(_year) - 1; TString att = codatt; _pla->zero(); *_pla_ditta = get_firm(); *_pla_anno = pryear; *_pla_codatt = att; if (_pla->read() == NOERR) { real va = _pla->get_real("R0"); // 1) consistenza volume d'affari <-> frequenza versamenti // deve essere: trimestrale ammesso solo se < 360.000.000 // per servizi, < 1.000.000.000 per altre imprese // a meno che non sia benzinaro che ha diritto comunque if (_freqviva == "T" && !_isbenzinaro) { bool err = FALSE; if (_isservizio) err = va > SOGLIA_TRIM_SERVIZI; else err = va > SOGLIA_TRIM_ALTRE; if (err) describe_error(TR("Incoerenza volume affari/frequenza versamenti"), att); } } } void TLiquidazione_app::describe_error(const char* err, const char* codatt) { if (!_isprint || !_canprint || (_isregis && _isfinal)) return; _errors.add(new _ErrItem(err, codatt, _nditte->curr().get(NDT_CODDITTA))); } // ---------------------------------------------------------------- // Setrows // ---------------------------------------------------------------- void TLiquidazione_app::set_firm(_DescrItem& d) { TString tim_title(80); tim_title << TR("Liquidazione IVA"); if (d._f1 == 13) tim_title << format(FR(": Riepilogo Annuale %s"), (const char*)_year); else { if (d._s2 == "T") tim_title << format(FR(" del %d° Trimestre %s"), d._f1/3, (const char*) _year); else tim_title << format(FR(" del mese di %s %s"), itom(d._f1), (const char*)_year); } reset_header(); int soh = 1; if (!_isregis) { set_header(soh++,FR("Ditta %s %s@107gData @>@125gPag. @#"), (const char*)(d._s0), (const char*)(d._s1)); set_header(soh++,""); } set_header(soh++,sep); set_header(soh++,FR("%s@102gFrequenza %s"), (const char*)tim_title, d._s2 == "T" ? TR("Trimestrale") : TR("Mensile")); set_header(soh++,sep); set_header(soh++,""); // notify errors if any int j = 0; int i = 0; for (i = 0; i < _errors.items(); i++) { _ErrItem& s = (_ErrItem&)_errors[i]; if (s._att == "ALL" && s._firm == d._s0) { j++; set_row(i+3, "@5g@b*** %s ***@r", (const char*)s._err); } } if (j) set_row(i+3,""); } static int _tipo_attivita_corrente = 0; void TLiquidazione_app::set_att(_DescrItem& d) { // set header TString tim_title(78); TString att_title(48); // Bookmark TString book_name(d._s3); const char flags = (char)d._f3; if (flags == '1') book_name << TR(" (servizi)"); else if (flags == '2') book_name << TR(" (altre)"); else if (flags == 'M') book_name = TR("Riepilogo att. mista"); else if (flags == 'Q') book_name = TR("Riepilogo quater"); if (_firm_bookmark == -1) _firm_bookmark = set_bookmark(d._s1); _att_bookmark = set_bookmark(book_name, _firm_bookmark); tim_title << TR("Liquidazione IVA"); if (d._f1 == 13) { if (d._s4 == "T" && !(d._f2)) // trimestrale e non benzinaro tim_title << format(FR(": Riepilogo Annuale %s"),(const char*)_year); else tim_title << format(FR(": Dichiarazione Annuale %s"),(const char*)_year); } else { if (d._s4 == "T") tim_title << format(FR(" del %d° Trimestre %s"), d._f1/3, (const char*)_year); else tim_title << format(FR(" del mese di %s %s"), itom(d._f1), (const char*)_year); } const char* tipatt = ""; if (d._f0 > 0) tipatt = d._f0 == 1 ? TR("SERVIZI") : TR("ALTRE ATTIVITA'"); if (d._s3.empty()) { att_title = flags == 'M' ? TR("Riepilogo attività mista") : TR("Riepilogo quater"); // att_title << d._s2; } else att_title = format(FR("Attività %s %s %s"), (const char*)(d._s2), (const char*)(d._s3), tipatt); reset_header(); int soh = 1; if (!_isregis) { set_header(soh++,FR("Ditta %s %s@107gData @>@125gPag. @#"), (const char*)(d._s0), (const char*)(d._s1)); set_header(soh++,""); } set_header(soh++,sep); set_header(soh++,"%s@55g%s", (const char*)tim_title, (const char*)att_title); set_header(soh++,sep); set_header(soh++,""); // notify errors if any int j = 0; for (int i = 0; i < _errors.items(); i++) { _ErrItem& s = (_ErrItem&)_errors[i]; if (d._s2 == s._att && s._firm == d._s0) { j++; set_row(i+10, "@5g@b*** %s ***@r", (const char*)s._err); } } if (j) set_auto_ff(TRUE); } void TLiquidazione_app::set_plafond(_DescrItem& d) { // In caso di stampa liquidazione da stampa registri, il prospetto plafond // complessivo va evidenziato in testa; solo nel caso di trimestrali. if (_isregis && _freqviva == "M") return; set_bookmark(TR("Quadro plafond"), _att_bookmark); real r1 = d._r1 + d._r0; real r2 = d._r4 + d._r3; real r3 = d._r7 + d._r6; real disponibile = d._r2 + d._r5 + d._r8; real riporto = disponibile - r1 - r2 -r3; set_print_zero(TRUE); set_row(1,TR("QUADRO RELATIVO ALLA DISPONIBILITA' ED ALL'UTILIZZO MENSILE DEI PLAFONDS")); set_row(2,""); set_row(3,FR("@31gDisponibile@48g%r"), &(disponibile)); set_row(4,TR("Art. 8 1° comma lettere a-b")); set_row(5,FR("Utilizzato all'interno@48g%r"), &(d._r0)); set_row(6,FR("Utilizzato per l'importazione@48g%r"),&(d._r1)); set_row(7,""); set_row(8,TR("Art. 8bis 1° comma")); set_row(9,FR("Utilizzato all'interno@48g%r"), &(d._r3)); set_row(10,FR("Utilizzato per l'importazione@48g%r"), &(d._r4)); set_row(11,""); set_row(12,TR("Art. 9 1° comma")); set_row(13,FR("Utilizzato all'interno@48g%r"), &(d._r6)); set_row(14,FR("Utilizzato per l'importazione@48g%r"), &(d._r7) ); set_row(15,FR("@31gRiporto@48g%r"), &(riporto)); set_print_zero(FALSE); set_auto_ff(); } /* Obsoleto void TLiquidazione_app::set_liqacc_1999(_DescrItem& d) { real r1 = d._r0 + d._r1 + d._r2 + d._r4; //real r2 = d._r5 + d._r10; real r2 = d._r5; //MI2258 (A me sembra una cagata, ma con certa gente non si riesce a parlare) real r3 = r2 + d._r9 + d._r7; if ((d._r3).sign() > 0) r1 += d._r3; else r3 += abs(d._r3); set_row(1,""); set_row(2,""); set_row(3,""); set_row(4,""); set_row(5,FR("@11gCALCOLO ACCONTO SU OPERAZIONI EFFETTUATE")); set_row(6,""); set_row(7,FR("@72gCredito@90gDebito")); set_row(8,""); if (!_isdiffacc) set_row(9,FR("@11gIva sulle operazioni annotate fino al 20 Dicembre@81g%r"), &(d._r0)); else set_row(9,FR("@11gIva sulle operazioni di vendita@81g%r"), &(d._r0)); int i = 10; if (!_isdiffacc) { set_row(i++,FR("@11gIva su operazioni fino al 20 Dic., ma non fatturate@81g%r"), &(d._r1)); set_row(i++,FR("@11gIva su operazioni fino al 20 Dic., ma non annotate@81g%r"), &(d._r2)); } set_row(i,FR("@11gRettifiche iva a debito")); if (d._r3.sign() > 0) set_row(i,"@81g%r", &(d._r3)); i++; set_row(i++,FR("@11gIva chiesta a rimborso@81g%r"), &(d._r4)); set_row(i++,FR("@11gRISULTATO@81g%r"), &r1); if (!_isdiffacc) set_row(i++,FR("@11gIva sugli acquisti annotati fino al 20 Dicembre@64g%r"), &r2); else set_row(i++,FR("@11gIva sulle operazioni di acquisto@64g%r"), &r2); if (d._r6 != ZERO) set_row(i++,FR("@11gmeno perc. di prorata pari a lire %r"), &(d._r6)); set_row(i++, FR("@11gCredito precedente@64g%r"), &(d._r9)); set_row(i, FR("@11gRettifiche iva a credito")); if ((d._r3).sign() <= 0) { real ab = abs(d._r3); set_row(i,"@64g%r", &ab); } i++; set_row(i++,FR("@11gRISULTATO@64g%r"), &r3); if ((d._r8).sign() < 0) { real ab = abs(d._r8); set_row(i++,FR("@23gCREDITO DA EVIDENZIARE@64g%r"), &ab); } else if ((d._r8).sign() > 0 && d._r8 > _ver->get(I_ACCONTOIVA)) set_row(i++,FR("@23gACCONTO DA VERSARE@81g%r"), &(d._r8)); else if ((d._r8).sign() > 0 && d._r8 <= _ver->get(I_ACCONTOIVA)) set_row(i++,FR("@23gACCONTO DA NON VERSARE@64g%r"), &(d._r8)); set_auto_ff(); } */ int TLiquidazione_app::calc_inc_diff(int tipoiva, real& imponibile_diff, real& imposta_diff, real& imponibile_xcas, real& imposta_xcas) const { int flag = 0; imponibile_diff = imposta_diff = imponibile_xcas = imposta_xcas = ZERO; TString limit; limit << "ANNOLIQ=" << _year; if (_month < 13) limit << " MESELIQ=" << _month; TString query; // righe pagamento (TIPOMOV>=3) ed escluse NC! query << "USE IVADIFF KEY 2 SELECT (TIPOMOV>2)&&(TIPOIVA=" << tipoiva << ')' << "\nFROM " << limit << "\nTO " << limit; TISAM_recordset id(query); const TRectype& rec = id.cursor()->curr(); for (bool ok = id.move_first(); ok; ok = id.move_next()) { const real iva = rec.get_real(RMI_IMPOSTA); if (!iva.is_zero()) { const int tipodiff = rec.get_int("TIPODIFF"); const real imp = rec.get_real(RMI_IMPONIBILE); switch (tipodiff) { case 1: imponibile_diff += imp; imposta_diff += iva; break; case 2: imponibile_xcas += imp; imposta_xcas += iva; break; default: break; } flag |= tipodiff; } } return flag; } int TLiquidazione_app::print_acc_diff_xcassa(const _DescrItem& d) { int i = 9; const real& totiva = d._r0; const real ivadiff_inc = d._r29; const real ivadiff_pag = d._r33; real ivaxcas_inc, ivaxcas_pag; if (has_module(ICAUT)) { // Calcolare qui la quota per cassa e toglierla a quella differita gloable } if (!_isdiffacc) { set_row(i++,FR("@11gIva esigibile fino al 20/12@81g%r"), &totiva); if (ivadiff_inc > ZERO) set_row(i++,FR("@11gIVA a liquidazione differita incassata fino al 20/12@75g%r"), &ivadiff_inc); if (ivadiff_pag > ZERO) set_row(i++,FR("@11gIVA a liquidazione differita pagata fino al 20/12@64g%r"), &ivadiff_pag); if (ivaxcas_inc > ZERO) set_row(i++,FR("@11gIVA per cassa incassata fino al 20/12@75g%r"), &ivaxcas_inc); if (ivaxcas_pag > ZERO) set_row(i++,FR("@11gIVA per cassa pagata fino al 20/12@64g%r"), &ivaxcas_pag); } else { set_row(i++,FR("@11gIva sulle operazioni di vendita@81g%r"), &totiva); if (ivadiff_inc > ZERO) set_row(i++,FR("@11gIVA a liquidazione differita incassata@75g%r"), &ivadiff_inc); if (ivadiff_pag > ZERO) set_row(i++,FR("@11gIVA a liquidazione differita pagata@64g%r"), &ivadiff_pag); if (ivadiff_inc > ZERO) set_row(i++,FR("@11gIVA per cassa incassata@75g%r"), &ivadiff_inc); if (ivadiff_pag > ZERO) set_row(i++,FR("@11gIVA per cassa pagata@64g%r"), &ivadiff_pag); } return i; } void TLiquidazione_app::set_liqacc_2000(_DescrItem& d) { set_row(1,""); set_row(2,""); set_row(3,""); set_row(4,""); set_row(5,FR("@11gCALCOLO ACCONTO SU OPERAZIONI EFFETTUATE")); if (!_isdiffacc) set_row(5,TR(" FINO AL 20 DICEMBRE")); set_row(6,""); set_row(7,FR("@72gCredito@90gDebito")); set_row(8,""); if (d._r3 > ZERO) d._r0 += d._r3; // Aggiungi rettifiche a debito int i = print_acc_diff_xcassa(d); if (!_isdiffacc) { set_row(i++,FR("@11gIva esigibile fino al 20/12 di cui non fatturata@81g%r"), &d._r1); set_row(i++,FR("@11gIva esigibile fino al 20/12 di cui non annotata@81g%r"), &d._r2); } if (d._r3 < ZERO) d._r5 -= d._r3; // Aggiungi rettifiche a credito if (!_isdiffacc) set_row(i++,FR("@11gIva che si detrae fino al 20/12@64g%r"), &d._r5); else set_row(i++,FR("@11gIva sulle operazioni di acquisto@64g%r"), &d._r5); set_row(i,FR("@11gIVA a debito/credito per il periodo")); real iva_dov_cre = d._r0 + d._r1 + d._r2 - d._r5; if (iva_dov_cre >= ZERO) set_row(i++,"@81g%r", &iva_dov_cre); else { const real tmp = -iva_dov_cre; set_row(i++,"@64g%r", &tmp); } set_row(i++, FR("@11gDebito/Credito da periodo precedente@64g%r"), &d._r9); set_row(i,FR("@11gIVA Dovuta o a Credito")); const real risultato = iva_dov_cre - d._r9; if (risultato >= ZERO) set_row(i++,"@81g%r", &risultato); else { const real tmp = -risultato; set_row(i++,"@64g%r", &tmp); } // Acconto if (d._r8 < ZERO) { const real ab = abs(d._r8); set_row(i++,FR("@23gCREDITO DA EVIDENZIARE@64g%r"), &ab); } else if (d._r8 > ZERO) { const real acconto_minimo = _ver->get(I_ACCONTOIVA); if (d._r8 > acconto_minimo) set_row(i++,FR("@23gACCONTO DA VERSARE@81g%r"), &d._r8); else set_row(i++,FR("@23gACCONTO DA NON VERSARE@81g%r"), &d._r8); } set_auto_ff(); } /* bool TLiquidazione_app::print_dainc_diff_log(int& rw, int tipoatt, int tipoiva) { TString limit; limit << "ANNOLIQ=" << _year; if (_month < 13) limit << " MESELIQ=" << _month; TString query; query << "USE IVADIFF KEY 2 SELECT (TIPOMOV==1)"; //if (_isregis && tipoiva > 0) query << "&&(TIPOIVA==" << tipoiva << ')'; if (tipoatt > 0) query << " &&(TIPOATT==" << tipoatt << ")"; query << "\nBY TIPOIVA DATAREG"; query << "\nJOIN MOV INTO NUMREG==NUMREG"; query << "\nJOIN CLIFO TO MOV INTO TIPOCF==TIPO CODCF==CODCF"; query << "\nFROM " << limit << "\nTO " << limit; int header = 0; TISAM_recordset id(query); const int rfat = id.items(); if (rfat > 0) { const TRectype& rec = id.cursor()->curr(); bool header_printed = false; for (bool ok = id.move_first(); ok; ok = id.move_next()) { real importo, imponibile, imposta; const TDate nulldate; residuo_da_liquidare(rec.get_long(RMI_NUMREG), rec.get_int(RMI_NUMRIG), nulldate, importo, imponibile, imposta); const int ti = rec.get_int("TIPOIVA"); if (ti != header) { if (ti < 2) set_row(rw++, TR("Fatture da incassare")); else set_row(rw++, TR("Fatture da pagare")); set_row(rw++, "IVA@17gImporto@30gImponibile@49gImposta@57gC/D@74gProt.@80gN. Doc.@89gData reg.@100gCodice@107gRagione sociale"); header = ti; } const TString4 codiva = rec.get("CODIVA"); const int protiva = id.get("MOV.PROTIVA").as_int(); const TString8 numfat = id.get("MOV.NUMDOC").as_string(); const TString16 datafat = rec.get("DATAREG"); const char* tipolog = id.get("TIPODIFF").as_int() == 2 ? TR("C") : TR("D"); const long codcf = id.get("CLIFO.CODCF").as_int(); TParagraph_string clifo(id.get("CLIFO.RAGSOC").as_string(), 25); set_row(rw++, "%s@9g%r@25g%r@41g%r@58g%s@74g%5d@80g%s@89g%s@100g%6ld@107g%s", (const char*)codiva, &importo, &imponibile, &imposta, tipolog, protiva, (const char*)numfat, (const char*)datafat, codcf, clifo.get()); const char* ragsoc2 = clifo.get(); if (ragsoc2 != NULL && strlen(ragsoc2) > 3) set_row(rw++, "@107g%s", ragsoc2); } } return rfat > 0; } bool TLiquidazione_app::print_inc_diff_log(int& rw, int tipoatt, int tipoiva) { TString limit; limit << "ANNOLIQ=" << _year; if (_month < 13) limit << " MESELIQ=" << _month; TString query; query << "USE IVADIFF KEY 2 SELECT (TIPOMOV>2)"; // if (_isregis && tipoiva > 0) query << "&&(TIPOIVA==" << tipoiva << ')'; if (tipoatt > 0) query << " &&(TIPOATT==" << tipoatt << ")"; query << "\nBY TIPOIVA DATAREGP"; query << "\nJOIN MOV INTO NUMREG==NUMREG"; query << "\nJOIN CLIFO TO MOV INTO TIPOCF==TIPO CODCF==CODCF"; query << "\nFROM " << limit << "\nTO " << limit; TISAM_recordset id(query); const int rpag = id.items(); if (rpag > 0) { const TRectype& rec = id.cursor()->curr(); int header = 0; for (bool ok = id.move_first(); ok; ok = id.move_next()) { const int ti = rec.get_int("TIPOIVA"); if (ti != header) { if (ti < 2) set_row(rw++, TR("Fatture incassate")); else set_row(rw++, TR("Fatture pagate")); set_row(rw++, "IVA@17gImporto@30gImponibile@49gImposta@57gC/D@61gPagamento@74gProt.@80gN. Doc.@89gData reg.@100gCodice@107gRagione sociale"); header = ti; } const TString4 codiva = rec.get(RMI_CODIVA); const real importo = rec.get("IMPORTO"); const real imponibile = rec.get(RMI_IMPONIBILE); const real imposta = rec.get(RMI_IMPOSTA); const char* tipolog = id.get("TIPODIFF").as_int() == 2 ? TR("C") : TR("D"); const TString16 datapag = rec.get("DATAREGP"); const int protiva = id.get("MOV.PROTIVA").as_int(); const TString16 numfat = id.get("MOV.NUMDOC").as_string(); const TString16 datafat = rec.get("DATAREG"); const long codcf = id.get("CLIFO.CODCF").as_int(); TParagraph_string clifo(id.get("CLIFO.RAGSOC").as_string(), 25); set_row(rw++, "%s@9g%r@25g%r@41g%r@58g%s@61g%s@74g%5d@80g%s@89g%s@100g%6ld@107g%s", (const char*)codiva, &importo, &imponibile, &imposta, tipolog, (const char*)datapag, protiva, (const char*)numfat, (const char*)datafat, codcf, clifo.get()); const char* ragsoc2 = clifo.get(); if (ragsoc2 != NULL && strlen(ragsoc2) > 3) set_row(rw++, "@107g%s", ragsoc2); } } return rpag > 0; } */ void TLiquidazione_app::set_pim_head(_DescrItem& d) { int r = 1; if (d._flags == PIM_HEAD) set_bookmark(TR("Riepilogo progressivi"), _att_bookmark); else { set_row(r++,""); if (d._flags == PIM_HEAD_D) { set_row(r++, TR("Movimenti a liquidazione differita o per cassa registrati nel periodo")); set_bookmark(TR("Riepilogo progressivi a liquidazione differita"), _att_bookmark); // print_dainc_diff_log(r, d._f2, d._f3); // 15-03-2013 obosleto in quanto stampato su registri? } else if (d._flags == PIM_HEAD_DI) { set_row(r++, TR("Incassi/pagamenti a liquidazione differita o per cassa")); set_bookmark(TR("Riepilogo progressivi a liquidazione differita incassati"), _att_bookmark); // print_inc_diff_log(r, d._f2, d._f3); } else // PIS_HEAD { if (d._flags == PIS_HEAD) { set_row(r++,TR(" Di cui da periodo successivo")); set_row(r++,""); set_bookmark(TR("Riepilogo progressivi successivi"), _att_bookmark); } else if (d._flags == PIS_HEAD_D) { set_row(r++, TR("Fatture a liquidazione differita da incassare")); set_bookmark(TR("Riepilogo progressivi successivi a liquidazione differita"), _att_bookmark); } else if (d._flags == PIS_HEAD_DI) { set_row(r++, TR("Fatture a liquidazione differita incassate")); set_bookmark(TR("Riepilogo progressivi successivi a liquidazione differita incassati"), _att_bookmark); } } set_row(r++,""); } if (d._f0) { if (d._flags == PIM_HEAD || d._flags == PIS_HEAD) { set_row(r++,FR(" Cod.@41gVENDITE@71gCORRISPETTIVI")); set_row(r++,FR(" IVA Descrizione@30gImponibile@49gImposta@63gImponibile@82gImposta")); set_row(r,""); } /* else { set_row(r++,FR(" Cod.@41gVENDITE")); set_row(r++,FR(" IVA Descrizione@30gImponibile@49gImposta")); } */ } else { if (d._flags == PIM_HEAD || d._flags == PIS_HEAD) { set_row(r++,FR(" Cod.@41gVENDITE@71gCORRISPETTIVI@106gACQUISTI")); set_row(r++,FR(" IVA Descrizione@30gImponibile@49gImposta@63gImponibile" "@82gImposta@96gImponibile@115gImposta")); set_row(r,""); } /* else { set_row(r++,FR(" Cod.@41gVENDITE")); set_row(r++,FR(" IVA Descrizione@30gImponibile@49gImposta")); } */ } } void TLiquidazione_app::set_pim(_DescrItem& d) { // succede con le autocazzate non residenti non movimentate eccetera const bool a = (d._r0 + d._r1) == ZERO; const bool b = (d._r2 + d._r3) == ZERO; const bool c = (d._r4 + d._r5) == ZERO; const bool e = (d._r26 + d._r27) == ZERO; const bool f = (d._r28 + d._r29) == ZERO; const bool g = (d._r30 + d._r31) == ZERO; const bool h = (d._r32 + d._r33) == ZERO; if (a && b && c && e && f && g && h) return; int rw = 1; if (d._s1 == "AF") //Il dio sistema colpisce ancora, non va bene A35, ma AF... d._s2 = TR("Artt.17c3/74c1"); // La descrizione non la metto uguale perche' cosi e' piu' fika else if (d._s1 == "VA7") // Sempre per merito del dio sistema ho dovuto aggiungere VA7. d._s2 = TR("Art.40c5/6/8 a.i."); else if (d._s0 == "74TER") rw++; else { look_iva(d._s1); d._s2 = _iva->get("S0"); if (d._s2.len() > 19) d._s2.cut(19); } if (d._flags == PIM_ROW || d._flags == PIS_ROW) { set_row(rw++,"%-4s %s@25g%r@41g%r@58g%r@74g%r@91g%r@107g%r", (const char*)d._s1, (const char*)d._s2, &(d._r0), &(d._r1), &(d._r2), &(d._r3), &(d._r4), &(d._r5)); } else if (d._flags == PIM_ROW_D || d._flags == PIS_ROW_D) { set_row(rw++,"%-4s %s@25g%r@41g%r@91g%r@107g%r", (const char*)d._s1, (const char*)d._s2, &(d._r26), &(d._r27), &(d._r30), &(d._r31)); } else if (d._flags == PIM_ROW_DI || d._flags == PIS_ROW_DI) { set_row(rw++,"%-4s %s@25g%r@41g%r@91g%r@107g%r", (const char*)d._s1, (const char*)d._s2, &(d._r28), &(d._r29), &(d._r32), &(d._r33)); } } void TLiquidazione_app::set_plm_diff(const _DescrItem& d) { int rw = 1; set_row(rw++,""); set_row(rw++,""); if (d._flags == TOT_ROW_D) { set_row(rw++,FR("Totale@25g%r@41g%r@91g%r@107g%r"), &(d._r26), &(d._r27), &(d._r30), &(d._r31)); } else { // Totale incassi/pagamenti ad IVA differita o per cassa set_row(rw++,FR("Totale@25g%r@41g%r@91g%r@107g%r"), &(d._r28), &(d._r29), &(d._r32), &(d._r33)); if (_isannual) { rw++; set_row(rw++,FR("Totale anni prec. @25g%r@41g%r@91g%r@107g%r"), &(d._diff_ven_ap), &(d._diff_ven_ap_iva), &(d._diff_acq_ap), &(d._diff_acq_ap_iva)); } } set_row(rw++,""); } void TLiquidazione_app::set_plm(_DescrItem& d) { int rw = 1; if (!(d._r0.is_zero() && d._r1.is_zero() && d._r2.is_zero() && d._r3.is_zero() && d._r4.is_zero() && d._r5.is_zero())) { set_row(rw++,""); set_row(rw++,""); set_row(rw++,FR("Totale@25g%r@41g%r@58g%r@74g%r@91g%r@107g%r"), &(d._r0), &(d._r1), &(d._r2), &(d._r3), &(d._r4), &(d._r5)); set_row(rw++,""); } if (!(d._r7.is_zero() && d._r8.is_zero())) { set_row(rw++,FR("Totale acquisti indeducibili per art.19@91g%r@107g%r"), &(d._r7), &(d._r8)); } if (! (d._r9.is_zero() && d._r10.is_zero())) { set_row(rw++, FR("Totale acquisti indeducibili su ricavi esenti@91g%r@107g%r"), &(d._r9), &(d._r10)); } real acq_pint(d._s0); real acq_pint_iva(d._s1); if (! (acq_pint.is_zero() && acq_pint_iva.is_zero())) { set_row(rw++, FR("Totale acquisti indeducibili per passaggi interni@91g%r@107g%r"), &acq_pint, &acq_pint_iva); } real tot1 = d._r7 + d._r4 + d._r9 + acq_pint; real tot2 = d._r8 + d._r5 + d._r10 + acq_pint_iva; if (tot1 != d._r4 || tot2 != d._r5) { // i corrispettivi finiscono nelle vendite d._r0 += d._r2; d._r1 += d._r3; d._r2 = ZERO; d._r3 = ZERO; // per ora lascio r2 e r3 anche se sono sempre 0 set_row(rw++, ""); set_row(rw++,FR("Totale Generale IVA@25g%r@41g%r@58g%r@74g%r@91g%r@107g%r"), &(d._r0), &(d._r1), &(d._r2), &(d._r3), &tot1, &tot2); } // Stampa il totale progressivo da registri, comprensivo dei movimenti valevoli per il calcolo vol. affari. real pr_imp(d._s2); real pr_iva(d._s3); if (!(d._r11.is_zero() && d._r12.is_zero() && d._r13.is_zero() && d._r14.is_zero() && pr_imp.is_zero() && pr_iva.is_zero())) { set_row(rw++,""); set_row(rw++,""); set_row(rw++,FR("Totale Prog. da registri@25g%r@41g%r@58g%r@74g%r@91g%r@107g%r"), &(d._r11), &(d._r12), &(d._r13), &(d._r14), &(pr_imp), &(pr_iva)); set_row(rw++,""); } } void TLiquidazione_app::set_pumpam(const _DescrItem& d) { bool printed = FALSE; // d._f1 dice se c'era qualcosa sopra nella stessa pagina real spgn(d._s2); real spgn_iva(d._s3); TToken_string tt(d._s4); // Token String TToken_string dp(d._s0); // Due Palle real aqsi(tt.get(0)); real aqsv(tt.get(1)); real vnsi(tt.get(2)); real vnsv(tt.get(3)); real aqli(tt.get(4)); real aqlv(tt.get(5)); real vnli(tt.get(6)); real vnlv(tt.get(7)); real ammindi(dp.get(1)); real ammindv(dp.get(2)); int row = 5; if (!(aqsi.is_zero() && aqsv.is_zero())) { printed = TRUE; set_row(row++, FR("Acquisti in sospensione di imposta@50g%r@69g%r"), &aqsi, &aqsv); } if (!(vnsi.is_zero() && vnsv.is_zero())) { printed = TRUE; set_row(row++, FR("Vendite in sospensione di imposta@50g%r@69g%r"), &vnsi, &vnsv); } if (!(aqli.is_zero() && aqlv.is_zero())) { printed = TRUE; set_row(row++, FR("IVA ad esigibilità differ. da detrarre nel periodo@50g%r@69g%r"), &aqli, &aqlv); } if (!(vnli.is_zero() && vnlv.is_zero())) { printed = TRUE; set_row(row++, FR("IVA ad esigibilità differ. da pagare nel periodo@50g%r@69g%r"), &vnli, &vnlv); } if (!(d._r8.is_zero() && d._r9.is_zero())) { printed = TRUE; set_row(row++, FR("Cessione beni ammortizzabili@50g%r@69g%r"), &(d._r8), &(d._r9)); } if (! (d._r4.is_zero() && d._r5.is_zero())) { printed = TRUE; set_row(row++, FR("Acquisto beni destinati alla rivendita@50g%r@69g%r"), &(d._r4), &(d._r5)); } if (! (ammindi.is_zero() && ammindv.is_zero())) { printed = TRUE; set_row(row++, FR("Acquisto beni ammortizzabili IVA indetraibile@50g%r@69g%r"), &ammindi, &ammindv); } if (! (d._r0.is_zero() && d._r1.is_zero())) { printed = TRUE; set_row(row++, FR("Acquisto beni ammortizzabili IVA detraibile@50g%r@69g%r"), &(d._r0), &(d._r1)); } if (!(d._r6.is_zero() && d._r7.is_zero())) { printed = TRUE; set_row(row++, FR("Altri beni strumentali acquisiti in leasing@50g%r@69g%r"), &(d._r6), &(d._r7)); } if (!(d._r2.is_zero() && d._r3.is_zero())) { printed = TRUE; // real rn = d._r2 * real(DETRAZIONE_6PERCENTO); // Detrazione obsoleta CM500344 set_row(row++, FR("Acquisto beni soggetti a detrazione (6%%)" "@50g%r@69g%r"), &(d._r2), &(d._r3)); } if (!(spgn.is_zero() && spgn_iva.is_zero())) { printed = TRUE; set_row(row++, FR("Spese generali@50g%r@69g%r"), &spgn, &spgn_iva); } // Prorata... int yy = atoi(_year); if (d._f0) { printed = TRUE; if (yy > 1997) // prorata 1998 { real prc(dp.get(0)); real rprc = CENTO - prc; TString ss(rprc.string()); set_row(row++, FR("%% PRO-RATA (%s%%) ed IVA non detraibile (%s%%)@69g%r"), (const char*) ss, (const char*)prc.string(), &(d._r11)); yy-=2; if (d._r13 != INVALID_PRORATA && d._r12 != ZERO) { rprc = CENTO - d._r13; ss = rprc.string(); set_row(row++, FR("%% PRO-RATA %d (%s%%) ed IVA non detraibile (%s%%)@69g%r"), yy, (const char*) ss, (const char*)d._r13.string(), &(d._r12)); } else if (!_isfinal && d._r13 == INVALID_PRORATA_ASSERT) set_row(row++, FR("Impossibile reperire la %% PRO-RATA relativa all'anno %d."), yy); yy--; if (d._r15 != INVALID_PRORATA && d._r14 != ZERO) { rprc = CENTO - d._r15; ss = rprc.string(); set_row(row++, FR("%% PRO-RATA %d (%s%%) ed IVA non detraibile (%s%%)@69g%r"), yy, (const char*) ss, (const char*)d._r15.string(), &(d._r14)); } else if (!_isfinal && d._r15 == INVALID_PRORATA_ASSERT) set_row(row++, FR("Impossibile reperire la %% PRO-RATA relativa all'anno %d."), yy); } else { real prc(dp.get(0)); set_row(row++, FR("%% PRO-RATA ed IVA non detraibile (%s%%)@69g%r"), (const char*)prc.string(), &(d._r11)); } } // items vari per dichiarazione annuale for (int i = 0; i < d._arr.items(); i++) { _DescrItem& dd = (_DescrItem&)d._arr[i]; printed |= set_annual(dd); } if (printed) { set_bookmark(TR("Altri dati"), _att_bookmark); set_row(1,""); set_row(2,""); set_row(3,FR("ALTRI DATI RELATIVI ALLA DICHIARAZIONE@55gimponibile" "@77gimposta@91gdetrazione")); set_row(4,""); set_row(row++,""); set_row(row,""); } else set_row(1,""); // form feed if (d._f2) set_auto_ff(TRUE); } /* void TLiquidazione_app::set_grand_1999(_DescrItem& d, int& rw) { real& risultato = d._r0; real& rimborso = d._r1; real& cred_cost = d._r2; real& deb_mens = d._r3; real& rettifiche = d._r5; real& detrazioni = d._r6; real& interessi = d._r7; real& versamenti = d._r8; real& vers_int = d._r9; real& conguaglio = d._r10; TToken_string tt(d._s0); real iva_vend(tt.get(0)); real iva_acq(tt.get(1)); real cred_prec(tt.get(2)); real debt_prec(tt.get(3)); real cred_trasf(tt.get(4)); cred_trasf = -cred_trasf; real acc_dec(d._s1); real res_cred(d._s2); real res_debt(d._s3); real rett_debt(0.0); real rett_cred(0.0); real& interesse = d._r11; if (rettifiche.sign() > 0) rett_debt = rettifiche; if (rettifiche.sign() < 0) rett_cred = -rettifiche; set_row(rw++,FR(" @66gCredito@84gDebito")); set_row(rw++,""); set_row(rw++,FR("@11gIva sulle operazioni di vendita@75g%r"), &iva_vend); set_row(rw++,FR("%s@11gRettifiche IVA a debito%s@75g%r"), _is_visliq ? "$[r]" : "", _is_visliq ? "$[n]" : "", &rett_debt); set_row(rw++,FR("%s@11gIva chiesta a rimborso%s@75g%r"), _is_visliq ? "$[r]" : "", _is_visliq ? "$[n]" : "", &rimborso); // conguaglio prorata if (conguaglio.sign() > 0) set_row(rw++,FR("@11gConguaglio pro-rata@75g%r"), &conguaglio); // debito liq. precedente < 50000 if (debt_prec > ZERO) set_row(rw++,FR("@11gDebito da liquidazione precedente@75g%r"), &debt_prec); set_row(rw++,FR("@11gRISULTATO@75g%r"), &res_debt); set_row(rw++,FR("@11gIva ammessa in detrazione@58g%r"), &iva_acq); if (_isannual || d._f1) { set_row(rw++,FR("@11gCredito inizio anno@58g%r"), &cred_prec); if (cred_trasf != ZERO) set_row(rw++,FR("@11gCredito trasferito @58g%r"), &cred_trasf); } else set_row(rw++,FR("@11gCredito precedente@58g%r"), &cred_prec); if (!acc_dec.is_zero()) set_row(rw++,FR("%s@11gVersamento acconto dicembre%s@58g%r"), _is_visliq ? "$[r]" : "", _is_visliq ? "$[n]" : "", &acc_dec); if (!detrazioni.is_zero()) set_row(rw++,FR("@11gUlteriori detrazioni@58g%r"), &detrazioni); set_row(rw++,FR("%s@11gRettifiche IVA a credito%s@58g%r"), _is_visliq ? "$[r]" : "", _is_visliq ? "$[n]" : "", &rett_cred); // versamenti effettuati if (!versamenti.is_zero() && (_month==13 || !_is_visliq)) { set_row(rw++,FR("@11gVersamenti effettuati@58g%r"), &versamenti); } // versamenti integrativi if (!vers_int.is_zero() && !_is_visliq) { set_row(rw++,FR("@11gVersamenti integrativi@58g%r"), &vers_int); } if (conguaglio.sign() < 0) { real cg = conguaglio; cg = -cg; set_row(rw++,FR("@11gConguaglio pro-rata@58g%r"), &cg); } set_row(rw++,FR("@11gRISULTATO@58g%r"), &res_cred); // se non c'e' nulla da versare stampa solo una riga vuota // Serve, non toglierla, stronzo. if (risultato.is_zero()) set_row(rw++,""); else { if (risultato.sign() < 0) { real iva = abs(risultato); if (_isannual || _isriepilogo) round_imposta(iva); set_row(rw++,FR("@23gCREDITO ATTUALE@58g%r"),&iva); if (_is_visliq) { // se chiamata dalla visualizzazione mette 2 righe vuote se non vi sono interessi // poiche' con le rettifiche a credito/debito posso volerle visualizzare set_row(rw++,""); set_row(rw++,""); } } else { if (_month == 13) round_imposta(interessi); real iva = risultato + interessi; if (_isannual || _isriepilogo) round_imposta(iva); if (!iva.is_zero()) { if (!interessi.is_zero()) { set_row(rw++,FR("@23gIVA DOVUTA@75g%r"),&risultato); set_row(rw++,FR("@23gInteresse @33g%6.2r @41g%%@75g%r"),&interesse, &interessi); } else if (_is_visliq) { // vedi sopra... set_row(rw++,""); set_row(rw++,""); } if (iva >= iva_da_riportare(_month)) set_row(rw++,FR("@23gIVA DA VERSARE@75g%r"),&iva); else set_row(rw++,FR("@23gIVA A DEBITO DA NON VERSARE@75g%r"),&iva); } } } if (_is_visliq && _month != 13) { // stampa versamenti (anche 0) ad uso visualizzazione liquidazione IVA rw++; set_row(rw++,FR("@11g$[r]Versamenti effettuati$[n]@58g%r"), &versamenti); set_row(rw++, ""); set_row(rw++, ""); } if (!_is_visliq) { // descrizione rettifiche if (d._s4.not_empty() || d._s5.not_empty()) { rw++; set_row(rw++, FR("@11g@bDESCRIZIONE RETTIFICHE@r")); rw++; if (d._s4.not_empty()) { set_row(rw++, "@11g%t", &(d._s4)); } if (d._s5.not_empty()) { set_row(rw++, "@11g%t", &(d._s5)); } } } } */ void TLiquidazione_app::print_importo(int rw, const char* prompt, real imp, bool red) { int tab = 75; if (imp < ZERO) { imp = -imp; tab = 58; } TString256 str; str << "@11g"; if (red) str << "$[r]"; str << prompt; if (red) str << "$[n]"; str << '@' << tab << "g%r"; set_row(rw, str, &imp); } // d._flags == THE_END void TLiquidazione_app::set_grand_2000(_DescrItem& d, int &rw) { const real risultato = d._r0; // Figuccia lo poteva cambiare, ora tornato const :-) const real& rimborso = d._r1; const real& cred_cost = d._r2; const real& deb_mens = d._r3; const real& rettifiche = d._r5; const real& detrazioni = d._r6; const real& interessi = d._r7; const real& versamenti = d._r8; const real& vers_int = d._r9; real diffinc_iva = d._r29; real diffinc_iva_acq = d._r33; real xcasinc_iva = ZERO; real xcasinc_iva_acq = ZERO; if (has_module(ICAUT) && (!diffinc_iva.is_zero() || !diffinc_iva_acq.is_zero())) { real dimp, diva, ximp, xiva; if (!diffinc_iva.is_zero() && calc_inc_diff(1, dimp, diva, ximp, xiva)) { diffinc_iva = diva; xcasinc_iva = xiva; } if (!diffinc_iva_acq.is_zero() && calc_inc_diff(2, dimp, diva, ximp, xiva)) { diffinc_iva_acq = diva; xcasinc_iva_acq = xiva; } } TToken_string tt(d._s0); real iva_vend(tt.get(0)); real iva_acq(tt.get(1)); real cred_prec(tt.get(2)); real debt_prec(tt.get(3)); real cred_trasf(tt.get(4)); cred_trasf = -cred_trasf; real acc_dec(d._s1); real res_cred(d._s2); real res_debt(d._s3); real rett_debt(0.0); real rett_cred(0.0); real& interesse = d._r11; real& credito_utilizzato_iva = d._r15; real& credito_utilizzato_f24 = d._r16; real& variazioni_imposta = d._r17; real& imposta_non_versata = d._r18; real& crediti_speciali = d._r19; if (rettifiche.sign() > 0) rett_debt = rettifiche; if (rettifiche.sign() < 0) rett_cred =-rettifiche; set_row(rw++,FR(" @66gCredito@84gDebito")); set_row(rw++,""); // Se sono in visualizzazione stampo i due importi separati, altrimenti li sommo if (!_is_visliq) iva_vend += rett_debt; set_row(rw++, FR("@11g@bIVA esigibile@r per il periodo@75g%r"), &iva_vend); if (!diffinc_iva.is_zero()) set_row(rw++,FR("@11g a liquidazione differita@75g%r"), &diffinc_iva); if (!xcasinc_iva.is_zero()) set_row(rw++,FR("@11g per cassa@75g%r"), &xcasinc_iva); if (_is_visliq) set_row(rw++,FR("@11g$[r]Rettifiche IVA a debito$[n]@75g%r"), &rett_debt); // Rettifiche modificabili // Se sono in visualizzazione stampo i due importi separati, altrimenti li sommo if (!_is_visliq) iva_acq += rett_cred; set_row(rw++, FR("@11g@bIVA detraibile@r per il periodo@58g%r"), &iva_acq); if (!diffinc_iva_acq.is_zero()) set_row(rw++,FR("@11g a liquidazione differita@58g%r"), &diffinc_iva_acq); if (!xcasinc_iva_acq.is_zero()) set_row(rw++,FR("@11g per cassa@58g%r"), &xcasinc_iva_acq); if (_is_visliq) set_row(rw++,FR("@11g$[r]Rettifiche IVA a credito$[n]@58g%r"), &rett_cred); real iva_deb_cred = iva_vend - iva_acq + diffinc_iva - diffinc_iva_acq + xcasinc_iva - xcasinc_iva_acq; if (_is_visliq) iva_deb_cred += rett_debt - rett_cred; if (_isannual) iva_deb_cred.round(0); print_importo(rw++, TR("IVA a debito o a credito per il periodo"), iva_deb_cred); rw++; print_importo(rw++, TR("Variazioni d'imposta"), variazioni_imposta, _is_visliq); print_importo(rw++, TR("Imposta non versata"), imposta_non_versata, _is_visliq); if (debt_prec > ZERO) set_row(rw++,FR("@11gDebito o credito da liquidazione precedente@75g%r"), &debt_prec); else { cred_prec -= rimborso; if (cred_prec > ZERO) set_row(rw++,FR("@11gDebito o credito da liquidazione precedente@58g%r"), &cred_prec); } set_row(rw++,FR("%s@11gRimborsi%s@75g%r"), _is_visliq ? "$[r]" : "", _is_visliq ? "$[n]" : "", &rimborso); set_row(rw++,FR("@11gCredito IVA compensabile detratto@58g%r"), &credito_utilizzato_iva); real cre_deb_per = risultato + crediti_speciali + acc_dec + vers_int; if (_month == 13) cre_deb_per += versamenti; print_importo(rw++, TR("IVA dovuta o a credito per il periodo"), cre_deb_per); if (crediti_speciali != ZERO || _is_visliq) set_row(rw++,FR("%s@11gCrediti speciali%s@58g%r"), _is_visliq ? "$[r]" : "", _is_visliq ? "$[n]" : "", &crediti_speciali); if (_freqviva == "T" && !interessi.is_zero()) set_row(rw++,FR("@11gInteressi dovuti per liquidazioni trimestrali %6.2r%%@75g%r"),&interesse, &interessi); else if (_is_visliq) rw++; if (!acc_dec.is_zero()) set_row(rw++,FR("%s@11gAcconto versato%s@58g%r"), _is_visliq ? "$[r]" : "", _is_visliq ? "$[n]" : "", &acc_dec); else if (_is_visliq) rw++; // versamenti effettuati if (!versamenti.is_zero() && (_month==13 || !_is_visliq)) set_row(rw++,FR("@11gVersamenti effettuati@58g%r"), &versamenti); else if (_is_visliq) rw++; // versamenti integrativi if (!vers_int.is_zero() && !_is_visliq) set_row(rw++,FR("@11gVersamenti integrativi@58g%r"), &vers_int); else if (_is_visliq) rw++; const real iva = risultato + interessi; if (iva > ZERO) { if (iva >= iva_da_riportare(_month)) set_row(rw++,FR("@23gIMPORTO DA VERSARE@75g%r"),&iva); else set_row(rw++,FR("@23gIMPORTO DA NON VERSARE@75g%r"),&iva); } else { if (_isannual) { const real& credito = d._r20; if (credito > ZERO) set_row(rw++,FR("@11gCREDITO RIPORTATO NELL'ANNO SUCCESSIVO@58g%r"), &credito); } if (_is_visliq) rw++; } if (_is_visliq && _month != 13) { rw++; set_row(rw++,FR("@11g$[r]Descrizione$[n]")); // stampa versamenti (anche 0) ad uso visualizzazione liquidazione IVA rw++; set_row(rw++,FR("@11g$[r]Versamenti effettuati$[n]@58g%r"), &versamenti); set_row(rw++, ""); set_row(rw++, ""); } if (!_is_visliq) { // descrizione rettifiche if (d._s6.not_empty()) { rw++; set_row(rw++, FR("@11g@bDESCRIZIONE RETTIFICHE@r")); rw++; if (d._s6.not_empty()) { set_row(rw++, "@11g%t", &(d._s6)); } } } } static void imp2string(const real& n, TString& str) { if (!n.is_zero()) { const TCurrency c(n); str = c.string(true); str.right_just(15); } else str.spaces(15); } void TLiquidazione_app::set_iva_succ(int& rw) { TString query; query << "USE IVADIFF KEY 2 SELECT (BETWEEN(DATAREG,#DAL,#AL))&&(BETWEEN(DATAREGP,0,#AL))" << "\nFROM ANNOLIQ=" << _year; TISAM_recordset id(query); const TDate da_datareg(1, 1, atoi(_year)); const TDate a_datareg(31, 12, atoi(_year)); id.set_var("#DAL", da_datareg); id.set_var("#AL", a_datareg); TImporto ven_diff, ven_xcas, acq_xcas; long cur_numreg = 0; int cur_tipodif = 0; int cur_tipoiva = 0; for (bool ok = id.move_first(); ok; ok = id.move_next()) { const long numreg = id.get(RMI_NUMREG).as_int(); if (numreg != cur_numreg) { cur_numreg = numreg; cur_tipodif = id.get("TIPODIFF").as_int(); cur_tipoiva = id.get("TIPOIVA").as_int(); } const char sezione = id.get("SEZIONE").as_string()[0]; const TImporto imp(sezione, id.get(RMI_IMPONIBILE).as_real()); if (!imp.is_zero()) { if (cur_tipoiva == 1) // Vendite { if (cur_tipodif == 1) ven_diff += imp; else ven_xcas += imp; } else acq_xcas += imp; } } if (!ven_diff.is_zero() || !ven_xcas.is_zero() || !acq_xcas.is_zero()) { set_row(rw++,FR("@11g@bOPERAZIONI EFFETTUATE NELL'ANNO CON IMPOSTA ESIGIBILE NEGLI ANNI SUCCESSIVI@r")); const real vd = ven_diff.valore(); const real vc = ven_xcas.valore(); const real vt = vc+vd; const real at = acq_xcas.valore(); set_row(rw++, "Totale vendite con IVA esigibile negli anni successivi@66g%r", &vt); set_row(rw++, "Di cui con IVA per cassa@66g%r", &vc); set_row(rw++, "Totale acquisti con IVA detraibile negli anni successivi@66g%r", &at); set_row(rw++, "Di cui con IVA per cassa@66g%r", &at); } } void TLiquidazione_app::set_grand(_DescrItem& d) { int rw = 1; if (_isannual) // Stampa annuale evidenzia importi esigibili l'anno dopo set_iva_succ(rw); set_bookmark(TR("Riepilogativo liquidazione"), _firm_bookmark); set_row(rw++,""); set_row(rw++,""); set_row(rw++,""); set_row(rw++,""); set_row(rw++,FR("@11g@bCALCOLO LIQUIDAZIONE D'IMPOSTA@r")); /* const bool new_print = atoi(_year) >= 2000; if (new_print) set_grand_2000(d, rw); else set_grand_1999(d, rw); */ set_grand_2000(d, rw); // rapportini per rimborso infraannuale // non si stampano se la stampa serve per la visualizz. // solo in st.di prova in coda ai registri deve scendere // il prospetto di rimborso // sempre (cioe' in bollato e in prova) deve scendere // il prospettino versamento if (d._arr.items() > 0 && !_is_visliq) { for (int i = 0; i < d._arr.items(); i++) { _DescrItem& di = (_DescrItem&)d._arr[i]; if (di._flags == RIMBORSO) { if (!_isregis || (_isregis && !_isfinal)) { set_print_zero(TRUE); set_row(rw++,""); set_row(rw++,""); set_bookmark(TR("Prospetto di rimborso"), _firm_bookmark); set_row(rw++, TR(" PROSPETTO DI RIMBORSO")); if (di._f0) { // esenti e non imponibili set_row(rw++,""); set_row(rw++,TR("1) Soggetto con quota di operazioni esenti e non" " imponibili superiore al 25%%")); real perc = di._r0 * CENTO / di._r1; perc.round(0); TString sep(strlen(REAL_PICTURE)+2); sep.fill('-'); set_row(rw++,""); set_row(rw++,FR("@26gTotale operazioni esenti e non imp.@66g%r"), &(di._r0)); set_row(rw++,FR("@66g%t x 100 = %3r%%"), &sep, &perc); set_row(rw++,FR("@26gVolume di affari lordo@66g%r"), &(di._r1)); set_row(rw++,""); } if (di._f1) { set_row(rw++,""); set_row(rw++,TR("2) Soggetto con acquisti ad aliquota media " "superiore a quella delle vendite")); TString sep(strlen(REAL_PICTURE)+2); sep.fill('-'); set_row(rw++,""); set_row(rw++,FR("@26gTotale imposte sugli acquisti@66g%r"), &(di._r5)); set_row(rw++,"@66g%t x 100 = %5.2r%%", &sep, &(di._r7)); set_row(rw++,FR("@26gTotale imponibili sugli acquisti@66g%r"), &(di._r3)); set_row(rw++,""); set_row(rw++,FR("@26gTotale imposte sulle vendite@66g%r"), &(di._r4)); set_row(rw++,"@66g%t x 100 = %5.2r%%", &sep, &(di._r6)); set_row(rw++,FR("@26gTotale imponibili sulle vendite@66g%r"), &(di._r2)); } set_print_zero(FALSE); } } // prospettino versamento else if (di._flags == DELEGA) { int rr = rw; int cont = 10; if (di._s4 == "ACC") { TToken_string ac(di._s5); if (!ac.empty_items() && _stampa_vers) cont = 14; } if (rw < (printer().formlen() - cont)) rw = printer().formlen() - cont; for (int i = rr; i < rw; i++) set_row(i,""); set_bookmark(TR("Riepilogo versamenti"), _firm_bookmark); TString dt = di._d0.string(); TString vr; imp2string(di._r0, vr); if (di._s4 == "ACC") // Acconto { TToken_string ac(di._s5); if (!ac.empty_items()) { TString dt (ac.get(4)); real app (ac.get(3)); TString vr; imp2string(app, vr); TString con (ac.get(0)); TString abi (ac.get(1)); TString cab (ac.get(2)); set_row(rw++, TR("- ACCONTO DICEMBRE -")); set_row(rw, FR(" Versamento di %s effettuato il %s"), (const char*)vr, (const char*)dt); set_row(rw++, FR("@68gCod Conc.: %3s"),(const char*)con); set_row(rw++, FR("@68gCod. ABI: %5s Cod. CAB o Cod. Dipendenza: %5s"),(const char*)abi,(const char*)cab); } } if (_stampa_acc && _stampa_vers) set_row(rw++, "- SALDO -"); if (_stampa_vers) { set_row(rw, FR(" Versamento di %s effettuato il %s"), (const char*)vr, (const char*)dt); set_row(rw++, FR("@68gCod Conc.: %3s"),(const char*)di._s0); set_row(rw++, FR("@68gCod. ABI: %5s Cod. CAB o Cod. Dipendenza: %5s"),(const char*)di._s1,(const char*)di._s2); } } } } if (!_is_visliq) set_auto_ff(TRUE); else set_auto_ff(FALSE); _firm_bookmark = -1; } bool TLiquidazione_app::set_annual(_DescrItem& d) { // chiamata internamente a set_pims bool ret = FALSE; int row = get_maxrow()+1; if (row == 1) row = 4; if (d._f0 & IS_PRORATA) { // non lo ha stampato prima se annuale, perche' Vladimiro il nefido // pretende l'assurdo aggiornamento della perc. a quella nuova const int year_int = atoi(_year); row++; set_row(++row, year_int > 1997 ? TR("CALCOLO DELLA PERCENTUALE DI DETRAIBILITA'") : TR("CALCOLO DELLA PERCENTUALE DI INDETRAIBILITA'")); row++; set_bookmark(TR("Calcolo pro-rata"), _att_bookmark); ret = TRUE; set_print_zero(TRUE); set_row(row++,""); if (year_int > 1997) { const real perc_det = CENTO - d._r2; const TString16 s1 = perc_det.string(); const TString16 s2 = d._r2.string(); set_row(row++, FR("%% PRO-RATA (%s%%) ed IVA non detraibile (%s%%)@69g%r"), (const char*)s1, (const char*)s2, &(d._r6)); set_row(row++,FR("C1 - Operazioni esenti escluse da nr. 1 a 9 e 11 art. 10 @69g%r"), &(d._r1)); set_row(row++,FR("C2 - Operazioni esenti di cui nr. 11 art. 10 @69g%r"), &(d._r4)); set_row(row++,FR("C3 - Operazioni esenti da nr. 1 a 9 art. 10 @69g%r"), &(d._r5)); set_row(row++,FR("@6gdi cui cessione beni ammortizzabili @69g%r"), &(d._r8)); set_row(row++,FR("C1A - Operazioni esenti di cui all'art.10 n. 27 quinquies @69g%r"), &(d._r7)); set_row(row++,FR("@6gdi cui cessione beni ammortizzabili @69g%r"), &(d._r9)); set_row(row++,FR("Volume d'affari @69g%r"), &(d._r0)); set_row(row++,FR("Detraibilità@69g%r%%"), &perc_det); } else { set_row(row++, FR("%% PRO-RATA ed IVA non detraibile (%s%%)@69g%r"), (const char*)(d._r2.string()), &(d._r6)); set_row(row++,FR("B1 - Operazioni esenti, escluse da nr. 1 a 9 e 11 art. 10 @69g%r"), &(d._r1)); set_row(row++,FR("B2 - Operazioni esenti, di cui nr. 11 art. 10 @69g%r"), &(d._r4)); set_row(row++,FR("B3 - Operazioni esenti da nr. 1 a 9 art. 10 @69g%r"), &(d._r5)); set_row(row++,FR("Volume d'affari - B3 @69g%r"), &(d._r0)); set_row(row++,FR("Indetraibilità@69g%r%%"), &(d._r2)); } set_print_zero(FALSE); } return ret; } void TLiquidazione_app::set_ventila(_DescrItem& d) { if (d._arr.items() == 0 || d._r0.is_zero()) return; set_bookmark(TR("Prospetto ventilazione"), _att_bookmark); set_row(1,FR("@54gPROSPETTO VENTILAZIONE")); set_row(2,""); set_row(3,""); set_row(4,FR("@10gTotale acquisti destinati alla rivendita@55g%r"), &(d._r0)); set_row(5,FR("@10gTotale dei corrispettivi da ventilare@55g%r"), &(d._r1)); set_row(6,FR("@10gMoltiplicatore@59g%3.9r"),&(d._r2)); set_row(7,""); set_row(8,FR("@10gCod.")); set_row(9,FR("@10gIVA@17gDescrizione@48gAcquisti" "@65gImponibile vendite@89gImposta vendite")); set_row(10,""); int row = 11; real t1, t2, t3; TString80 s0; int i; for(i = 0; i < d._arr.items(); i++) { _vDesc& vd = (_vDesc&)d._arr[i]; look_iva(vd._codiva); s0 = _iva->get("S0"); s0.cut(23); set_row(row+i,"@8g%5s@17g%-23s@41g%r@68g%r@89g%r", (const char*)vd._codiva, (const char*)s0, &(vd._acq), &(vd._vnd), &(vd._viv)); t1 += vd._acq; t2 += vd._vnd; t3 += vd._viv; } set_row(row+i+1,""); set_row(row+i+2,FR("@10gTotale@41g%r@68g%r@89g%r"), &t1, &t2, &t3); set_auto_ff(TRUE); } static void real2string(const real& r, TString& str) { TCurrency cur(r); str = cur.string(TRUE); } void TLiquidazione_app::set_regagr(_DescrItem& d) { set_print_zero(TRUE); const bool is1998 = atoi(_year) >= 1998; CHECK(is1998 == _isagr98, "Mucca pazza!"); real& agr_1 = d._r0; real& agr_2 = d._r1; real& agr_3 = d._r2; real& agr_4 = d._r3; real& agr_5 = d._r4; real& agr_6 = d._r5; real& agr_7 = d._r6; real& agr_1i = d._r7; real& agr_2i = d._r8; real& pdetr = d._r9; real& ivadt = d._r10; real& iva_detIA = d._r11; real ara = agr_5 + agr_6; real arn = agr_3 + agr_4; real agr_ven = agr_1 + agr_2; real ivadt_amm = agr_3 + ivadt + (is1998 ? iva_detIA : agr_1); set_bookmark(TR("Prospetto regime agricolo"), _att_bookmark); int r = 1; set_row(r++,FR("@50gPROSPETTO REGIME AGRICOLO")); set_row(r++,""); // percentuale detraibilita' set_row(r++, FR("Iva vendite beni I parte Tabella A @56g%r"),&agr_1); set_row(r++, ""); set_row(r++, FR("Iva vendite beni diversi da I parte Tabella A @56g%r"),&agr_2); set_row(r++, ""); set_row(r++, FR("Totale iva sulle operazioni di vendita @56g%r"), &agr_ven); set_row(r++, ""); set_row(r++, FR("Iva acquisti in regime agricolo@56g%r"),&ara); set_row(r++, ""); set_row(r++, FR("Iva acquisti per operazioni diverse I parte Tabella A@56g%r"),&arn); set_row(r++, FR("... di cui beni ammortizzabili@56g%r"),&agr_4); set_row(r++, ""); set_row(r++, FR("Iva acquisti ad uso promiscuo@56g%r"),&agr_7); TString dn,riga; if (agr_1i != ZERO) { real2string(agr_1i, riga); dn << riga << " + "; } real2string(agr_2i, riga); dn << riga; int ln = max(riga.len(),dn.len()) + 2; int corr = ln % 2 == 0 ? 0 : 1; TString middle(ln); middle.fill('-'); int xl = 71 - riga.len()/2; int times_sign = xl + ln/2 + 3; // per allineare i segni moltiplicativi middle << "@" << times_sign << "gx 100 = " << pdetr.string(".") << " %"; set_row(r++, ""); set_row(r++, "@56g%r",&agr_2i); riga.format(FR("Percentuale delle operazioni diverse@%dg%%s"),xl - corr - ln/2); set_row(r++, riga, (const char*)middle); corr = dn.len() % 2 == 0 ? 0 : 1; riga.format("@%dg%%s",xl - corr - dn.len()/2); set_row(r++, riga, (const char*)dn); real2string(agr_7, riga); dn = "100"; ln = max(riga.len(),dn.len()) + 2; xl = 71 - riga.len()/2; corr = ln % 2 == 0 ? 0 : 1; middle.fill('-',ln); middle << "@" << times_sign << "gx " << pdetr.string("."); middle << " = " << TCurrency(ivadt).string(TRUE); set_row(r++, ""); set_row(r++, "@56g%r", &agr_7); riga.format(FR("Iva ammessa in detrazione sugli acquisti promiscui@%dg%%s"),xl - corr - ln/2); set_row(r++, riga, (const char*)middle); corr = dn.len() % 2 == 0 ? 0 : 1; riga.format("@%dg%%s",xl - corr - dn.len()/2); set_row(r++, riga, (const char*)dn); set_row(r++, ""); if (is1998) { set_row(r++, FR("Iva ammessa in detrazione I parte tabella A@56g%r"),&iva_detIA); set_row(r++, ""); } set_row(r++, FR("Totale iva ammessa in detrazione@56g%r"),&ivadt_amm); // Last pain... TArray& agr_array = d._arr; const int pia_items = agr_array.items(); if (pia_items) // Se non siamo ancora nel 1998 questo vale 0, ossia non vi sono items. { real t1,t2; // Totale imponibile/imposta TString des; // Descrizione codice iva ordinario real al; // Aliquota IVA r+=2; // Stampa l' intestazione... set_row(r++,FR(" Codice IVA@45gAliquota IVA@73gCodice IVA@88gAliquota IVA")); set_row(r++,FR(" Ordinario@45gOrdinaria@61gImponibile@73gCompensazione@88gCompensazione@108gImposta")); set_row(r++,""); for (int i=0; iget("S0"); des.cut(25); al = _iva->get_real("R0"); set_row(r,"%4s %-25s@48g%s %%", (const char*) di._s0, (const char*) des, al.string("#@,@@")); set_row(r,"@56g%r@75g%4s",&di._r0, (const char*)di._s1); look_iva(di._s1); al = _iva->get_real("R0"); set_row(r++,"@92g%s %%@100g%r", al.string("#@,@@"), &di._r1); t1 += di._r0; t2 += di._r1; } // ... ed il totale minchiativo r++; set_row(r++,FR("Totale@56g%r@100g%r"),&t1,&t2); } set_auto_ff(TRUE); set_print_zero(FALSE); } void TLiquidazione_app::set_viaggio(_DescrItem& d) { // the longest & stronzest // Nel corso della scrittura di questa funzione // Berlusconi + Fini + Bossi hanno vinto le elezioni // ... lungo commento cancellato real& corr_CEE = d._r0; real& corr_misCEE = d._r1; real& corr_noCEE = d._r2; real& acq_CEE = d._r3; real& acq_misCEE = d._r4; real& acq_noCEE = d._r5; real& acq_misnoCEE = d._r6; real& perc_r = d._r7; real& cred_cos = d._r8; real& ivm = d._r9; real tc = (corr_CEE + ivm); real ta = (acq_CEE + acq_misCEE); real& bi = d._r10; real& dovuta = d._r11; real tcc = corr_CEE + corr_noCEE + corr_misCEE; real tco = acq_CEE + acq_noCEE + acq_misCEE + acq_misnoCEE; real tma = acq_CEE + acq_misCEE; set_print_zero(TRUE); set_bookmark(FR("Prospetto 74 ter"), _att_bookmark); set_row(1,""); set_row(2,FR("@54gRIEPILOGO 74 TER")); set_row(3,""); set_row(4,FR("Ammontare dei corrispettivi relativi a viaggi eseguiti" " interamente nella CEE .....................@100g%r"), &(corr_CEE)); set_row(5,FR("Ammontare dei corrispettivi relativi a viaggi misti (dentro" " e fuori CEE) ......................... @100g%r"), &(corr_misCEE)); set_row(6,FR("Ammontare dei corrispettivi relativi a viaggi eseguiti" " interamente fuori CEE ..................... @100g%r"), &(corr_noCEE)); set_row(7,""); set_row(8,FR("@56gTotale corrispettivi@100g%r"), &tcc); set_row(9,""); set_row(10,FR("Ammontare dei costi relativi a viaggi interamente" " svolti nella CEE ............................... @100g%r"), &(acq_CEE)); set_row(11,FR("Ammontare dei costi relativi a viaggi misti (per la" " parte CEE) ................................... @100g%r"), &(acq_misCEE)); set_row(12,FR("Ammontare dei costi relativi a viaggi interamente" " svolti fuori CEE ............................... @100g%r"), &(acq_noCEE)); set_row(13,FR("Ammontare dei costi relativi a viaggi misti (per la" " parte fuori CEE) .............................@100g%r"), &(acq_misnoCEE)); set_row(14,""); set_row(15,FR("@64gTotale costi@100g%r"), &tco); set_row(16,""); set_row(17,TR("DETERMINAZIONE CORRISPETTIVI IMPONIBILI " "RELATIVI A VIAGGI MISTI")); set_row(18,""); // la bella frazioncina della percentuale di ripartizione TString tmp; real2string(acq_misCEE, tmp); TString up = tmp; up << " x 100"; TString dn = tmp; real2string(acq_misnoCEE, tmp); dn << " + " << tmp; int ln = max(up.len(), dn.len()) + 2; TString den(ln); den.fill('-'); up.center_just(ln); dn.center_just(ln); // la bella frazioncina degli imponibili viaggi misti TString tmp2; real2string(corr_misCEE, tmp2); TString up2 = tmp2; const TString16 perc_r_str = perc_r.string("###,@@"); up2 << " x" << perc_r_str; TString dn2 = "100"; int ln2 = max(up2.len(), 3) + 2; TString den2(ln2); den2.fill('-'); up2.center_just(ln2); dn2.center_just(ln2); // la gran frazionazza centrata e stupenda int tot = 35 + ln + ln2; int rem1 = (100 - tot)/2; if (rem1 < 0) rem1 = 0; int pos1 = rem1 + 13; int rem2 = pos1+ den.len() + 11; int pos2 = rem2 + 20; set_row(19,format("@%dg%%t@%dg%%t", pos1, pos2), &up, &up2); set_row(20,format(FR("@%dgPerc. rip. = %%t = %%t; @%dg" "Imp. viaggi misti = %%t = @100g%%r"), rem1, rem2), &den, &perc_r_str, &den2, &ivm); set_row(21,format("@%dg%%t@%dg%%t", pos1, pos2), &dn, &dn2); real tmr = corr_CEE + ivm; // whew, come dicono su Topolino real2string(corr_CEE, tmp); up = "("; up << tmp << " + "; real2string(ivm, tmp); up << tmp << ")"; den.fill('.',59-up.len()); set_row(23,FR("Ammontare dei corrispettivi imponibili@40g%t %t@100g%r"), &up, &den, &tmr); // se e' l'annuale non ha senso altro if (d._f1) return; real2string(acq_CEE, tmp); up = "("; up << tmp << " + "; real2string(acq_misCEE, tmp); up << tmp << ")"; den.fill('.',59-up.len()); set_row(24,FR("Ammontare dei costi deducibili@40g%t %t@100g%r"), &up, &den, &tma); den.fill('.',60); set_row(25,FR("Credito di costo precedente @40g%t@100g%r"), &den, &(cred_cos)); real2string(tmr, tmp); up = "["; up << tmp << " - ("; real2string(tma, tmp); up << tmp << " + "; real2string(d._r8, tmp); up << tmp << ")]"; den.fill('.',59-up.len()); set_row(26,FR("Base imponibile lorda@40g%t %t@100g%r"), &up, &den, &bi); set_row(27,""); if (bi > ZERO) { const real aliva = aliquota_agvia(); const real alcnt = aliva + CENTO; real2string(bi, tmp); up = tmp; up << " x" << aliva.string("###,@@"); dn = alcnt.string("###,@@"); ln = max(up.len(), 3) + 2; den.fill('-',ln); up.center_just(ln); dn.center_just(ln); tmp.fill('.', 59 - den.len()); set_row(28,"@40g%t",&up); set_row(29,FR("IVA A DEBITO@40g%t %t@100g%r"), &den, &tmp, &dovuta); set_row(30,"@40g%t", &dn); } else if (bi.sign() < 0) { bi = abs(bi); set_row(28,""); set_row(29,FR("CREDITO DI COSTO DA RIPORTARE@100g%r"), &bi); } set_print_zero(FALSE); set_auto_ff(TRUE); } void TLiquidazione_app::set_acconto_p(_DescrItem& d) { const char* errmsg[3] = { {TR("manca la tabella risultati liquidazione per l'anno corrente")}, {TR("manca la tabella risultati liquidazione per l'anno precedente")}, {TR("manca la tabella dichiarazione annuale per l'anno precedente")}}; set_row(1,"%t@7g%t",&(d._s0), &(d._s1)); if (d._f2) set_row(1,"@50g@b*** %s ***@r", errmsg[d._f2 -1]); else { if (d._f0) // base anno in corso { if (d._f1) // stampa base di calcolo { set_row(1,"@58g%r@74g%r@96g%r@122g%s", &(d._r3), &(d._r2), &(d._r1), d._f3 ? "Si" : "No"); } else set_row(1,"@62g%r@91g%s", &(d._r1), d._f3 ? "Si" : "No"); } else //metodo storico { if (d._f1 && (d._r0).sign()>0) // stampa base di calcolo set_row(1,"@58g%r@88g%r", &(d._r0), &(d._r1)); else set_row(1,"@87g%r",&(d._r1)); } } } void TLiquidazione_app::set_acchead_p(_DescrItem& d) { reset_header(); set_header(1,FR("Gestione IVA@107gData @>@125gPag. @#")); set_header(3,sep); if (d._f0) // base anno in corso { set_header(2,FR("@40gCALCOLO ACCONTI IVA DICEMBRE %s " "(base anno in corso)"), (const char*) _year); if (d._f1) // stampa base calcolo { set_header(4,FR("@58g------- Base di calcolo -------")); set_header(5,FR("Ditta@7gDenominazione@62gDebito@78gCredito" "@94gACCONTO calcolato@115gLiq. differita")); set_header(6,sep); set_header(7,""); } else { set_header(4,FR("Ditta@7gDenominazione@60gACCONTO calcolato" "@84gLiq. differita")); set_header(5,sep); set_header(6,""); } } else { set_header(2,FR("@40gCALCOLO ACCONTI IVA DICEMBRE %s"), (const char*) _year); set_header(5,sep); set_header(6,""); if (d._f1) set_header(4,FR("Ditta@7gDenominazione@58gBase di calcolo" "@86gACCONTO calcolato")); else set_header(4,FR("Ditta@7gDenominazione@85gACCONTO calcolato")); } } // --------------------------------------------------------------------- // Tabulato deleghe // --------------------------------------------------------------------- void TLiquidazione_app::set_deltab(_DescrItem& d, bool iscred) { reset_header(); int rw = 1; static bool credpr; if (iscred) { // set header set_header(1,FR("ELENCO DITTE A CREDITO@30g%s %s@107gData @>@125gPag. @#"), d._f0 == 13 ? TR("Annuale ") : itom(d._f0), (const char*)_year); set_header(2,sep); set_header(3,FR("@40gF@60gImporto a")); set_header(4,FR("Cod.@8gDenominazione@40gR@62gcredito")); set_header(5,sep); set_header(6,""); // set rows for (int i = 0; i < d._arr.items(); i++) { TToken_string& tt = (TToken_string&)(d._arr)[i]; TString cod(tt.get(0)); TParagraph_string rgs(tt.get(1), 30); TString diocantaro(rgs.get(0)); TString frq(tt.get(2)); real tp (tt.get(3)); real in (tt.get(4)); tp -= in; tp = -tp; set_row(rw++, "%-5s@8g%-30s@40g%1s@54g%r", (const char*)cod, (const char*)diocantaro, (const char*)frq, &tp); for (int i = 1; i < rgs.items(); i++) set_row(rw++, "@8g%-30s", (const char*)rgs.get(i)); } } else { // set header set_header(1,FR("ELENCO DITTE A DEBITO@30g%s %s@107gData @>@125gPag. @#"), d._f0 == 13 ? TR("Annuale ") : itom(d._f0), (const char*)_year); set_header(2,sep); set_header(3,FR("@40gF@60gImporto da@73gCodice@83gCod.")); set_header(4,FR("Cod.@8gDenominazione@40gR Numero telefonico@63gversare Banca Dip. Con.")); set_header(5,sep); set_header(6,""); // set rows for (int i = 0; i < d._arr.items(); i++) { TToken_string& tt = (TToken_string&)(d._arr)[i]; TString cod(tt.get(0)); TParagraph_string rgs(tt.get(1), 30); TString diocantaro(rgs.get(0)); TString frq(tt.get(2)); real tp (tt.get(3)); real in (tt.get(4)); TString abi(tt.get(5)); TString cab(tt.get(6)); TString con(tt.get(7)); TString tel(tt.get(8)); if (!tel.blank()) tel << '/'; tel << tt.get(9); TString desc(tt.get(10)); set_row(rw++, "%-5s@8g%-30s@40g%1s %s @55g%r %5s %5s %3s %-.45s", (const char*)cod, (const char*)diocantaro, (const char*)frq, (const char*)tel, &tp, (const char*)abi, (const char*)cab, (const char*)con, (const char*)desc); for (int i = 1; i < rgs.items(); i++) set_row(rw++, "@8g%-30s", (const char*)rgs.get(i)); } } set_auto_ff(TRUE); }