Corretta apertura partite da saldi

git-svn-id: svn://10.65.10.50/trunk@2044 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-10-30 10:20:10 +00:00
parent 83c7e3992e
commit 658d370f05
2 changed files with 248 additions and 348 deletions

View File

@ -1,19 +1,19 @@
#include <applicat.h> #include <applicat.h>
#include <mask.h> #include <mask.h>
#include <progind.h> #include <progind.h>
#include <relation.h>
#include <urldefid.h> #include <urldefid.h>
#include <utility.h>
#include <saldi.h> #include <saldi.h>
#include <pconti.h> #include <pconti.h>
#include <partite.h> #include <partite.h>
#include <scadenze.h> #include <scadenze.h>
#include <pagsca.h> #include <pagsca.h>
#include <lffiles.h>
#include <relation.h>
#include <utility.h>
#include "../cg/conto.h"
#include "../cg/pagament.h"
#include "../cg/cglib.h" #include "../cg/cglib.h"
#include "../cg/conto.h"
#include "../cg/saldacon.h"
#include "sc1200.h" #include "sc1200.h"
@ -36,7 +36,7 @@ protected:
public: public:
int is_clifo(int g, int c, char& cf, int& indbil); char is_clifo(int g, int c, int& indbil);
TCreatepart_app() {} TCreatepart_app() {}
virtual ~TCreatepart_app() {} virtual ~TCreatepart_app() {}
}; };
@ -69,7 +69,7 @@ bool TCreatepart_app::destroy()
bool TCreatepart_app::zap_partite() bool TCreatepart_app::zap_partite()
{ {
bool first = TRUE; bool first = TRUE;
for (_partite->first(); !_partite->eof(); _partite->next()) for (_partite->first(); !_partite->eof(); _partite->read(_isgreat))
{ {
// ignora saldaconto altri esercizi // ignora saldaconto altri esercizi
if (_partite->get_long(PART_ANNO) != _anno) if (_partite->get_long(PART_ANNO) != _anno)
@ -82,91 +82,45 @@ bool TCreatepart_app::zap_partite()
" Si desidera proseguire?"); " Si desidera proseguire?");
if (ok) if (ok)
ok = yesno_box("Confermare l'azzeramento del saldaconto esistente"); ok = yesno_box("Confermare l'azzeramento del saldaconto esistente");
if (!ok) return FALSE; if (!ok)
return FALSE;
first = FALSE; first = FALSE;
} }
bool gos = TRUE; TPartita game(_partite->curr());
bool goi = TRUE; game.remove();
for (int i = 1; gos || goi ; i++)
{
// zappa scadenze
if (gos)
{
_scadenze->zero();
_scadenze->put(SCAD_ANNO, _partite->get(PART_ANNO));
_scadenze->put(SCAD_NUMPART, _partite->get(PART_NUMPART));
_scadenze->put(SCAD_NRATA, i+1);
if (gos = (_scadenze->read() == NOERR))
_scadenze->remove();
}
// zappa pagamenti
if (goi)
{
_pagsca->zero();
_pagsca->put(PAGSCA_ANNO, _partite->get(PART_ANNO));
_pagsca->put(PAGSCA_NUMPART, _partite->get(PART_NUMPART));
_pagsca->put(PAGSCA_NRIGP, i+1);
if (goi = (_pagsca->read() == NOERR))
_pagsca->remove();
}
}
_partite->remove();
} }
return TRUE; return TRUE;
} }
int TCreatepart_app::is_clifo(int g, int c, char& cf, int& indbil) char TCreatepart_app::is_clifo(int g, int c, int& indbil)
{ {
// deve ritornare QUANTI sono i conti in cui appare lo stesso
// cliente; se piu' di uno deve creare n rate, una per cliente
_conti->zero(); _conti->zero();
_conti->put(PCN_GRUPPO, g); _conti->put(PCN_GRUPPO, g);
_conti->put(PCN_CONTO, c); _conti->put(PCN_CONTO, c);
if (_conti->read() != NOERR) if (_conti->read() != NOERR)
{ {
warning_box("Piano dei conti disallineato con archivio saldi: esecuzione interrotta"); warning_box("Piano dei conti disallineato con archivio saldi: esecuzione interrotta");
return 0; return '\0';
} }
if (_conti->get(PCN_TMCF).empty()) const char cf = _conti->get_char(PCN_TMCF);
return 0;
cf = _conti->get_char(PCN_TMCF);
indbil = _conti->get_int(PCN_INDBIL); indbil = _conti->get_int(PCN_INDBIL);
long cl = _conti->get_long(PCN_SOTTOCONTO);
// cerca tutti i conti in cui compare lo stesso cliente o return cf;
// fornitore
int ncli = 0;
for (_conti->first(); !_conti->eof(); _conti->next())
{
if (_conti->get_char(PCN_TMCF) == cf &&
_conti->get_long(PCN_SOTTOCONTO) == cl)
ncli++;
}
return ncli;
} }
bool TCreatepart_app::menu(MENU_TAG) bool TCreatepart_app::menu(MENU_TAG)
{ {
const TDate today(TODAY);
TMask m("sc1200a"); TMask m("sc1200a");
TRelation saldi(LF_SALDI);
saldi.zero();
TDate today(TODAY); TString desccl(80); desccl << "Apertura clienti al " << today.string();
TString80 desccl = "Apertura clienti al "; desccl << today.string(); TString descfo(80); descfo << "Apertura fornitori al " << today.string();
TString80 descfo = "Apertura fornitori al "; descfo << today.string();
m.set(F_DESCCL, desccl); m.set(F_DESCCL, desccl);
m.set(F_DESCFO, descfo); m.set(F_DESCFO, descfo);
@ -176,40 +130,34 @@ bool TCreatepart_app::menu(MENU_TAG)
_anno = m.get_int(F_ANNO); _anno = m.get_int(F_ANNO);
desccl = m.get(F_DESCCL); desccl = m.get(F_DESCCL);
descfo = m.get(F_DESCFO); descfo = m.get(F_DESCFO);
int n_part = 0; int n_part = 0;
m.set(F_NUMPART, n_part); m.set(F_NUMPART, n_part);
// sputtana tutto il saldaculo // sputtana tutto il saldaculo
if (!zap_partite()) break; if (!zap_partite())
continue;
saldi.lfile().zero(); TRelation saldi(LF_SALDI);
saldi.lfile().put(SLD_ANNOES, _anno); saldi.curr().put(SLD_ANNOES, _anno);
TCursor cur(&saldi, "", 1, &saldi.curr(), &saldi.curr()); TCursor cur(&saldi, "", 1, &saldi.curr(), &saldi.curr());
const long items = cur.items(); const long items = cur.items();
long npart = 0L;
// determina ultima partita; la prima volta,
// se ce n'e' chiedi se si vuole cancellare
long last_partita = 1l;
long npart = 0L;
if (items > 0) if (items > 0)
{ {
begin_wait(); begin_wait();
TProgind prind(items, "Creazione saldaconto", FALSE, TRUE,45); TProgind prind(items, "Creazione saldaconto", FALSE, TRUE,45);
int hw = 0; for (cur = 0; cur.pos() < items; ++cur)
for (cur = 0, hw = 0 ; cur.pos() < items; ++cur, hw++)
{ {
char cf; int nclienti; const int gruppo = cur.curr().get_int(SLD_GRUPPO);
int gruppo = cur.curr().get_int(SLD_GRUPPO); const int conto = cur.curr().get_int(SLD_CONTO);
int conto = cur.curr().get_int(SLD_CONTO); const long sottoc = cur.curr().get_long(SLD_SOTTOCONTO);
long sottoc = cur.curr().get_long(SLD_SOTTOCONTO);
int indbil; int indbil;
const char cf = is_clifo(gruppo, conto, indbil);
nclienti = is_clifo(gruppo, conto, cf, indbil); if (cf > ' ')
if (nclienti > 0)
{ {
TSaldo sld; TSaldo sld;
@ -239,85 +187,37 @@ bool TCreatepart_app::menu(MENU_TAG)
if (!saldo.is_zero()) if (!saldo.is_zero())
{ {
TString16 id; const TBill clifo(gruppo, conto, sottoc, cf);
real val(saldo.valore()); TPartita game(clifo, _anno, "*");
// TPagamento pag(codpag, today.string()); TRiga_partite& riga = game.new_row();
// pag.set_total(val, ZERO, ZERO); riga.put(PART_DATAREG, today);
// pag.set_rate_auto(); riga.put(PART_DATADOC, today);
riga.put(PART_SEZ, saldo.sezione());
// apri partita dimmerda riga.put(PART_IMPORTO, saldo.valore());
id << format("*%05ld", last_partita++); riga.put(PART_DESCR, cf == 'C' ? desccl : descfo);
_partite->zero();
_partite->put(PART_ANNO, _anno);
_partite->put(PART_NUMPART, id);
_partite->put(PART_NUMRIG, 1);
_partite->put(PART_NRIGA, 1);
_partite->put(PART_DATAREG, today);
_partite->put(PART_DATADOC, today);
_partite->put(PART_SEZ, saldo.sezione());
_partite->put(PART_IMPORTO, saldo.valore());
_partite->put(PART_CODVAL, "LIT");
_partite->put(PART_TIPOCF, cf);
_partite->put(PART_GRUPPOCL, gruppo);
_partite->put(PART_CONTOCL, conto);
_partite->put(PART_SOTTOCONTO,sottoc);
_partite->put(PART_DESCR, cf == 'C' ? desccl : descfo);
// _partite->put(PART_CODPAG, codpag);
// cazzata dare/avere/fare/baciare/cagare // cazzata dare/avere/fare/baciare/cagare
int tipo = (cf == 'C' ? (saldo.sezione() == 'D' ? 1 : 3) : const int tipo = (cf == 'C' ? (saldo.sezione() == 'D' ? 1 : 2) :
(saldo.sezione() == 'D' ? 3 : 1)); (saldo.sezione() == 'D' ? 2 : 1));
_partite->put(PART_TIPOMOV, tipo); riga.put(PART_TIPOMOV, tipo);
_partite->write();
if (tipo == 1) if (tipo == 1)
{ {
// apri scadenze dimmerda: tante quanti clienti ci sono TRiga_scadenze& scad = riga.new_row();
for (int i = 0; i < nclienti; i++) scad.put(SCAD_IMPORTO, saldo.valore());
{ scad.put(SCAD_DATASCAD, today);
_scadenze->zero(); scad.put(SCAD_TIPOPAG, 2);
_scadenze->put(SCAD_ANNO, _anno);
_scadenze->put(SCAD_NUMPART, id);
_scadenze->put(SCAD_NRATA, i+1);
_scadenze->put(SCAD_IMPORTO, val/real((double)nclienti));
_scadenze->put(SCAD_TIPOCF, cf);
_scadenze->put(SCAD_SOTTOCONTO, sottoc);
// oldies and goldies
// not removed, you know why
// ------------------------------------------------------------
// _scadenze->put(SCAD_CODPAG, codpag);
// _scadenze->put(SCAD_ULTCLASS, pag.ulc_rata(i));
// _scadenze->put(SCAD_TIPOPAG, pag.tipo_rata(i));
// _scadenze->put(SCAD_DATASCAD, pag.data_rata(i));
// _scadenze->put(SCAD_GRUPPO, gruppo);
// _scadenze->put(SCAD_CONTO, conto);
_scadenze->write();
}
} }
else else
{ {
// apri insoluto TRectype& unas = game.unassigned().row(riga.get_int(PART_NRIGA), TRUE);
for (int i = 0; i < nclienti; i++) unas.put(PAGSCA_IMPORTO, saldo.valore());
{ unas.put(PAGSCA_ACCSAL, 'A');
_pagsca->zero();
_pagsca->put(PAGSCA_ANNO, _anno);
_pagsca->put(PAGSCA_NUMPART, id);
_pagsca->put(PAGSCA_NRIGP, i+1);
_pagsca->put(PAGSCA_IMPORTO, val/real((double)nclienti));
_pagsca->put(PAGSCA_TIPOC, cf);
_pagsca->put(PAGSCA_SOTTOCONTO, sottoc);
_pagsca->write();
}
} }
game.write();
n_part++; m.set(F_NUMPART, ++n_part);
m.set(F_NUMPART, format("%d",n_part));
} }
} }
prind.addstatus(1); prind.addstatus(1);
@ -335,6 +235,6 @@ bool TCreatepart_app::menu(MENU_TAG)
int sc1200(int argc, char** argv) int sc1200(int argc, char** argv)
{ {
TCreatepart_app a; TCreatepart_app a;
a.run(argc, argv, "Apertura scadenze da saldi contabili"); a.run(argc, argv, "Apertura scadenze da saldi");
return 0; return 0;
} }

View File

@ -21,7 +21,7 @@ protected:
static bool zap_handler(TMask_field& f, KEY k); static bool zap_handler(TMask_field& f, KEY k);
static SollecitiStorici_app& app() static SollecitiStorici_app& app()
{ return (SollecitiStorici_app&)main_app();} { return (SollecitiStorici_app&)main_app();}
public: public:
@ -34,7 +34,7 @@ public:
bool SollecitiStorici_app::user_create() bool SollecitiStorici_app::user_create()
{ {
_rel = new TRelation(LF_STOSOLL); _rel = new TRelation(LF_PAGSCA);
_msk = new TMask("sc1300a"); _msk = new TMask("sc1300a");
_msk->set_handler(F_ZAP, zap_handler); _msk->set_handler(F_ZAP, zap_handler);
@ -58,8 +58,8 @@ bool SollecitiStorici_app::zap_handler(TMask_field& f, KEY k)
if (yesno_box("Si desidera azzerare l'archivio solleciti per " if (yesno_box("Si desidera azzerare l'archivio solleciti per "
"il cliente %s?", (const char*)f.mask().get(F_DESCR))) "il cliente %s?", (const char*)f.mask().get(F_DESCR)))
{ {
app().zap_cliente(f.mask().get(F_CODICE)); app().zap_cliente(f.mask().get(F_CODICE));
f.mask().stop_run(K_ESC); f.mask().stop_run(K_ESC);
} }
} }
return TRUE; return TRUE;