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:
parent
a76aa73e5a
commit
8991ea22a3
@ -92,8 +92,8 @@ void TMotore_application::init_query_mode( TMask& m )
|
||||
_msk->set(F_TIPODOC, _tipodoc, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
TEdit_field& n = m.efield(F_NDOC);
|
||||
|
||||
if (!n.empty())
|
||||
{
|
||||
if (find(0))
|
||||
@ -275,12 +275,11 @@ int TMotore_application::user_function(int index)
|
||||
{
|
||||
switch(index)
|
||||
{
|
||||
case 1:
|
||||
break;
|
||||
default:
|
||||
yesnofatal_box("Chiamata ad una procedura utente non definita: %d", index);
|
||||
return NOERR;
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
default:
|
||||
yesnofatal_box("Chiamata ad una procedura utente non definita: %d", index);
|
||||
break;
|
||||
}
|
||||
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();
|
||||
for (int i = 0; i < last; i++ )
|
||||
if (tipodoc_ok(cod_num.tipo_doc(i)))
|
||||
@ -610,6 +608,32 @@ bool num_filter(const TRelation* r)
|
||||
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( )
|
||||
{
|
||||
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);
|
||||
|
||||
TISAM_recordset num("USE %NUM");
|
||||
|
||||
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");
|
||||
|
||||
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);
|
||||
|
||||
// Metto in relazione testata e righe
|
||||
_rel = new TRelation( LF_DOC );
|
||||
_rel = new TRelation(LF_DOC);
|
||||
_rel->lfile().set_curr(new TDocumento);
|
||||
|
||||
_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_NUMDOCRIF, TDocumento_mask::numdocrif_search_handler );
|
||||
_msk->set_handler( F_RAGSOCSEARCH, TDocumento_mask::ragsoc_search_handler );
|
||||
_msk->set_handler( F_NDOC, ndoc_handler );
|
||||
|
||||
const int args = argc() ;
|
||||
|
||||
|
@ -63,7 +63,7 @@ protected:
|
||||
|
||||
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();
|
||||
|
||||
@ -86,7 +86,7 @@ public:
|
||||
virtual void preview();
|
||||
virtual void mailto();
|
||||
|
||||
virtual TRelation* get_relation( ) const { return _rel;}
|
||||
virtual TRelation* get_relation( ) const { return _rel; }
|
||||
|
||||
// Funzioni di accesso alle variabili private
|
||||
|
||||
|
@ -14,6 +14,5 @@ int main(int argc, char** argv)
|
||||
case 5 : ve5600(argc, argv); break; // recupero testate documenti
|
||||
default: ve5100(argc, argv); break; // Cancella documenti
|
||||
}
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include <xvt.h>
|
||||
|
||||
#include "ve8.h" // dichiarazioni delle procedure
|
||||
|
||||
int main( int argc, char** argv )
|
||||
|
@ -433,7 +433,7 @@ protected:
|
||||
const char* varname, const char* formula);
|
||||
|
||||
public:
|
||||
TObject* dup() const { return new TTipo_riga_documento(codice()); }
|
||||
virtual TObject* dup() const { return new TTipo_riga_documento(codice()); }
|
||||
|
||||
public:
|
||||
const TFilename& profile_name(TFilename& name) const;
|
||||
@ -476,7 +476,7 @@ public:
|
||||
const TString& provv1() const { return _field_provv1;}
|
||||
const int incr_perc_prezzo() const { return _incrp;}
|
||||
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"); }
|
||||
|
||||
|
@ -459,7 +459,7 @@ protected:
|
||||
// Compila le righe del movimento per le fatture da emettere / ricevere
|
||||
error_type compile_rows_mov_re(TDocumento&);
|
||||
// scrive le scadenze
|
||||
error_type write_scadenze(TDocumento&);
|
||||
error_type write_scadenze(TDocumento& doc, bool recontabilizing);
|
||||
// scrive il movimento e le scadenze
|
||||
virtual error_type write_all(TDocumento& doc, TMovimentoPN_VE & movimento);
|
||||
// scrive il movimento e le scadenze per le fatture da emettere / ricevere
|
||||
|
148
ve/velib04b.cpp
148
ve/velib04b.cpp
@ -1,38 +1,23 @@
|
||||
#include <dongle.h>
|
||||
#include <execp.h>
|
||||
#include <printer.h>
|
||||
#include <viswin.h>
|
||||
|
||||
#include "velib04.h"
|
||||
#include "../ca/calib01.h"
|
||||
|
||||
#include <comuni.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/cglib02.h"
|
||||
#include "../cg/cgsaldac.h"
|
||||
#include "../in/inlib01.h"
|
||||
#include "../mg/anamag.h"
|
||||
|
||||
#include "../ca/movana.h"
|
||||
#include "../m770/scperc.h"
|
||||
#include "../m770/rpag.h"
|
||||
#include "../m770/rver.h"
|
||||
#include "../m770/perc.h"
|
||||
|
||||
#include <comuni.h>
|
||||
#include <unloc.h>
|
||||
#include <dongle.h>
|
||||
#include <execp.h>
|
||||
#include <printer.h>
|
||||
#include <viswin.h>
|
||||
|
||||
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
|
||||
// reperisce la descrizione dal tipo documento e la completa con la data documento ed il
|
||||
// numero documento
|
||||
const bool short_rif = pack_rif();
|
||||
TString descr;
|
||||
const bool short_rif = pack_rif();
|
||||
TString descr;
|
||||
|
||||
if (!short_rif)
|
||||
{
|
||||
doc.riferimento(descr);
|
||||
if (descr.empty()) descr = tipo.descrizione();
|
||||
if (descr.full())
|
||||
descr << ' ';
|
||||
}
|
||||
if (!short_rif)
|
||||
{
|
||||
doc.riferimento(descr);
|
||||
if (descr.empty()) descr = tipo.descrizione();
|
||||
if (descr.full())
|
||||
descr << ' ';
|
||||
}
|
||||
|
||||
|
||||
const TString16 rif = doc.get(DOC_NUMDOCRIF);
|
||||
const bool use_rif = _caus->iva() == iva_acquisti && rif.not_empty();
|
||||
if (use_rif)
|
||||
{
|
||||
descr << "n. " << rif;
|
||||
const TString & data_rif = doc.get_date(DOC_DATADOCRIF).string(short_rif ? brief : full);
|
||||
descr << " del " << data_rif;
|
||||
}
|
||||
else
|
||||
{
|
||||
descr << "n. " << doc.numero();
|
||||
descr << " del " << datadoc.string(short_rif ? brief : full);
|
||||
}
|
||||
|
||||
|
||||
const TString16 rif = doc.get(DOC_NUMDOCRIF);
|
||||
const bool use_rif = _caus->iva() == iva_acquisti && rif.not_empty();
|
||||
if (use_rif)
|
||||
{
|
||||
descr << "n. " << rif;
|
||||
const TString & data_rif = doc.get_date(DOC_DATADOCRIF).string(short_rif ? brief : full);
|
||||
descr << " del " << data_rif;
|
||||
}
|
||||
else
|
||||
{
|
||||
descr << "n. " << doc.numero();
|
||||
descr << " del " << datadoc.string(short_rif ? brief : full);
|
||||
}
|
||||
|
||||
if (doc.in_valuta())
|
||||
{
|
||||
@ -1236,34 +1219,29 @@ error_type TContabilizzazione::compile_head_mov(TDocumento& doc)
|
||||
}
|
||||
|
||||
// Reperisce la valuta
|
||||
TDate datacam(doc.get_date(DOC_DATACAMBIO));
|
||||
real cambio(doc.cambio());
|
||||
TString4 codval(doc.valuta());
|
||||
|
||||
codval.trim();
|
||||
|
||||
if (!doc.in_valuta())
|
||||
TString4 codval;
|
||||
real cambio;
|
||||
TDate datacam;
|
||||
if (doc.in_valuta())
|
||||
{
|
||||
codval = "";
|
||||
cambio = ZERO;
|
||||
}
|
||||
if (codval.not_empty())
|
||||
{
|
||||
_val->put("CODTAB",codval);
|
||||
if (_val->read() != NOERR)
|
||||
codval = doc.valuta(); codval.trim();
|
||||
cambio = doc.cambio();
|
||||
datacam = doc.get_date(DOC_DATACAMBIO);
|
||||
if (::is_true_value(codval))
|
||||
{
|
||||
_error = val_error;
|
||||
return _error;
|
||||
_val->put("CODTAB",codval);
|
||||
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...
|
||||
const TString4 tipocf(doc.get(DOC_TIPOCF));
|
||||
const long codcf = doc.get_long(DOC_CODCF);
|
||||
@ -2657,7 +2635,7 @@ error_type TContabilizzazione::change_doc_status(TDocumento& doc)
|
||||
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.
|
||||
{
|
||||
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 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);
|
||||
// const real change(head.get_real(MOV_CAMBIO));
|
||||
|
||||
TString8 numpart; // Max. 7 chars
|
||||
|
||||
if (_nump_cfg)
|
||||
{
|
||||
numpart = head.get(MOV_PROTIVA);
|
||||
@ -2728,7 +2726,7 @@ error_type TContabilizzazione::write_scadenze(TDocumento& doc)
|
||||
}
|
||||
|
||||
TPartita* newgame = NULL;
|
||||
if (anno > 0 && !numpart.blank())
|
||||
if (anno > 0 && numpart.full())
|
||||
{
|
||||
const int tmov = _caus->tipomov();
|
||||
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));
|
||||
if (has_sc)
|
||||
write_scadenze(doc);
|
||||
write_scadenze(doc, numreg == old_numreg); // Recontbilizing?
|
||||
|
||||
if (good() && in_enabled())
|
||||
write_intra(doc);
|
||||
|
Loading…
x
Reference in New Issue
Block a user