Aggiunto messaggio di avvertimento se non si rispetta la sequenza dei numeri documento

Corretta ricontabilizzazione documento cliente modificato rispetto alla prima volta

git-svn-id: svn://10.65.10.50/branches/R_10_00@22722 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2012-09-07 14:53:41 +00:00
parent a76aa73e5a
commit 8991ea22a3
7 changed files with 116 additions and 97 deletions

View File

@ -92,8 +92,8 @@ void TMotore_application::init_query_mode( TMask& m )
_msk->set(F_TIPODOC, _tipodoc, TRUE); _msk->set(F_TIPODOC, _tipodoc, TRUE);
} }
} }
TEdit_field& n = m.efield(F_NDOC); TEdit_field& n = m.efield(F_NDOC);
if (!n.empty()) if (!n.empty())
{ {
if (find(0)) if (find(0))
@ -275,12 +275,11 @@ int TMotore_application::user_function(int index)
{ {
switch(index) switch(index)
{ {
case 1: case 1:
break; break;
default: default:
yesnofatal_box("Chiamata ad una procedura utente non definita: %d", index); yesnofatal_box("Chiamata ad una procedura utente non definita: %d", index);
return NOERR; break;
break;
} }
return NOERR; return NOERR;
} }
@ -599,10 +598,9 @@ void TMotore_application::load_auto_reopen_data()
} }
} }
bool num_filter(const TRelation* r) static bool num_filter(const TRelation* r)
{ {
const TCodice_numerazione & cod_num = cached_numerazione(r->curr().get("CODTAB")); const TCodice_numerazione& cod_num = cached_numerazione(r->curr().get("CODTAB"));
const int last = cod_num.ntipi_doc(); const int last = cod_num.ntipi_doc();
for (int i = 0; i < last; i++ ) for (int i = 0; i < last; i++ )
if (tipodoc_ok(cod_num.tipo_doc(i))) if (tipodoc_ok(cod_num.tipo_doc(i)))
@ -610,6 +608,32 @@ bool num_filter(const TRelation* r)
return false; return false;
} }
bool TMotore_application::ndoc_handler(TMask_field& f, KEY k)
{
if (k == K_ENTER && !f.empty())
{
const TMask& m = f.mask();
const TString& codnum = m.get(F_CODNUM);
const TCodice_numerazione& num = cached_numerazione(codnum);
if (num.auto_num())
{
const char provv = m.get(F_PROVV)[0];
const int anno = m.get_int(F_ANNO);
const long ndoc = atol(f.get());
long last_ndoc = 0;
TDate last_datadoc;
if (app().last_doc(provv, anno, codnum, last_ndoc, last_datadoc))
{
last_ndoc++;
if (ndoc > last_ndoc)
return yesno_box(TR("Il numero documento %ld non rispetta la sequenza prevista (%ld).\n"
"Si desidera proseguire ugualmente?"), ndoc, last_ndoc);
}
}
}
return true;
}
bool TMotore_application::user_create( ) bool TMotore_application::user_create( )
{ {
open_files(LF_DOC, LF_RIGHEDOC, LF_CONDV, LF_RCONDV, LF_ANAMAG, LF_SCONTI, LF_UMART, LF_DESLIN, LF_CODCORR, open_files(LF_DOC, LF_RIGHEDOC, LF_CONDV, LF_RCONDV, LF_ANAMAG, LF_SCONTI, LF_UMART, LF_DESLIN, LF_CODCORR,
@ -617,19 +641,17 @@ bool TMotore_application::user_create( )
LF_MOVMAG, LF_RMOVMAG, LF_MAG, LF_SVRIEP, LF_AGENTI, LF_PERCPROV, LF_ATTIV, LF_CAUSALI, 0); LF_MOVMAG, LF_RMOVMAG, LF_MAG, LF_SVRIEP, LF_AGENTI, LF_PERCPROV, LF_ATTIV, LF_CAUSALI, 0);
TISAM_recordset num("USE %NUM"); TISAM_recordset num("USE %NUM");
for (bool ok = num.move_first(); ok; ok = num.move_next()) for (bool ok = num.move_first(); ok; ok = num.move_next())
const TCodice_numerazione & n = cached_numerazione(num.get("CODTAB").as_string()); cached_numerazione(num.get("CODTAB").as_string());
TISAM_recordset tip("USE %TIP"); TISAM_recordset tip("USE %TIP");
for (bool ok = tip.move_first(); ok; ok = tip.move_next()) for (bool ok = tip.move_first(); ok; ok = tip.move_next())
const TTipo_documento & n = cached_tipodoc(tip.get("CODTAB").as_string()); cached_tipodoc(tip.get("CODTAB").as_string());
_config_ditta = new TConfig(CONFIG_DITTA); _config_ditta = new TConfig(CONFIG_DITTA);
// Metto in relazione testata e righe // Metto in relazione testata e righe
_rel = new TRelation( LF_DOC ); _rel = new TRelation(LF_DOC);
_rel->lfile().set_curr(new TDocumento); _rel->lfile().set_curr(new TDocumento);
_msk = new TMask(query_mask_name()); _msk = new TMask(query_mask_name());
@ -639,6 +661,7 @@ bool TMotore_application::user_create( )
_msk->set_handler( F_CODNUM, TDocumento_mask::num_handler ); _msk->set_handler( F_CODNUM, TDocumento_mask::num_handler );
_msk->set_handler( F_NUMDOCRIF, TDocumento_mask::numdocrif_search_handler ); _msk->set_handler( F_NUMDOCRIF, TDocumento_mask::numdocrif_search_handler );
_msk->set_handler( F_RAGSOCSEARCH, TDocumento_mask::ragsoc_search_handler ); _msk->set_handler( F_RAGSOCSEARCH, TDocumento_mask::ragsoc_search_handler );
_msk->set_handler( F_NDOC, ndoc_handler );
const int args = argc() ; const int args = argc() ;

View File

@ -63,7 +63,7 @@ protected:
void user_set_handler( int fieldid, int index, TMask* m = NULL ); void user_set_handler( int fieldid, int index, TMask* m = NULL );
virtual const char * extra_modules() const {return "dt";} virtual const char* extra_modules() const { return "dt"; }
virtual void on_firm_change(); virtual void on_firm_change();
@ -86,7 +86,7 @@ public:
virtual void preview(); virtual void preview();
virtual void mailto(); virtual void mailto();
virtual TRelation* get_relation( ) const { return _rel;} virtual TRelation* get_relation( ) const { return _rel; }
// Funzioni di accesso alle variabili private // Funzioni di accesso alle variabili private

View File

@ -14,6 +14,5 @@ int main(int argc, char** argv)
case 5 : ve5600(argc, argv); break; // recupero testate documenti case 5 : ve5600(argc, argv); break; // recupero testate documenti
default: ve5100(argc, argv); break; // Cancella documenti default: ve5100(argc, argv); break; // Cancella documenti
} }
exit(0);
return 0; return 0;
} }

