Apertura partite da saldi contabili (sc1 -1)
git-svn-id: svn://10.65.10.50/trunk@1146 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
2e7da1d997
commit
b0e1e719dc
232
sc/sc1200.cpp
232
sc/sc1200.cpp
@ -3,71 +3,241 @@
|
|||||||
#include <progind.h>
|
#include <progind.h>
|
||||||
#include <urldefid.h>
|
#include <urldefid.h>
|
||||||
#include <saldi.h>
|
#include <saldi.h>
|
||||||
|
#include <pconti.h>
|
||||||
#include <partite.h>
|
#include <partite.h>
|
||||||
#include <scadenze.h>
|
#include <scadenze.h>
|
||||||
#include <lffiles.h>
|
#include <lffiles.h>
|
||||||
#include <relation.h>
|
#include <relation.h>
|
||||||
|
#include <utility.h>
|
||||||
|
|
||||||
|
#include "../cg/conto.h"
|
||||||
|
#include "../cg/pagament.h"
|
||||||
#include "sc1200.h"
|
#include "sc1200.h"
|
||||||
|
|
||||||
class TCreatepart_app : public TApplication
|
class TCreatepart_app : public TApplication
|
||||||
{
|
{
|
||||||
|
TLocalisamfile* _conti;
|
||||||
|
TLocalisamfile* _partite;
|
||||||
|
TLocalisamfile* _scadenze;
|
||||||
|
|
||||||
|
int _anno;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual bool create();
|
virtual bool create();
|
||||||
virtual bool destroy();
|
virtual bool destroy();
|
||||||
virtual bool menu(MENU_TAG m);
|
virtual bool menu(MENU_TAG m);
|
||||||
|
|
||||||
|
long get_last_partita(bool check_erase);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TCreatepart_app() {};
|
|
||||||
|
bool is_clifo(int g, int c, char& cf);
|
||||||
|
TCreatepart_app() {}
|
||||||
|
virtual ~TCreatepart_app() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
bool TCreatepart_app::create()
|
bool TCreatepart_app::create()
|
||||||
{
|
{
|
||||||
TApplication::create();
|
TApplication::create();
|
||||||
|
|
||||||
|
_conti = new TLocalisamfile(LF_PCON);
|
||||||
|
_partite = new TLocalisamfile(LF_PARTITE);
|
||||||
|
_scadenze = new TLocalisamfile(LF_SCADENZE);
|
||||||
|
|
||||||
dispatch_e_menu(BAR_ITEM(1));
|
dispatch_e_menu(BAR_ITEM(1));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TCreatepart_app::destroy()
|
bool TCreatepart_app::destroy()
|
||||||
{
|
{
|
||||||
|
delete _conti;
|
||||||
|
delete _partite;
|
||||||
|
delete _scadenze;
|
||||||
|
|
||||||
return TApplication::destroy();
|
return TApplication::destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
long TCreatepart_app::get_last_partita(bool zap)
|
||||||
|
{
|
||||||
|
// ritorna il primo valore utile per partita temporanea AP;
|
||||||
|
// se ce ne sono gia' propone la cancellazione e se ok
|
||||||
|
// la esegue perfidamente
|
||||||
|
|
||||||
|
_partite->zero();
|
||||||
|
_partite->put(PART_ANNO, _anno);
|
||||||
|
_partite->put(PART_NUMPART, "AP");
|
||||||
|
|
||||||
|
long last = 0l;
|
||||||
|
bool go = _partite->read(_isgteq) == NOERR;
|
||||||
|
|
||||||
|
if (zap && go)
|
||||||
|
zap = yesno_box("Esistono gia' partite generate in base ai"
|
||||||
|
" saldi contabili. Si desidera cancellarle?");
|
||||||
|
|
||||||
|
while (go)
|
||||||
|
{
|
||||||
|
if (zap)
|
||||||
|
{
|
||||||
|
for (int i = 0; ; i++)
|
||||||
|
{
|
||||||
|
// zappa scadenze
|
||||||
|
_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 (_scadenze->read() == NOERR) _scadenze->remove();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_partite->remove();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else last = atol(_partite->get(PART_NUMPART).mid(2)) + 1l;
|
||||||
|
|
||||||
|
go = _partite->next() == NOERR &&
|
||||||
|
_partite->get(PART_NUMPART).mid(0,2) == "AP";
|
||||||
|
}
|
||||||
|
|
||||||
|
return last;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool TCreatepart_app::is_clifo(int g, int c, char& cf)
|
||||||
|
{
|
||||||
|
static int gr = -1, ct = -1;
|
||||||
|
|
||||||
|
if (g != gr || c != ct)
|
||||||
|
{
|
||||||
|
_conti->zero();
|
||||||
|
_conti->put(PCN_GRUPPO, g);
|
||||||
|
_conti->put(PCN_CONTO, c);
|
||||||
|
if (_conti->read() != NOERR)
|
||||||
|
error_box("Piano dei conti disallineato con archivio saldi");
|
||||||
|
gr = g; ct = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_conti->get(PCN_TMCF).empty())
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
cf = _conti->get_char(PCN_TMCF);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TCreatepart_app::menu(MENU_TAG)
|
bool TCreatepart_app::menu(MENU_TAG)
|
||||||
{
|
{
|
||||||
TMask m("sc1200a");
|
TMask m("sc1200a");
|
||||||
TRelation saldi(LF_SALDI);
|
TRelation saldi(LF_SALDI);
|
||||||
TLocalisamfile conti(LF_PCON);
|
saldi.zero();
|
||||||
saldi.zero();
|
|
||||||
|
|
||||||
while (m.run() != K_QUIT)
|
while (m.run() != K_QUIT)
|
||||||
{
|
{
|
||||||
const int anno = m.get_int(F_ANNO);
|
int n_part = 0;
|
||||||
|
TDate data(m.get(F_DATA));
|
||||||
// saldi.curr().put(SLD_ANNO, anno);
|
TString16 codpag(m.get(F_CODPAG));
|
||||||
TCursor cur(&saldi, "", 1, &saldi.curr(), &saldi.curr());
|
|
||||||
const long items = cur.items();
|
TPagamento pag(codpag, data.string());
|
||||||
long npart = 0L;
|
|
||||||
|
m.set(F_NUMPART, format("%d",n_part));
|
||||||
// if (items > 0)
|
_anno = m.get_int(F_ANNO);
|
||||||
// {
|
|
||||||
// for (cur = 0 ; cur.pos() < items; ++cur)
|
saldi.lfile().zero();
|
||||||
// {
|
saldi.lfile().put(SLD_ANNOES, _anno);
|
||||||
// if (is_clifo(cur.curr().get_int(SLD_GRUPPO), cur.curr().get_int(SLD_CONTO)))
|
|
||||||
// {
|
TCursor cur(&saldi, "", 1, &saldi.curr(), &saldi.curr());
|
||||||
// TSaldo s(????);
|
const long items = cur.items();
|
||||||
// Timporto saldo(s.saldo??);
|
long npart = 0L;
|
||||||
|
|
||||||
// if (saldo != ZERO)
|
if (items > 0)
|
||||||
// {
|
{
|
||||||
// }
|
begin_wait();
|
||||||
// }
|
int hw = 0;
|
||||||
// }
|
for (cur = 0, hw = 0 ; cur.pos() < items; ++cur, hw++)
|
||||||
// else
|
{
|
||||||
// message_box("Nessun saldo presente per l'anno %d", anno);
|
char cf;
|
||||||
|
int gruppo = cur.curr().get_int(SLD_GRUPPO);
|
||||||
} // while run
|
int conto = cur.curr().get_int(SLD_CONTO);
|
||||||
|
long sottoc = cur.curr().get_long(SLD_SOTTOCONTO);
|
||||||
|
|
||||||
|
if (is_clifo(gruppo, conto, cf))
|
||||||
|
{
|
||||||
|
TImporto saldo(cur.curr().get_char(SLD_FLAGSALINI), cur.curr().get_real(SLD_SALDO));
|
||||||
|
TImporto pdare('D', cur.curr().get_real(SLD_PDARE));
|
||||||
|
TImporto pavere('A', cur.curr().get_real(SLD_PAVERE));
|
||||||
|
|
||||||
|
saldo += pdare;
|
||||||
|
saldo += pavere;
|
||||||
|
saldo.normalize();
|
||||||
|
|
||||||
|
if (!saldo.is_zero())
|
||||||
|
{
|
||||||
|
TString16 id;
|
||||||
|
real val(saldo.valore());
|
||||||
|
|
||||||
|
pag.set_total(val, ZERO, ZERO);
|
||||||
|
pag.set_rate_auto();
|
||||||
|
|
||||||
|
// determina ultima partita; la prima volta,
|
||||||
|
// se ce n'e' chiedi se si vuole cancellare
|
||||||
|
long last_partita = get_last_partita(hw == 0);
|
||||||
|
|
||||||
|
// apri partita dimmerda
|
||||||
|
id << format("AP%05ld", last_partita);
|
||||||
|
|
||||||
|
_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, data);
|
||||||
|
_partite->put(PART_DATADOC, data);
|
||||||
|
_partite->put(PART_SEZ, saldo.sezione());
|
||||||
|
_partite->put(PART_IMPORTO, saldo.valore());
|
||||||
|
_partite->put(PART_CODPAG, codpag);
|
||||||
|
_partite->put(PART_CODVAL, "LIT");
|
||||||
|
_partite->put(PART_TIPOCF, cf);
|
||||||
|
_partite->put(PART_GRUPPO, gruppo);
|
||||||
|
_partite->put(PART_CONTO, conto);
|
||||||
|
_partite->put(PART_SOTTOCONTO,sottoc);
|
||||||
|
_partite->put(PART_DESCR, "Apertura partite da saldi contabili");
|
||||||
|
_partite->write();
|
||||||
|
|
||||||
|
// apri scadenze dimmerda
|
||||||
|
for (int i = 0; i < pag.n_rate(); i++)
|
||||||
|
{
|
||||||
|
_scadenze->zero();
|
||||||
|
_scadenze->put(SCAD_ANNO, _anno);
|
||||||
|
_scadenze->put(SCAD_NUMPART, id);
|
||||||
|
_scadenze->put(SCAD_NRATA, i+1);
|
||||||
|
_scadenze->put(SCAD_CODPAG, codpag);
|
||||||
|
_scadenze->put(SCAD_ULTCLASS, pag.ulc_rata(i));
|
||||||
|
_scadenze->put(SCAD_TIPOPAG, pag.tipo_rata(i));
|
||||||
|
_scadenze->put(SCAD_IMPORTOVAL, pag.tpay_rata(i));
|
||||||
|
_scadenze->put(SCAD_DATASCAD, pag.data_rata(i));
|
||||||
|
_scadenze->put(SCAD_TIPOCF, cf);
|
||||||
|
_scadenze->put(SCAD_GRUPPO, gruppo);
|
||||||
|
_scadenze->put(SCAD_CONTO, conto);
|
||||||
|
_scadenze->put(SCAD_SOTTOCONTO, sottoc);
|
||||||
|
_scadenze->write();
|
||||||
|
}
|
||||||
|
|
||||||
|
n_part++;
|
||||||
|
m.set(F_NUMPART, format("%d",n_part));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end_wait();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
message_box("Nessun saldo presente per l'anno %d", _anno);
|
||||||
|
} // while run
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
|
#define F_ANNO 101
|
||||||
#define F_ANNO 101
|
#define F_NUMPART 102
|
||||||
|
#define F_DATA 103
|
||||||
|
#define F_CODPAG 104
|
||||||
|
@ -1,25 +1,31 @@
|
|||||||
#include "sc1200.h"
|
#include "sc1200.h"
|
||||||
|
|
||||||
PAGE "Apertura partite da saldi contabili" -1 -1 47 10
|
PAGE "Apertura partite da saldi contabili" -1 -1 51 12
|
||||||
|
|
||||||
|
GROUPBOX DLG_NULL 49 6
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 0 ""
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
TEXT DLG_NULL
|
TEXT DLG_NULL
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 18 1 "ATTENZIONE"
|
PROMPT 20 1 "ATTENZIONE"
|
||||||
END
|
END
|
||||||
|
|
||||||
TEXT DLG_NULL
|
TEXT DLG_NULL
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 2 3 "La generazione della partite puo' richiedere"
|
PROMPT 4 3 "La generazione della partite puo' richiedere"
|
||||||
END
|
END
|
||||||
|
|
||||||
TEXT DLG_NULL
|
TEXT DLG_NULL
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 5 4 "tempo. Siate certi di voler proseguire."
|
PROMPT 7 4 "tempo. Siate certi di voler proseguire."
|
||||||
END
|
END
|
||||||
|
|
||||||
NUMBER F_ANNO 4
|
NUMBER F_ANNO 4
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 3 6 "Anno di esercizio "
|
PROMPT 1 6 "Anno esercizio "
|
||||||
USE ESC
|
USE ESC
|
||||||
INPUT CODTAB F_ANNO
|
INPUT CODTAB F_ANNO
|
||||||
DISPLAY "Anno Esercizio" CODTAB
|
DISPLAY "Anno Esercizio" CODTAB
|
||||||
@ -31,16 +37,36 @@ BEGIN
|
|||||||
WARNING "L' anno di esercizio e' obbligatorio"
|
WARNING "L' anno di esercizio e' obbligatorio"
|
||||||
END
|
END
|
||||||
|
|
||||||
TEXT DLG_NULL
|
STRING F_CODPAG 4
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 2 3 "La generazione delle partite puo' richiedere"
|
PROMPT 27 6 "Pagamento "
|
||||||
|
HELP "Codice del pagamento concordato per il movimento"
|
||||||
|
FIELD CODPAG
|
||||||
|
FLAGS "UZ"
|
||||||
|
USE %CPG
|
||||||
|
INPUT CODTAB F_CODPAG
|
||||||
|
DISPLAY "Codice" CODTAB
|
||||||
|
DISPLAY "Descrizione@50" S0
|
||||||
|
OUTPUT F_CODPAG CODTAB
|
||||||
|
CHECKTYPE REQUIRED
|
||||||
|
ADD RUN ba3 -6
|
||||||
|
WARNING "Codice pagamento obbligatorio"
|
||||||
END
|
END
|
||||||
|
|
||||||
TEXT DLG_NULL
|
|
||||||
BEGIN
|
DATE F_DATA
|
||||||
PROMPT 5 4 "tempo. Siate certi di voler proseguire."
|
BEGIN
|
||||||
|
PROMPT 1 8 "Data scadenza "
|
||||||
|
FLAGS "A"
|
||||||
END
|
END
|
||||||
|
|
||||||
|
NUMBER F_NUMPART 3
|
||||||
|
BEGIN
|
||||||
|
PROMPT 27 8 "N. partite aperte "
|
||||||
|
FLAGS "D"
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
BUTTON DLG_OK 9 2
|
BUTTON DLG_OK 9 2
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT -12 -1 "Conferma"
|
PROMPT -12 -1 "Conferma"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user