e983f63eec
git-svn-id: svn://10.65.10.50/trunk@2046 c028cbd2-c16b-5b4b-a496-9718f37d4682
242 lines
6.3 KiB
C++
Executable File
242 lines
6.3 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <mask.h>
|
|
#include <progind.h>
|
|
#include <relation.h>
|
|
#include <urldefid.h>
|
|
#include <utility.h>
|
|
|
|
#include <saldi.h>
|
|
#include <pconti.h>
|
|
#include <partite.h>
|
|
#include <scadenze.h>
|
|
#include <pagsca.h>
|
|
|
|
#include "../cg/cglib.h"
|
|
#include "../cg/conto.h"
|
|
#include "../cg/saldacon.h"
|
|
|
|
#include "sc1200.h"
|
|
|
|
class TCreatepart_app : public TApplication
|
|
{
|
|
TLocalisamfile* _conti;
|
|
TLocalisamfile* _partite;
|
|
TLocalisamfile* _scadenze;
|
|
TLocalisamfile* _pagsca;
|
|
|
|
int _anno;
|
|
|
|
protected:
|
|
|
|
virtual bool create();
|
|
virtual bool destroy();
|
|
virtual bool menu(MENU_TAG m);
|
|
|
|
bool zap_partite();
|
|
|
|
public:
|
|
|
|
char is_clifo(int g, int c, int& indbil);
|
|
TCreatepart_app() {}
|
|
virtual ~TCreatepart_app() {}
|
|
};
|
|
|
|
|
|
bool TCreatepart_app::create()
|
|
{
|
|
TApplication::create();
|
|
|
|
_conti = new TLocalisamfile(LF_PCON);
|
|
_partite = new TLocalisamfile(LF_PARTITE);
|
|
_scadenze = new TLocalisamfile(LF_SCADENZE);
|
|
_pagsca = new TLocalisamfile(LF_PAGSCA);
|
|
|
|
dispatch_e_menu(BAR_ITEM(1));
|
|
return TRUE;
|
|
}
|
|
|
|
bool TCreatepart_app::destroy()
|
|
{
|
|
delete _conti;
|
|
delete _partite;
|
|
delete _scadenze;
|
|
delete _pagsca;
|
|
|
|
return TApplication::destroy();
|
|
}
|
|
|
|
|
|
bool TCreatepart_app::zap_partite()
|
|
{
|
|
bool first = TRUE;
|
|
for (_partite->first(); !_partite->eof(); _partite->read(_isgreat))
|
|
{
|
|
// ignora saldaconto altri esercizi
|
|
if (_partite->get_long(PART_ANNO) != _anno)
|
|
continue;
|
|
|
|
if (first)
|
|
{
|
|
bool ok = yesno_box("Il saldaconto per l'esercizio scelto non e' vuoto."
|
|
" La procedura lo azzera completamente."
|
|
" Si desidera proseguire?");
|
|
if (ok)
|
|
ok = yesno_box("Confermare l'azzeramento del saldaconto esistente");
|
|
if (!ok)
|
|
return FALSE;
|
|
first = FALSE;
|
|
}
|
|
|
|
TPartita game(_partite->curr());
|
|
game.remove();
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
char TCreatepart_app::is_clifo(int g, int c, int& indbil)
|
|
{
|
|
_conti->zero();
|
|
_conti->put(PCN_GRUPPO, g);
|
|
_conti->put(PCN_CONTO, c);
|
|
|
|
if (_conti->read() != NOERR)
|
|
{
|
|
warning_box("Piano dei conti disallineato con archivio saldi: esecuzione interrotta");
|
|
return '\0';
|
|
}
|
|
|
|
const char cf = _conti->get_char(PCN_TMCF);
|
|
indbil = _conti->get_int(PCN_INDBIL);
|
|
|
|
return cf;
|
|
}
|
|
|
|
|
|
bool TCreatepart_app::menu(MENU_TAG)
|
|
{
|
|
const TDate today(TODAY);
|
|
TMask m("sc1200a");
|
|
|
|
TString desccl(80); desccl << "Apertura clienti al " << today.string();
|
|
TString descfo(80); descfo << "Apertura fornitori al " << today.string();
|
|
|
|
m.set(F_DESCCL, desccl);
|
|
m.set(F_DESCFO, descfo);
|
|
|
|
while (m.run() == K_ENTER)
|
|
{
|
|
_anno = m.get_int(F_ANNO);
|
|
desccl = m.get(F_DESCCL);
|
|
descfo = m.get(F_DESCFO);
|
|
|
|
int n_part = 0;
|
|
m.set(F_NUMPART, n_part);
|
|
|
|
// sputtana tutto il saldaculo
|
|
if (!zap_partite())
|
|
continue;
|
|
|
|
TRelation saldi(LF_SALDI);
|
|
saldi.curr().put(SLD_ANNOES, _anno);
|
|
|
|
TCursor cur(&saldi, "", 1, &saldi.curr(), &saldi.curr());
|
|
const long items = cur.items();
|
|
|
|
long npart = 0L;
|
|
if (items > 0)
|
|
{
|
|
begin_wait();
|
|
TProgind prind(items, "Creazione saldaconto", FALSE, TRUE,45);
|
|
|
|
for (cur = 0; cur.pos() < items; ++cur)
|
|
{
|
|
const int gruppo = cur.curr().get_int(SLD_GRUPPO);
|
|
const int conto = cur.curr().get_int(SLD_CONTO);
|
|
const long sottoc = cur.curr().get_long(SLD_SOTTOCONTO);
|
|
int indbil;
|
|
const char cf = is_clifo(gruppo, conto, indbil);
|
|
if (cf > ' ')
|
|
{
|
|
TSaldo sld;
|
|
|
|
// ciuccia il saldo e vedi se e' movimentato nell'esercizio corrente
|
|
if (!sld.ultima_immissione_verifica(_anno, gruppo, conto, sottoc, indbil, 1))
|
|
{
|
|
// non movimentato: se e' conto patrimoniale....
|
|
if (!(indbil == 1 || indbil == 2 || indbil == 5))
|
|
{
|
|
prind.addstatus(1);
|
|
continue;
|
|
}
|
|
// .. vedi saldo esercizio precedente, altrimenti inkul
|
|
sld.saldofin_esprec(_anno, gruppo, conto, sottoc);
|
|
}
|
|
|
|
// genera importo con sezione appropriata
|
|
TImporto saldo(cur.curr().get_char(SLD_FLAGSALINI), sld.saldoini());
|
|
TImporto pdare('D', sld.prgdare());
|
|
TImporto pavere('A', sld.prgavere());
|
|
|
|
saldo += pdare;
|
|
saldo += pavere;
|
|
saldo.normalize();
|
|
|
|
// (whew)
|
|
|
|
if (!saldo.is_zero())
|
|
{
|
|
const TBill clifo(gruppo, conto, sottoc, cf);
|
|
TPartita game(clifo, _anno, "*");
|
|
|
|
TRiga_partite& riga = game.new_row();
|
|
riga.put(PART_DATAREG, today);
|
|
riga.put(PART_DATADOC, today);
|
|
riga.put(PART_SEZ, saldo.sezione());
|
|
riga.put(PART_IMPORTO, saldo.valore());
|
|
riga.put(PART_DESCR, cf == 'C' ? desccl : descfo);
|
|
|
|
// cazzata dare/avere/fare/baciare/cagare
|
|
const int tipo = (cf == 'C' ? (saldo.sezione() == 'D' ? 1 : 2) :
|
|
(saldo.sezione() == 'D' ? 2 : 1));
|
|
|
|
riga.put(PART_TIPOMOV, tipo);
|
|
|
|
if (tipo == 1)
|
|
{
|
|
TRiga_scadenze& scad = riga.new_row();
|
|
scad.put(SCAD_IMPORTO, saldo.valore());
|
|
scad.put(SCAD_DATASCAD, today);
|
|
scad.put(SCAD_TIPOPAG, 1);
|
|
}
|
|
else
|
|
{
|
|
TRectype& unas = game.unassigned().row(riga.get_int(PART_NRIGA), TRUE);
|
|
unas.put(PAGSCA_IMPORTO, saldo.valore());
|
|
unas.put(PAGSCA_DATAPAG, today);
|
|
unas.put(PAGSCA_ACCSAL, 'A');
|
|
}
|
|
game.write();
|
|
m.set(F_NUMPART, ++n_part);
|
|
}
|
|
}
|
|
prind.addstatus(1);
|
|
}
|
|
end_wait();
|
|
}
|
|
else
|
|
message_box("Nessun saldo presente per l'esercizio %d", _anno);
|
|
} // while run
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
int sc1200(int argc, char** argv)
|
|
{
|
|
TCreatepart_app a;
|
|
a.run(argc, argv, "Apertura scadenze da saldi");
|
|
return 0;
|
|
}
|