Gestione del saldaconto in prima nota
git-svn-id: svn://10.65.10.50/trunk@1696 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
f51bfda33c
commit
0516fcfdde
@ -47,7 +47,7 @@ protected:
|
||||
virtual void on_config_change();
|
||||
|
||||
////////////
|
||||
static bool indsp_notify(int r, KEY key);
|
||||
static bool indsp_notify(TSheet_field& s, int r, KEY key);
|
||||
static bool indsp_handler(TMask_field& f, KEY key) ;
|
||||
virtual int write(const TMask& m);
|
||||
virtual int rewrite(const TMask& m);
|
||||
@ -553,10 +553,8 @@ bool TClifo_application::indsp_handler(TMask_field& f, KEY key)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TClifo_application::indsp_notify(int r, KEY key)
|
||||
bool TClifo_application::indsp_notify(TSheet_field& indsp, int r, KEY key)
|
||||
{
|
||||
TSheet_field& indsp=app().indsp_sheet();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case K_SPACE:
|
||||
@ -564,7 +562,6 @@ bool TClifo_application::indsp_notify(int r, KEY key)
|
||||
// Request to modify row #r
|
||||
// Disable field CODIND update # of row
|
||||
TMask& m = indsp.sheet_mask();
|
||||
|
||||
if (m.get_int(F_CODINDI)==0) // Is it a new row ?
|
||||
m.set(F_CODINDI,(long)(r+1));
|
||||
m.disable(F_CODINDI);
|
||||
|
@ -57,7 +57,7 @@ protected:
|
||||
static bool sottoconto_hndl (TMask_field& f, KEY k);
|
||||
static bool codcausim_hndl (TMask_field& f, KEY k);
|
||||
static bool m770_hndl (TMask_field& f, KEY k);
|
||||
static bool ss_notify (int r, KEY k);
|
||||
static bool ss_notify (TSheet_field& s, int r, KEY k);
|
||||
|
||||
bool fill_sheet(TMask&);
|
||||
|
||||
@ -498,11 +498,11 @@ bool TCaus_app::cod_reg_hndl (TMask_field& f, KEY k)
|
||||
// Handler della maschera dello spreadsheet
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TCaus_app::ss_notify(int r, KEY k)
|
||||
bool TCaus_app::ss_notify(TSheet_field& s, int r, KEY k)
|
||||
{
|
||||
if (k == K_ENTER)
|
||||
{
|
||||
TToken_string &riga = app().ss().row(r);
|
||||
TToken_string &riga = s.row(r);
|
||||
const int g = riga.get_int(3);
|
||||
if (g == 0) // riga azzerata
|
||||
app().clear(r); // pulisco la riga anche nell'array
|
||||
|
@ -143,21 +143,22 @@ TMask* TPrimanota_application::load_mask(int n)
|
||||
|
||||
bool TPrimanota_application::user_create()
|
||||
{
|
||||
_tabcom = new TLocalisamfile(LF_TABCOM);
|
||||
_tab = new TLocalisamfile(LF_TAB);
|
||||
_caus = new TLocalisamfile(LF_CAUSALI);
|
||||
_rcaus = new TLocalisamfile(LF_RCAUSALI);
|
||||
_clifo = new TLocalisamfile(LF_CLIFO);
|
||||
_pcon = new TLocalisamfile(LF_PCON);
|
||||
_attiv = new TLocalisamfile(LF_ATTIV);
|
||||
_saldo = new TLocalisamfile(LF_SALDI);
|
||||
_comuni = new TLocalisamfile(LF_COMUNI);
|
||||
_occas = new TLocalisamfile(LF_OCCAS);
|
||||
_nditte = new TLocalisamfile(LF_NDITTE);
|
||||
_scadenze = new TLocalisamfile(LF_SCADENZE);
|
||||
|
||||
_tabcom = new TLocalisamfile(LF_TABCOM);
|
||||
_tab = new TLocalisamfile(LF_TAB);
|
||||
_caus = new TLocalisamfile(LF_CAUSALI);
|
||||
_rcaus = new TLocalisamfile(LF_RCAUSALI);
|
||||
_clifo = new TLocalisamfile(LF_CLIFO);
|
||||
_pcon = new TLocalisamfile(LF_PCON);
|
||||
_attiv = new TLocalisamfile(LF_ATTIV);
|
||||
_saldo = new TLocalisamfile(LF_SALDI);
|
||||
_comuni = new TLocalisamfile(LF_COMUNI);
|
||||
_occas = new TLocalisamfile(LF_OCCAS);
|
||||
_nditte = new TLocalisamfile(LF_NDITTE);
|
||||
_scadenze = new TLocalisamfile(LF_SCADENZE);
|
||||
_pagamenti = new TLocalisamfile(LF_PAGSCA);
|
||||
|
||||
_rel = new TMovimentoPN;
|
||||
_rel->add(LF_PARTITE, "NREG=NUMREG", 2);
|
||||
_rel->add(LF_PARTITE, "NREG=NUMREG", 2); // Collega la partita aperta dalla fattura
|
||||
|
||||
_causale = new TCausale();
|
||||
_giornale = new TLibro_giornale();
|
||||
|
@ -413,7 +413,7 @@ BEGIN
|
||||
FLAGS "H"
|
||||
END
|
||||
|
||||
STRING F_VALUTA 3
|
||||
STRING S_VALUTA 3
|
||||
BEGIN
|
||||
PROMPT 1 12 "Valuta "
|
||||
HELP "Codice della valuta per operazione con l'estero"
|
||||
@ -421,18 +421,18 @@ BEGIN
|
||||
FLAGS "UZ"
|
||||
GROUP 3
|
||||
USE %VAL
|
||||
INPUT CODTAB F_VALUTA
|
||||
INPUT CODTAB S_VALUTA
|
||||
DISPLAY "Codice" CODTAB
|
||||
DISPLAY "Nome@50" S0
|
||||
DISPLAY "Cambio@15" R10
|
||||
DISPLAY "Ultimo aggiornamento" D0
|
||||
OUTPUT F_VALUTA CODTAB
|
||||
OUTPUT F_CAMBIO R10
|
||||
OUTPUT S_VALUTA CODTAB
|
||||
OUTPUT S_CAMBIO R10
|
||||
CHECKTYPE NORMAL
|
||||
WARNING "Codice valuta assente"
|
||||
END
|
||||
|
||||
NUMBER F_CAMBIO 12 5
|
||||
NUMBER S_CAMBIO 12 5
|
||||
BEGIN
|
||||
PROMPT 20 12 "Cambio "
|
||||
HELP "Cambio della valuta per operazione con l'estero"
|
||||
@ -442,13 +442,6 @@ BEGIN
|
||||
PICTURE ".5"
|
||||
END
|
||||
|
||||
BOOLEAN F_VISVAL
|
||||
BEGIN
|
||||
PROMPT 47 12 "Visualizza importi in valuta"
|
||||
HELP "Indicare se visualizzare gli importi in valuta (non in Lit.)"
|
||||
GROUP 3
|
||||
END
|
||||
|
||||
NUMBER F_TOTALE 15
|
||||
BEGIN
|
||||
PROMPT 1 13 "Totale documento "
|
||||
|
@ -166,10 +166,7 @@ int TMovimentoPN::registra(bool re, bool force)
|
||||
int err = re ? TRelation::rewrite(force) : TRelation::write(force);
|
||||
|
||||
if (err != NOERR)
|
||||
{
|
||||
CHECKD(!m.empty(), "Record empty after error ", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
if (!re)
|
||||
_cg.renum_key("NUMREG", numreg);
|
||||
|
@ -465,7 +465,7 @@ void TPrimanota_application::cgs_pack()
|
||||
if (can_remove(r))
|
||||
{
|
||||
if (salda && row_type(r) == ' ')
|
||||
cg_notify(i, K_DEL);
|
||||
cg_notify(cgs(), i, K_DEL);
|
||||
rows.destroy(i, salda);
|
||||
}
|
||||
}
|
||||
@ -688,13 +688,12 @@ void TPrimanota_application::generazione_righe_cg(int r)
|
||||
}
|
||||
|
||||
|
||||
bool TPrimanota_application::cg_notify(int r, KEY k)
|
||||
bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k)
|
||||
{
|
||||
switch(k)
|
||||
{
|
||||
case K_SPACE:
|
||||
{
|
||||
TSheet_field& cg = app().cgs();
|
||||
const char tipo = row_type(cg.row(r));
|
||||
cg.sheet_mask().enable(DLG_DELREC, tipo <= ' ');
|
||||
}
|
||||
@ -930,12 +929,11 @@ void TPrimanota_application::ivas_pack()
|
||||
}
|
||||
|
||||
// Certified 50%
|
||||
bool TPrimanota_application::iva_notify(int r, KEY k)
|
||||
bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k)
|
||||
{
|
||||
static int oldpos,oldposiva;
|
||||
static real oldimp, oldiva;
|
||||
|
||||
TSheet_field& iva = app().ivas();
|
||||
TToken_string& row = iva.row(r);
|
||||
const TCausale& cau = app().causale();
|
||||
|
||||
@ -1247,7 +1245,7 @@ bool TPrimanota_application::num_handler(TMask_field& f, KEY key)
|
||||
"si desidera continuare ugualmente");
|
||||
}
|
||||
|
||||
if (ok)
|
||||
if (ok) // Riempie a mano i campi necessari nel caso non sia stato usata la ricerca F9
|
||||
{
|
||||
m.set(F_DATAREG, mov.get("DATAREG"), TRUE);
|
||||
m.set(F_DATACOMP, mov.get("DATACOMP"), TRUE);
|
||||
@ -1687,7 +1685,7 @@ bool TPrimanota_application::main_codiva_handler(TMask_field& f, KEY key)
|
||||
TToken_string& row = app().ivas().row(0);
|
||||
|
||||
TMask& m = f.mask();
|
||||
iva_notify(0, K_SPACE);
|
||||
iva_notify(app().ivas(), 0, K_SPACE);
|
||||
|
||||
const TCodiceIVA iva(f.get());
|
||||
const bool corr = app().causale().corrispettivi();
|
||||
@ -1710,7 +1708,7 @@ bool TPrimanota_application::main_codiva_handler(TMask_field& f, KEY key)
|
||||
}
|
||||
app().ivas().force_update(0);
|
||||
|
||||
iva_notify(0, K_ENTER);
|
||||
iva_notify(app().ivas(), 0, K_ENTER);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
@ -1915,9 +1913,9 @@ bool TPrimanota_application::solaiva_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
oldrow = r;
|
||||
r = "";
|
||||
iva_notify(i, K_SPACE);
|
||||
iva_notify(iva, i, K_SPACE);
|
||||
r = oldrow;
|
||||
iva_notify(i, K_ENTER);
|
||||
iva_notify(iva, i, K_ENTER);
|
||||
}
|
||||
pi.setstatus(i+1);
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ class TPrimanota_application : public TRelation_application
|
||||
TLocalisamfile* _occas;
|
||||
TLocalisamfile* _nditte;
|
||||
TLocalisamfile* _scadenze;
|
||||
TLocalisamfile* _pagamenti;
|
||||
|
||||
TPagamento* _pag;
|
||||
|
||||
@ -104,11 +105,11 @@ class TPrimanota_application : public TRelation_application
|
||||
static bool cg_conto_handler(TMask_field& f, KEY key);
|
||||
static bool codpag_handler(TMask_field& f, KEY key);
|
||||
|
||||
static bool iva_notify(int r, KEY key);
|
||||
static bool iva_notify(TSheet_field& s, int r, KEY key);
|
||||
static bool iva_handler(TMask_field& f, KEY key);
|
||||
static bool cg_notify(int r, KEY key);
|
||||
static bool cg_notify(TSheet_field& s, int r, KEY key);
|
||||
static bool cg_handler(TMask_field& f, KEY key);
|
||||
static bool pag_notify(int r, KEY key);
|
||||
static bool pag_notify(TSheet_field& s, int r, KEY key);
|
||||
|
||||
void reset_sheet_row(TSheet_field& s, int n);
|
||||
|
||||
@ -209,7 +210,7 @@ protected:
|
||||
void write_scadenze(const TMask& m);
|
||||
|
||||
bool edit_partite(int riga);
|
||||
bool edit_scadenze(int anno, const char* num);
|
||||
bool edit_scadenze(const TBill& clifo, int anno, const char* num);
|
||||
int nuovo_pagamento(TPartita& partita, int rata, int rmov, TRectype& part);
|
||||
bool edit_pagamento(TPartita& partita, TRectype& part);
|
||||
|
||||
|
381
cg/cg2104.cpp
381
cg/cg2104.cpp
@ -4,17 +4,18 @@
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <sheet.h>
|
||||
#include "pagament.h"
|
||||
|
||||
#include "cg2102.h"
|
||||
#include "cg2100.h"
|
||||
#include "cg21sld.h"
|
||||
#include "pagament.h"
|
||||
#include "cg2100p.h"
|
||||
|
||||
#include <clifo.h>
|
||||
#include <partite.h>
|
||||
#include <scadenze.h>
|
||||
|
||||
bool TPrimanota_application::pag_notify(int r, KEY k)
|
||||
bool TPrimanota_application::pag_notify(TSheet_field&, int r, KEY k)
|
||||
{
|
||||
TPagamento& pag = app().pagamento();
|
||||
TSheet_field& ps = app().pags();
|
||||
@ -340,7 +341,7 @@ void TPrimanota_application::write_scadenze(const TMask& m)
|
||||
int gruppo = (tipocf == 'C' || tipocf == 'F') ? 0 : _rel->cg(0).get_char("GRUPPO");
|
||||
int conto = (tipocf == 'C' || tipocf == 'F') ? 0 : _rel->cg(0).get_char("CONTO");
|
||||
long sottoconto = _rel->cg(0).get_long("SOTTOCONTO");
|
||||
int nriga = 1;
|
||||
const int nriga = 1;
|
||||
int numrig = 1;
|
||||
|
||||
partita.put(PART_ANNO, anno);
|
||||
@ -400,9 +401,14 @@ void TPrimanota_application::write_scadenze(const TMask& m)
|
||||
{
|
||||
new_scad = FALSE;
|
||||
scadenza.zero();
|
||||
scadenza.put("ANNO", anno);
|
||||
scadenza.put("NUMPART", numpart);
|
||||
scadenza.put("NRATA", i+1);
|
||||
scadenza.put(SCAD_TIPOCF, tipocf);
|
||||
scadenza.put(SCAD_GRUPPO, gruppo);
|
||||
scadenza.put(SCAD_CONTO, conto);
|
||||
scadenza.put(SCAD_SOTTOCONTO, sottoconto);
|
||||
scadenza.put(SCAD_ANNO, anno);
|
||||
scadenza.put(SCAD_NUMPART, numpart);
|
||||
scadenza.put(SCAD_NRIGA, nriga);
|
||||
scadenza.put(SCAD_NRATA, i+1);
|
||||
|
||||
if (scadenza.read() != NOERR)
|
||||
{
|
||||
@ -414,6 +420,7 @@ void TPrimanota_application::write_scadenze(const TMask& m)
|
||||
scadenza.put(SCAD_SOTTOCONTO, sottoconto);
|
||||
scadenza.put(SCAD_ANNO, anno);
|
||||
scadenza.put(SCAD_NUMPART, numpart);
|
||||
scadenza.put(SCAD_NRIGA, nriga);
|
||||
scadenza.put(SCAD_NRATA, i+1);
|
||||
}
|
||||
// set everything
|
||||
@ -447,24 +454,159 @@ void TPrimanota_application::write_scadenze(const TMask& m)
|
||||
// Sheet partite
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
HIDDEN void add_importo(TToken_string& s, const TImporto& i)
|
||||
{
|
||||
if (i.is_zero())
|
||||
s.add("");
|
||||
else
|
||||
{
|
||||
s.add(i.valore().string());
|
||||
s << ' ' << i.sezione();
|
||||
}
|
||||
}
|
||||
|
||||
HIDDEN bool partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
{
|
||||
if (k == K_TAB)
|
||||
{
|
||||
TMask& m = partite.mask();
|
||||
TSheet_field& scadenze = (TSheet_field&)m.field(P_SCADENZE);
|
||||
scadenze.destroy();
|
||||
|
||||
const TBill zio(m.get_int(P_GRUPPO), m.get_int(P_CONTO),
|
||||
m.get_long(P_SOTTOCONTO), m.get(P_TIPOC)[0]);
|
||||
TToken_string& row = partite.row(r);
|
||||
const int anno = row.get_int(0);
|
||||
const TString16 num = row.get();
|
||||
m.set(P_ANNO, anno); // Aggiorna campi di ricerca
|
||||
m.set(P_NUMERO, num);
|
||||
|
||||
TPartita game(zio, anno, num);
|
||||
TRecord_array& p = game.rows_array();
|
||||
const int lastr = p.last_row();
|
||||
for (int r = p.first_row(); r <= lastr; r++) if (p.exist(r))
|
||||
{
|
||||
const TRiga_partite& riga = game.riga(r);
|
||||
for (int ra = 1; ra <= riga.rate(); ra++)
|
||||
{
|
||||
const TRiga_scadenze& scad = riga.rata(ra);
|
||||
TToken_string& row = scadenze.row(-1);
|
||||
row.add(ra);
|
||||
row.add(riga.get(PART_DATADOC));
|
||||
row.add(riga.get(PART_NREG));
|
||||
row.add(riga.get(PART_DATAREG));
|
||||
row.add(scad.get(SCAD_DATASCAD));
|
||||
row.add(scad.get(SCAD_IMPORTO));
|
||||
row.add(scad.get(SCAD_IMPORTOVAL));
|
||||
row.add(riga.get(PART_DESCR));
|
||||
row.add(riga.get(PART_NUMDOC));
|
||||
row.add(riga.get(PART_PROTIVA));
|
||||
|
||||
const TRecord_array& ap = scad.rows_array();
|
||||
const int lastp = ap.last_row();
|
||||
for (int pa = ap.first_row(); pa < lastp; pa++) if (ap.exist(pa))
|
||||
{
|
||||
const TRectype& pag = ap.row(pa);
|
||||
|
||||
TToken_string& row = scadenze.row(-1);
|
||||
row.add("");
|
||||
row.add(riga.get(PART_DATADOC));
|
||||
row.add(riga.get(PART_DATAREG));
|
||||
row.add(scad.get(SCAD_DATASCAD));
|
||||
row.add(pag.get_real(SCAD_IMPORTO).string(0, 0));
|
||||
row.add(pag.get_real(SCAD_IMPORTOVAL).string(0, 2));
|
||||
row.add(riga.get(PART_DESCR));
|
||||
row.add(riga.get(PART_NUMDOC));
|
||||
row.add(riga.get(PART_PROTIVA));
|
||||
}
|
||||
}
|
||||
}
|
||||
scadenze.force_update();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
HIDDEN bool numpart_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
if (k == K_TAB && f.dirty())
|
||||
{
|
||||
const TMask& m = f.mask();
|
||||
const int anno = m.get_int(P_ANNO);
|
||||
const TString16 num = f.get();
|
||||
if (anno > 0 && num.not_empty())
|
||||
{
|
||||
TSheet_field& sheet = (TSheet_field&)m.field(P_PARTITE);
|
||||
for (int i = 0; i < sheet.items(); i++)
|
||||
{
|
||||
TToken_string& row = sheet.row(i);
|
||||
if (anno == row.get_int(0)) // Se corrisponde l'anno e ...
|
||||
if (num == row.get()) // corrisponde il numero partita ...
|
||||
{
|
||||
sheet.select(i); // Seleziona la partita
|
||||
partite_notify(sheet, i, K_TAB); // ed esplodi le sue righe
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i >= sheet.items())
|
||||
f.warning_box("Partita inesistente");
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
HIDDEN bool annopart_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
if (k == K_TAB && f.dirty() && f.get().not_empty())
|
||||
{
|
||||
TMask_field& n = f.mask().field(P_NUMERO);
|
||||
n.set_dirty();
|
||||
numpart_handler(f, k);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN bool scambio_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
const TMask& m = f.mask();
|
||||
if (k == K_SPACE && m.is_running())
|
||||
{
|
||||
const TSheet_field& sheet = (TSheet_field&)m.field(P_SCADENZE);
|
||||
sheet.swap_columns(103, 109);
|
||||
sheet.swap_columns(104, 110);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TPrimanota_application::edit_partite(int riga)
|
||||
{
|
||||
TToken_string& cgr = cgs().row(riga);
|
||||
const TBill b(cgr, 2, 0x3); // Legge il conto della riga selezionata
|
||||
|
||||
if (!b.ok()) return FALSE;
|
||||
|
||||
|
||||
begin_wait();
|
||||
|
||||
TString caption("Partite aperte del conto ");
|
||||
caption << b.gruppo() << ' ' << b.conto() << ' ' << b.sottoconto();
|
||||
TMask mask("cg2100p"); // Inizializzazione maschera di selezione partite
|
||||
|
||||
TArray_sheet a(-1, -1, 0, 0, caption, "Anno|Numero@7|Dare@15R|Avere@15R|Descrizione@50", 0x8);
|
||||
const char tipocf[2] = { b.tipo(), '\0' };
|
||||
mask.set(P_TIPOC, tipocf);
|
||||
mask.set(P_GRUPPO, b.gruppo());
|
||||
mask.set(P_CONTO, b.conto());
|
||||
mask.set(P_SOTTOCONTO, b.sottoconto());
|
||||
mask.set(P_DESCR, ((TBill&)b).descrizione());
|
||||
|
||||
mask.set_handler(P_ANNO, annopart_handler);
|
||||
mask.set_handler(P_NUMERO, numpart_handler);
|
||||
mask.set_handler(P_SCAMBIO, scambio_handler);
|
||||
|
||||
TSheet_field& sheet = (TSheet_field&)mask.field(P_PARTITE);
|
||||
sheet.set_notify(partite_notify);
|
||||
TString_array& a = sheet.rows_array();
|
||||
|
||||
TLocalisamfile partita(LF_PARTITE);
|
||||
partita.setkey(2); // Chiave per conto
|
||||
|
||||
partita.zero();
|
||||
partita.zero();
|
||||
if (b.tipo() > ' ') // Ignora gruppo e conto dei clifo
|
||||
{
|
||||
partita.put(PART_TIPOCF, b.tipo());
|
||||
@ -472,76 +614,121 @@ bool TPrimanota_application::edit_partite(int riga)
|
||||
}
|
||||
else b.put(partita.curr()); // Scrive completamente i conti normali
|
||||
|
||||
const TRectype recpar(partita.curr());// Record campione
|
||||
const TRectype filter(partita.curr());// Record campione
|
||||
|
||||
int ult, anno; // Anno ultima partita
|
||||
TString16 last, num; // Ultimo numero partita e numero corrente
|
||||
long nreg;
|
||||
TString desc; // Descrizione prima partita del gruppo
|
||||
TString16 numdoc;
|
||||
TString16 datadoc;
|
||||
|
||||
TImporto saldo; // Saldo ultima parita
|
||||
TImporto documenti; // Documenti ultima parita
|
||||
TImporto pagamenti; // Pagamenti ultima parita
|
||||
TImporto importi; // Altri importi ultima parita
|
||||
TToken_string r(80);
|
||||
|
||||
const long curreg = curr_mask().get_long(F_NUMREG); // Numero registrazione
|
||||
|
||||
for (int err = partita.read(_isgteq); err == NOERR && partita.curr() == recpar; err = partita.next())
|
||||
for (int err = partita.read(_isgteq); err == NOERR && partita.curr() == filter; err = partita.next())
|
||||
{
|
||||
num = partita.get(PART_NUMPART);
|
||||
anno = partita.get_int(PART_ANNO);
|
||||
nreg = partita.get_long(PART_NREG);
|
||||
|
||||
num = partita.get(PART_NUMPART);
|
||||
|
||||
const int tipomov = partita.get_int(PART_TIPOMOV);
|
||||
if (num == last && anno == ult) // Se la partita e' la stessa ...
|
||||
{
|
||||
const TImporto i(partita.get_char(PART_SEZ), partita.get_real(PART_IMPORTO));
|
||||
switch (tipomov)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
documenti += i;
|
||||
break;
|
||||
case 3:
|
||||
pagamenti += i;
|
||||
break;
|
||||
default:
|
||||
importi += i;
|
||||
break;
|
||||
}
|
||||
saldo += i; // ... incrementa totale
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!saldo.is_zero() || nreg == curreg) // Se il saldo non e' nullo allora e' aperta
|
||||
if (!saldo.is_zero()) // Se il saldo non e' nullo allora e' aperta
|
||||
{
|
||||
r.cut(0);
|
||||
r.add(ult); r.add(last);
|
||||
saldo.add_to(r, 2);
|
||||
r.add(ult);
|
||||
r.add(last);
|
||||
r.add(datadoc);
|
||||
r.add(numdoc);
|
||||
add_importo(r, saldo);
|
||||
add_importo(r, documenti);
|
||||
add_importo(r, pagamenti);
|
||||
add_importo(r, importi);
|
||||
r.add(desc);
|
||||
a.add(r); // Aggiunge partita alla lista
|
||||
}
|
||||
ult = anno;
|
||||
last = num;
|
||||
desc = partita.get(PART_DESCR);
|
||||
ult = anno;
|
||||
last = num;
|
||||
numdoc = partita.get(PART_NUMDOC);
|
||||
datadoc = partita.get(PART_DATADOC);
|
||||
desc = partita.get(PART_DESCR);
|
||||
|
||||
saldo.set(partita.get_char(PART_SEZ), partita.get_real(PART_IMPORTO));
|
||||
switch (tipomov)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
documenti = saldo;
|
||||
pagamenti.set('D', ZERO);
|
||||
importi.set('D', ZERO);
|
||||
break;
|
||||
case 3:
|
||||
pagamenti = saldo;
|
||||
documenti.set('D', ZERO);
|
||||
importi.set('D', ZERO);
|
||||
break;
|
||||
default:
|
||||
importi = saldo;
|
||||
documenti.set('D', ZERO);
|
||||
pagamenti.set('D', ZERO);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!saldo.is_zero() || nreg == curreg) // Aggiunge ultima partita se aperta
|
||||
if (!saldo.is_zero()) // Aggiunge ultima partita se aperta
|
||||
{
|
||||
r.cut(0);
|
||||
r.add(ult); r.add(last);
|
||||
saldo.add_to(r, 2);
|
||||
r.add(ult);
|
||||
r.add(last);
|
||||
r.add(datadoc);
|
||||
r.add(numdoc);
|
||||
add_importo(r, saldo);
|
||||
add_importo(r, documenti);
|
||||
add_importo(r, pagamenti);
|
||||
add_importo(r, importi);
|
||||
r.add(desc);
|
||||
a.add(r);
|
||||
}
|
||||
|
||||
end_wait();
|
||||
|
||||
bool dirty = FALSE;
|
||||
|
||||
KEY k = a.items() > 0 ? K_ENTER : K_ESC; // Esce se non ci sono righe
|
||||
while (k == K_ENTER)
|
||||
if (a.items() > 0)
|
||||
{
|
||||
k = a.run();
|
||||
if (k == K_ENTER)
|
||||
{
|
||||
const int anno = a.row().get_int(0);
|
||||
const TString16 num = a.row().get(1);
|
||||
dirty |= edit_scadenze(anno, num); // Edita pagamenti
|
||||
}
|
||||
}
|
||||
sheet.force_update();
|
||||
mask.run();
|
||||
}
|
||||
|
||||
return dirty;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
int TPrimanota_application::nuovo_pagamento(TPartita& partita, int rata, int rmov, TRectype& part)
|
||||
{
|
||||
{
|
||||
/*
|
||||
CHECKD(rata >= 1 && rata <= partita.rate(), "Rata errata ", rata);
|
||||
CHECKD(!partita.rata_pagata(rata), "Rata pagata ", rata);
|
||||
|
||||
@ -569,7 +756,7 @@ int TPrimanota_application::nuovo_pagamento(TPartita& partita, int rata, int rmo
|
||||
part.zero(PART_REG);
|
||||
part.zero(PART_PROTIVA);
|
||||
|
||||
part.put(PART_SEZ, (partita.totale().sezione() == 'D') ? 'A' : 'D');
|
||||
// part.put(PART_SEZ, (partita.totale().sezione() == 'D') ? 'A' : 'D');
|
||||
part.zero(PART_IMPORTO); // Azzera importi vari
|
||||
part.zero(PART_IMPOSTA);
|
||||
part.zero(PART_SPESE);
|
||||
@ -662,105 +849,22 @@ int TPrimanota_application::nuovo_pagamento(TPartita& partita, int rata, int rmo
|
||||
part.put(PART_CODCABPR, tmp);
|
||||
|
||||
return nriga+1;
|
||||
*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// Edit scadenze relative all'anno/numero partita specificati
|
||||
bool TPrimanota_application::edit_scadenze(int anno, const char* num)
|
||||
bool TPrimanota_application::edit_scadenze(const TBill& clifo, int anno, const char* num)
|
||||
{
|
||||
TString caption; caption.format("Pagamenti della partita %s dell'anno %d", num, anno);
|
||||
TArray_sheet a(-1, -1, 0, 0, caption, "Rata|Data@10|Dare@15R|Avere@15R|Descrizione@50|Riga", 0x8);
|
||||
TPartita& partita = _partite.partita(anno, num);
|
||||
|
||||
TPartita& partita = _partite.partita(clifo, anno, num);
|
||||
|
||||
const long curreg = curr_mask().get_long(F_NUMREG); // Numero registrazione corrente
|
||||
const int currig = cgs().selected()+1; // Numero riga corrente
|
||||
|
||||
TToken_string r(80); // Work string
|
||||
|
||||
KEY k = K_ENTER;
|
||||
bool dirty = TRUE, one_dirty = FALSE;
|
||||
|
||||
while (k == K_ENTER)
|
||||
{
|
||||
if (dirty)
|
||||
{
|
||||
const TString desc(partita.descrizione());
|
||||
|
||||
a.destroy();
|
||||
long nr;
|
||||
|
||||
const char sez_par = partita.riga(1).get_char(PART_SEZ);
|
||||
|
||||
for (int s = 1; s <= partita.rate(); s++)
|
||||
{
|
||||
const TRectype& rata = partita.rata(s);
|
||||
r.cut(0);
|
||||
r.add(rata.get(SCAD_NRATA));
|
||||
r.add(rata.get(SCAD_DATASCAD));
|
||||
if (sez_par == 'A')
|
||||
{
|
||||
r.add(rata.get(SCAD_IMPORTO));
|
||||
r.add("");
|
||||
}
|
||||
else
|
||||
{
|
||||
r.add("");
|
||||
r.add(rata.get(SCAD_IMPORTO));
|
||||
}
|
||||
r.add(desc);
|
||||
r.add("S");
|
||||
nr = a.add(r);
|
||||
if (partita.rata_pagata(s))
|
||||
a.disable(nr);
|
||||
|
||||
for (int p = 1; p <= partita.righe(); p++)
|
||||
{
|
||||
const TRectype& paga = partita.riga(p);
|
||||
if (paga.get_int(PART_NRATA) == s)
|
||||
{
|
||||
r.cut(0);
|
||||
r.add(s);
|
||||
r.add(paga.get(PART_DATAREG));
|
||||
const char sez = paga.get_char(PART_SEZ);
|
||||
if (sez == 'D')
|
||||
{
|
||||
r.add(paga.get(PART_IMPORTO));
|
||||
r.add("");
|
||||
}
|
||||
else
|
||||
{
|
||||
r.add(paga.get(PART_IMPORTO));
|
||||
r.add("");
|
||||
}
|
||||
r.add(paga.get(PART_DESCR));
|
||||
r.add(paga.get(PART_NRIGA));
|
||||
nr = a.add(r);
|
||||
if (paga.get_long(PART_NREG) != curreg || paga.get_int(PART_NUMRIG) != currig)
|
||||
a.disable(nr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
k = a.run();
|
||||
if (k == K_ENTER)
|
||||
{
|
||||
const int rata = a.row().get_int(0);
|
||||
int nrig = a.row().get_int(5); // Numero riga pagamento corrente
|
||||
|
||||
TRectype part(LF_PARTITE);
|
||||
|
||||
if (nrig == 0) // Se ho cliccato su una scadenza ...
|
||||
nrig = nuovo_pagamento(partita, rata, currig, part);
|
||||
else
|
||||
part = partita.riga(nrig);
|
||||
|
||||
dirty = edit_pagamento(partita, part);
|
||||
one_dirty |= dirty;
|
||||
} // if k == K_ENTER
|
||||
} // while k == K_ENTER
|
||||
|
||||
return one_dirty;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@ -792,7 +896,8 @@ static bool importopag_handler(TMask_field& f, KEY k)
|
||||
|
||||
|
||||
bool TPrimanota_application::edit_pagamento(TPartita& p, TRectype& part)
|
||||
{
|
||||
{
|
||||
/*
|
||||
TMask m("cg2100s");
|
||||
m.set_handler(S_IMPORTOPAG, importopag_handler);
|
||||
|
||||
@ -880,6 +985,8 @@ bool TPrimanota_application::edit_pagamento(TPartita& p, TRectype& part)
|
||||
}
|
||||
|
||||
return key != K_ESC;
|
||||
*/
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool TPrimanota_application::notify_cgline_deletion(TPartita& partita, long nreg, int numrig)
|
||||
@ -887,7 +994,7 @@ bool TPrimanota_application::notify_cgline_deletion(TPartita& partita, long nreg
|
||||
bool found = FALSE;
|
||||
const int riga_ritenute = type2pos('F');
|
||||
|
||||
for (int r = partita.righe(); r > 0; r--)
|
||||
for (int r = 1; r > 0; r--)
|
||||
{
|
||||
TRectype pag(partita.riga(r));
|
||||
|
||||
@ -917,19 +1024,19 @@ bool TPrimanota_application::notify_cgline_deletion(TPartita& partita, long nreg
|
||||
else
|
||||
error_box("Non esiste la riga dell'importo di un pagamento della riga %d", numrig);
|
||||
}
|
||||
partita.remove_riga(pag);
|
||||
// partita.remove_riga(pag);
|
||||
found = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
const int n = pag.get_int(PART_NUMRIG);
|
||||
pag.put(PART_NUMRIG, n-1);
|
||||
partita.add_riga(pag);
|
||||
// partita.add_riga(pag);
|
||||
}
|
||||
}
|
||||
else // numrig == 0
|
||||
{
|
||||
partita.remove_riga(pag); // Cancellazione pura e semplice
|
||||
// partita.remove_riga(pag); // Cancellazione pura e semplice
|
||||
found = TRUE; // usata solo da ::remove
|
||||
}
|
||||
} // if reg == numreg
|
||||
|
@ -51,7 +51,7 @@ protected: // Relapp
|
||||
protected:
|
||||
void check_registers(int year);
|
||||
void init_array(TMask& m, bool update);
|
||||
static bool sheet_action(int r, KEY k);
|
||||
static bool sheet_action(TSheet_field& s, int r, KEY k);
|
||||
|
||||
public:
|
||||
|
||||
@ -175,7 +175,7 @@ bool TParaliq_app::user_destroy()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TParaliq_app::sheet_action(int r, KEY k)
|
||||
bool TParaliq_app::sheet_action(TSheet_field& s, int r, KEY k)
|
||||
{
|
||||
// non si possono cancellare o aggiungere righe in PLA
|
||||
return (k != K_DEL && k != K_INS);
|
||||
|
@ -214,13 +214,13 @@ void Visliq_app::set_mask_freq(TMask& m)
|
||||
}
|
||||
|
||||
|
||||
bool Visliq_app::sheet_action(int r, KEY k)
|
||||
bool Visliq_app::sheet_action(TSheet_field& s, int r, KEY k)
|
||||
{
|
||||
// non si possono cancellare o aggiungere righe
|
||||
return (k != K_DEL && k != K_INS);
|
||||
}
|
||||
|
||||
bool Visliq_app::vers_action(int r, KEY k)
|
||||
bool Visliq_app::vers_action(TSheet_field& s, int r, KEY k)
|
||||
{
|
||||
// non si possono cancellare o aggiungere righe
|
||||
return (k != K_DEL && k != K_INS);
|
||||
|
@ -60,8 +60,8 @@ protected:
|
||||
|
||||
static const char* link_handler(TMask&, int, const char*, bool doubleclick);
|
||||
|
||||
static bool sheet_action(int r, KEY k);
|
||||
static bool vers_action(int r, KEY k);
|
||||
static bool sheet_action(TSheet_field& s, int r, KEY k);
|
||||
static bool vers_action(TSheet_field& s, int r, KEY k);
|
||||
|
||||
public:
|
||||
|
||||
|
@ -213,7 +213,7 @@ STRINGA
|
||||
BEGIN
|
||||
KEY "Partita IVA"
|
||||
PROMPT 12 30 ""
|
||||
PICTURE "# # # # # # # ~ ~ ~ #"
|
||||
PICTURE "# # # # # # # ^ ^ ^ #"
|
||||
FIELD 6->PAIV
|
||||
END
|
||||
|
||||
@ -229,7 +229,7 @@ NUMERO
|
||||
BEGIN
|
||||
KEY "Anno di versamento"
|
||||
PROMPT 40 35 ""
|
||||
PICTURE "~ ~ @ @"
|
||||
PICTURE "^ ^ @ @"
|
||||
FIELD CODTAB[6,9]
|
||||
END
|
||||
|
||||
@ -299,7 +299,7 @@ NUMERO
|
||||
BEGIN
|
||||
KEY "Importo in cifre"
|
||||
PROMPT 20 52 ""
|
||||
PICTURE "###.###.###~~~"
|
||||
PICTURE "###.###.###^^^"
|
||||
FIELD R0
|
||||
END
|
||||
|
||||
@ -347,7 +347,7 @@ STRINGA
|
||||
BEGIN
|
||||
KEY "Codice Filiale"
|
||||
PROMPT 70 62 ""
|
||||
PICTURE "~ ~ @ @"
|
||||
PICTURE "^ ^ @ @"
|
||||
FIELD S8
|
||||
END
|
||||
|
||||
|
2782
cg/pagament.cpp
2782
cg/pagament.cpp
File diff suppressed because it is too large
Load Diff
@ -165,57 +165,103 @@ public:
|
||||
#include <partite.h>
|
||||
#endif
|
||||
|
||||
class TPartita : public TObject
|
||||
{
|
||||
TRecord_array _scad, _part;
|
||||
TImporto _totale;
|
||||
class TTree_rectype : public TRectype
|
||||
{
|
||||
protected:
|
||||
TRecord_array _recarr;
|
||||
|
||||
public: // TObject
|
||||
virtual bool ok() const { return rate() > 0; }
|
||||
void copy_key_to_row(TRectype& row) const;
|
||||
int fill_array();
|
||||
|
||||
protected: // TRectype
|
||||
virtual TObject* dup() const;
|
||||
|
||||
virtual int read(TBaseisamfile& f, word op = _isequal);
|
||||
virtual int next(TBaseisamfile& f);
|
||||
virtual int write(TBaseisamfile& f) const;
|
||||
virtual int rewrite(TBaseisamfile& f) const;
|
||||
virtual int remove(TBaseisamfile& f);
|
||||
|
||||
public:
|
||||
const TRecord_array& rows_array() const { return _recarr; }
|
||||
|
||||
TTree_rectype(const TRectype& testata, const TRectype& riga, const char* num);
|
||||
TTree_rectype(int testata, int riga, const char* num);
|
||||
TTree_rectype(const TTree_rectype& t);
|
||||
virtual ~TTree_rectype() {}
|
||||
};
|
||||
|
||||
class TRiga_scadenze : public TTree_rectype
|
||||
{
|
||||
public:
|
||||
TRiga_scadenze();
|
||||
virtual ~TRiga_scadenze() {}
|
||||
};
|
||||
|
||||
class TRiga_partite : public TTree_rectype
|
||||
{
|
||||
public: // TTree_rectype
|
||||
virtual TObject* dup() const;
|
||||
virtual int read(TBaseisamfile& f, word op);
|
||||
|
||||
public:
|
||||
int add_riga(const TRectype& r);
|
||||
const TRectype& riga(int r) const { return _part.row(r); }
|
||||
void remove_riga(TRectype& z);
|
||||
int righe() const { return _part.rows(); }
|
||||
|
||||
int rate() const { return _recarr.rows(); }
|
||||
TRiga_scadenze& rata(int r) const { return (TRiga_scadenze&)_recarr.row(r); }
|
||||
bool rata_pagata(int r) const;
|
||||
int add_rata(const TRectype& r);
|
||||
const TRectype& rata(int r) const { return _scad.row(r); }
|
||||
int rate() const { return _scad.rows(); }
|
||||
int ultimo_pagamento(int rata) const;
|
||||
|
||||
TRiga_partite();
|
||||
TRiga_partite(const TRiga_partite& r);
|
||||
virtual ~TRiga_partite() {}
|
||||
};
|
||||
|
||||
class TPartita : public TObject
|
||||
{
|
||||
TRecord_array _part;
|
||||
TRecord_array _unassigned;
|
||||
|
||||
public: // TObject
|
||||
virtual bool ok() const { return _part.rows() > 0; }
|
||||
|
||||
public:
|
||||
int add_riga(const TRiga_partite& r);
|
||||
const TRiga_partite& riga(int r) const { return (const TRiga_partite&)_part.row(r); }
|
||||
TRecord_array& rows_array() { return _part; }
|
||||
|
||||
void remove_riga(TRiga_partite& z);
|
||||
|
||||
bool reread();
|
||||
bool read(int anno, const char* num);
|
||||
bool read(const TBill& clifo, int anno, const char* num);
|
||||
bool write(bool re = FALSE);
|
||||
bool rewrite() { return write(TRUE); }
|
||||
|
||||
int anno() const { return riga(1).get_int(PART_ANNO); }
|
||||
const TString& numero() const { return riga(1).get(PART_NUMPART); }
|
||||
const TString& descrizione() const { return riga(1).get(PART_DESCR); }
|
||||
const TImporto& totale() const { return _totale; }
|
||||
void conto(TBill& c) const { c.get(_part.key()); }
|
||||
int anno() const { return _part.key().get_int(PART_ANNO); }
|
||||
const TString& numero() const { return _part.key().get(PART_NUMPART); }
|
||||
const TString& descrizione() const { return _part.key().get(PART_DESCR); }
|
||||
|
||||
TImporto importo_speso(long numreg, int numrig) const;
|
||||
void update_reg_num(long nreg, const TRectype& mov);
|
||||
|
||||
TPartita(int anno, const char* num);
|
||||
TPartita(const TBill& clifo, int anno, const char* num);
|
||||
};
|
||||
|
||||
|
||||
class TPartite_array : private TAssoc_array
|
||||
{
|
||||
TString16 _key; // Work string
|
||||
TString80 _key; // Work string
|
||||
|
||||
protected:
|
||||
const TString& key(int anno, const char* num); // Build key for TAssoc_array
|
||||
TPartita* find(int anno, const char* numero, bool create);
|
||||
const TString& key(const TBill& clifo, int anno, const char* num); // Build key for TAssoc_array
|
||||
TPartita* find(const TBill& clifo, int anno, const char* numero, bool create);
|
||||
TPartita* find(const TRectype& part, bool create);
|
||||
|
||||
public: // TAssoc_array
|
||||
virtual void destroy() { TAssoc_array::destroy(); }
|
||||
|
||||
public:
|
||||
TPartita& partita(int anno, const char* numero);
|
||||
TPartita& partita(const TBill& clifo, int anno, const char* numero);
|
||||
TPartita& partita(const TRectype& r);
|
||||
|
||||
bool write(bool re = FALSE);
|
||||
@ -228,7 +274,8 @@ public:
|
||||
TPartita* first() { restart(); return next(); }
|
||||
TPartita* next() { return (TPartita*)get(); }
|
||||
|
||||
TPartite_array() {}
|
||||
TPartite_array() {}
|
||||
virtual ~TPartite_array() {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user