From 0aeeb04dadea9159a2ef7ec8dfb02ea5f7fce989 Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 4 Dec 1995 11:04:35 +0000 Subject: [PATCH] Gestione numero paritita in inserimento git-svn-id: svn://10.65.10.50/trunk@2232 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg2100.cpp | 22 +++++++++++++--------- cg/cg2104.cpp | 34 +++++++++++++++++++++++++++++----- cg/cglib02.cpp | 6 +++--- cg/saldacon.cpp | 11 ++++------- cg/saldacon.h | 10 +++++++--- 5 files changed, 56 insertions(+), 27 deletions(-) diff --git a/cg/cg2100.cpp b/cg/cg2100.cpp index 3e0ce5e82..89cd25083 100755 --- a/cg/cg2100.cpp +++ b/cg/cg2100.cpp @@ -476,7 +476,7 @@ void TPrimanota_application::init_mask(TMask& m) m.show(F_CODIVA, m.mode() == MODE_INS); // Codice IVA standard - if (pagamento() != NULL) + if (is_fattura()) { const TPartita* game = partite().first(); const bool scad_free = game == NULL || !game->esistono_abbuoni_diffcam(m.get_long(F_NUMREG)); @@ -487,7 +487,8 @@ void TPrimanota_application::init_mask(TMask& m) m.enable(F_CODPAG, scad_free); // Disabilita codice pagamento m.enable(FS_RESET, scad_free); // Disabilita tasto di reset - if (!scad_free) m.set(FS_RECALC, "", TRUE); + if (!scad_free) + m.set(FS_RECALC, "", TRUE); m.enable(FS_RECALC, scad_free); // Disabilita ricalcolo automatico } } @@ -574,11 +575,15 @@ void TPrimanota_application::init_insert_mode(TMask& m) set_pagamento(NULL,dt); set_scadenze(m); } + else + set_pagamento(NULL,NULL); // Annulla pagamento } else + { partite().destroy(); - - _saldi.reset(); // Inizializza saldi + set_pagamento(NULL,NULL); // Annulla pagamento + } + _saldi.reset(); // Inizializza saldi } @@ -695,8 +700,7 @@ int TPrimanota_application::read(TMask& m) calcola_imp(); // Calcola totale imponibile ed imposte partite().destroy(); - const int tm = causale().tipomov(); - if (tm != 0 && tm != 2) // Ci sono scadenze + if (is_fattura()) // Ci sono scadenze { const TString16 cp(m.get(F_CODPAG)); const TString16 dt(m.get(F_DATAREG)); @@ -892,9 +896,9 @@ int TPrimanota_application::write(const TMask& m) { switch (causale().tipomov()) { - case 1: + case tm_fattura: write_scadenze(m); break; // Salva fattura - case 2: + case tm_nota_credito: salvaconto = TRUE; break; // Salva nota credito default: break; @@ -945,7 +949,7 @@ int TPrimanota_application::rewrite(const TMask& m) bool salvaconto = FALSE; if (iva() != nessuna_iva) { - if (causale().tipomov() == 2) + if (causale().tipomov() == tm_nota_credito) salvaconto = TRUE; else write_scadenze(m); diff --git a/cg/cg2104.cpp b/cg/cg2104.cpp index cf690d61f..5e45c2513 100755 --- a/cg/cg2104.cpp +++ b/cg/cg2104.cpp @@ -181,11 +181,30 @@ bool TPrimanota_application::numrif_handler(TMask_field& f, KEY key) { bool ok = TRUE; if (f.to_check(key)) - { + { + TMask& m = f.mask(); + const bool empty = f.get().blank(); + if (empty && m.insert_mode()) + { + f.set(m.get(app()._npart_is_prot ? F_PROTIVA : F_NUMDOC)); + if (m.get(F_ANNORIF).empty()) + { + const TString& anno = m.get(F_DATADOC).right(4); + m.set(F_ANNORIF, anno); + } + if (m.get(F_CODPAG).empty()) + { + TMask_field& clifo = m.field(app().iva() == iva_vendite ? F_CLIENTE : F_FORNITORE); + clifo.on_hit(); + } + return 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."); + } + const TPartita* old = app().partite().first(); - if (old && f.get().blank()) // Se esisteva una partita ma ora non piu' + if (old && empty) // Se esisteva una partita ma ora non piu' { - TMask& m = f.mask(); const KEY k = yesnocancel_box("Attenzione la fattura della partita %d %s verra' eliminata.\n" "Premere SI per cancellarla, NO per ripristinarla, ANNULLA modificarla", old->anno(), (const char*)old->numero()); @@ -343,8 +362,13 @@ void TPrimanota_application::recalc_scadenze(const TDate& d) void TPrimanota_application::set_pagamento(const char* c, const char* d) { - if (_pag != NULL) delete _pag; - _pag = new TPagamento(c,d); + if (_pag != NULL) + { + delete _pag; + _pag = NULL; + } + if (c != NULL || d != NULL) + _pag = new TPagamento(c, d); } void TPrimanota_application::set_scadenze(TMask& m) diff --git a/cg/cglib02.cpp b/cg/cglib02.cpp index 1254cc2b7..f8f4f29a2 100755 --- a/cg/cglib02.cpp +++ b/cg/cglib02.cpp @@ -7,7 +7,7 @@ #include -#include +#include #include #include "cglib.h" @@ -284,7 +284,7 @@ TEsercizi_contabili::TEsercizi_contabili() : _firm(0) void TEsercizi_contabili::update() { - _firm = main_app().get_firm(); + _firm = prefix().get_codditta(); destroy(); TTable esc("ESC"); @@ -298,7 +298,7 @@ void TEsercizi_contabili::update() void TEsercizi_contabili::check() { - if (_firm != main_app().get_firm()) + if (_firm != prefix().get_codditta()) { #ifdef DBG if (_firm != 0) diff --git a/cg/saldacon.cpp b/cg/saldacon.cpp index d82413d08..dfc7bde20 100755 --- a/cg/saldacon.cpp +++ b/cg/saldacon.cpp @@ -571,14 +571,11 @@ int TRiga_partite::ultima_ratapagata() const return r; } -bool TRiga_partite::is_fattura() const +tipo_movimento TRiga_partite::tipo() const { - return get_int(PART_TIPOMOV) == 1; -} - -bool TRiga_partite::is_nota_credito() const -{ - return get_int(PART_TIPOMOV) == 2; + const tipo_movimento tm = (tipo_movimento)get_int(PART_TIPOMOV); + CHECKD(tm != tm_nessuno, "Riga partite con un tipo losco ", tm); + return tm; } int TRiga_partite::read(TBaseisamfile& f, word op) diff --git a/cg/saldacon.h b/cg/saldacon.h index 9d81488ef..b3112c8f1 100755 --- a/cg/saldacon.h +++ b/cg/saldacon.h @@ -158,6 +158,9 @@ public: virtual ~TRiga_scadenze() {} }; +enum tipo_movimento { tm_nessuno = 0, tm_fattura = 1, tm_nota_credito = 2, + tm_pagamento = 3, tm_insoluto = 5, tm_pagamento_insoluto = 6 }; + class TRiga_partite : public TTree_rectype { friend class TPartita; @@ -179,9 +182,10 @@ public: TRiga_scadenze& rata(int r) const { return (TRiga_scadenze&)_recarr.row(r); } void elimina_rata(int r = 0); TRiga_scadenze& new_row(int r = 0); - - bool is_fattura() const; - bool is_nota_credito() const; + + tipo_movimento tipo() const; + bool is_fattura() const { return tipo() == tm_fattura; } + bool is_nota_credito() const { return tipo() == tm_nota_credito; } int ultima_ratapagata() const; int ultimo_pagamento(int rata) const; int rata_con_abbuoni_diffcam() const;