diff --git a/cg/cg2100.cpp b/cg/cg2100.cpp index 2bf9b74c7..b7098a317 100755 --- a/cg/cg2100.cpp +++ b/cg/cg2100.cpp @@ -300,12 +300,9 @@ void TPrimanota_application::init_mask(TMask& m) void TPrimanota_application::init_query_mode(TMask& m) { - <<<<<<< cg2100.cpp - read_firm_params(); + read_firm_params(); enable_menu_item(M_FILE_PRINT); - ======= - >>>>>>> 1.25 - m.enable(DLG_NEWREC); + m.enable(DLG_NEWREC); } @@ -386,7 +383,8 @@ void TPrimanota_application::init_insert_mode(TMask& m) if (iva() == nessuna_iva) { - set_cgs_row(-1,zero,tc,desc,' '); + const int pos = set_cgs_row(-1,zero,tc,desc,' '); + cgs().disable_cell(pos, sezione == 'D' ? 1 : 0); } else { @@ -765,9 +763,13 @@ void TPrimanota_application::genera_incasso(const char* causimm) ::remove(tmp); // Cancella file temporaneo const TCausale caus(causimm); // Causale da usare + TBill conto; caus.bill(2, conto); // Conto della seconda riga della causale + m.set(F_NUMREG, ++_lastreg); // Incrementa numero di registrazione m.set(F_CODCAUS, causimm); // Cambia causale e ... m.set(F_TIPODOC, caus.tipo_doc()); // relativo tipo documento + m.set(F_GRUPPOCLIFO, conto.gruppo()); + m.set(F_CONTOCLIFO, conto.conto()); if (m.run() == K_SAVE) { @@ -776,7 +778,7 @@ void TPrimanota_application::genera_incasso(const char* causimm) TRectype r(_rel->cg(0)); // Copia la prima riga contabile m.autosave(&inc); - inc.lfile().put("REG", ""); // Annulla eventuale registro IVA + inc.lfile().put("REG", ""); // Annulla eventuale registro IVA const real imp(m.get(F_TOTALE)); const char sez = r.get_char("SEZIONE"); @@ -788,13 +790,6 @@ void TPrimanota_application::genera_incasso(const char* causimm) r.put("SEZIONE", sez == 'A' ? 'D' : 'A'); inc.cg(0) = r; - TBill conto; caus.bill(2, conto); // Conto della seconda riga della causale - - r.put("TIPOC", conto.tipo()); - r.put("GRUPPO", conto.gruppo()); - r.put("CONTO", conto.conto()); - r.put("SOTTOCONTO", conto.sottoconto()); - r.put("NUMRIG", 2); r.put("SEZIONE", sez); inc.cg(1) = r; diff --git a/cg/cg2100i.uml b/cg/cg2100i.uml index df1456b89..dfd5d967c 100755 --- a/cg/cg2100i.uml +++ b/cg/cg2100i.uml @@ -154,13 +154,13 @@ END NUMBER F_GRUPPOCLIFO 3 BEGIN PROMPT 1 8 "Gruppo " - LF_MOV->GRUPPO + FIELD LF_MOV->GRUPPO END NUMBER F_CONTOCLIFO 3 BEGIN PROMPT 16 8 "Conto " - LF_MOV->CONTO + FIELD LF_MOV->CONTO END NUMBER F_TOTALE 14 @@ -174,7 +174,7 @@ END BUTTON DLG_SAVEREC 9 2 BEGIN PROMPT -12 -1 "~Registra" - MESSAGE EXIT,K_SAVEREC + MESSAGE EXIT,K_SAVE END BUTTON DLG_CANCEL 9 2 diff --git a/cg/cg2101.cpp b/cg/cg2101.cpp index 5b669cf81..6d91164e4 100755 --- a/cg/cg2101.cpp +++ b/cg/cg2101.cpp @@ -187,7 +187,7 @@ int TMovimentoPN::write(bool force, TDate&) int tipoatt = 1; if (mista) { - const char tipo = r.get_char("TIPOC"); + const char tipo = r.get_char("TIPO"); if (tipo == ' ') { TBill c(r.get_int("GRUPPO"), r.get_int("CONTO"), r.get_long("SOTTOCONTO")); diff --git a/cg/cg2102.cpp b/cg/cg2102.cpp index 2db682a78..066bdfd0a 100755 --- a/cg/cg2102.cpp +++ b/cg/cg2102.cpp @@ -422,7 +422,7 @@ void TPrimanota_application::cgs_pack() real TPrimanota_application::calcola_saldo() const { TArray& rows = cgs().rows_array(); - const int max = rows.size(); + const int max = rows.items(); real tdare, tavere; for (int i = 0; i < max; i++) @@ -476,14 +476,14 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k) const int max = cg.items(); for (int i = 0; i < max; i++) { - const TImporto im(get_cgs_imp(i)); + const TImporto im(app().get_cgs_imp(i)); if (!im.valore().is_zero()) { const TBill c(cg.row(i), 3, 0x0); - if (!c.ok()) + if ((c.gruppo() > 0 || c.sottoconto() > 0) && !c.ok()) return error_box("Il conto della riga %d non e' completo", i+1); - const TBill co(cg.row(i), 9, 0x0); - if (!co.ok()) + const TBill co(cg.row(i), 10, 0x0); + if ((co.gruppo() > 0 || co.sottoconto() > 0) && !co.ok()) return error_box("La contropartita della riga %d non e' completa", i+1); } } @@ -695,17 +695,22 @@ bool TPrimanota_application::iva_notify(int r, KEY k) const char tipod = detraibile(row) ? 'D' : 'N'; oldposiva = type2pos(tipod); + TString80 d; if (oldposiva < 0 && oldiva != ZERO) { const int r = tipod == 'D' ? 3 : 4; TBill c; cau.bill(r, c); - oldposiva = app().set_cgs_row(-1, app().real2imp(ZERO, 'I'), c, cau.desc_agg(r), tipod); + d = cau.desc_agg(r); + oldposiva = app().set_cgs_row(-1, app().real2imp(ZERO, 'I'), c, d, tipod); } TBill oldconto(row, 6, 0x0); // g/c/s 6 7 8 oldpos = bill2pos(oldconto, 'I'); - if (oldpos < 0 && oldconto.ok()) - oldpos = app().set_cgs_row(-1, app().real2imp(ZERO, 'I'), oldconto, cau.desc_agg(2), 'I'); + if (oldpos < 0 && oldconto.ok()) + { + d = cau.desc_agg(2); + oldpos = app().set_cgs_row(-1, app().real2imp(ZERO, 'I'), oldconto, d, 'I'); + } } if (k == K_DEL) { @@ -717,11 +722,11 @@ bool TPrimanota_application::iva_notify(int r, KEY k) { if (oldpos >= 0) // Il conto esisteva anche prima { - app().sub_cgs_imp(oldpos, oldimp); + const TImporto& imp = app().sub_cgs_imp(oldpos, oldimp); } if (oldposiva >= 0) // Il conto IVA esisteva anche prima { - app().sub_cgs_imp(oldposiva, oldiva); + const TImporto& imp = app().sub_cgs_imp(oldposiva, oldiva); } // Aggiorna conto sulla riga contabile @@ -736,12 +741,16 @@ bool TPrimanota_application::iva_notify(int r, KEY k) TBill conto(row, 5, 0x3); int newpos = bill2pos(conto, 'I'); + TString80 d; if (newpos < 0) { const TImporto val(app().real2imp(imp, 'I')); if (val.valore() != ZERO) - app().set_cgs_row(-1, val, conto, cau.desc_agg(2), 'I'); + { + d = cau.desc_agg(2); + app().set_cgs_row(-1, val, conto, d, 'I'); + } } else { @@ -768,7 +777,10 @@ bool TPrimanota_application::iva_notify(int r, KEY k) { const TImporto val(app().real2imp(imposta, 'I')); if (val.valore() != ZERO) - newposiva = app().set_cgs_row(-1, val, conto, cau.desc_agg(r), tipod); + { + d = cau.desc_agg(r); + newposiva = app().set_cgs_row(-1, val, conto, d, tipod); + } } else { @@ -780,9 +792,12 @@ bool TPrimanota_application::iva_notify(int r, KEY k) newposiva = -1; } } + oldiva = imposta; - oldposiva = newposiva; + oldposiva = newposiva; + if (r == 0) + app().add_cgs_tot(app().mask()); app().calcola_imp(); app().calcola_saldo(); } @@ -1162,6 +1177,7 @@ bool TPrimanota_application::main_codiva_handler(TMask_field& f, KEY key) const real imp(row.get(0)); if (imp == ZERO) { + TMask& m = f.mask(); iva_notify(0, K_SPACE); const bool corr = app().causale().corrispettivi(); @@ -1184,14 +1200,13 @@ bool TPrimanota_application::main_codiva_handler(TMask_field& f, KEY key) if (tipo == "NS") app().causale().bill(7, bill); } if (!bill.ok() && !corr) - { - const TMask& m = f.mask(); bill.set(m.get_int(F_GRUPPORIC), m.get_int(F_CONTORIC), m.get_long(F_SOTTOCONTORIC)); - } if (!bill.ok()) app().causale().bill(2, bill); bill.add_to(row, 4, 0x7); + app().ivas().force_update(0); + iva_notify(0, K_ENTER); } } diff --git a/cg/cg2104.cpp b/cg/cg2104.cpp index 7d6c0b4f0..c8f4a137c 100755 --- a/cg/cg2104.cpp +++ b/cg/cg2104.cpp @@ -1,225 +1,3 @@ -<<<<<<< cg2104.cpp -// -------------------------------------------------------------------------- -// Scadenzario -// fv 24/8/94 -// -------------------------------------------------------------------------- - -#include "cg2102.h" -#include "cg2100.h" -#include "cg2104a.h" -#include "pagament.h" - -struct shuttle -{ - Pagamento* _pag; // pagamento - TSheet_field* _sheet; // sheet - TMask* _mask; // maschera - TArray* _rows; // righe spreadsheet nella versione originale -}; - -bool TPrimanota_application::pag_notify(int r, KEY k) -{ - // questo e' il bello - shuttle* sh = (shuttle*)(((TPrimanota_application*)MainApp())->get_app_data()); - - Pagamento* pag = sh->_pag; - TSheet_field* ps = sh->_sheet; - TMask* msk = sh->_mask; - TArray* rws = sh->_rows; - - int rdiff = atoi(msk->get(F_RDIFFER)); - - // ts contiene la vecchia riga, ns la nuova - TToken_string ts(36), ns(36); - - - bool doit = TRUE, m_imp = FALSE, m_perc = FALSE, m_pag = FALSE; - bool m_scad = FALSE, m_tipo = FALSE, mod = FALSE; - word ahiahi = P_OK; - - TString news(15), newi(15), newp(15), newt(2); - - bool recalc = msk->get_bool(F_RECALC); - bool mcomm = msk->get_bool(F_MCOMM); - - switch (k) - { - case K_SPACE: - break; - case K_ENTER: - ns = ps->row(r); - ts = (TToken_string&)(*rws)[r]; - - news = ns.get(0); - newp = ns.get(1); - newi = ns.get(2); - newt = ns.get(3); - - // qui viene il bello, si fa per dire - if (strcmp(ts.get(0),news) != 0) // modificata data scadenza - { - mod = m_scad = TRUE; - } - if (strcmp(ts.get(1),newp) != 0) // modificata percentuale - { - mod = m_perc = TRUE; - } - if (strcmp(ts.get(2),newi) != 0) // modificato importo - { - if ((recalc && !m_perc) || (!recalc)) // se si modifica la percentuale l'importo non viene cagato - { - mod = m_imp = TRUE; - } - } - if (strcmp(ts.get(3),newt) != 0) // modificato tipo pagamento - { - mod = m_tipo = TRUE; - } - break; - case K_DEL: - case K_INS: - doit = FALSE; - break; - default: - break; - } - - - // settato da recalc_rate se occorre ridefinire lo sheet - // aggiungendo o togliendo righe - bool need_recalc = FALSE; - - if (k == K_ENTER) - { - if (mod && recalc) - { - // ricalcola sheet come sai fare tu - ahiahi = pag->recalc_rate(r, m_perc, - ((m_perc || m_imp) ? - (m_perc ? (const char*)newp : (const char*)newi) : - NULL), - (m_scad ? (const char*)news : NULL), - (m_tipo ? (const char*)newt : NULL), - rdiff, mcomm, need_recalc); - // see if rdiff changed - msk->field(F_RDIFFER).set(pag->rate_differenziate() ? "1" : "2"); - } - if (!recalc) - { - ahiahi = P_OK; - // put data as they are - TToken_string& trw = pag->rata(r); - TToken_string srw = trw; - if (m_scad) trw.add(news,3); - if (m_perc) trw.add(newp,1); - if (m_imp) trw.add(newi,4); - if (m_tipo) trw.add(newt,2); - // validate the payment - if ((ahiahi = pag->validate()) != P_OK) - pag->rata(r) = srw; - } - if (ahiahi) // any error? - // rimetti le righe com'erano prima - { - beep(); - - // se gli errori sono voluti, spiegali - if (!recalc) - { - TString s(256); - pag->strerr(ahiahi,s); - warning_box(s); - } - - ps->row(r) = (TToken_string&)(*rws)[r]; - ps->force_update(r); - } - - else if (recalc && mod && need_recalc) - { - // ridefinisci lo sheet sulla base delle nuove rate - pag->set_sheet(*ps); - ps->force_update(-1); - rws->destroy(); - (*rws) = ps->rows_array(); - } - } - - return doit; -} - -void TPrimanota_application::aggiorna_scadenzario(const TMask& m) -{ - real imponibile(0.0); - real imposta(0.0); - real spese(0.0); - TString dt(m.get(F_DATAREG)); - Pagamento pag(m.get(F_CODPAG), (const char*)dt); - - if (pag.is_new()) return; - - TMask ms("cg2104a"); - TSheet_field& ps = (TSheet_field&)ms.field(F_RATESHEET); - ps.set_notify(pag_notify); - - ms.field(F_RDIFFER).set(pag.rate_differenziate() ? "1" : "2"); - ms.field(F_NAMEPAG).set(pag.name()); - ms.field(F_TIPOPR).set(pag.desc_tpr()); - ms.field(F_MCOMM).set(pag.mese_commerciale() ? "X" : ""); - - TSheet_field& iva_sh = ivas(); - - for (int i = 0; i < iva_sh.items(); i++) - { - TToken_string& tt = iva_sh.row(i); - real mpo(tt.get(0)); - real imp(tt.get(3)); - imponibile += mpo; - imposta += imp; - // TBI: le spese che cazzo sono? - // ----------------------------- - } - - ms.field(F_IMPONIBILE).set(imponibile.string()); - ms.field(F_IMPOSTA).set(imposta.string()); - ms.field(F_SPESE).set(spese.string()); - ms.field(F_RECALC).set("X"); - - pag.set_total(imponibile, imposta, spese); - - // TBI TBI TBI TBI TBI TBI TBI TBI TBI - // controllare se c'e' una rateazione non standard gia' registrata - // in tal caso occorre zappare e settare le rate a mano - pag.set_rate_auto(); - - // se la prima rata e' fissa non si tocca - if (pag.tipo_prima_rata() > 0) - { - ps.disable_cell(0,0); - ps.disable_cell(0,1); - ps.disable_cell(0,2); - ps.disable_cell(0,3); - } - - // prepara lo sheet - pag.set_sheet(ps); - TArray rows(ps.rows_array()); - - shuttle sh; - - sh._pag = &pag; - sh._sheet = &ps; - sh._mask = &ms; - sh._rows = &rows; - - set_app_data(&sh); - ms.run(); - - // TBI se modificato riaggiustare i files - // chiamando la write del caso - // ------------------------------------------------- -} -======= // -------------------------------------------------------------------------- // Scadenzario // fv 24/8/94 @@ -230,7 +8,8 @@ void TPrimanota_application::aggiorna_scadenzario(const TMask& m) #include "cg2104a.h" #include "pagament.h" -struct shuttle { +struct shuttle +{ Pagamento* _pag; // pagamento TSheet_field* _sheet; // sheet TMask* _mask; // maschera @@ -240,7 +19,6 @@ struct shuttle { bool TPrimanota_application::pag_notify(int r, KEY k) { // questo e' il bello - shuttle* sh = (shuttle*)(((TPrimanota_application*)MainApp())->get_app_data()); Pagamento* pag = sh->_pag; @@ -281,11 +59,11 @@ bool TPrimanota_application::pag_notify(int r, KEY k) { mod = m_scad = TRUE; } - if (real(ts.get(1)) != real(newp)) // modificata percentuale + if (strcmp(ts.get(1),newp) != 0) // modificata percentuale { mod = m_perc = TRUE; } - if (real(ts.get(2)) != real(newi)) // modificato importo + if (strcmp(ts.get(2),newi) != 0) // modificato importo { if ((recalc && !m_perc) || (!recalc)) // se si modifica la percentuale l'importo non viene cagato { @@ -440,4 +218,3 @@ void TPrimanota_application::aggiorna_scadenzario(const TMask& m) // chiamando la write del caso // ------------------------------------------------- } ->>>>>>> 1.2