View File

@ -1,5 +1,4 @@
#include <xvt.h> #include <xvt.h>
#include "ve8.h" // dichiarazioni delle procedure #include "ve8.h" // dichiarazioni delle procedure
int main( int argc, char** argv ) int main( int argc, char** argv )

View File

@ -433,7 +433,7 @@ protected:
const char* varname, const char* formula); const char* varname, const char* formula);
public: public:
TObject* dup() const { return new TTipo_riga_documento(codice()); } virtual TObject* dup() const { return new TTipo_riga_documento(codice()); }
public: public:
const TFilename& profile_name(TFilename& name) const; const TFilename& profile_name(TFilename& name) const;
@ -476,7 +476,7 @@ public:
const TString& provv1() const { return _field_provv1;} const TString& provv1() const { return _field_provv1;}
const int incr_perc_prezzo() const { return _incrp;} const int incr_perc_prezzo() const { return _incrp;}
const int decr_perc_prezzo() const { return _decrp;} const int decr_perc_prezzo() const { return _decrp;}
TToken_string * genconf(int i) const { return (TToken_string *) _genconf.objptr(i);} TToken_string* genconf(int i) const { return (TToken_string*)_genconf.objptr(i);}
bool formfeed() const { return get_bool("B0"); } bool formfeed() const { return get_bool("B0"); }

View File

