Correzioni invio a Proforma
git-svn-id: svn://10.65.10.50/branches/R_10_00@23010 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
868a300efd
commit
c3564c70ed
@ -19,7 +19,6 @@
|
|||||||
#include <rmoviva.h>
|
#include <rmoviva.h>
|
||||||
#include <multirel.h>
|
#include <multirel.h>
|
||||||
|
|
||||||
#include "../cg/cglib01.h"
|
|
||||||
#include "../cg/cg2103.h"
|
#include "../cg/cg2103.h"
|
||||||
|
|
||||||
bool TTS_mask::apply_filter(const TRecordset& righe) const
|
bool TTS_mask::apply_filter(const TRecordset& righe) const
|
||||||
@ -107,30 +106,38 @@ TRecordset & TTS_campo_sender::movrecset()
|
|||||||
|
|
||||||
TRecordset & TTS_campo_sender::rmovrecset(const TRecordset & mov)
|
TRecordset & TTS_campo_sender::rmovrecset(const TRecordset & mov)
|
||||||
{
|
{
|
||||||
TRecordset * rmov = get_recset(LF_RMOV);
|
TRecordset* rmov = get_recset(LF_RMOV);
|
||||||
|
|
||||||
if (rmov == NULL)
|
if (rmov == NULL)
|
||||||
rmov = set_recset(LF_RMOV, ::create_recordset("USE RMOV\nFROM NUMREG=#NUMREG\nTO NUMREG=#NUMREG"));
|
rmov = set_recset(LF_RMOV, ::create_recordset("USE RMOV\nFROM NUMREG=#NUMREG\nTO NUMREG=#NUMREG"));
|
||||||
|
|
||||||
const TVariant & numreg = mov.get(MOV_NUMREG);
|
const TVariant& numreg = mov.get(MOV_NUMREG);
|
||||||
|
|
||||||
if (numreg != rmov->get("#NUMREG"))
|
if (numreg != rmov->get("#NUMREG"))
|
||||||
rmov->set_var("#NUMREG", numreg);
|
rmov->set_var("#NUMREG", numreg);
|
||||||
return *rmov;
|
|
||||||
|
const int numrig = rmov->items();
|
||||||
|
if (numrig > 80)
|
||||||
|
{
|
||||||
|
TString msg;
|
||||||
|
msg.format(FR("Registrazione con %d righe contabili. (Max. 80)"), numrig);
|
||||||
|
log(2, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return *rmov;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRecordset & TTS_campo_sender::rivarecset(const TRecordset & mov)
|
TRecordset& TTS_campo_sender::rivarecset(const TRecordset & mov)
|
||||||
{
|
{
|
||||||
TRecordset * rmoviva = get_recset(LF_RMOVIVA);
|
TRecordset* rmoviva = get_recset(LF_RMOVIVA);
|
||||||
|
|
||||||
if (rmoviva == NULL)
|
if (rmoviva == NULL)
|
||||||
rmoviva = set_recset(LF_RMOVIVA, ::create_recordset("USE RMOVIVA\nFROM NUMREG=#NUMREG\nTO NUMREG=#NUMREG"));
|
rmoviva = set_recset(LF_RMOVIVA, ::create_recordset("USE RMOVIVA\nFROM NUMREG=#NUMREG\nTO NUMREG=#NUMREG"));
|
||||||
|
|
||||||
const TVariant & numreg = mov.get(MOV_NUMREG);
|
const TVariant& numreg = mov.get(MOV_NUMREG);
|
||||||
|
|
||||||
if (numreg != rmoviva->get("#NUMREG"))
|
if (numreg != rmoviva->get("#NUMREG"))
|
||||||
rmoviva->set_var("#NUMREG", numreg);
|
rmoviva->set_var("#NUMREG", numreg);
|
||||||
return *rmoviva;
|
|
||||||
|
return *rmoviva;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TRecordset& TTS_campo_sender::clirecset(const char tipocf, const long codcf)
|
const TRecordset& TTS_campo_sender::clirecset(const char tipocf, const long codcf)
|
||||||
@ -185,8 +192,7 @@ bool TTS_campo_sender::swap_ritsoc(const TRecordset& mov)
|
|||||||
bool TTS_campo_sender::mov_regolarizzazione(const TRecordset& mov)
|
bool TTS_campo_sender::mov_regolarizzazione(const TRecordset& mov)
|
||||||
{
|
{
|
||||||
const TString& codcaus = mov.get(MOV_CODCAUS).as_string();
|
const TString& codcaus = mov.get(MOV_CODCAUS).as_string();
|
||||||
|
return _caus_regolarizzazione.is_key(codcaus);
|
||||||
return _caus_regolarizzazione.objptr(codcaus) != NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TTS_campo_sender::mov_intra(const TRecordset& mov)
|
bool TTS_campo_sender::mov_intra(const TRecordset& mov)
|
||||||
@ -243,59 +249,71 @@ TMask & TTS_campo_sender::get_mask()
|
|||||||
return * _mask;
|
return * _mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TTS_campo_sender::find_regolarizzazione(TRecordset& mov)
|
bool TTS_campo_sender::find_regolarizzazione(TRecordset& movset)
|
||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
const TRectype& caus = cache().get(LF_CAUSALI, mov.get(MOV_CODCAUS).as_string());
|
const TRecnotype pos = movset.current_row(); // Salva la posizione
|
||||||
const TString4 causreg = caus.get(CAU_CODCAUREG);
|
|
||||||
real totdoc = mov.get(MOV_TOTDOC).as_real();
|
|
||||||
const real ritfis = mov.get(MOV_RITFIS).as_real();
|
|
||||||
const real ritsoc = mov.get(MOV_RITSOC).as_real();
|
|
||||||
|
|
||||||
if (ritfis != ZERO)
|
const TRectype& mov = ((TISAM_recordset&)movset).cursor()->curr();
|
||||||
|
|
||||||
|
const TString4 causreg = cache().get(LF_CAUSALI, mov.get(MOV_CODCAUS), CAU_CODCAUREG);
|
||||||
|
real totdoc = mov.get_real(MOV_TOTDOC);
|
||||||
|
const real ritfis = mov.get_real(MOV_RITFIS);
|
||||||
|
const real ritsoc = mov.get_real(MOV_RITSOC);
|
||||||
|
|
||||||
|
if (!ritfis.is_zero())
|
||||||
totdoc += ritfis;
|
totdoc += ritfis;
|
||||||
if (ritsoc != ZERO)
|
if (!ritsoc.is_zero())
|
||||||
{
|
{
|
||||||
if (swap_ritsoc(mov)) // Somma ritenute sociali con segno
|
if (swap_ritsoc(movset)) // Somma ritenute sociali con segno
|
||||||
totdoc -= ritsoc;
|
totdoc -= ritsoc;
|
||||||
else
|
else
|
||||||
totdoc += ritsoc;
|
totdoc += ritsoc;
|
||||||
}
|
}
|
||||||
if (test_swap(mov))
|
if (test_swap(movset))
|
||||||
totdoc = -totdoc;
|
totdoc = -totdoc;
|
||||||
|
|
||||||
TToken_string key(mov.get(MOV_TIPO).as_string());
|
TToken_string key(mov.get(MOV_TIPO));
|
||||||
key.add(mov.get(MOV_CODCF).as_int());
|
key.add(mov.get(MOV_CODCF));
|
||||||
const TRectype & cli = cache().get(LF_CLIFO, key);
|
const TRectype & cli = cache().get(LF_CLIFO, key);
|
||||||
const TString16 paiv = cli.get(CLI_PAIV);
|
const TString16 paiv = cli.get(CLI_PAIV);
|
||||||
const TString16 cf = cli.get(CLI_COFI);
|
const TString16 cf = cli.get(CLI_COFI);
|
||||||
TEsercizi_contabili esc;
|
TEsercizi_contabili esc;
|
||||||
const TEsercizio & e = esc.esercizio(esc.date2esc(mov.get(MOV_DATAREG).as_date()));
|
const TEsercizio& e = esc.esercizio(esc.date2esc(mov.get_date(MOV_DATAREG)));
|
||||||
const TDate to(e.fine());
|
const TDate dfin = e.fine();
|
||||||
|
|
||||||
for (bool ok = mov.move_next(); ok && ! found; ok = mov.move_next())
|
for (bool ok = movset.move_next(); ok && !found; ok = movset.move_next())
|
||||||
{
|
{
|
||||||
const TDate dreg = mov.get(MOV_DATAREG).as_date();
|
const TDate dreg = mov.get(MOV_DATAREG);
|
||||||
if (dreg >to)
|
if (dreg > dfin)
|
||||||
break;
|
break;
|
||||||
const TRectype& caus = cache().get(LF_CAUSALI, mov.get(MOV_CODCAUS).as_string());
|
|
||||||
const TString4 cod = caus.get(CAU_CODCAUS);
|
|
||||||
|
|
||||||
found = (causreg.full() && cod == causreg) || (causreg.blank() && (_caus_regolarizzazione.objptr(cod) || caus.get_bool(CAU_SOLOIVA)));
|
const TString4 cod = mov.get(MOV_CODCAUS);
|
||||||
found &= (totdoc == mov.get(MOV_TOTDOC).as_real());
|
const TRectype& caus = cache().get(LF_CAUSALI, cod);
|
||||||
|
found = (causreg.full() && cod == causreg) ||
|
||||||
|
(causreg.blank() && (_caus_regolarizzazione.objptr(cod) || caus.get_bool(CAU_SOLOIVA)));
|
||||||
|
if (!found)
|
||||||
|
continue; // causale incoerente
|
||||||
|
|
||||||
key = mov.get(MOV_TIPO).as_string();
|
const real td = mov.get_real(MOV_TOTDOC);
|
||||||
key.add(mov.get(MOV_CODCF).as_int());
|
found = abs(totdoc - td) < 0.01;
|
||||||
|
if (!found)
|
||||||
|
continue; // Importo incoerente
|
||||||
|
|
||||||
|
key = mov.get(MOV_TIPO);
|
||||||
|
key.add(mov.get(MOV_CODCF));
|
||||||
const TRectype & clireg = cache().get(LF_CLIFO, key);
|
const TRectype & clireg = cache().get(LF_CLIFO, key);
|
||||||
const TString16 paivreg = clireg.get(CLI_PAIV);
|
const TString16 paivreg = clireg.get(CLI_PAIV);
|
||||||
const TString16 cfreg = clireg.get(CLI_COFI);
|
const TString16 cfreg = clireg.get(CLI_COFI);
|
||||||
|
|
||||||
found &= ((paiv.full() && paiv == paivreg) || (paiv.blank() && cf == cfreg));
|
found = paiv.full() ? paiv == paivreg : cf == cfreg;
|
||||||
if (found)
|
if (found) // partita IVA coerente
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
movset.move_to(pos);
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
18
tc/tc0700.h
18
tc/tc0700.h
@ -28,16 +28,16 @@ public:
|
|||||||
|
|
||||||
class TTS_campo_sender : public TTS_sender
|
class TTS_campo_sender : public TTS_sender
|
||||||
{
|
{
|
||||||
TTS_mask * _mask;
|
TTS_mask* _mask;
|
||||||
TAssoc_array _caus_regolarizzazione;
|
TAssoc_array _caus_regolarizzazione;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual TRecordset & movrecset();
|
virtual TRecordset& movrecset();
|
||||||
virtual TRecordset & rmovrecset(const TRecordset & mov);
|
virtual TRecordset& rmovrecset(const TRecordset& mov);
|
||||||
virtual TRecordset & rivarecset(const TRecordset & mov);
|
virtual TRecordset& rivarecset(const TRecordset& mov);
|
||||||
virtual const TRecordset & clirecset(const char tipocf, const long codcf);
|
virtual const TRecordset& clirecset(const char tipocf, const long codcf);
|
||||||
virtual TMask & get_mask();
|
virtual TMask& get_mask();
|
||||||
virtual const char * mask_name() const {return "tc0700a"; }
|
virtual const char* mask_name() const { return "tc0700a"; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool find_regolarizzazione(TRecordset& mov);
|
virtual bool find_regolarizzazione(TRecordset& mov);
|
||||||
@ -50,14 +50,12 @@ protected:
|
|||||||
virtual long iva11_reverse(const TRecordset & mov);
|
virtual long iva11_reverse(const TRecordset & mov);
|
||||||
virtual bool regime_agricolo(const TRecordset& mov) const;
|
virtual bool regime_agricolo(const TRecordset& mov) const;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void postprocess_movs(TRecordset & mov);
|
virtual void postprocess_movs(TRecordset & mov);
|
||||||
virtual bool create();
|
virtual bool create();
|
||||||
virtual bool destroy();
|
virtual bool destroy();
|
||||||
|
|
||||||
TTS_campo_sender() : TTS_sender(), _mask(NULL) {}
|
TTS_campo_sender() : _mask(NULL) {}
|
||||||
~TTS_campo_sender() {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -563,7 +563,10 @@ void TTS_sender::log(int sev, const char* msg)
|
|||||||
if (sev > 0 && _tsfile != NULL)
|
if (sev > 0 && _tsfile != NULL)
|
||||||
{
|
{
|
||||||
TString m;
|
TString m;
|
||||||
m << TR("Record") << ' ' << _tsfile->rec_type() << ": " << msg;
|
if (_numreg > 0)
|
||||||
|
m.format("Movimento %6ld ", _numreg);
|
||||||
|
m << TR("Tipo record ") << _tsfile->rec_type();
|
||||||
|
m << " : " << msg;
|
||||||
_log->log(sev, m);
|
_log->log(sev, m);
|
||||||
_errors_logged = true;
|
_errors_logged = true;
|
||||||
}
|
}
|
||||||
@ -603,7 +606,7 @@ bool TTS_sender::add_regol(TRecordset& mov, bool rec_to_add)
|
|||||||
{
|
{
|
||||||
rec_to_add = add_optional_rec(mov, rec_to_add);
|
rec_to_add = add_optional_rec(mov, rec_to_add);
|
||||||
|
|
||||||
TString16 codval = mov.get(MOV_CODVALI).as_string();
|
TString4 codval = mov.get(MOV_CODVALI).as_string();
|
||||||
real corrvaluta = mov.get(MOV_CORRVALUTA).as_real();
|
real corrvaluta = mov.get(MOV_CORRVALUTA).as_real();
|
||||||
|
|
||||||
if (codval.blank())
|
if (codval.blank())
|
||||||
@ -621,26 +624,24 @@ bool TTS_sender::add_regol(TRecordset& mov, bool rec_to_add)
|
|||||||
set("TRF-TOTVAL", corrvaluta);
|
set("TRF-TOTVAL", corrvaluta);
|
||||||
}
|
}
|
||||||
|
|
||||||
const TRecnotype pos = mov.current_row(); // Salva la posizione
|
|
||||||
|
|
||||||
if (find_regolarizzazione(mov))
|
if (find_regolarizzazione(mov))
|
||||||
{
|
{
|
||||||
set("TRF-NUM-AUTOFATT", mov.get(MOV_PROTIVA).as_int());
|
set("TRF-NUM-AUTOFATT", mov.get(MOV_PROTIVA).as_int());
|
||||||
|
|
||||||
const TString16 codice = scod2ricl("TSREG", mov.get(MOV_REG));
|
const TString& codice = scod2ricl("TSREG", mov.get(MOV_REG));
|
||||||
const long codreg = atol(codice.mid(1));
|
const long codreg = atol(codice.mid(1));
|
||||||
set("TRF-SERIE-AUTOFATT", codreg);
|
set("TRF-SERIE-AUTOFATT", codreg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
TString msg;
|
||||||
if (is_intra)
|
if (is_intra)
|
||||||
log(2, TR("Manca la regolarizzazione del movimento intra"));
|
msg << TR("Manca la regolarizzazione del movimento intra");
|
||||||
else
|
else
|
||||||
log(2, TR("Manca la regolarizzazione del movimento reverse charge"));
|
msg << TR("Manca la regolarizzazione del movimento reverse charge");
|
||||||
|
log(2, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
mov.move_to(pos); // Ripristina posizione
|
|
||||||
|
|
||||||
return rec_to_add;
|
return rec_to_add;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -754,13 +755,13 @@ void TTS_sender::add_diversi(const TRecordset& mov, const bool moviva)
|
|||||||
{
|
{
|
||||||
const real importo = rmov.get(RMV_IMPORTO).as_real();
|
const real importo = rmov.get(RMV_IMPORTO).as_real();
|
||||||
const char sez = rmov.get(RMV_SEZIONE).as_string()[0];
|
const char sez = rmov.get(RMV_SEZIONE).as_string()[0];
|
||||||
TImporto i(sez, importo);
|
TImporto imp(sez, importo);
|
||||||
|
|
||||||
i.normalize(seznor);
|
imp.normalize(seznor);
|
||||||
field.format("TRF-CONTORIC_%d", k);
|
field.format("TRF-CONTORIC_%d", k);
|
||||||
set(field, contoricl);
|
set(field, contoricl);
|
||||||
field.format("TRF-IMP-RIC_%d", k);
|
field.format("TRF-IMP-RIC_%d", k);
|
||||||
set(field, i.valore());
|
set(field, imp.valore());
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -776,8 +777,8 @@ void TTS_sender::add_diversi(const TRecordset& mov, const bool moviva)
|
|||||||
switch (tiporiga)
|
switch (tiporiga)
|
||||||
{
|
{
|
||||||
case 'T':
|
case 'T':
|
||||||
first_cli = false;
|
first_cli = false;
|
||||||
contoclifor = contoricl;
|
contoclifor = contoricl;
|
||||||
case 'I':
|
case 'I':
|
||||||
case 'D':
|
case 'D':
|
||||||
case 'N':
|
case 'N':
|
||||||
@ -1032,12 +1033,16 @@ void TTS_sender::add_datiiva(const TRecordset& mov)
|
|||||||
item->imposta() += imposta;
|
item->imposta() += imposta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const int numrig = _iva.items();
|
||||||
|
if (numrig > 8)
|
||||||
|
{
|
||||||
|
TString msg;
|
||||||
|
msg.format(FR("Registrazione con %d righe IVA (Max.8)"), numrig);
|
||||||
|
log(2, msg);
|
||||||
|
}
|
||||||
|
|
||||||
TString80 field;
|
TString80 field;
|
||||||
|
|
||||||
if (_iva.items() > 8)
|
|
||||||
log(2, TR("Registrazione con piu di 8 righe IVA"));
|
|
||||||
|
|
||||||
|
|
||||||
FOR_EACH_ASSOC_OBJECT(_iva, o, k, it)
|
FOR_EACH_ASSOC_OBJECT(_iva, o, k, it)
|
||||||
{
|
{
|
||||||
TIVA_item & item = (TIVA_item &) *it;
|
TIVA_item & item = (TIVA_item &) *it;
|
||||||
@ -1259,8 +1264,7 @@ void TTS_sender::add_clifor(char tipocf, long codcf)
|
|||||||
|
|
||||||
void TTS_sender::add_mov(TRecordset& mov)
|
void TTS_sender::add_mov(TRecordset& mov)
|
||||||
{
|
{
|
||||||
TString msg; msg << TR("Registrazione n.") << ' ' << mov.get(MOV_NUMREG);
|
set_log_numreg(mov.get(MOV_NUMREG).as_int());
|
||||||
log(0, msg);
|
|
||||||
if (new_rec("0"))
|
if (new_rec("0"))
|
||||||
{
|
{
|
||||||
char tipocf = mov.get(MOV_TIPO).as_string()[0];
|
char tipocf = mov.get(MOV_TIPO).as_string()[0];
|
||||||
@ -1481,36 +1485,37 @@ bool TTS_sender::destroy()
|
|||||||
|
|
||||||
void TTS_sender::main_loop()
|
void TTS_sender::main_loop()
|
||||||
{
|
{
|
||||||
TMask & m = get_mask();
|
TMask& m = get_mask();
|
||||||
while (m.run() != K_QUIT)
|
while (m.run() != K_QUIT)
|
||||||
{
|
{
|
||||||
const char* const title = TR("Invio a TeamSystem");
|
|
||||||
_tsfile = new TTS_textset;
|
_tsfile = new TTS_textset;
|
||||||
_log = new TLog_report(title);
|
_log = new TLog_report(title());
|
||||||
_errors_logged = false;
|
_errors_logged = false;
|
||||||
|
|
||||||
TRecordset & mov = movrecset();
|
TRecordset & mov = movrecset();
|
||||||
TProgind pi(mov.items(), TR("Scansione movimenti"), true, true);
|
TProgress_monitor pi(mov.items(), TR("Scansione movimenti prima nota"));
|
||||||
|
|
||||||
for (bool ok = mov.move_first(); ok; ok = mov.move_next())
|
for (bool ok = mov.move_first(); ok; ok = mov.move_next())
|
||||||
{
|
{
|
||||||
if (!pi.addstatus(1))
|
|
||||||
break;
|
|
||||||
if (!mov_regolarizzazione(mov))
|
if (!mov_regolarizzazione(mov))
|
||||||
add_mov(mov);
|
add_mov(mov);
|
||||||
|
if (!pi.addstatus(1))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
set_log_numreg(0);
|
||||||
|
|
||||||
TReport_book book;
|
TReport_book book;
|
||||||
book.add(*_log);
|
book.add(*_log);
|
||||||
#ifdef DBG
|
//#ifdef DBG
|
||||||
TAS400_report rep(*_tsfile);
|
// TAS400_report rep(*_tsfile);
|
||||||
book.add(rep);
|
// book.add(rep);
|
||||||
#endif
|
//#endif
|
||||||
book.preview();
|
book.preview();
|
||||||
|
|
||||||
bool save = true;
|
bool save = true;
|
||||||
if (_errors_logged)
|
if (_errors_logged)
|
||||||
{
|
{
|
||||||
save = yesno_box(TR("Sono stati riscontrati uno o piu' errori:\n"
|
save = noyes_box(TR("Sono stati riscontrati uno o più errori:\n"
|
||||||
"Si desidera salvare il file ugualmente?"));
|
"Si desidera salvare il file ugualmente?"));
|
||||||
}
|
}
|
||||||
if (save)
|
if (save)
|
||||||
|
@ -35,6 +35,7 @@ class TTS_sender : public TSkeleton_application
|
|||||||
TAssoc_array _riclassifica;
|
TAssoc_array _riclassifica;
|
||||||
TTS_textset* _tsfile;
|
TTS_textset* _tsfile;
|
||||||
TLog_report* _log;
|
TLog_report* _log;
|
||||||
|
long _numreg;
|
||||||
bool _errors_logged;
|
bool _errors_logged;
|
||||||
TString8 _dittamulti;
|
TString8 _dittamulti;
|
||||||
TAssoc_array _dittemulti;
|
TAssoc_array _dittemulti;
|
||||||
@ -91,7 +92,7 @@ protected:
|
|||||||
bool add_iva_to_mov(const TRecordset& mov) { return mov_intra(mov) || mov_reverse_charge(mov);}
|
bool add_iva_to_mov(const TRecordset& mov) { return mov_intra(mov) || mov_reverse_charge(mov);}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool find_regolarizzazione(TRecordset& mov) {return false;}
|
virtual bool find_regolarizzazione(TRecordset& mov) { return false; }
|
||||||
virtual TRecordset & movrecset() pure;
|
virtual TRecordset & movrecset() pure;
|
||||||
virtual TRecordset & rmovrecset(const TRecordset & mov) pure;
|
virtual TRecordset & rmovrecset(const TRecordset & mov) pure;
|
||||||
virtual TRecordset & rivarecset(const TRecordset & mov) pure;
|
virtual TRecordset & rivarecset(const TRecordset & mov) pure;
|
||||||
@ -100,6 +101,7 @@ protected:
|
|||||||
virtual TMask & get_mask() pure ;
|
virtual TMask & get_mask() pure ;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
void set_log_numreg(long n) { _numreg = n; }
|
||||||
void log(int sev, const char* msg);
|
void log(int sev, const char* msg);
|
||||||
virtual bool multi_activity() const { return true; }
|
virtual bool multi_activity() const { return true; }
|
||||||
virtual const TString & dittamulti(const TRecordset& mov) const ;
|
virtual const TString & dittamulti(const TRecordset& mov) const ;
|
||||||
|
149
tc/tc9100.cpp
149
tc/tc9100.cpp
@ -1,29 +1,21 @@
|
|||||||
#include <applicat.h>
|
#include <applicat.h>
|
||||||
#include <defmask.h>
|
|
||||||
#include <filetext.h>
|
#include <filetext.h>
|
||||||
#include <progind.h>
|
#include <progind.h>
|
||||||
#include <recarray.h>
|
|
||||||
#include <recset.h>
|
#include <recset.h>
|
||||||
|
|
||||||
#include "tc9.h"
|
#include "tc9.h"
|
||||||
#include "tc9100a.h"
|
#include "tc9100a.h"
|
||||||
|
|
||||||
#include <pagsca.h>
|
|
||||||
#include <partite.h>
|
|
||||||
|
|
||||||
#include "../cg/cg2101.h"
|
#include "../cg/cg2101.h"
|
||||||
#include "../cg/cg2103.h"
|
#include "../cg/cg2103.h"
|
||||||
#include "../cg/cgsaldac.h"
|
#include "../cg/cgsaldac.h"
|
||||||
|
#include <pconti.h>
|
||||||
|
|
||||||
#include "../ca/calib01.h"
|
#include "../ca/calib01.h"
|
||||||
#include "../ca/movana.h"
|
|
||||||
#include "../ca/rmovana.h"
|
#include "../ca/rmovana.h"
|
||||||
|
|
||||||
#include "../ve/velib.h"
|
#include "../ve/velib.h"
|
||||||
|
|
||||||
#include <doc.h>
|
|
||||||
#include <rdoc.h>
|
|
||||||
|
|
||||||
|
|
||||||
class TInvioP_file: public TFile_text
|
class TInvioP_file: public TFile_text
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
@ -34,9 +26,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
TInvioP_file::TInvioP_file(const TString& file_name)
|
TInvioP_file::TInvioP_file(const TString& file_name)
|
||||||
: TFile_text(file_name, "tc9100a.ini")
|
: TFile_text(file_name, "tc9100a.ini")
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
// MASCHERA
|
// MASCHERA
|
||||||
@ -560,20 +551,30 @@ bool TInvioP::i_proforma_righe(TCursor& cur, TInvioP_file* trasfilerighe)
|
|||||||
const TString& zio = conti_importi.conto(k);
|
const TString& zio = conti_importi.conto(k);
|
||||||
stringa_grcosot(recrighe, zio);
|
stringa_grcosot(recrighe, zio);
|
||||||
|
|
||||||
const TString tipocf = pn.curr().get(MOV_TIPO);
|
char tipocf = pn.curr().get_char(MOV_TIPO);
|
||||||
recrighe.add(tipocf, 6); //tipocf
|
long codcf = pn.curr().get_long(MOV_CODCF);
|
||||||
|
|
||||||
|
if (tipocf < 'C') // Nei pagamenti la prima nota non scrive TIPO e CODCF in testata, per cui...
|
||||||
|
{
|
||||||
|
workstring = recrighe.get(3);
|
||||||
|
workstring << '|' << recrighe.get(4);
|
||||||
|
tipocf = cache().get(LF_PCON, workstring, PCN_TMCF)[0];
|
||||||
|
if (tipocf >= 'C')
|
||||||
|
codcf = atol(recrighe.get(5));
|
||||||
|
}
|
||||||
|
|
||||||
//procedura per stringare il codice clifo
|
//procedura per stringare il codice clifo
|
||||||
if (tipocf > ' ')
|
if (tipocf >= 'C' && codcf > 0L)
|
||||||
{
|
{
|
||||||
const long codcf = pn.curr().get_long(MOV_CODCF);
|
workstring.cut(0) << tipocf;
|
||||||
TString cf;
|
recrighe.add(workstring, 6); // tipocf
|
||||||
cf.format("%ld", codcf);
|
workstring.format("%ld", codcf);
|
||||||
recrighe.add(cf, 7); //codcf
|
recrighe.add(workstring, 7); // codcf
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
recrighe.add("", 7); //codcf
|
recrighe.add(EMPTY_STRING, 6); // tipocf
|
||||||
|
recrighe.add(EMPTY_STRING, 7); // codcf
|
||||||
}
|
}
|
||||||
|
|
||||||
recrighe.add(pn.curr().get(RMV_DESCR), 8); //descrizione
|
recrighe.add(pn.curr().get(RMV_DESCR), 8); //descrizione
|
||||||
@ -915,18 +916,12 @@ bool TInvioP::cerca_conto(const TBill& bill, const TAssoc_array& assoc, const ch
|
|||||||
|
|
||||||
int TInvioP::cerca_costo(const TBill& bill) const
|
int TInvioP::cerca_costo(const TBill& bill) const
|
||||||
{
|
{
|
||||||
if (cerca_conto(bill, _costi, 'C'))
|
return cerca_conto(bill, _costi, 'C') ? 1 : 0;
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int TInvioP::cerca_pagamento(const TBill& bill) const
|
int TInvioP::cerca_pagamento(const TBill& bill) const
|
||||||
{
|
{
|
||||||
if (cerca_conto(bill, _pagamenti, 'P'))
|
return cerca_conto(bill, _pagamenti, 'P') ? 2 : 0;
|
||||||
return 2;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TInvioP::cerca_fiscali(const TBill& bill) const
|
bool TInvioP::cerca_fiscali(const TBill& bill) const
|
||||||
@ -978,10 +973,21 @@ void TInvioP::calcola_imposte(const real& importo, const real& imposta,
|
|||||||
if (rec.get_int("I0") > 0)
|
if (rec.get_int("I0") > 0)
|
||||||
perc = rec.get_real("R0");
|
perc = rec.get_real("R0");
|
||||||
}
|
}
|
||||||
//valori delle varie ive
|
if (perc > ZERO) // C'è indetraibilità?
|
||||||
iva_ind = imposta * perc / CENTO;
|
{
|
||||||
iva_ind.round(2);
|
//valori delle varie ive
|
||||||
iva_det = imposta - iva_ind;
|
if (perc < CENTO)
|
||||||
|
{
|
||||||
|
iva_ind = imposta * perc / CENTO;
|
||||||
|
iva_ind.round(2);
|
||||||
|
iva_det = imposta - iva_ind;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iva_ind = imposta;
|
||||||
|
iva_det = ZERO;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1026,9 +1032,9 @@ bool TInvioP::calcola_imponibile_totdoc(const long nreg, const TRectype& pag_rec
|
|||||||
{
|
{
|
||||||
const TRectype& mov = pn.curr();
|
const TRectype& mov = pn.curr();
|
||||||
TCausale caus(mov.get(MOV_CODCAUS));
|
TCausale caus(mov.get(MOV_CODCAUS));
|
||||||
const bool swapt = test_swap(caus, false); // Totale invertito ?
|
const bool swapt = test_swap(caus, false); // Totale invertito ?
|
||||||
const bool swaps = test_swap(caus, true); // Ritenute sociali invertite ?
|
const bool swaps = test_swap(caus, true); // Ritenute sociali invertite ?
|
||||||
if (swapt ^ swaps) // Somma ritenute sociali con segno
|
if (swapt ^ swaps) // Somma ritenute sociali con segno
|
||||||
totpagato -= ritsoc;
|
totpagato -= ritsoc;
|
||||||
else
|
else
|
||||||
totpagato += ritsoc;
|
totpagato += ritsoc;
|
||||||
@ -1051,7 +1057,7 @@ bool TInvioP::calcola_imponibile_totdoc(const long nreg, const TRectype& pag_rec
|
|||||||
//calcola i valori dell'iva detraibile e delle ive indetraibili in diverse percentuali
|
//calcola i valori dell'iva detraibile e delle ive indetraibili in diverse percentuali
|
||||||
calcola_imposte(importo, iva, codind, iva_det, iva_ind);
|
calcola_imposte(importo, iva, codind, iva_det, iva_ind);
|
||||||
//se esiste un'iva indetraibile..
|
//se esiste un'iva indetraibile..
|
||||||
if (iva_ind != ZERO)
|
if (!iva_ind.is_zero())
|
||||||
{
|
{
|
||||||
iva_indetraibile += iva_ind;
|
iva_indetraibile += iva_ind;
|
||||||
imponibile += iva_ind;
|
imponibile += iva_ind;
|
||||||
@ -1223,13 +1229,13 @@ bool TInvioP::i_proforma_pagamenti()
|
|||||||
lettura_conti(_costi, 'C');
|
lettura_conti(_costi, 'C');
|
||||||
lettura_conti(_pagamenti, 'P');
|
lettura_conti(_pagamenti, 'P');
|
||||||
|
|
||||||
TProgind pi(cur_items, "Trasferimento pagamenti...", true, true);
|
TProgress_monitor pi(cur_items, TR("Trasferimento pagamenti..."));
|
||||||
|
|
||||||
cur.freeze();
|
cur.freeze();
|
||||||
TRectype& cur_rec = cur.curr();
|
TRectype& cur_rec = cur.curr();
|
||||||
for (cur = 0; cur.pos() < cur_items; ++(cur))
|
for (cur = 0; cur.pos() < cur_items; ++(cur))
|
||||||
{
|
{
|
||||||
if (!pi.addstatus(1))
|
if (!pi.set_status(cur.pos()))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//pagamenti saldacontati! vedi l'else per quelli non saldacontati
|
//pagamenti saldacontati! vedi l'else per quelli non saldacontati
|
||||||
@ -1239,11 +1245,16 @@ bool TInvioP::i_proforma_pagamenti()
|
|||||||
//attraverso le partite,noto il MOV_NUMREG,riesce a collegarsi al pagamento in LF_PAGSCA
|
//attraverso le partite,noto il MOV_NUMREG,riesce a collegarsi al pagamento in LF_PAGSCA
|
||||||
TRelation relpart(LF_PARTITE);
|
TRelation relpart(LF_PARTITE);
|
||||||
TRectype da(LF_PARTITE);
|
TRectype da(LF_PARTITE);
|
||||||
da.put(PART_NREG, cur_rec.get(MOV_NUMREG));
|
const long numreg = cur_rec.get_long(MOV_NUMREG);
|
||||||
|
da.put(PART_NREG, numreg);
|
||||||
|
#ifdef DBG
|
||||||
|
if (numreg == 91653)
|
||||||
|
int cazzone = 1;
|
||||||
|
#endif
|
||||||
TCursor curpart(&relpart, "", 2, &da, &da);
|
TCursor curpart(&relpart, "", 2, &da, &da);
|
||||||
const long curpart_items = curpart.items();
|
const TRecnotype curpart_items = curpart.items();
|
||||||
//se trova la partita relativa al numreg...
|
//se trova la partita relativa al numreg...
|
||||||
if (curpart_items != 0)
|
if (curpart_items > 0)
|
||||||
{
|
{
|
||||||
curpart.freeze();
|
curpart.freeze();
|
||||||
TRectype& curpart_rec = curpart.curr();
|
TRectype& curpart_rec = curpart.curr();
|
||||||
@ -1262,12 +1273,12 @@ bool TInvioP::i_proforma_pagamenti()
|
|||||||
TString80 filtro;
|
TString80 filtro;
|
||||||
filtro.format("NRIGP == %d", nrigapart);
|
filtro.format("NRIGP == %d", nrigapart);
|
||||||
TCursor curpag(&relpag, filtro, 1, &da, &da);
|
TCursor curpag(&relpag, filtro, 1, &da, &da);
|
||||||
const long curpag_items = curpag.items();
|
const TRecnotype curpag_items = curpag.items();
|
||||||
|
|
||||||
real iva_indet = ZERO; //valore dell'eventuale iva indetraibile
|
real iva_indet = ZERO; //valore dell'eventuale iva indetraibile
|
||||||
|
|
||||||
//se trova i pagamenti,che sono alla fin fine cio' che cerca...
|
//se trova i pagamenti,che sono alla fin fine cio' che cerca...
|
||||||
if (curpag_items != 0)
|
if (curpag_items > 0)
|
||||||
{
|
{
|
||||||
TAssoc_array pagame;
|
TAssoc_array pagame;
|
||||||
pagame.destroy();
|
pagame.destroy();
|
||||||
@ -1307,6 +1318,10 @@ bool TInvioP::i_proforma_pagamenti()
|
|||||||
_nregpag = cur_rec.get_long(MOV_NUMREG); //registrazione del movimento di pagamento
|
_nregpag = cur_rec.get_long(MOV_NUMREG); //registrazione del movimento di pagamento
|
||||||
//deve cercare la prima registrazione da cui deriva il pagamento..
|
//deve cercare la prima registrazione da cui deriva il pagamento..
|
||||||
const long nregfatt = fattura.get_long(PART_NREG);
|
const long nregfatt = fattura.get_long(PART_NREG);
|
||||||
|
#ifdef DBG
|
||||||
|
if (nregfatt == 91296)
|
||||||
|
int cazzone = 1;
|
||||||
|
#endif
|
||||||
_nregcosto = calcola_fattura_originale(nregfatt);
|
_nregcosto = calcola_fattura_originale(nregfatt);
|
||||||
_importo = pi->_somma;
|
_importo = pi->_somma;
|
||||||
//acconto/saldo in modo standard
|
//acconto/saldo in modo standard
|
||||||
@ -1452,7 +1467,7 @@ bool TInvioP::i_proforma_pagamenti()
|
|||||||
if (items > 0)
|
if (items > 0)
|
||||||
{
|
{
|
||||||
if (items > 1)
|
if (items > 1)
|
||||||
error_box(TR("Esiste piu' di un movimento analitico collegato al movimento contabile %ld"),numregcg);
|
error_box(FR("Esiste più d'un movimento analitico collegato al movimento contabile %ld"), numregcg);
|
||||||
|
|
||||||
movana.move_last(); //si posiziona sul record corretto
|
movana.move_last(); //si posiziona sul record corretto
|
||||||
|
|
||||||
@ -1513,21 +1528,20 @@ bool TInvioP::i_proforma_clifor(char tipocf)
|
|||||||
{
|
{
|
||||||
TInvioP_file* trasfile = NULL;
|
TInvioP_file* trasfile = NULL;
|
||||||
|
|
||||||
TString progind_string = "Trasferimento ";
|
TString progind_string = TR("Trasferimento ");
|
||||||
|
|
||||||
if (tipocf == 'C')
|
if (tipocf == 'C')
|
||||||
{
|
{
|
||||||
trasfile = apri_file("clienti");
|
trasfile = apri_file("clienti");
|
||||||
progind_string << "clienti";
|
progind_string << TR("clienti");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
trasfile = apri_file("fornit");
|
trasfile = apri_file("fornit");
|
||||||
progind_string << "fornitori";
|
progind_string << TR("fornitori");
|
||||||
}
|
}
|
||||||
|
|
||||||
TString80 filtro = "";
|
TString16 filtro; filtro.format("TIPOCF==\"%c\"", tipocf);
|
||||||
filtro.format("TIPOCF == \"%c\"", tipocf);
|
|
||||||
TRelation rel(LF_CLIFO);
|
TRelation rel(LF_CLIFO);
|
||||||
rel.add(LF_COMUNI, "STATO==STATOCF|COM==COMCF", 1);
|
rel.add(LF_COMUNI, "STATO==STATOCF|COM==COMCF", 1);
|
||||||
TCursor cur(&rel, filtro);
|
TCursor cur(&rel, filtro);
|
||||||
@ -1535,21 +1549,20 @@ bool TInvioP::i_proforma_clifor(char tipocf)
|
|||||||
|
|
||||||
if (cur_items != 0)
|
if (cur_items != 0)
|
||||||
{
|
{
|
||||||
progind_string << "...";
|
|
||||||
TProgind pi(cur_items, progind_string, true, true);
|
|
||||||
|
|
||||||
cur.freeze();
|
cur.freeze();
|
||||||
TRectype& cur_rec = cur.curr();
|
TRectype& cur_rec = cur.curr();
|
||||||
for (cur = 0; cur.pos() < cur_items; ++(cur))
|
|
||||||
{
|
|
||||||
pi.addstatus(1);
|
|
||||||
if (pi.iscancelled())
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
progind_string << "...";
|
||||||
|
TProgress_monitor pi(cur_items, progind_string);
|
||||||
|
for (cur = 0; cur.pos() < cur_items; ++cur)
|
||||||
|
{
|
||||||
TRecord_text rec;
|
TRecord_text rec;
|
||||||
rec.set_type("C");
|
rec.set_type("C");
|
||||||
trasfile->autoload(rec, cur);
|
trasfile->autoload(rec, cur);
|
||||||
trasfile->write(rec);
|
trasfile->write(rec);
|
||||||
|
|
||||||
|
if (!pi.add_status())
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chiudi_file(trasfile);
|
chiudi_file(trasfile);
|
||||||
@ -1573,6 +1586,12 @@ void TInvioP::invio_proforma()
|
|||||||
|
|
||||||
bool TInvioP::create()
|
bool TInvioP::create()
|
||||||
{
|
{
|
||||||
|
//il programma si puo' usare SOLO se in contabilita' analitica si usa il piano dei conti contabile
|
||||||
|
TConfig& cfg = ca_config();
|
||||||
|
const bool use_pdcc = cfg.get_bool("UsePdcc");
|
||||||
|
if (!use_pdcc)
|
||||||
|
return error_box(TR("Il programma funziona SOLO se in contabilità analitica si usa il piano dei conti contabile"));
|
||||||
|
|
||||||
_msk = new TInvioP_mask();
|
_msk = new TInvioP_mask();
|
||||||
_configfile = new TConfig("tc9100a.ini");
|
_configfile = new TConfig("tc9100a.ini");
|
||||||
return TSkeleton_application::create();
|
return TSkeleton_application::create();
|
||||||
@ -1582,22 +1601,14 @@ bool TInvioP::destroy()
|
|||||||
{
|
{
|
||||||
if (_configfile != NULL)
|
if (_configfile != NULL)
|
||||||
delete _configfile;
|
delete _configfile;
|
||||||
delete _msk;
|
if (_msk != NULL)
|
||||||
|
delete _msk;
|
||||||
|
|
||||||
return TSkeleton_application::destroy();
|
return TSkeleton_application::destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TInvioP::main_loop()
|
void TInvioP::main_loop()
|
||||||
{
|
{
|
||||||
//il programma si puo' usare SOLO se in contabilita' analitica si usa il piano dei conti contabile
|
|
||||||
TConfig& cfg = ca_config();
|
|
||||||
const bool use_pdcc = cfg.get_bool("UsePdcc");
|
|
||||||
if (!use_pdcc)
|
|
||||||
{
|
|
||||||
error_box(TR("Programma funzionante SOLO se in contabilita' analitica si usa il piano dei conti contabile"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TFilename configname = "tc9100conf.ini"; //file configurazione della maschera
|
TFilename configname = "tc9100conf.ini"; //file configurazione della maschera
|
||||||
configname.custom_path();
|
configname.custom_path();
|
||||||
TConfig configfile(configname);
|
TConfig configfile(configname);
|
||||||
@ -1619,7 +1630,7 @@ void TInvioP::main_loop()
|
|||||||
int tc9100(int argc, char **argv)
|
int tc9100(int argc, char **argv)
|
||||||
{
|
{
|
||||||
TInvioP a;
|
TInvioP a;
|
||||||
a.run(argc, argv, "Invio dati contabilità a Proforma");
|
a.run(argc, argv, TR("Invio dati contabilità a Proforma"));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user