git-svn-id: svn://10.65.10.50/branches/R_10_00@22992 c028cbd2-c16b-5b4b-a496-9718f37d4682
182 lines
4.1 KiB
C++
Executable File
182 lines
4.1 KiB
C++
Executable File
// Rinumerazione movimenti e saldi
|
|
// fv 12/12/93
|
|
// -------------------------------------------------------------------------
|
|
// *TBI* Partenza dall'ultimo movimento stampato
|
|
// *TBI* Aggiornamento scadenziario
|
|
// *TBI* Aggiornamento cespiti
|
|
// -------------------------------------------------------------------------
|
|
|
|
#include <applicat.h>
|
|
#include <isam.h>
|
|
#include <mask.h>
|
|
#include <progind.h>
|
|
#include <recset.h>
|
|
#include <relation.h>
|
|
#include <sort.h>
|
|
#include <utility.h>
|
|
|
|
#define FLD_CG41_YEAR 100
|
|
#define MAX_CNT 300
|
|
|
|
#include <mov.h>
|
|
#include <rmov.h>
|
|
#include <rmoviva.h>
|
|
#include <saldi.h>
|
|
#include <causali.h>
|
|
|
|
#include "cglib02.h"
|
|
|
|
struct therec
|
|
{
|
|
char DATAREG[9];
|
|
char REG[4];
|
|
char DATADOC[9];
|
|
char NUMPROT[9];
|
|
char ANNOES[5];
|
|
char NUMREG[8];
|
|
};
|
|
|
|
class CG4100_App : public TSkeleton_application
|
|
{
|
|
int _year;
|
|
TMask* _msk;
|
|
|
|
public:
|
|
bool set_parms();
|
|
virtual void main_loop();
|
|
|
|
void sort_all();
|
|
bool sort_sal();
|
|
};
|
|
|
|
bool CG4100_App::set_parms()
|
|
{
|
|
_msk->run();
|
|
_year = _msk->get_int(FLD_CG41_YEAR);
|
|
return _msk->last_key() == K_ENTER;
|
|
}
|
|
|
|
void CG4100_App::main_loop()
|
|
{
|
|
if (fexist("__sal__.sav"))
|
|
warning_box(TR("Un'operazione di riordino saldi si e' conclusa impropriamente. Si raccomanda di rieseguirla"));
|
|
|
|
_msk = new TMask("cg4100b");
|
|
|
|
sort_sal();
|
|
|
|
delete _msk;
|
|
}
|
|
|
|
bool CG4100_App::sort_sal()
|
|
{
|
|
if (!set_parms())
|
|
return FALSE;
|
|
|
|
TSystemisamfile saldi(LF_SALDI); saldi.open(_excllock);
|
|
TLocalisamfile mov(LF_MOV);
|
|
TSaldo_agg sal;
|
|
|
|
FILE* fp = fopen ("__sal__.sav","w");
|
|
fclose(fp);
|
|
|
|
int gruppo, conto;
|
|
const int year = _year;
|
|
long oldnumreg = 0L, sottoconto;
|
|
|
|
mov.setkey(1);
|
|
sal.reset();
|
|
sal.set_anno_es(year);
|
|
sal.clear_saldi(year);
|
|
long numreg = 0L;
|
|
tiposal tsal = normale;
|
|
bool provvis = FALSE;
|
|
TDate datareg;
|
|
|
|
TString query; query << "USE RMOV SELECT ANNOES=" << _year;
|
|
TISAM_recordset righe(query);
|
|
|
|
TProgind prnd(righe.items(),
|
|
TR("Riordino archivio saldi in corso\nLettura archivio movimenti..."),
|
|
FALSE, TRUE);
|
|
|
|
const TRectype& rmov = righe.cursor()->curr();
|
|
|
|
for (bool ok = righe.move_first(); ok; ok = righe.move_next())
|
|
{
|
|
if (!prnd.addstatus(1))
|
|
break;
|
|
if (_year != rmov.get_int(RMV_ANNOES))
|
|
continue;
|
|
|
|
numreg = rmov.get_long(RMV_NUMREG);
|
|
|
|
gruppo = rmov.get_int(RMV_GRUPPO);
|
|
conto = rmov.get_int(RMV_CONTO);
|
|
sottoconto = rmov.get_long(RMV_SOTTOCONTO);
|
|
|
|
bool scaricato = false;
|
|
if (numreg != oldnumreg)
|
|
{
|
|
if (sal.items() > 0)
|
|
{
|
|
sal.registra();
|
|
sal.reset();
|
|
}
|
|
oldnumreg = numreg;
|
|
mov.zero();
|
|
mov.put(MOV_NUMREG, numreg);
|
|
mov.read();
|
|
CHECK(mov.good(),"Archivi movimenti e righe inconsistenti");
|
|
|
|
// Tipo saldo normale per default
|
|
tsal = normale;
|
|
const TString& codcaus = mov.get(MOV_CODCAUS);
|
|
const TRectype& causale = cache().get(LF_CAUSALI, codcaus);
|
|
if (!causale.empty())
|
|
{
|
|
const char ac = causale.get_char(CAU_MOVAP);
|
|
if (ac == 'A')
|
|
tsal = apertura; else
|
|
if (ac == 'C')
|
|
tsal = chiusura;
|
|
}
|
|
|
|
scaricato = mov.get_bool(MOV_SCARCON);
|
|
provvis = mov.get(MOV_PROVVIS).not_empty();
|
|
datareg = mov.get_date(MOV_DATAREG);
|
|
|
|
sal.set_anno_es(_year);
|
|
sal.set_tipo_saldo(tsal);
|
|
sal.set_movprovv(provvis);
|
|
sal.set_data_ulmov(datareg);
|
|
sal.set_num_ulmov(oldnumreg);
|
|
}
|
|
const char sezione = rmov.get(RMV_SEZIONE)[0];
|
|
const real importo = rmov.get(RMV_IMPORTO);
|
|
|
|
if (!importo.is_zero())
|
|
{
|
|
if (gruppo <= 0 || conto <= 0 || sottoconto <= 0)
|
|
{
|
|
warning_box(FR("Conto non valido alla riga %d nel movimento %ld"),
|
|
rmov.get_int(RMV_NUMRIG), numreg);
|
|
continue;
|
|
}
|
|
sal.aggiorna(gruppo, conto, sottoconto, importo, sezione, true, scaricato);
|
|
}
|
|
}
|
|
|
|
sal.registra();
|
|
|
|
remove("__sal__.sav");
|
|
return true;
|
|
}
|
|
|
|
int cg4100(int argc, char* argv[])
|
|
{
|
|
CG4100_App main_app;
|
|
main_app.run(argc, argv, TR("Ricalcolo Saldi"));
|
|
return TRUE;
|
|
}
|