Patch level : 10.0 218
Files correlati : ve0.exe ve6.exe Ricompilazione Demo : [ ] Commento : Contabilizzazione schede percipiente git-svn-id: svn://10.65.10.50/trunk@18167 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
d69a5b2854
commit
fff659f797
237
ve/velib04b.cpp
237
ve/velib04b.cpp
@ -29,6 +29,10 @@
|
|||||||
#include "../in/inlib01.h"
|
#include "../in/inlib01.h"
|
||||||
#include "../mg/anamag.h"
|
#include "../mg/anamag.h"
|
||||||
#include "../ca/movana.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 <comuni.h>
|
||||||
#include <unloc.h>
|
#include <unloc.h>
|
||||||
@ -2787,6 +2791,12 @@ error_type TContabilizzazione::write_all(TDocumento& doc, TMovimentoPN_VE & movi
|
|||||||
if (good() && (dongle().active(CMAUT) || dongle().active(CAAUT)))
|
if (good() && (dongle().active(CMAUT) || dongle().active(CAAUT)))
|
||||||
write_anal(doc, movimento);
|
write_anal(doc, movimento);
|
||||||
|
|
||||||
|
const int tipocoll = _caus->link_m770();
|
||||||
|
const bool do_770 = tipocoll == 1 || tipocoll == 5 || tipocoll == 6;
|
||||||
|
|
||||||
|
if (good() && dongle().active(M77AUT) && do_770)
|
||||||
|
write_percip(doc, movimento);
|
||||||
|
|
||||||
if (doc.get_real(DOC_IMPPAGATO) != ZERO)
|
if (doc.get_real(DOC_IMPPAGATO) != ZERO)
|
||||||
if (write_anticipo(doc) != no_error)
|
if (write_anticipo(doc) != no_error)
|
||||||
movimento.remove(); // Se si è verificato un errore nella scrittura dell'anticipo rimuove il movimento di prima nota
|
movimento.remove(); // Se si è verificato un errore nella scrittura dell'anticipo rimuove il movimento di prima nota
|
||||||
@ -3530,6 +3540,229 @@ error_type TContabilizzazione::write_anal(TDocumento& doc, const TMovimentoPN& m
|
|||||||
return _error;
|
return _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error_type TContabilizzazione::write_percip(TDocumento& doc, const TMovimentoPN& movimento)
|
||||||
|
{
|
||||||
|
const char tipopercip = doc.clifor().get_char(CLI_TIPOAPER);
|
||||||
|
const long codpercip = doc.clifor().get_long(CLI_CODANAGPER);
|
||||||
|
|
||||||
|
if (codpercip > 0L)
|
||||||
|
{
|
||||||
|
TBit_array to_delete;
|
||||||
|
TArray schede;
|
||||||
|
TLocalisamfile schperc(LF_SCPERC);
|
||||||
|
TLocalisamfile rpag(LF_RPAG);
|
||||||
|
TLocalisamfile rver(LF_RVER);
|
||||||
|
TLocalisamfile perc(LF_PERC);
|
||||||
|
const long numreg = movimento.lfile().get_long(MOV_NUMREG);
|
||||||
|
int numsch = 0;
|
||||||
|
|
||||||
|
schperc.setkey(3);
|
||||||
|
schperc.put(SCH_CODDITTA, prefix().firm().codice());
|
||||||
|
schperc.put(SCH_NUMREG, numreg);
|
||||||
|
|
||||||
|
TRectype schcmp(schperc.curr());
|
||||||
|
int err;
|
||||||
|
|
||||||
|
for (err = schperc.read(_isgteq); err == NOERR && schperc.curr() == schcmp; err = schperc.next())
|
||||||
|
{
|
||||||
|
schede.add(schperc.curr());
|
||||||
|
to_delete.set(numsch++);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool changed_percip = (numsch == 0) || (tipopercip != ((TRectype &) schede[0]).get_char(SCH_TIPOA)) ||
|
||||||
|
(codpercip != ((TRectype &) schede[0]).get_long(SCH_CODANAGR));
|
||||||
|
int newprog = 0L;
|
||||||
|
const int orig_numsch = numsch;
|
||||||
|
const int doc_rows = doc.physical_rows();
|
||||||
|
int i = 1;
|
||||||
|
|
||||||
|
schperc.setkey(1);
|
||||||
|
schperc.zero();
|
||||||
|
schperc.put(SCH_CODDITTA, prefix().firm().codice());
|
||||||
|
schperc.put(SCH_TIPOA, tipopercip);
|
||||||
|
schperc.put(SCH_CODANAGR, codpercip);
|
||||||
|
schcmp = schperc.curr();
|
||||||
|
schperc.put(SCH_NPROG, 9999);
|
||||||
|
if (schperc.read(_isgteq) == NOERR)
|
||||||
|
schperc.prev();
|
||||||
|
if (schperc.curr() == schcmp)
|
||||||
|
newprog = schperc.get_int(SCH_NPROG);
|
||||||
|
newprog++;
|
||||||
|
for (i = 1; i <= doc_rows; i++)
|
||||||
|
{
|
||||||
|
const TRiga_documento & row = doc[i];
|
||||||
|
|
||||||
|
if (row.is_spese())
|
||||||
|
{
|
||||||
|
const TSpesa_prest & sp = row.spesa();
|
||||||
|
|
||||||
|
if (sp.tipo_ritenuta() == 'F')
|
||||||
|
{
|
||||||
|
const int caus_770 = sp.caus_770();
|
||||||
|
|
||||||
|
if (caus_770 > 0)
|
||||||
|
{
|
||||||
|
TString val ;
|
||||||
|
bool found = false;
|
||||||
|
int j = 0;
|
||||||
|
int recpos = -1;
|
||||||
|
|
||||||
|
val.format("%02d", caus_770);
|
||||||
|
if (!changed_percip)
|
||||||
|
for (j = 0; recpos < 0 && j < numsch; j++)
|
||||||
|
{
|
||||||
|
TRectype & rec = (TRectype &) schede[j];
|
||||||
|
if (val == rec.get(SCH_CODCAUS))
|
||||||
|
recpos = j;
|
||||||
|
}
|
||||||
|
|
||||||
|
TRectype * schrow = NULL;
|
||||||
|
bool reset_row = false;
|
||||||
|
|
||||||
|
if (recpos >= 0)
|
||||||
|
schrow = (TRectype *) schede.objptr(recpos);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
schrow = new TRectype(LF_SCPERC);
|
||||||
|
schrow->put(SCH_CODDITTA, prefix().firm().codice());
|
||||||
|
schrow->put(SCH_TIPOA, tipopercip);
|
||||||
|
schrow->put(SCH_CODANAGR, codpercip);
|
||||||
|
schrow->put(SCH_NPROG, newprog++);
|
||||||
|
schrow->put(SCH_NUMREG, numreg);
|
||||||
|
schede.add(schrow);
|
||||||
|
recpos = numsch++;
|
||||||
|
}
|
||||||
|
const TRectype & rec_caus = cache().get("%CA7", val);
|
||||||
|
|
||||||
|
schrow->put(SCH_CODCAUS, val);
|
||||||
|
const TDate datarif = doc.get_date(DOC_DATADOCRIF);
|
||||||
|
schrow->put(SCH_DATADOC, datarif);
|
||||||
|
const TString & docnum = doc.get(DOC_NUMDOCRIF);
|
||||||
|
schrow->put(SCH_NUMDOC, docnum);
|
||||||
|
|
||||||
|
const real ritenuta = doc.ritenute('F');
|
||||||
|
const real spese = doc.get_real("SP770");
|
||||||
|
|
||||||
|
schrow->put(SCH_COMPENSO, doc.imponibile() - spese);
|
||||||
|
schrow->put(SCH_SPESE, spese);
|
||||||
|
schrow->put(SCH_IVA, doc.imposta());
|
||||||
|
schrow->put(SCH_TOTALE, doc.totale_doc());
|
||||||
|
schrow->put(SCH_TOTRIT, ritenuta);
|
||||||
|
schrow->put(SCH_RITSOC, doc.ritenute('S'));
|
||||||
|
const TDate datadoc = doc.get_date(DOC_DATADOC);
|
||||||
|
schrow->put(SCH_MESEC, datadoc.month());
|
||||||
|
schrow->put(SCH_ANNOC, datadoc.year());
|
||||||
|
schrow->put(SCH_CAUSQUA, rec_caus.get("S1"));
|
||||||
|
schrow->put(SCH_FLAGTS, rec_caus.get("S4"));
|
||||||
|
// i pagamenti non sono gestiti qui per ora
|
||||||
|
to_delete.reset(recpos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err = NOERR;
|
||||||
|
for (i = 0; err == NOERR && i < numsch; i++)
|
||||||
|
{
|
||||||
|
TRectype & rec = (TRectype &) schede[i];
|
||||||
|
const char tipo = rec.get_char(SCH_TIPOA);
|
||||||
|
const long codanagr = rec.get_long(SCH_CODANAGR);
|
||||||
|
|
||||||
|
if (to_delete[i])
|
||||||
|
{
|
||||||
|
TToken_string msg(256, '.');
|
||||||
|
const int nprog = rec.get_int(SCH_NPROG);
|
||||||
|
|
||||||
|
msg.format("Sono state eliminate le righe di pagamento e versamento relative alla scheda %c/%ld/%d."
|
||||||
|
"Dovranno quindi essere ripristinate dell'utente.", tipo, codanagr, nprog);
|
||||||
|
err = rec.remove(schperc);
|
||||||
|
|
||||||
|
rver.curr().zero();
|
||||||
|
rver.put(VER_CODDITTA, prefix().firm().codice());
|
||||||
|
rver.put(VER_TIPOA, tipopercip);
|
||||||
|
rver.put(VER_CODANAGR, codpercip);
|
||||||
|
rver.put(VER_NPROG, nprog);
|
||||||
|
|
||||||
|
const TRectype rvercmp(rver.curr());
|
||||||
|
bool removed = false;
|
||||||
|
|
||||||
|
for (int errver = rver.read(_isgteq); errver == NOERR && rver.curr() == rvercmp; errver = rver.next())
|
||||||
|
{
|
||||||
|
rver.remove();
|
||||||
|
}
|
||||||
|
if (removed)
|
||||||
|
msg.format("Sono state eliminate le righe di versamento relative alla scheda %c/%ld/%d."
|
||||||
|
"Dovranno quindi essere ripristinate dell'utente.", tipo, codanagr, nprog);
|
||||||
|
|
||||||
|
rpag.curr().zero();
|
||||||
|
rver.put(PAG_CODDITTA, prefix().firm().codice());
|
||||||
|
rver.put(PAG_TIPOA, tipopercip);
|
||||||
|
rver.put(PAG_CODANAGR, codpercip);
|
||||||
|
rver.put(PAG_NPROG, nprog);
|
||||||
|
|
||||||
|
const TRectype rpagcmp(rpag.curr());
|
||||||
|
removed = false;
|
||||||
|
|
||||||
|
for (int errpag = rpag.read(_isgteq); errpag == NOERR && rpag.curr() == rpagcmp; errpag = rpag.next())
|
||||||
|
{
|
||||||
|
removed = true;
|
||||||
|
rpag.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (removed)
|
||||||
|
{
|
||||||
|
TString s;
|
||||||
|
|
||||||
|
s.format("Sono state eliminate le righe di pagamento relative alla scheda %c/%ld/%d."
|
||||||
|
"Dovranno quindi essere ripristinate dell'utente.", tipo, codanagr, nprog);
|
||||||
|
msg << s;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_viswin && msg.full())
|
||||||
|
{
|
||||||
|
TString riga;
|
||||||
|
FOR_EACH_TOKEN(msg, line)
|
||||||
|
{
|
||||||
|
if (*line)
|
||||||
|
{
|
||||||
|
riga = riga.empty() ? "*** " : " ";
|
||||||
|
riga << line << '.';
|
||||||
|
_viswin->add_line(riga);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
message_box(msg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (i < orig_numsch)
|
||||||
|
{
|
||||||
|
err = rec.rewrite(schperc);
|
||||||
|
if (err == _iskeynotfound)
|
||||||
|
err = rec.write(schperc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
err = rec.write(schperc);
|
||||||
|
while (err == _isreinsert)
|
||||||
|
{
|
||||||
|
int newprog = rec.get_int(SCH_NPROG) + 1;
|
||||||
|
|
||||||
|
rec.put(SCH_NPROG, newprog);
|
||||||
|
err = rec.rewrite(schperc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
perc.zero();
|
||||||
|
perc.put(PRC_CODDITTA, prefix().firm().codice());
|
||||||
|
perc.put(PRC_TIPOA, tipo);
|
||||||
|
perc.put(PRC_CODANAGR, codanagr);
|
||||||
|
perc.write();
|
||||||
|
}
|
||||||
|
if (err != NOERR)
|
||||||
|
_error = m770_write_error;
|
||||||
|
}
|
||||||
|
return _error;
|
||||||
|
}
|
||||||
|
|
||||||
void TContabilizzazione::aggiorna_saldi(TSaldo_agg& saldo, TMovimentoPN& mv, bool save)
|
void TContabilizzazione::aggiorna_saldi(TSaldo_agg& saldo, TMovimentoPN& mv, bool save)
|
||||||
{
|
{
|
||||||
const TRectype& mov = mv.curr();
|
const TRectype& mov = mv.curr();
|
||||||
@ -3712,6 +3945,10 @@ void TContabilizzazione::display_error(TDocumento& doc)
|
|||||||
msg.format("Il documento precedente al %s/%ld non e' stato contabilizzato."
|
msg.format("Il documento precedente al %s/%ld non e' stato contabilizzato."
|
||||||
"E' necessario contabilizzare tutti i documenti in sequenza.",
|
"E' necessario contabilizzare tutti i documenti in sequenza.",
|
||||||
(const char*)numerazione, numero);
|
(const char*)numerazione, numero);
|
||||||
|
break;
|
||||||
|
case m770_write_error:
|
||||||
|
msg.format("Errore in scrittura della scheda percipiente relativa\nal documento %s/%ld.",
|
||||||
|
(const char*)numerazione, numero);
|
||||||
break;
|
break;
|
||||||
default: // errori generici o non indicati vengono visualizzati nel punto dell'errore
|
default: // errori generici o non indicati vengono visualizzati nel punto dell'errore
|
||||||
//msg.format("E' stato rilevato un errore generico contabilizzando il documento %s/%ld.",
|
//msg.format("E' stato rilevato un errore generico contabilizzando il documento %s/%ld.",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user