@ -459,7 +459,7 @@ protected:
// Compila le righe del movimento per le fatture da emettere / ricevere // Compila le righe del movimento per le fatture da emettere / ricevere
error_type compile_rows_mov_re(TDocumento&); error_type compile_rows_mov_re(TDocumento&);
// scrive le scadenze // scrive le scadenze
error_type write_scadenze(TDocumento&); error_type write_scadenze(TDocumento& doc, bool recontabilizing);
// scrive il movimento e le scadenze // scrive il movimento e le scadenze
virtual error_type write_all(TDocumento& doc, TMovimentoPN_VE & movimento); virtual error_type write_all(TDocumento& doc, TMovimentoPN_VE & movimento);
// scrive il movimento e le scadenze per le fatture da emettere / ricevere // scrive il movimento e le scadenze per le fatture da emettere / ricevere

View File

@ -1,38 +1,23 @@
#include <dongle.h>
#include <execp.h>
#include <printer.h>
#include <viswin.h>
#include "velib04.h" #include "velib04.h"
#include "../ca/calib01.h"
#include <comuni.h> #include <comuni.h>
#include <unloc.h> #include <unloc.h>
#include <mov.h>
#include <rmov.h>
#include <rmoviva.h>
#include <clifo.h>
#include <cfven.h>
#include <nditte.h>
#include <occas.h>
#include <scadenze.h>
#include <doc.h>
#include <rdoc.h>
#include "velib.h" #include "../ca/calib01.h"
#include "../cg/cg2103.h" #include "../cg/cg2103.h"
#include "../cg/cglib02.h" #include "../cg/cglib02.h"
#include "../cg/cgsaldac.h" #include "../cg/cgsaldac.h"
#include "../in/inlib01.h" #include "../in/inlib01.h"
#include "../mg/anamag.h"
#include "../ca/movana.h" #include "../ca/movana.h"
#include "../m770/scperc.h" #include "../m770/scperc.h"
#include "../m770/rpag.h"
#include "../m770/rver.h" #include "../m770/rver.h"
#include "../m770/perc.h" #include "../m770/perc.h"
#include <comuni.h> #include <dongle.h>
#include <unloc.h> #include <execp.h>
#include <printer.h>
#include <viswin.h>
void TMovimentoPN_VE::destroy_iva_row(int i) void TMovimentoPN_VE::destroy_iva_row(int i)
{ {
@ -1173,33 +1158,31 @@ error_type TContabilizzazione::compile_head_mov(TDocumento& doc)
// per reperire il tipo documento ed il tipo movimento // per reperire il tipo documento ed il tipo movimento
// reperisce la descrizione dal tipo documento e la completa con la data documento ed il // reperisce la descrizione dal tipo documento e la completa con la data documento ed il
// numero documento // numero documento
const bool short_rif = pack_rif(); const bool short_rif = pack_rif();
TString descr; TString descr;
if (!short_rif) if (!short_rif)
{ {
doc.riferimento(descr); doc.riferimento(descr);
if (descr.empty()) descr = tipo.descrizione(); if (descr.empty()) descr = tipo.descrizione();
if (descr.full()) if (descr.full())
descr << ' '; descr << ' ';
} }
const TString16 rif = doc.get(DOC_NUMDOCRIF); const TString16 rif = doc.get(DOC_NUMDOCRIF);
const bool use_rif = _caus->iva() == iva_acquisti && rif.not_empty(); const bool use_rif = _caus->iva() == iva_acquisti && rif.not_empty();
if (use_rif) if (use_rif)
{ {
descr << "n. " << rif; descr << "n. " << rif;
const TString & data_rif = doc.get_date(DOC_DATADOCRIF).string(short_rif ? brief : full); const TString & data_rif = doc.get_date(DOC_DATADOCRIF).string(short_rif ? brief : full);
descr << " del " << data_rif; descr << " del " << data_rif;
} }
else else
{ {
descr << "n. " << doc.numero(); descr << "n. " << doc.numero();
descr << " del " << datadoc.string(short_rif ? brief : full); descr << " del " << datadoc.string(short_rif ? brief : full);
} }
if (doc.in_valuta()) if (doc.in_valuta())
{ {
@ -1236,34 +1219,29 @@ error_type TContabilizzazione::compile_head_mov(TDocumento& doc)
} }
// Reperisce la valuta // Reperisce la valuta
TDate datacam(doc.get_date(DOC_DATACAMBIO)); TString4 codval;
real cambio(doc.cambio()); real cambio;
TString4 codval(doc.valuta()); TDate datacam;
if (doc.in_valuta())
codval.trim();
if (!doc.in_valuta())
{ {
codval = ""; codval = doc.valuta(); codval.trim();
cambio = ZERO; cambio = doc.cambio();
} datacam = doc.get_date(DOC_DATACAMBIO);
if (codval.not_empty()) if (::is_true_value(codval))
{
_val->put("CODTAB",codval);
if (_val->read() != NOERR)
{ {
_error = val_error; _val->put("CODTAB",codval);
return _error; if (_val->read() != NOERR)
return _error = val_error;
if (cambio.is_zero())
return _error = change_error;
}
else
{
if (cambio != ZERO)
return _error = change_error;
} }
} }
// Reperisce il cambio
if ((cambio != ZERO && codval.empty()) ||
cambio == ZERO && codval.not_empty())
{
_error = change_error;
return _error;
}
// Dati del cliente... // Dati del cliente...
const TString4 tipocf(doc.get(DOC_TIPOCF)); const TString4 tipocf(doc.get(DOC_TIPOCF));
const long codcf = doc.get_long(DOC_CODCF); const long codcf = doc.get_long(DOC_CODCF);
@ -2657,7 +2635,7 @@ error_type TContabilizzazione::change_doc_status(TDocumento& doc)
return _error; return _error;
} }
error_type TContabilizzazione::write_scadenze(TDocumento& doc) error_type TContabilizzazione::write_scadenze(TDocumento& doc, bool recontabilizing)
// Scrive le scadenze. Liberamente tratto da cg2104.cpp. // Scrive le scadenze. Liberamente tratto da cg2104.cpp.
{ {
const TRectype& head = _movimento->curr(); const TRectype& head = _movimento->curr();
@ -2666,11 +2644,31 @@ error_type TContabilizzazione::write_scadenze(TDocumento& doc)
const bool is_nc = doc.is_nota_credito(); const bool is_nc = doc.is_nota_credito();
const long nreg = head.get_long(MOV_NUMREG); const long nreg = head.get_long(MOV_NUMREG);
if (recontabilizing)
{
TPartite_array pa; pa.add_numreg(nreg);
bool dirty = false;
for (TPartita* game = pa.first(); game; game = pa.next())
{
if (game->conto() != _co_cliente)
{
const int rf = game->first();
if (game->last() > rf)
return _error = scadenze_error;
else
{
game->rimuovi_riga(rf);
dirty = true;
}
}
}
if (dirty)
pa.rewrite();
}
int anno = head.get_int(MOV_ANNOIVA); int anno = head.get_int(MOV_ANNOIVA);
// const real change(head.get_real(MOV_CAMBIO));
TString8 numpart; // Max. 7 chars TString8 numpart; // Max. 7 chars
if (_nump_cfg) if (_nump_cfg)
{ {
numpart = head.get(MOV_PROTIVA); numpart = head.get(MOV_PROTIVA);
@ -2728,7 +2726,7 @@ error_type TContabilizzazione::write_scadenze(TDocumento& doc)
} }
TPartita* newgame = NULL; TPartita* newgame = NULL;
if (anno > 0 && !numpart.blank()) if (anno > 0 && numpart.full())
{ {
const int tmov = _caus->tipomov(); const int tmov = _caus->tipomov();
const TString80 desc(head.get(MOV_DESCR)); const TString80 desc(head.get(MOV_DESCR));
@ -3090,7 +3088,7 @@ error_type TContabilizzazione::write_all(TDocumento& doc, TMovimentoPN_VE & movi
const bool has_sc = sc_enabled(head.get_date(MOV_DATAREG)); const bool has_sc = sc_enabled(head.get_date(MOV_DATAREG));
if (has_sc) if (has_sc)
write_scadenze(doc); write_scadenze(doc, numreg == old_numreg); // Recontbilizing?
if (good() && in_enabled()) if (good() && in_enabled())
write_intra(doc); write_intra(doc);