diff --git a/cg/cg2100.cpp b/cg/cg2100.cpp index e120d685e..2a355cb70 100755 --- a/cg/cg2100.cpp +++ b/cg/cg2100.cpp @@ -787,15 +787,16 @@ void TPrimanota_application::mask2rel(const TMask& m) if (_iva == nessuna_iva) return; + TRectype& rec = _rel->curr(); // Record della testata + if (causale().corrispettivi()) { - TRectype& rec = _rel->lfile().curr(); rec.put("TIPO", ""); rec.put("CODCF", ""); // Azzera il cliente nei movimenti dei corrispettivi } else { - _rel->lfile().put("TIPO", clifo()); + rec.put("TIPO", clifo()); int err = ~NOERR; if (m.field(F_OCCASEDIT).active()) // Se e' un occasionale @@ -809,35 +810,39 @@ void TPrimanota_application::mask2rel(const TMask& m) err = occas.rewrite(); if (err == NOERR) - _rel->lfile().put("OCFPI", occas_mask().get(O_CODICE)); + rec.put("OCFPI", occas_mask().get(O_CODICE)); else error_box("Errore di scrittura sul file dei clienti/fornitori occasionali: %d", err); } - if (err) _rel->lfile().zero("OCFPI"); + if (err) + rec.zero("OCFPI"); } - const bool intra = causale().intra(); const bool to_swap = test_swap(FALSE); if (to_swap) { - real totale = _rel->lfile().get("TOTDOC"); + real totale = rec.get("TOTDOC"); totale = -totale; - _rel->lfile().put("TOTDOC", totale); + rec.put("TOTDOC", totale); } - ivas_pack(); + const bool intra = causale().intra(); + TArray& irows = ivas().rows_array(); + ivas_pack(); + for (int i = 0; i < irows.items(); i++) { TToken_string& row = (TToken_string&)irows[i]; TRectype &r = _rel->iva(i); r.zero(); - r.put("ANNOES", annoes); // Anno d'esercizio della testata (che ca$$ata!) r.put("NUMREG", numreg); - r.put("INTRA", intra); // Causale intra (che ca$$ata!) r.put("NUMRIG", i+1); + r.put("ANNOES", annoes); // Anno d'esercizio della testata (che ca$$ata!) + r.put("INTRA", intra); // Causale intra (che ca$$ata!) + real imponibile(row.get(0)); if (to_swap) imponibile = -imponibile; r.put("IMPONIBILE", imponibile); @@ -862,7 +867,7 @@ void TPrimanota_application::mask2rel(const TMask& m) void TPrimanota_application::check_saldi() { TString_array& rows = cgs().rows_array(); - const int anno = _rel->lfile().get_int("ANNOES"); + const int anno = _rel->curr().get_int("ANNOES"); for (int i = 0; i < rows.items(); i++) { diff --git a/cg/cg2102.cpp b/cg/cg2102.cpp index cba32e4ca..94423bb17 100755 --- a/cg/cg2102.cpp +++ b/cg/cg2102.cpp @@ -558,10 +558,10 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k) return f.error_box("Il movimento e' sbilanciato di %s lire.", ss); } - const bool paga = a.is_pagamento(); - const bool nota = a.is_nota_credito(); - TMask& m = f.mask(); + const bool paga = a.is_pagamento(); + const bool nota = a.is_nota_credito() && m.field(F_NUMRIF).active(); + const long numreg = m.get_long(F_NUMREG); const bool in_valuta = m.get(SK_VALUTA).not_empty(); @@ -1892,13 +1892,17 @@ void TPrimanota_application::add_cgs_tot(TMask& m) // Certified 99% bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key) { + if (!suspended_handler(f, key)) + return FALSE; + if (key == K_TAB && f.active()) - { + { + TPrimanota_application& a = app(); TMask& m = f.mask(); - if (f.focusdirty() && app().is_nota_credito()) + if (f.focusdirty() && a.is_nota_credito()) { - TPartite_array& p = app().partite(); + TPartite_array& p = a.partite(); if (m.edit_mode()) p.add_numreg(m.get_long(F_NUMREG)); @@ -1913,11 +1917,11 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key) return TRUE; } f.set_dirty(); // yesno_box cleared the dirty flag - app().notify_cgline_deletion(-1); + a.notify_cgline_deletion(-1); } } - const char cf = app().clifo(); + const char cf = a.clifo(); const long codice = atol(f.get()); if (codice == 0) @@ -1926,7 +1930,7 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key) m.show(F_STATOPAIV); // Stato partita IVA m.show(cf == 'C' ? F_PIVACLIENTE : F_PIVAFORNITORE); // Partita IVA m.show(cf == 'C' ? F_COFICLIENTE : F_COFIFORNITORE); // Codice Fiscale - + a.activate_numrif(TRUE); return TRUE; } @@ -1936,14 +1940,11 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key) clifo.put(CLI_CODCF, codice); cliforel.read(); - if (!suspended_handler(f, key)) - return FALSE; - if (!m.is_running() || f.dirty()) { - app()._conto_ricavo.set(clifo.get_int(CLI_GRUPPORIC), - clifo.get_int(CLI_CONTORIC), - clifo.get_long(CLI_SOTTOCRIC)); + a._conto_ricavo.set(clifo.get_int(CLI_GRUPPORIC), + clifo.get_int(CLI_CONTORIC), + clifo.get_long(CLI_SOTTOCRIC)); const int alleg = clifo.get_int(CLI_ALLEG); TEdit_field& upi = m.efield(F_RIEPILOGO); @@ -1964,7 +1965,7 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key) } } - if (f.focusdirty() && app().is_saldaconto()) + if (f.focusdirty() && a.is_saldaconto()) { if (m.field(SK_VALUTA).active() && m.get(SK_VALUTA).empty()) { @@ -1973,12 +1974,12 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key) m.set(SK_VALUTA, valuta, TRUE); } - if (app().is_fattura()) + if (a.is_fattura()) { if (clifo.get(CLI_CODCAB).not_empty()) { - m.set(FS_VSABI, clifo.get(CLI_CODABI)); - m.set(FS_VSCAB, clifo.get(CLI_CODCAB)); + m.set(FS_VSABI, clifo.get(CLI_CODABI)); + m.set(FS_VSCAB, clifo.get(CLI_CODCAB)); m.send_key(K_TAB, FS_VSCAB); } @@ -1992,16 +1993,21 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key) } } - const bool occas = clifo.get_bool(CLI_OCCAS) && !app().is_saldaconto(); + const bool occas = clifo.get_bool(CLI_OCCAS); m.show(F_OCCASEDIT, occas); // Bottone Dati anagrafici m.show(F_STATOPAIV, !occas); // Stato partita IVA m.show(cf == 'C' ? F_PIVACLIENTE : F_PIVAFORNITORE, !occas); // Partita IVA m.show(cf == 'C' ? F_COFICLIENTE : F_COFIFORNITORE, !occas); // Codice Fiscale + if (occas && a.is_fattura() && a.partite().first() != NULL) + f.warning_box("Attenzione, il saldaconto verra' eliminato!"); + + a.activate_numrif(TRUE); + if (f.focusdirty()) { - app().add_cgs_tot(m); - if (occas && app().occas_mask().get(O_CODICE).empty()) + a.add_cgs_tot(m); + if (occas && a.occas_mask().get(O_CODICE).blank()) m.send_key(K_SPACE, F_OCCASEDIT); // Lancia maschera occasionali } } @@ -2338,8 +2344,8 @@ bool TPrimanota_application::activate_numrif(bool init_pag) if (shown) { - const bool solaiva = m.get_bool(F_SOLAIVA); - if (solaiva) shown = FALSE; + const bool hide = m.get_bool(F_SOLAIVA) || m.field(F_OCCASEDIT).shown(); + if (hide) shown = FALSE; } if (shown != m.field(F_NUMRIF).shown()) diff --git a/cg/cg2104.cpp b/cg/cg2104.cpp index 73845e084..4bc34cf86 100755 --- a/cg/cg2104.cpp +++ b/cg/cg2104.cpp @@ -339,16 +339,17 @@ bool TPrimanota_application::codpag_handler(TMask_field& f, KEY key) bool TPrimanota_application::annorif_handler(TMask_field& f, KEY key) { bool ok = TRUE; - const TMask& m = f.mask(); - - if (f.to_check(key, TRUE) && f.get().empty() && - (m.insert_mode() || m.get(F_NUMRIF).not_empty())) - { - const TString& anno = m.get(F_DATADOC).right(4); - f.set(anno); - ok = error_box("Il numero di riferimento partita e' obbligatorio!\n" - "Se possibile esso verra' proposto, ma potra'\n" - "essere modificato prima di registrare il movimento."); + if (f.to_check(key, TRUE)) + { + const TMask& m = f.mask(); + if (!m.get(F_NUMRIF).blank() && f.get().empty()) + { + const TString& anno = m.get(F_DATADOC).right(4); + f.set(anno); + ok = error_box("L'anno di riferimento partita e' obbligatorio!\n" + "Se possibile esso verra' proposto, ma potra'\n" + "essere modificato prima di registrare il movimento."); + } } return ok; } @@ -361,8 +362,12 @@ bool TPrimanota_application::numrif_handler(TMask_field& f, KEY key) { TPrimanota_application& a = app(); TMask& m = f.mask(); + + const bool required = m.insert_mode() && a.is_fattura() && + (key == K_ENTER || f.focusdirty()) && + !(m.get_bool(F_SOLAIVA) || m.field(F_OCCASEDIT).enabled()); - if (f.focusdirty() && m.insert_mode() && f.get().blank()) + if (required && f.get().blank()) { f.set(m.get(a._npart_is_prot ? F_PROTIVA : F_NUMDOC));