Continua senza posa lo sviluppo del saldaconto
git-svn-id: svn://10.65.10.50/trunk@1224 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
2db49dce54
commit
5ef3de0323
@ -133,6 +133,8 @@ int TStampa_deleghe_IVA::select()
|
|||||||
TToken_string d(80);
|
TToken_string d(80);
|
||||||
|
|
||||||
_ditte->destroy();
|
_ditte->destroy();
|
||||||
|
|
||||||
|
begin_wait();
|
||||||
for (_nditte->first(); _nditte->good(); _nditte->next())
|
for (_nditte->first(); _nditte->good(); _nditte->next())
|
||||||
{
|
{
|
||||||
TLocalisamfile& anag = _nditte->lfile(LF_ANAG);
|
TLocalisamfile& anag = _nditte->lfile(LF_ANAG);
|
||||||
@ -166,6 +168,7 @@ int TStampa_deleghe_IVA::select()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
end_wait();
|
||||||
|
|
||||||
int res = 1;
|
int res = 1;
|
||||||
if (_ditte->items() > 0)
|
if (_ditte->items() > 0)
|
||||||
|
@ -133,6 +133,8 @@ int TStampa_deleghe_IVA::select()
|
|||||||
TToken_string d(80);
|
TToken_string d(80);
|
||||||
|
|
||||||
_ditte->destroy();
|
_ditte->destroy();
|
||||||
|
|
||||||
|
begin_wait();
|
||||||
for (_nditte->first(); _nditte->good(); _nditte->next())
|
for (_nditte->first(); _nditte->good(); _nditte->next())
|
||||||
{
|
{
|
||||||
TLocalisamfile& anag = _nditte->lfile(LF_ANAG);
|
TLocalisamfile& anag = _nditte->lfile(LF_ANAG);
|
||||||
@ -166,6 +168,7 @@ int TStampa_deleghe_IVA::select()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
end_wait();
|
||||||
|
|
||||||
int res = 1;
|
int res = 1;
|
||||||
if (_ditte->items() > 0)
|
if (_ditte->items() > 0)
|
||||||
|
@ -161,10 +161,11 @@ bool TPrimanota_application::user_create()
|
|||||||
_comuni = new TLocalisamfile(LF_COMUNI);
|
_comuni = new TLocalisamfile(LF_COMUNI);
|
||||||
_occas = new TLocalisamfile(LF_OCCAS);
|
_occas = new TLocalisamfile(LF_OCCAS);
|
||||||
_nditte = new TLocalisamfile(LF_NDITTE);
|
_nditte = new TLocalisamfile(LF_NDITTE);
|
||||||
|
_scadenze = new TLocalisamfile(LF_SCADENZE);
|
||||||
|
|
||||||
_rel = new TMovimentoPN;
|
_rel = new TMovimentoPN;
|
||||||
_rel->add(LF_PARTITE, "NREG=NUMREG", 2);
|
_rel->add(LF_PARTITE, "NREG=NUMREG", 2);
|
||||||
|
|
||||||
_causale = new TCausale();
|
_causale = new TCausale();
|
||||||
_giornale = new TLibro_giornale();
|
_giornale = new TLibro_giornale();
|
||||||
|
|
||||||
@ -194,6 +195,8 @@ bool TPrimanota_application::user_destroy()
|
|||||||
delete _giornale;
|
delete _giornale;
|
||||||
delete _causale;
|
delete _causale;
|
||||||
delete _rel;
|
delete _rel;
|
||||||
|
|
||||||
|
delete _scadenze;
|
||||||
delete _nditte;
|
delete _nditte;
|
||||||
delete _occas;
|
delete _occas;
|
||||||
delete _comuni;
|
delete _comuni;
|
||||||
@ -544,6 +547,8 @@ void TPrimanota_application::init_insert_mode(TMask& m)
|
|||||||
set_pagamento(NULL,dt);
|
set_pagamento(NULL,dt);
|
||||||
set_scadenze(m);
|
set_scadenze(m);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
_partite.destroy();
|
||||||
|
|
||||||
_saldi.reset(); // Inizializza saldi
|
_saldi.reset(); // Inizializza saldi
|
||||||
}
|
}
|
||||||
@ -555,6 +560,8 @@ void TPrimanota_application::init_modify_mode(TMask& m)
|
|||||||
calcola_saldo(); // Verifica eventuali sbilanci contabili
|
calcola_saldo(); // Verifica eventuali sbilanci contabili
|
||||||
if (iva() != nessuna_iva)
|
if (iva() != nessuna_iva)
|
||||||
calcola_imp(); // Calcola totale imponibile ed imposte
|
calcola_imp(); // Calcola totale imponibile ed imposte
|
||||||
|
else
|
||||||
|
_partite.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Controlla sulla causale se il segno del totale documento (ritsoc=FALSE)
|
// Controlla sulla causale se il segno del totale documento (ritsoc=FALSE)
|
||||||
@ -662,7 +669,6 @@ int TPrimanota_application::read(TMask& m)
|
|||||||
riga.add(r.get("CODIVA")); // IVA 102
|
riga.add(r.get("CODIVA")); // IVA 102
|
||||||
riga.add(r.get("TIPODET")); // Detrazione 103
|
riga.add(r.get("TIPODET")); // Detrazione 103
|
||||||
|
|
||||||
|
|
||||||
real imposta(r.get("IMPOSTA"));
|
real imposta(r.get("IMPOSTA"));
|
||||||
if (to_swap) imposta = -imposta;
|
if (to_swap) imposta = -imposta;
|
||||||
if (imponibile.sign() * imposta.sign() < 0)
|
if (imponibile.sign() * imposta.sign() < 0)
|
||||||
@ -680,7 +686,7 @@ int TPrimanota_application::read(TMask& m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TString16 dt(m.get(F_DATAREG));
|
TString16 dt(m.get(F_DATAREG));
|
||||||
set_pagamento(m.get(F_CODPAG),dt);
|
set_pagamento(m.get(F_CODPAG), dt);
|
||||||
if (!read_scadenze(m))
|
if (!read_scadenze(m))
|
||||||
set_scadenze(m);
|
set_scadenze(m);
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ BEGIN
|
|||||||
WARNING "Inserire un importo inferiore al residuo"
|
WARNING "Inserire un importo inferiore al residuo"
|
||||||
END
|
END
|
||||||
|
|
||||||
NUMBER S_IMPORTOPAG 15
|
NUMBER S_RITENUTE 15
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 38 8 "Ritenute professionali "
|
PROMPT 38 8 "Ritenute professionali "
|
||||||
PICTURE "."
|
PICTURE "."
|
||||||
|
@ -326,7 +326,7 @@ void TPrimanota_application::disable_cgs_cells(int n, char tipo)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last > 0)
|
if (last > 0)
|
||||||
{
|
{
|
||||||
TSheet_field& cg = cgs();
|
TSheet_field& cg = cgs();
|
||||||
for (int i = 0; i < last; i++)
|
for (int i = 0; i < last; i++)
|
||||||
@ -803,7 +803,7 @@ bool TPrimanota_application::imposta_handler(TMask_field& f, KEY key)
|
|||||||
if (val != imposta)
|
if (val != imposta)
|
||||||
{
|
{
|
||||||
f.warning_box("L'imposta dovrebbe essere %s", (const char*)imposta.string("."));
|
f.warning_box("L'imposta dovrebbe essere %s", (const char*)imposta.string("."));
|
||||||
if (val.is_zero()) f.set(imposta.string());
|
if (imposta.is_zero()) f.reset();
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
if (key == K_F8)
|
if (key == K_F8)
|
||||||
|
18
cg/cg2102.h
18
cg/cg2102.h
@ -1,14 +1,14 @@
|
|||||||
#ifndef __CG2102_H
|
#ifndef __CG2102_H
|
||||||
#define __CG2102_H
|
#define __CG2102_H
|
||||||
|
|
||||||
#ifndef __MSKSHEET_H
|
|
||||||
#include <msksheet.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __RELAPP_H
|
#ifndef __RELAPP_H
|
||||||
#include <relapp.h>
|
#include <relapp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __PAGAMENT_H
|
||||||
|
#include "pagament.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __CGLIB_H
|
#ifndef __CGLIB_H
|
||||||
#include "cglib.h"
|
#include "cglib.h"
|
||||||
#endif
|
#endif
|
||||||
@ -21,8 +21,6 @@
|
|||||||
#include "cg2103.h"
|
#include "cg2103.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class TPagamento;
|
|
||||||
|
|
||||||
class TPrimanota_application : public TRelation_application
|
class TPrimanota_application : public TRelation_application
|
||||||
{
|
{
|
||||||
TMovimentoPN* _rel;
|
TMovimentoPN* _rel;
|
||||||
@ -37,6 +35,8 @@ class TPrimanota_application : public TRelation_application
|
|||||||
TLocalisamfile* _comuni;
|
TLocalisamfile* _comuni;
|
||||||
TLocalisamfile* _occas;
|
TLocalisamfile* _occas;
|
||||||
TLocalisamfile* _nditte;
|
TLocalisamfile* _nditte;
|
||||||
|
TLocalisamfile* _scadenze;
|
||||||
|
|
||||||
TPagamento* _pag;
|
TPagamento* _pag;
|
||||||
|
|
||||||
TCausale* _causale; // Causale corrente
|
TCausale* _causale; // Causale corrente
|
||||||
@ -56,6 +56,7 @@ class TPrimanota_application : public TRelation_application
|
|||||||
bool _is_saldaconto; // saldaconto si/no (vede parametri e causale)
|
bool _is_saldaconto; // saldaconto si/no (vede parametri e causale)
|
||||||
|
|
||||||
TSaldo_agg _saldi; // Saldi da aggiornare
|
TSaldo_agg _saldi; // Saldi da aggiornare
|
||||||
|
TPartite_array _partite; // Partite coinvolte
|
||||||
|
|
||||||
TMask* _msk[4]; // Maschere di query, cg, iva
|
TMask* _msk[4]; // Maschere di query, cg, iva
|
||||||
long _lastreg; // Numero ultima registrazione
|
long _lastreg; // Numero ultima registrazione
|
||||||
@ -210,8 +211,9 @@ protected:
|
|||||||
void write_scadenze(const TMask& m);
|
void write_scadenze(const TMask& m);
|
||||||
|
|
||||||
bool edit_partite(int riga);
|
bool edit_partite(int riga);
|
||||||
bool edit_scadenze(int riga, const TBill& b, int anno, const char* num);
|
bool edit_scadenze(int anno, const char* num);
|
||||||
bool edit_pagamento(TRectype& parbas, TRectype& scaden, TRectype& part);
|
int nuovo_pagamento(TPartita& partita, int rata, int rmov, TRectype& part);
|
||||||
|
bool edit_pagamento(TPartita& partita, TRectype& part);
|
||||||
|
|
||||||
static TPrimanota_application& app() { return (TPrimanota_application&)main_app(); }
|
static TPrimanota_application& app() { return (TPrimanota_application&)main_app(); }
|
||||||
|
|
||||||
|
@ -483,15 +483,15 @@ TCodiceIVA::TCodiceIVA(const char* cod) : TRectype(LF_TABCOM)
|
|||||||
bool TCodiceIVA::read(const char* cod)
|
bool TCodiceIVA::read(const char* cod)
|
||||||
{
|
{
|
||||||
int err = ~NOERR;
|
int err = ~NOERR;
|
||||||
TTable iva("%IVA");
|
|
||||||
if (cod && *cod)
|
if (cod && *cod)
|
||||||
{
|
{
|
||||||
iva.setkey(1);
|
TTable iva("%IVA");
|
||||||
iva.put("CODTAB", cod);
|
iva.put("CODTAB", cod);
|
||||||
err = iva.read();
|
err = iva.read();
|
||||||
|
TRectype::operator=(iva.curr());
|
||||||
}
|
}
|
||||||
TRectype::operator=(iva.curr());
|
if (err != NOERR)
|
||||||
if (err != NOERR) zero();
|
zero();
|
||||||
return err == NOERR;
|
return err == NOERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ public:
|
|||||||
bool read(const char* codice);
|
bool read(const char* codice);
|
||||||
bool ok() const { return !empty(); }
|
bool ok() const { return !empty(); }
|
||||||
const TString& codice() const { return get("CODTAB"); }
|
const TString& codice() const { return get("CODTAB"); }
|
||||||
real percentuale() const { return get_real("R0"); }
|
const real& percentuale() const { return get_real("R0"); }
|
||||||
const TString& tipo() const { return get("S1"); }
|
const TString& tipo() const { return get("S1"); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
494
cg/cg2104.cpp
494
cg/cg2104.cpp
@ -270,10 +270,6 @@ bool TPrimanota_application::read_scadenze(const TMask& m)
|
|||||||
int nriga = 1;
|
int nriga = 1;
|
||||||
int numrig = 1;
|
int numrig = 1;
|
||||||
|
|
||||||
// partita.put("TIPOCF", tipocf);
|
|
||||||
// partita.put("GRUPPO", gruppo);
|
|
||||||
// partita.put("CONTO", conto);
|
|
||||||
// partita.put("SOTTOCONTO", sottoconto);
|
|
||||||
partita.put(PART_ANNO, anno);
|
partita.put(PART_ANNO, anno);
|
||||||
partita.put(PART_NUMPART, numpart);
|
partita.put(PART_NUMPART, numpart);
|
||||||
partita.put(PART_NRIGA, nriga);
|
partita.put(PART_NRIGA, nriga);
|
||||||
@ -307,10 +303,6 @@ bool TPrimanota_application::read_scadenze(const TMask& m)
|
|||||||
{
|
{
|
||||||
// cerca rata
|
// cerca rata
|
||||||
scadenza.zero();
|
scadenza.zero();
|
||||||
// scadenza.put("TIPOCF", tipocf);
|
|
||||||
// scadenza.put("GRUPPO", gruppo);
|
|
||||||
// scadenza.put("CONTO", conto);
|
|
||||||
// scadenza.put("SOTTOCONTO", sottoconto);
|
|
||||||
scadenza.put(PART_ANNO, anno);
|
scadenza.put(PART_ANNO, anno);
|
||||||
scadenza.put(PART_NUMPART, numpart);
|
scadenza.put(PART_NUMPART, numpart);
|
||||||
scadenza.put(PART_NRATA, i+1);
|
scadenza.put(PART_NRATA, i+1);
|
||||||
@ -378,10 +370,6 @@ void TPrimanota_application::write_scadenze(const TMask& m)
|
|||||||
int nriga = 1;
|
int nriga = 1;
|
||||||
int numrig = 1;
|
int numrig = 1;
|
||||||
|
|
||||||
// partita.put("TIPOCF", tipocf);
|
|
||||||
// partita.put("GRUPPO", gruppo);
|
|
||||||
// partita.put("CONTO", conto);
|
|
||||||
// partita.put("SOTTOCONTO", sottoconto);
|
|
||||||
partita.put("ANNO", anno);
|
partita.put("ANNO", anno);
|
||||||
partita.put("NUMPART", numpart);
|
partita.put("NUMPART", numpart);
|
||||||
partita.put("NRIGA", nriga);
|
partita.put("NRIGA", nriga);
|
||||||
@ -439,10 +427,6 @@ void TPrimanota_application::write_scadenze(const TMask& m)
|
|||||||
{
|
{
|
||||||
new_scad = FALSE;
|
new_scad = FALSE;
|
||||||
scadenza.zero();
|
scadenza.zero();
|
||||||
// scadenza.put("TIPOCF", tipocf);
|
|
||||||
// scadenza.put("GRUPPO", gruppo);
|
|
||||||
// scadenza.put("CONTO", conto);
|
|
||||||
// scadenza.put("SOTTOCONTO", sottoconto);
|
|
||||||
scadenza.put("ANNO", anno);
|
scadenza.put("ANNO", anno);
|
||||||
scadenza.put("NUMPART", numpart);
|
scadenza.put("NUMPART", numpart);
|
||||||
scadenza.put("NRATA", i+1);
|
scadenza.put("NRATA", i+1);
|
||||||
@ -475,10 +459,6 @@ void TPrimanota_application::write_scadenze(const TMask& m)
|
|||||||
for (; !new_scad ; i++)
|
for (; !new_scad ; i++)
|
||||||
{
|
{
|
||||||
scadenza.zero();
|
scadenza.zero();
|
||||||
// scadenza.put("TIPOCF", tipocf);
|
|
||||||
// scadenza.put("GRUPPO", gruppo);
|
|
||||||
// scadenza.put("CONTO", conto);
|
|
||||||
// scadenza.put("SOTTOCONTO", sottoconto);
|
|
||||||
scadenza.put("ANNO", anno);
|
scadenza.put("ANNO", anno);
|
||||||
scadenza.put("NUMPART", numpart);
|
scadenza.put("NUMPART", numpart);
|
||||||
scadenza.put("NRATA", i+1);
|
scadenza.put("NRATA", i+1);
|
||||||
@ -494,6 +474,9 @@ void TPrimanota_application::write_scadenze(const TMask& m)
|
|||||||
// Sheet partite
|
// Sheet partite
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
HIDDEN int _riga;
|
||||||
|
HIDDEN TImporto _soldi, _max;
|
||||||
|
|
||||||
bool TPrimanota_application::edit_partite(int riga)
|
bool TPrimanota_application::edit_partite(int riga)
|
||||||
{
|
{
|
||||||
begin_wait();
|
begin_wait();
|
||||||
@ -502,8 +485,9 @@ bool TPrimanota_application::edit_partite(int riga)
|
|||||||
|
|
||||||
TToken_string& cgr = cgs().row(riga);
|
TToken_string& cgr = cgs().row(riga);
|
||||||
const TBill b(cgr, 2, 0x3); // Legge il conto della riga selezionata
|
const TBill b(cgr, 2, 0x3); // Legge il conto della riga selezionata
|
||||||
|
|
||||||
TImporto soldi; soldi = cgr; // Importo della riga selezionata
|
_riga = riga; // Riga correntemente in gestione
|
||||||
|
_soldi = cgr; // Importo della riga selezionata
|
||||||
|
|
||||||
TString80 caption("Partite aperte del conto ");
|
TString80 caption("Partite aperte del conto ");
|
||||||
caption << b.gruppo() << ' ' << b.conto() << ' ' << b.sottoconto();
|
caption << b.gruppo() << ' ' << b.conto() << ' ' << b.sottoconto();
|
||||||
@ -545,7 +529,7 @@ bool TPrimanota_application::edit_partite(int riga)
|
|||||||
{
|
{
|
||||||
const int numrig = partita.get_int(PART_NUMRIG);
|
const int numrig = partita.get_int(PART_NUMRIG);
|
||||||
if (numrig == (riga+1))
|
if (numrig == (riga+1))
|
||||||
soldi -= i;
|
_soldi -= i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -582,251 +566,212 @@ bool TPrimanota_application::edit_partite(int riga)
|
|||||||
{
|
{
|
||||||
const int anno = a.row().get_int(0);
|
const int anno = a.row().get_int(0);
|
||||||
const TString16 num = a.row().get(1);
|
const TString16 num = a.row().get(1);
|
||||||
edit_scadenze(riga, b, anno, num); // Edita pagamenti
|
edit_scadenze(anno, num); // Edita pagamenti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
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);
|
||||||
|
|
||||||
|
const int nriga = partita.righe();
|
||||||
|
CHECKD(nriga > 0, "Riga partita errata ", nriga);
|
||||||
|
|
||||||
|
part = partita.riga(nriga);
|
||||||
|
|
||||||
|
// PART_ANNO viene preso dalla partita base
|
||||||
|
// PART_NUMPART viene preso dalla partita base
|
||||||
|
part.put(PART_NRIGA, nriga+1); // Riga di partita
|
||||||
|
|
||||||
|
part.put(PART_TIPOMOV, causale().tipomov()); // Dati causale corrente
|
||||||
|
part.put(PART_CODCAUS, causale().codice());
|
||||||
|
|
||||||
|
part.put(PART_NREG, curr_mask().get(F_NUMREG)); // Numero operazione
|
||||||
|
part.put(PART_NUMRIG, rmov+1); // Riga su cui ho cliccato
|
||||||
|
|
||||||
|
// Copia dati movimento corrente
|
||||||
|
part.put(PART_DATAREG, curr_mask().get(F_DATAREG));
|
||||||
|
part.put(PART_DATADOC, curr_mask().get(F_DATADOC));
|
||||||
|
part.put(PART_NUMDOC, curr_mask().get(F_NUMDOC));
|
||||||
|
part.put(PART_DESCR, curr_mask().get(F_DESCR));
|
||||||
|
|
||||||
|
part.zero(PART_REG);
|
||||||
|
part.zero(PART_PROTIVA);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
TString80 tmp;
|
||||||
|
|
||||||
|
part.zero(PART_CODVAL);
|
||||||
|
part.zero(PART_CAMBIO);
|
||||||
|
part.zero(PART_IMPORTOVAL);
|
||||||
|
part.zero(PART_DATACAM);
|
||||||
|
|
||||||
|
const TRectype& scadenza = partita.rata(rata);
|
||||||
|
tmp = scadenza.get(SCAD_CODPAG);
|
||||||
|
part.put(PART_CODPAG, tmp);
|
||||||
|
|
||||||
|
tmp = scadenza.get(SCAD_TIPOPAG);
|
||||||
|
part.put(PART_TIPOPAG, tmp);
|
||||||
|
|
||||||
|
int caus = 2; // Calcola riga causale per la contropartita in base al tipo pagamento
|
||||||
|
switch (atoi(tmp))
|
||||||
|
{
|
||||||
|
case 2: // Tratta
|
||||||
|
case 7: // Tratta accettata
|
||||||
|
caus = 3; break;
|
||||||
|
case 3: // Ricevuta bancaria
|
||||||
|
caus = 4; break;
|
||||||
|
case 4: // Cessione
|
||||||
|
caus = 5; break;
|
||||||
|
case 5: // Paghero'
|
||||||
|
caus = 6; break;
|
||||||
|
case 6: // Fattura di credito
|
||||||
|
caus = 7; break;
|
||||||
|
case 1: // Rimessa
|
||||||
|
case 8: // Rapporti interbancari diretti
|
||||||
|
case 9: // Bonifico
|
||||||
|
default:
|
||||||
|
caus = 2; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
TBill bill; causale().bill(caus, bill);
|
||||||
|
if (bill.empty()) causale().bill(caus = 1, bill);
|
||||||
|
bill.put(part);
|
||||||
|
|
||||||
|
TBill b; b.get(partita.riga(1));
|
||||||
|
if (b.tipo() > ' ') // Se cliente o fornitore cerca sua banca
|
||||||
|
{
|
||||||
|
TRelation cliforel(LF_CLIFO);
|
||||||
|
cliforel.add(LF_CFVEN, "TIPOCF=TIPOCF|CODCF=CODCF");
|
||||||
|
TRectype& clifo = cliforel.lfile().curr();
|
||||||
|
|
||||||
|
clifo.put(CLI_TIPOCF, b.tipo());
|
||||||
|
clifo.put(CLI_CODCF, b.codclifo());
|
||||||
|
const int err = cliforel.read();
|
||||||
|
CHECK(err == NOERR, "Chiss'e' fregato il clifo");
|
||||||
|
|
||||||
|
tmp = clifo.get(CLI_CODABI);
|
||||||
|
part.put(PART_CODABI, tmp);
|
||||||
|
tmp = clifo.get(CLI_CODCAB);
|
||||||
|
part.put(PART_CODCAB, tmp);
|
||||||
|
tmp = cliforel.lfile(LF_CFVEN).get(CLI_CODAG);
|
||||||
|
part.put(PART_CODAG, tmp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
part.zero(PART_CODABI);
|
||||||
|
part.zero(PART_CODCAB);
|
||||||
|
part.zero(PART_CODAG);
|
||||||
|
}
|
||||||
|
|
||||||
|
part.zero(PART_IMPTOTPAG);
|
||||||
|
part.zero(PART_SALACC);
|
||||||
|
part.zero(PART_RITENUTE);
|
||||||
|
|
||||||
|
part.zero(PART_DATARIFPAG);
|
||||||
|
part.zero(PART_NUMRIFPAG);
|
||||||
|
part.zero(PART_CHIUSA);
|
||||||
|
|
||||||
|
tmp = scadenza.get(SCAD_NRATA);
|
||||||
|
part.put(PART_NRATA, tmp);
|
||||||
|
|
||||||
|
tmp = scadenza.get(SCAD_CODABIPR);
|
||||||
|
part.put(PART_CODABIPR, tmp);
|
||||||
|
|
||||||
|
tmp = scadenza.get(SCAD_CODCABPR);
|
||||||
|
part.put(PART_CODCABPR, tmp);
|
||||||
|
|
||||||
|
return nriga+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Edit scadenze relative all'anno/numero partita specificati
|
// Edit scadenze relative all'anno/numero partita specificati
|
||||||
bool TPrimanota_application::edit_scadenze(int currig, const TBill& b, int anno, const char* num)
|
bool TPrimanota_application::edit_scadenze(int anno, const char* num)
|
||||||
{
|
{
|
||||||
TString caption; caption.format("Pagamenti della partita %s dell'anno %d", num, anno);
|
TString caption; caption.format("Pagamenti della partita %s dell'anno %d", num, anno);
|
||||||
TArray_sheet a(-1, -1, 0, 0, caption, "Rata|Data@10|Importo@15|Descrizione@50|Tipo", 0x8);
|
TArray_sheet a(-1, -1, 0, 0, caption, "Rata|Data@10|Importo@15|Descrizione@50|Riga", 0x8);
|
||||||
|
|
||||||
TLocalisamfile scadenza(LF_SCADENZE);
|
TPartita* game = _partite.partita(anno, num);
|
||||||
scadenza.zero(); scadenza.put(SCAD_ANNO, anno); scadenza.put(SCAD_NUMPART, num);
|
if (game == NULL)
|
||||||
|
|
||||||
const TRectype recsca(scadenza.curr()); // Filtra scadenze su anno partita
|
|
||||||
|
|
||||||
TToken_string r(80);
|
|
||||||
for (int err = scadenza.read(_isgteq);
|
|
||||||
err == NOERR && scadenza.curr() == recsca;
|
|
||||||
err = scadenza.next())
|
|
||||||
{
|
{
|
||||||
r.cut(0);
|
game = new TPartita(anno, num);
|
||||||
r.add(scadenza.get(SCAD_NRATA)); // Numero rata
|
_partite.add(game);
|
||||||
r.add(scadenza.get(SCAD_DATASCAD)); // Data scadenza rata
|
|
||||||
r.add(scadenza.get(SCAD_IMPORTO)); // Importo rata
|
|
||||||
r.add(""); // Descrizione movimento
|
|
||||||
r.add(""); // Tipo movimento
|
|
||||||
a.add(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
TLocalisamfile partita(LF_PARTITE);
|
|
||||||
partita.setkey(1);
|
|
||||||
partita.zero(); partita.put(PART_ANNO, anno); partita.put(PART_NUMPART, num);
|
|
||||||
const TRectype recpar(partita.curr());
|
|
||||||
|
|
||||||
const TString16 curreg(curr_mask().get(F_NUMREG)); // Numero registrazione corrente
|
|
||||||
TString desc; // Descrizione di default
|
|
||||||
|
|
||||||
TRectype parbas(recpar); // Partita base
|
|
||||||
|
|
||||||
for (err = partita.read(_isgteq); err == NOERR && partita.curr() == recpar; err = partita.next())
|
|
||||||
{
|
|
||||||
const int rata = partita.get_int(PART_NRATA); // Legge eventuale numero rata
|
|
||||||
|
|
||||||
if (desc.empty())
|
|
||||||
{
|
|
||||||
parbas = partita.curr(); // Memorizza parita base
|
|
||||||
|
|
||||||
desc = partita.get(PART_DESCR); // Aggiorna descrizione scadenze
|
|
||||||
for (int i = 0; i < a.items(); i++)
|
|
||||||
{
|
|
||||||
TToken_string& t = a.row(i);
|
|
||||||
const TFixed_string d(t.get(3));
|
|
||||||
if (d.blank()) t.add(desc, 3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rata < 1 || partita.get(PART_REG).not_empty())
|
|
||||||
continue; // Ignora chi non e' un pagamento
|
|
||||||
|
|
||||||
for (long i = a.items()-1; i >= 0; i--) // Cerca scadenza corrispondente
|
|
||||||
if (a.row(i).get_int(0) == rata) break;
|
|
||||||
|
|
||||||
if (i < 0)
|
|
||||||
error_box("Non esiste una scadenza per la rata %d", rata);
|
|
||||||
|
|
||||||
r.cut(0);
|
|
||||||
r.add(rata);
|
|
||||||
r.add(partita.get(PART_DATADOC));
|
|
||||||
r.add(partita.get(PART_IMPORTO));
|
|
||||||
r.add(desc);
|
|
||||||
r.add(partita.get(PART_NRIGA));
|
|
||||||
i = a.insert(r, i >= 0 ? i+1 : -1);
|
|
||||||
|
|
||||||
// Disabilita la righe che non riguardano la riga cliccata
|
|
||||||
if (partita.get(PART_NREG) != curreg || partita.get_int(PART_NUMRIG) != (currig+1))
|
|
||||||
a.disable(i);
|
|
||||||
}
|
}
|
||||||
|
TPartita& partita = *game;
|
||||||
|
|
||||||
KEY k = a.items() > 0 ? K_ENTER : K_ESC; // Esce se non ci sono righe
|
const long curreg = curr_mask().get_long(F_NUMREG); // Numero registrazione corrente
|
||||||
|
|
||||||
|
TToken_string r(80); // Work string
|
||||||
|
|
||||||
|
KEY k = K_ENTER;
|
||||||
|
bool dirty = TRUE;
|
||||||
|
|
||||||
while (k == K_ENTER)
|
while (k == K_ENTER)
|
||||||
{
|
{
|
||||||
k = a.run();
|
if (dirty)
|
||||||
|
{
|
||||||
|
const TString desc(partita.descrizione());
|
||||||
|
|
||||||
|
a.destroy();
|
||||||
|
long nr;
|
||||||
|
|
||||||
long pos;
|
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));
|
||||||
|
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));
|
||||||
|
r.add(paga.get(PART_IMPORTO));
|
||||||
|
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) != _riga+1)
|
||||||
|
a.disable(nr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
k = a.run();
|
||||||
if (k == K_ENTER)
|
if (k == K_ENTER)
|
||||||
{
|
{
|
||||||
const int rata = a.row().get_int(0);
|
const int rata = a.row().get_int(0);
|
||||||
scadenza.zero();
|
int nrig = a.row().get_int(4); // Numero riga pagamento corrente
|
||||||
scadenza.put(SCAD_ANNO, anno);
|
|
||||||
scadenza.put(SCAD_NUMPART, num);
|
TRectype part(LF_PARTITE);
|
||||||
scadenza.put(SCAD_NRATA, rata);
|
|
||||||
err = scadenza.read();
|
|
||||||
CHECKD(err == NOERR, "Non ritrovo piu' la scadenza della rata ", rata);
|
|
||||||
|
|
||||||
int urig = 1;
|
if (nrig == 0) // Se ho cliccato su una scadenza ...
|
||||||
int nrig = a.row().get_int(4);
|
nrig = nuovo_pagamento(partita, rata, _riga, part);
|
||||||
if (nrig == 0) // Ho cliccato su una scadenza
|
|
||||||
{
|
|
||||||
for (pos = a.selected()+1; pos < a.items(); pos++) // Cerca pagamento
|
|
||||||
{
|
|
||||||
const int nr = a.row(pos).get_int(4);
|
|
||||||
if (nr) urig = nr;
|
|
||||||
if (nr == 0 || a.enabled(pos))
|
|
||||||
{
|
|
||||||
nrig = nr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool nuovo = nrig == 0;
|
|
||||||
TRectype part(parbas);
|
|
||||||
if (nuovo) // Inserimento di un nuovo pagamento
|
|
||||||
{
|
|
||||||
// PART_ANNO viene preso dalla partita base
|
|
||||||
// PART_NUMPART viene preso dalla partita base
|
|
||||||
|
|
||||||
nrig = urig+1;
|
|
||||||
part.put(PART_NRIGA, nrig); // Riga di partita
|
|
||||||
|
|
||||||
part.put(PART_TIPOMOV, causale().tipomov()); // Dati causale corrente
|
|
||||||
part.put(PART_CODCAUS, causale().codice());
|
|
||||||
|
|
||||||
part.put(PART_NREG, curreg); // Numero operazione
|
|
||||||
part.put(PART_NUMRIG, currig+1); // Riga su cui ho cliccato
|
|
||||||
|
|
||||||
// Copia dati movimento corrente
|
|
||||||
part.put(PART_DATAREG, curr_mask().get(F_DATAREG));
|
|
||||||
part.put(PART_DATADOC, curr_mask().get(F_DATADOC));
|
|
||||||
part.put(PART_NUMDOC, curr_mask().get(F_NUMDOC));
|
|
||||||
part.put(PART_DESCR, curr_mask().get(F_DESCR));
|
|
||||||
|
|
||||||
part.zero(PART_REG);
|
|
||||||
part.zero(PART_PROTIVA);
|
|
||||||
|
|
||||||
TImporto imp; imp = cgs().row(currig);
|
|
||||||
part.put(PART_SEZ, imp.sezione()); // Sezione della riga cliccata
|
|
||||||
|
|
||||||
part.zero(PART_IMPOSTA);
|
|
||||||
part.zero(PART_IMPORTO);
|
|
||||||
part.zero(PART_SPESE);
|
|
||||||
|
|
||||||
TString80 tmp;
|
|
||||||
|
|
||||||
tmp = scadenza.get(SCAD_CODPAG);
|
|
||||||
part.put(PART_CODPAG, tmp);
|
|
||||||
|
|
||||||
tmp = scadenza.get(SCAD_TIPOPAG);
|
|
||||||
part.put(PART_TIPOPAG, tmp);
|
|
||||||
|
|
||||||
part.zero(PART_CODVAL);
|
|
||||||
part.zero(PART_CAMBIO);
|
|
||||||
part.zero(PART_IMPORTOVAL);
|
|
||||||
part.zero(PART_DATACAM);
|
|
||||||
|
|
||||||
int caus = 2; // Calcola riga causale per la contropartita
|
|
||||||
switch (atoi(tmp))
|
|
||||||
{
|
|
||||||
case 2: // Tratta
|
|
||||||
case 7: // Tratta accettata
|
|
||||||
caus = 3; break;
|
|
||||||
case 3: // Ricevuta bancaria
|
|
||||||
caus = 4; break;
|
|
||||||
case 4: // Cessione
|
|
||||||
caus = 5; break;
|
|
||||||
case 5: // Paghero'
|
|
||||||
caus = 6; break;
|
|
||||||
case 6: // Fattura di credito
|
|
||||||
caus = 7; break;
|
|
||||||
case 1: // Rimessa
|
|
||||||
case 8: // Rapporti interbancari diretti
|
|
||||||
case 9: // Bonifico
|
|
||||||
default:
|
|
||||||
caus = 2; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
TBill bill; causale().bill(caus, bill);
|
|
||||||
if (bill.empty()) causale().bill(caus = 1, bill);
|
|
||||||
bill.put(part);
|
|
||||||
|
|
||||||
if (b.tipo() > ' ') // Se cliente o fornitore cerca sua banca
|
|
||||||
{
|
|
||||||
TRelation cliforel(LF_CLIFO);
|
|
||||||
cliforel.add(LF_CFVEN, "TIPOCF=TIPOCF|CODCF=CODCF");
|
|
||||||
TRectype& clifo = cliforel.lfile().curr();
|
|
||||||
|
|
||||||
clifo.put(CLI_TIPOCF, b.tipo());
|
|
||||||
clifo.put(CLI_CODCF, b.codclifo());
|
|
||||||
const int err = cliforel.read();
|
|
||||||
CHECK(err == NOERR, "Chiss'e' fregato il clifo");
|
|
||||||
|
|
||||||
tmp = clifo.get(CLI_CODABI);
|
|
||||||
part.put(PART_CODABI, tmp);
|
|
||||||
tmp = clifo.get(CLI_CODCAB);
|
|
||||||
part.put(PART_CODCAB, tmp);
|
|
||||||
tmp = cliforel.lfile(LF_CFVEN).get(CLI_CODAG);
|
|
||||||
part.put(PART_CODAG, tmp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
part.zero(PART_CODABI);
|
|
||||||
part.zero(PART_CODCAB);
|
|
||||||
part.zero(PART_CODAG);
|
|
||||||
}
|
|
||||||
|
|
||||||
part.zero(PART_IMPTOTPAG);
|
|
||||||
part.zero(PART_RITENUTE);
|
|
||||||
|
|
||||||
part.zero(PART_DATARIFPAG);
|
|
||||||
part.zero(PART_NUMRIFPAG);
|
|
||||||
part.zero(PART_CHIUSA);
|
|
||||||
|
|
||||||
tmp = scadenza.get(SCAD_NRATA);
|
|
||||||
part.put(PART_NRATA, tmp);
|
|
||||||
|
|
||||||
tmp = scadenza.get(SCAD_CODABIPR);
|
|
||||||
part.put(PART_CODABIPR, tmp);
|
|
||||||
|
|
||||||
tmp = scadenza.get(SCAD_CODCABPR);
|
|
||||||
part.put(PART_CODCABPR, tmp);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
part = partita.riga(nrig);
|
||||||
}
|
|
||||||
|
dirty = edit_pagamento(partita, part);
|
||||||
if (edit_pagamento(parbas, scadenza.curr(), part))
|
} // if k == K_ENTER
|
||||||
{
|
} // while k == K_ENTER
|
||||||
err = nuovo ? partita.write(part) : partita.rewrite(part);
|
|
||||||
|
|
||||||
if (nuovo && err == NOERR)
|
|
||||||
{
|
|
||||||
r.cut(0);
|
|
||||||
r.add(part.get(PART_NRATA));
|
|
||||||
r.add(part.get(PART_DATADOC));
|
|
||||||
r.add(part.get(PART_IMPORTO));
|
|
||||||
r.add(part.get(PART_DESCR));
|
|
||||||
r.add(part.get(PART_NRIGA));
|
|
||||||
a.insert(r, pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -847,6 +792,12 @@ static bool importopag_handler(TMask_field& f, KEY k)
|
|||||||
i = r;
|
i = r;
|
||||||
f.set(i.string());
|
f.set(i.string());
|
||||||
}
|
}
|
||||||
|
if (i > _max.valore())
|
||||||
|
{
|
||||||
|
const TFixed_string val(_max.valore().string("."));
|
||||||
|
warning_box("La riga contabile ha un residuo di %s", (const char*)val);
|
||||||
|
f.set(val);
|
||||||
|
}
|
||||||
if (i == r)
|
if (i == r)
|
||||||
{
|
{
|
||||||
m.set(S_SALDOACC, "X");
|
m.set(S_SALDOACC, "X");
|
||||||
@ -854,12 +805,18 @@ static bool importopag_handler(TMask_field& f, KEY k)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
m.enable(S_SALDOACC);
|
m.enable(S_SALDOACC);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (k == K_F8)
|
||||||
|
{
|
||||||
|
const TString& val = f.mask().get(S_RESIDUO);
|
||||||
|
f.set(val);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TPrimanota_application::edit_pagamento(TRectype& parbas, TRectype& scaden, TRectype& part)
|
bool TPrimanota_application::edit_pagamento(TPartita& p, TRectype& part)
|
||||||
{
|
{
|
||||||
TMask m("cg2100s");
|
TMask m("cg2100s");
|
||||||
m.set_handler(S_IMPORTOPAG, importopag_handler);
|
m.set_handler(S_IMPORTOPAG, importopag_handler);
|
||||||
@ -868,6 +825,10 @@ bool TPrimanota_application::edit_pagamento(TRectype& parbas, TRectype& scaden,
|
|||||||
TLocalisamfile& partita = rel.lfile();
|
TLocalisamfile& partita = rel.lfile();
|
||||||
partita.curr() = part;
|
partita.curr() = part;
|
||||||
m.autoload(&rel); // Load current record on mask
|
m.autoload(&rel); // Load current record on mask
|
||||||
|
|
||||||
|
const TRectype& parbas = p.riga(1);
|
||||||
|
const int rata = part.get_int(PART_NRATA);
|
||||||
|
const TRectype& scaden = p.rata(rata);
|
||||||
|
|
||||||
const real dapagare(scaden.get(SCAD_IMPORTO));
|
const real dapagare(scaden.get(SCAD_IMPORTO));
|
||||||
const real pagato(scaden.get(SCAD_IMPORTOPAG));
|
const real pagato(scaden.get(SCAD_IMPORTOPAG));
|
||||||
@ -890,8 +851,7 @@ bool TPrimanota_application::edit_pagamento(TRectype& parbas, TRectype& scaden,
|
|||||||
const real importo(part.get(PART_IMPORTO));
|
const real importo(part.get(PART_IMPORTO));
|
||||||
const real ritenute(part.get(PART_RITENUTE));
|
const real ritenute(part.get(PART_RITENUTE));
|
||||||
|
|
||||||
if (importo.is_zero())
|
_max.set(_soldi.sezione(), _soldi.valore() + importo); // Importo massimo del campo S_IMPORTOPAG
|
||||||
m.set(S_IMPORTOPAG, residuo.string());
|
|
||||||
|
|
||||||
const KEY key = m.run();
|
const KEY key = m.run();
|
||||||
if (key == K_ENTER)
|
if (key == K_ENTER)
|
||||||
@ -899,9 +859,37 @@ bool TPrimanota_application::edit_pagamento(TRectype& parbas, TRectype& scaden,
|
|||||||
m.autosave(&rel);
|
m.autosave(&rel);
|
||||||
part = partita.curr();
|
part = partita.curr();
|
||||||
|
|
||||||
|
const char sez = _soldi.sezione() == 'D' ? 'A' : 'D';
|
||||||
|
|
||||||
const real imp(m.get(S_IMPORTOPAG));
|
const real imp(m.get(S_IMPORTOPAG));
|
||||||
scaden.put(SCAD_IMPORTOPAG, pagato-importo+imp);
|
const TImporto impg(sez, imp-importo);
|
||||||
|
|
||||||
|
if (!impg.is_zero())
|
||||||
|
{
|
||||||
|
_soldi += impg; // Sottrai soldi spesi qui
|
||||||
|
TBill conto(m.get_int(S_GRUPPO), m.get_int(S_CONTO), m.get_long(S_SOTTOCONTO));
|
||||||
|
const int riga = bill2pos(conto, 'I');
|
||||||
|
if (riga < 0)
|
||||||
|
set_cgs_row(riga, impg, conto, m.get(S_DESCAGG), 'I');
|
||||||
|
else
|
||||||
|
add_cgs_imp(riga, impg);
|
||||||
|
}
|
||||||
|
|
||||||
|
const real rit(m.get(S_RITENUTE));
|
||||||
|
const TImporto ritg(sez, rit-ritenute);
|
||||||
|
|
||||||
|
if (!ritg.is_zero())
|
||||||
|
{
|
||||||
|
const riga = type2pos('F');
|
||||||
|
if (riga < 0)
|
||||||
|
{
|
||||||
|
TBill conto_rit; causale().bill(11, conto_rit);
|
||||||
|
set_cgs_row(riga, ritg, conto_rit, "", 'F');
|
||||||
|
}
|
||||||
|
else add_cgs_imp(riga, ritg);
|
||||||
|
}
|
||||||
|
p.add_riga(part);
|
||||||
}
|
}
|
||||||
|
|
||||||
return key == K_ENTER;
|
return key == K_ENTER;
|
||||||
}
|
}
|
||||||
|
@ -324,6 +324,9 @@ const TImporto& TImporto::set(char s, const real& v)
|
|||||||
|
|
||||||
const TImporto& TImporto::operator += (const TImporto& i)
|
const TImporto& TImporto::operator += (const TImporto& i)
|
||||||
{
|
{
|
||||||
|
if (_valore.is_zero())
|
||||||
|
_sezione = i._sezione;
|
||||||
|
|
||||||
if (_sezione == i._sezione)
|
if (_sezione == i._sezione)
|
||||||
_valore += i._valore;
|
_valore += i._valore;
|
||||||
else
|
else
|
||||||
@ -334,6 +337,9 @@ const TImporto& TImporto::operator += (const TImporto& i)
|
|||||||
|
|
||||||
const TImporto& TImporto::operator -= (const TImporto& i)
|
const TImporto& TImporto::operator -= (const TImporto& i)
|
||||||
{
|
{
|
||||||
|
if (_valore.is_zero())
|
||||||
|
_sezione = i._sezione;
|
||||||
|
|
||||||
if (_sezione == i._sezione)
|
if (_sezione == i._sezione)
|
||||||
_valore -= i._valore;
|
_valore -= i._valore;
|
||||||
else
|
else
|
||||||
|
198
cg/pagament.cpp
198
cg/pagament.cpp
@ -1,6 +1,10 @@
|
|||||||
#include "pagament.h"
|
|
||||||
#include <utility.h>
|
#include <utility.h>
|
||||||
|
|
||||||
|
#include "pagament.h"
|
||||||
|
|
||||||
|
#include <scadenze.h>
|
||||||
|
|
||||||
|
|
||||||
int TPagamento::_rata_ifield(int n, int f) const
|
int TPagamento::_rata_ifield(int n, int f) const
|
||||||
{
|
{
|
||||||
TToken_string& t = (TToken_string&)_rate[n];
|
TToken_string& t = (TToken_string&)_rate[n];
|
||||||
@ -905,14 +909,13 @@ void TPagamento::set_sheet(TSheet_field& sf, int sscad)
|
|||||||
// si istanzia uno sheet di primanota
|
// si istanzia uno sheet di primanota
|
||||||
for (int i = 0; i < n_rate(); i++)
|
for (int i = 0; i < n_rate(); i++)
|
||||||
{
|
{
|
||||||
TToken_string* ts = new TToken_string(36);
|
TToken_string& ts = sf.row(-1);
|
||||||
// istanzia, o stronzo
|
// istanzia, o stronzo
|
||||||
ts->add((const char*)data_rata(i));
|
ts.add((const char*)data_rata(i));
|
||||||
ts->add(perc_rata(i).string());
|
ts.add(perc_rata(i).string());
|
||||||
ts->add(tpay_rata(i).string());
|
ts.add(tpay_rata(i).string());
|
||||||
ts->add(tipo_rata(i));
|
ts.add(tipo_rata(i));
|
||||||
ts->add(desc_tipo(tipo_rata(i)));
|
ts.add(desc_tipo(tipo_rata(i)));
|
||||||
sf.row(-1) = (*ts);
|
|
||||||
if (ratapagata(i))
|
if (ratapagata(i))
|
||||||
{
|
{
|
||||||
sf.disable_cell(1,1); // percentuale
|
sf.disable_cell(1,1); // percentuale
|
||||||
@ -924,14 +927,13 @@ void TPagamento::set_sheet(TSheet_field& sf, int sscad)
|
|||||||
{
|
{
|
||||||
for (int i = 0, scr = 0; i < n_rate(); i++)
|
for (int i = 0, scr = 0; i < n_rate(); i++)
|
||||||
{
|
{
|
||||||
TToken_string* s = new TToken_string(32);
|
TToken_string& s = sf.row(-1);
|
||||||
scr += scad_rata(i);
|
scr += scad_rata(i);
|
||||||
s->add(format("%d",scr));
|
s.add(scr);
|
||||||
s->add(perc_rata(i).string());
|
s.add(perc_rata(i).string());
|
||||||
s->add(format("%d",tipo_rata(i)));
|
s.add(tipo_rata(i));
|
||||||
s->add(desc_tipo(tipo_rata(i)));
|
s.add(desc_tipo(tipo_rata(i)));
|
||||||
s->add(ulc_rata(i));
|
s.add(ulc_rata(i));
|
||||||
sf.row(-1) = *s;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // new: set with 1 or 2 rates according to tpr
|
else // new: set with 1 or 2 rates according to tpr
|
||||||
@ -944,14 +946,13 @@ void TPagamento::set_sheet(TSheet_field& sf, int sscad)
|
|||||||
|
|
||||||
for (int i = 0, scr = 0; i < n_rate(); i++)
|
for (int i = 0, scr = 0; i < n_rate(); i++)
|
||||||
{
|
{
|
||||||
TToken_string* s = new TToken_string(32);
|
TToken_string& s = sf.row(-1);
|
||||||
scr += scad_rata(i);
|
scr += scad_rata(i);
|
||||||
s->add(format("%d",scr));
|
s.add(format("%d",scr));
|
||||||
s->add(perc_rata(i).string());
|
s.add(perc_rata(i).string());
|
||||||
s->add(format("%d",tipo_rata(i)));
|
s.add(format("%d",tipo_rata(i)));
|
||||||
s->add(desc_tipo(tipo_rata(i)));
|
s.add(desc_tipo(tipo_rata(i)));
|
||||||
s->add(ulc_rata(i));
|
s.add(ulc_rata(i));
|
||||||
sf.row(-1) = *s;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_tpr > 0)
|
if (_tpr > 0)
|
||||||
@ -980,3 +981,156 @@ _spese(0.0), _code(codtab), _dirty(FALSE), _inited(FALSE)
|
|||||||
_new = TRUE;
|
_new = TRUE;
|
||||||
// if (_new && data != NULL) error_box("Modalita' pagamento inesistente");
|
// if (_new && data != NULL) error_box("Modalita' pagamento inesistente");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TPartita
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
TPartita::TPartita(int anno, const char* num)
|
||||||
|
: _scad(LF_SCADENZE, SCAD_NRATA), _part(LF_PARTITE, PART_NRIGA)
|
||||||
|
{
|
||||||
|
read(anno, num);
|
||||||
|
}
|
||||||
|
|
||||||
|
int TPartita::add_riga(const TRectype& r)
|
||||||
|
{
|
||||||
|
const char sez = r.get_char(PART_SEZ);
|
||||||
|
const real val = r.get_real(PART_IMPORTO);
|
||||||
|
const TImporto imp(sez, val);
|
||||||
|
|
||||||
|
TImporto grow(imp);
|
||||||
|
const int n = r.get_int(PART_NRIGA);
|
||||||
|
CHECK(n > 0, "Numero riga nullo");
|
||||||
|
if (n <= righe())
|
||||||
|
{
|
||||||
|
const TRectype& oldrow = riga(n);
|
||||||
|
const char osez = oldrow.get_char(PART_SEZ);
|
||||||
|
const real oval = oldrow.get_real(PART_IMPORTO);
|
||||||
|
const TImporto old(osez, oval);
|
||||||
|
grow -= old;
|
||||||
|
}
|
||||||
|
_totale += grow;
|
||||||
|
|
||||||
|
if (rate() > 0) // Se sono in aggiornamento (non nella read!)
|
||||||
|
{
|
||||||
|
const int nr = r.get_int(PART_NRATA);
|
||||||
|
TRectype scad = rata(nr);
|
||||||
|
real ip(scad.get(SCAD_IMPORTOPAG));
|
||||||
|
ip += grow.valore();
|
||||||
|
scad.put(SCAD_IMPORTOPAG, ip);
|
||||||
|
add_rata(scad);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _part.add_row(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
int TPartita::add_rata(const TRectype& r)
|
||||||
|
{
|
||||||
|
return _scad.add_row(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Costruisce le righe della partita a partire da 1
|
||||||
|
bool TPartita::read(int anno, const char* num)
|
||||||
|
{
|
||||||
|
TRectype partita(LF_PARTITE); partita.zero();
|
||||||
|
partita.put(PART_ANNO, anno); partita.put(PART_NUMPART, num);
|
||||||
|
_part.read(partita);
|
||||||
|
|
||||||
|
TRectype scadenza(LF_SCADENZE); scadenza.zero();
|
||||||
|
scadenza.put(SCAD_ANNO, anno); scadenza.put(SCAD_NUMPART, num);
|
||||||
|
_scad.read(scadenza);
|
||||||
|
|
||||||
|
_totale.set('D', ZERO); // Azzera totale partita
|
||||||
|
|
||||||
|
for (int i = 1; i <= righe(); i++)
|
||||||
|
{
|
||||||
|
const TRectype& r = riga(i);
|
||||||
|
const char sez = r.get_char(PART_SEZ);
|
||||||
|
const real val = r.get_real(PART_IMPORTO);
|
||||||
|
const TImporto imp(sez, val);
|
||||||
|
_totale += imp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TPartita::reread()
|
||||||
|
{
|
||||||
|
const int year = anno();
|
||||||
|
const TString16 num = numero();
|
||||||
|
return read(year, num);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TPartita::write(bool re)
|
||||||
|
{
|
||||||
|
const bool ok = _part.write(re) && _scad.write(re);
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TPartita::ultimo_pagamento(int rata) const
|
||||||
|
{
|
||||||
|
int ultimo = 1;
|
||||||
|
|
||||||
|
for (int p = 1; p <= righe(); p++)
|
||||||
|
{
|
||||||
|
const TRectype& paga = riga(p);
|
||||||
|
if (paga.get_int(PART_NRATA) == rata)
|
||||||
|
{
|
||||||
|
int u = paga.get_int(PART_NRIGA); // Non pretende che siano in ordine
|
||||||
|
if (u > ultimo) ultimo = u;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ultimo;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Controlla se la rata r e' stata completamente pagata
|
||||||
|
bool TPartita::rata_pagata(int r) const
|
||||||
|
{
|
||||||
|
const TRectype& scad = rata(r);
|
||||||
|
real importo(scad.get(SCAD_IMPORTO));
|
||||||
|
importo -= scad.get_real(SCAD_IMPORTOPAG);
|
||||||
|
const bool pagata = importo.is_zero();
|
||||||
|
return pagata;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TPartite_array
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// Certified 99%
|
||||||
|
const TString& TPartite_array::key(int anno, const char* num)
|
||||||
|
{
|
||||||
|
_key.format("%4d%s", anno, num);
|
||||||
|
return _key;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Certified 99%
|
||||||
|
void TPartite_array::add(TPartita* p)
|
||||||
|
{
|
||||||
|
const TString& k = key(p->anno(), p->numero());
|
||||||
|
TAssoc_array::add(k, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
TPartita* TPartite_array::partita(int anno, const char* num)
|
||||||
|
{
|
||||||
|
const TString& k = key(anno, num);
|
||||||
|
TPartita* p = (TPartita*)objptr(k);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TPartite_array::write(bool re)
|
||||||
|
{
|
||||||
|
int err = NOERR;
|
||||||
|
|
||||||
|
restart();
|
||||||
|
TPartita* p;
|
||||||
|
while ((p = (TPartita*)get()) != NULL)
|
||||||
|
{
|
||||||
|
err = p->write(re);
|
||||||
|
if (err != NOERR) // L'errore viene gia' segnalato dalla partita
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return err == NOERR;
|
||||||
|
}
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
#ifndef __PAGAMENT_H
|
#ifndef __PAGAMENT_H
|
||||||
#define __PAGAMENT_H
|
#define __PAGAMENT_H
|
||||||
|
|
||||||
|
#ifndef __ASSOC_H
|
||||||
|
#include <assoc.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __MSKSHEET_H
|
#ifndef __MSKSHEET_H
|
||||||
#include <msksheet.h>
|
#include <msksheet.h>
|
||||||
#endif
|
#endif
|
||||||
@ -9,6 +13,14 @@
|
|||||||
#include <tabutil.h>
|
#include <tabutil.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __RELATION_H
|
||||||
|
#include <relation.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __CONTO_H
|
||||||
|
#include "conto.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// Error codes for pagation
|
// Error codes for pagation
|
||||||
const word P_OK = 0x0000; // ok
|
const word P_OK = 0x0000; // ok
|
||||||
const word P_RSUM = 0x0001; // percentages do not sum up to 100
|
const word P_RSUM = 0x0001; // percentages do not sum up to 100
|
||||||
@ -136,4 +148,62 @@ public:
|
|||||||
virtual ~TPagamento() {}
|
virtual ~TPagamento() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef __PARTITE_H
|
||||||
|
#include <partite.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class TPartita : public TObject
|
||||||
|
{
|
||||||
|
TRecord_array _scad, _part;
|
||||||
|
TImporto _totale;
|
||||||
|
|
||||||
|
public: // TObject
|
||||||
|
virtual bool ok() const { return rate() > 0; }
|
||||||
|
|
||||||
|
public:
|
||||||
|
int add_riga(const TRectype& r);
|
||||||
|
const TRectype& riga(int r) const { return _part.row(r); }
|
||||||
|
int righe() const { return _part.rows(); }
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
bool reread();
|
||||||
|
bool read(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; }
|
||||||
|
|
||||||
|
TPartita(int anno, const char* num);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class TPartite_array : private TAssoc_array
|
||||||
|
{
|
||||||
|
TString16 _key;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
const TString& key(int anno, const char* num);
|
||||||
|
|
||||||
|
public: // TAssoc_array
|
||||||
|
virtual void destroy() { TAssoc_array::destroy(); }
|
||||||
|
|
||||||
|
public:
|
||||||
|
TPartita* partita(int anno, const char* numero);
|
||||||
|
|
||||||
|
void add(TPartita* p);
|
||||||
|
|
||||||
|
bool write(bool re = FALSE);
|
||||||
|
bool rewrite() { return write(TRUE); }
|
||||||
|
|
||||||
|
TPartite_array() {}
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user