Files correlati : cg Commento : Risolto mancato aggiornamento valore per TF git-svn-id: svn://10.65.10.50/branches/R_10_00@24323 c028cbd2-c16b-5b4b-a496-9718f37d4682
165 lines
4.0 KiB
C++
165 lines
4.0 KiB
C++
//****************************
|
|
//* Aggiornamento Tipo Conto *
|
|
//****************************
|
|
#include <mask.h>
|
|
#include <recarray.h>
|
|
|
|
#include <nditte.h>
|
|
#include <pconti.h>
|
|
#include <rcausali.h>
|
|
#include <rmov.h>
|
|
#include <rmoviva.h>
|
|
#include <nditte.h>
|
|
|
|
#include <lffiles.h>
|
|
#include <recset.h>
|
|
#include "cg1314.h"
|
|
#include "cg1300n.h"
|
|
#include "cglib01.h"
|
|
|
|
bool TAgg_tcontoCF::create()
|
|
{
|
|
open_files(LF_RCAUSALI, LF_RMOV, LF_RMOVIVA, 0);
|
|
|
|
return TSkeleton_application::create();
|
|
}
|
|
|
|
void TAgg_tcontoCF::update_causali(TRectype & pcon, TLog_report & log)
|
|
{
|
|
TString use("USE "); use << LF_RCAUSALI;
|
|
TISAM_recordset rcaus(use);
|
|
TLocalisamfile & frcaus = rcaus.cursor()->relation()->lfile();
|
|
|
|
for (bool ok = rcaus.move_first(); ok; ok = rcaus.move_next())
|
|
{
|
|
const int gruppo = rcaus.get(RCA_GRUPPO).as_int();
|
|
const int conto = rcaus.get(RCA_CONTO).as_int();
|
|
const TString4 tipocf = rcaus.get(RCA_TIPOCF).as_string();
|
|
TBill tc(gruppo, conto, 0L);
|
|
|
|
tc.read(pcon);
|
|
|
|
const TString4 tipocf_pcon = pcon.get(PCN_TMCF);
|
|
|
|
if (tipocf != tipocf_pcon)
|
|
{
|
|
frcaus.put(RCA_TIPOCF, tipocf_pcon);
|
|
frcaus.rewrite();
|
|
TString msg("Causale ");
|
|
|
|
msg << rcaus.get(RCA_CODCAUS).as_string();
|
|
msg << " Riga " << rcaus.get(RCA_NRIGA).as_int();
|
|
msg << " impostato tipo conto (" << tipocf_pcon << ")";
|
|
log.log(0, msg);
|
|
}
|
|
}
|
|
|
|
}
|
|
void TAgg_tcontoCF::update_movimenti(TRectype & pcon, TLog_report & log)
|
|
{
|
|
TString use("USE "); use << LF_RMOV;
|
|
TISAM_recordset rmov(use);
|
|
TLocalisamfile & frmov = rmov.cursor()->relation()->lfile();
|
|
|
|
for (bool ok = rmov.move_first(); ok; ok = rmov.move_next())
|
|
{
|
|
const int gruppo = rmov.get(RMV_GRUPPO).as_int();
|
|
const int conto = rmov.get(RMV_CONTO).as_int();
|
|
const TString4 tipocf = rmov.get(RMV_TIPOC).as_string();
|
|
TBill tc(gruppo, conto, 0L);
|
|
|
|
tc.read(pcon);
|
|
|
|
const TString4 tipocf_pcon = pcon.get(PCN_TMCF);
|
|
|
|
if (tipocf != tipocf_pcon)
|
|
{
|
|
frmov.put(RMV_TIPOC, tipocf_pcon);
|
|
frmov.rewrite();
|
|
TString msg("Movimento ");
|
|
|
|
msg << rmov.get(RMV_NUMREG).as_int();
|
|
msg << " Riga " << rmov.get(RMV_NUMRIG).as_int();
|
|
msg << " impostato tipo conto (" << tipocf_pcon << ")";
|
|
log.log(0, msg);
|
|
}
|
|
}
|
|
}
|
|
|
|
void TAgg_tcontoCF::update_movimenti_IVA(TRectype & pcon, TLog_report & log)
|
|
{
|
|
TString use("USE "); use << LF_RMOVIVA;
|
|
TISAM_recordset rmoviva(use);
|
|
TLocalisamfile & frmoviva = rmoviva.cursor()->relation()->lfile();
|
|
|
|
for (bool ok = rmoviva.move_first(); ok; ok = rmoviva.move_next())
|
|
{
|
|
const int gruppo = rmoviva.get(RMI_GRUPPO).as_int();
|
|
const int conto = rmoviva.get(RMI_CONTO).as_int();
|
|
const TString4 tipocf = rmoviva.get(RMI_TIPOC).as_string();
|
|
TBill tc(gruppo, conto, 0L);
|
|
|
|
tc.read(pcon);
|
|
|
|
const TString4 tipocf_pcon = pcon.get(PCN_TMCF);
|
|
|
|
if (tipocf != tipocf_pcon)
|
|
{
|
|
frmoviva.put(RMI_TIPOC, tipocf_pcon);
|
|
frmoviva.rewrite();
|
|
TString msg("Movimento ");
|
|
|
|
msg << rmoviva.get(RMI_NUMREG).as_int();
|
|
msg << " Riga IVA " << rmoviva.get(RMI_NUMRIG).as_int();
|
|
msg << " impostato tipo conto (" << tipocf_pcon << ")";
|
|
log.log(0, msg);
|
|
}
|
|
}
|
|
}
|
|
|
|
void TAgg_tcontoCF::main_loop()
|
|
{
|
|
TMask m("cg1300n");
|
|
const TString16 arg = argv(3);
|
|
const bool force = arg.starts_with("-f");
|
|
TRectype pcon(LF_PCON);
|
|
TLog_report log;
|
|
|
|
if (force)
|
|
{
|
|
const int ditta = get_firm();
|
|
TString use("USE "); use << LF_NDITTE;
|
|
TISAM_recordset d(use);
|
|
|
|
for (bool ok = d.move_first(); ok; ok = d.move_next())
|
|
{
|
|
set_firm(d.get(NDT_CODDITTA).as_int());
|
|
|
|
TString msg("Ditta ");
|
|
|
|
msg << get_firm();
|
|
log.log(0, msg);
|
|
log.log(0, "");
|
|
update_causali(pcon, log);
|
|
update_movimenti(pcon, log);
|
|
update_movimenti_IVA(pcon, log);
|
|
log.log(0, "");
|
|
}
|
|
set_firm(ditta);
|
|
}
|
|
else
|
|
{
|
|
if (m.run() == K_ENTER)
|
|
{
|
|
// Aggiorno le causali
|
|
update_causali(pcon, log);
|
|
// Aggiorno i movimenti: CONTABILITA'
|
|
update_movimenti(pcon, log);
|
|
update_movimenti_IVA(pcon, log);
|
|
}
|
|
}
|
|
// Salvo a che versione di aggiornamenti sono per il TF
|
|
ini_set_int(CONFIG_DITTA, "cg", "atccf", 1);
|
|
log.print_or_preview();
|
|
}
|