Corretto conflitto su pagament e corrette maschere saldaconto
git-svn-id: svn://10.65.10.50/trunk@2004 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
c50d894972
commit
e77565deb7
56
cg/cg2.url
56
cg/cg2.url
@ -1,45 +1,11 @@
|
||||
#include <default.url>
|
||||
|
||||
MENU TASK_MENUBAR
|
||||
SUBMENU MENU_FILE "~File"
|
||||
|
||||
MENUBAR MENU_BAR(1)
|
||||
|
||||
MENU MENU_BAR(1)
|
||||
SUBMENU MENU_FILE "~File"
|
||||
|
||||
MENUBAR MENU_BAR(2)
|
||||
|
||||
MENU MENU_BAR(2)
|
||||
SUBMENU MENU_FILE "~File"
|
||||
|
||||
MENUBAR MENU_BAR(3)
|
||||
|
||||
MENU MENU_BAR(3)
|
||||
SUBMENU MENU_FILE "~File"
|
||||
|
||||
MENUBAR MENU_BAR(4)
|
||||
|
||||
MENU MENU_BAR(4)
|
||||
SUBMENU MENU_FILE "~File"
|
||||
|
||||
MENUBAR MENU_BAR(5)
|
||||
|
||||
MENU MENU_BAR(5)
|
||||
SUBMENU MENU_FILE "~File"
|
||||
|
||||
MENUBAR MENU_BAR(6)
|
||||
|
||||
MENU MENU_BAR(6)
|
||||
SUBMENU MENU_FILE "~File"
|
||||
|
||||
MENUBAR MENU_BAR(7)
|
||||
|
||||
MENU MENU_BAR(7)
|
||||
SUBMENU MENU_FILE "~File"
|
||||
|
||||
MENUBAR MENU_BAR(8)
|
||||
|
||||
MENU MENU_BAR(8)
|
||||
SUBMENU MENU_FILE "~File"
|
||||
|
||||
#include <default.url>
|
||||
|
||||
MENU TASK_MENUBAR
|
||||
SUBMENU MENU_FILE "~File"
|
||||
|
||||
MENUBAR MENU_BAR(1)
|
||||
|
||||
MENU MENU_BAR(1)
|
||||
SUBMENU MENU_FILE "~File"
|
||||
|
||||
|
||||
|
@ -17,20 +17,27 @@
|
||||
#include <rcausali.h>
|
||||
|
||||
TPrimanota_application::TPrimanota_application()
|
||||
: _rel(NULL), _lastreg(0), _mode(0), _iva(nessuna_iva), _causale(NULL), _giornale(NULL)
|
||||
: _rel(NULL), _mode(0), _iva(nessuna_iva), _causale(NULL), _giornale(NULL),
|
||||
_lastreg(0), _last_dreg(TODAY), _last_dcom(TODAY)
|
||||
{
|
||||
memset(_msk, 0, sizeof(_msk));
|
||||
}
|
||||
|
||||
|
||||
TMask* TPrimanota_application::load_mask(int n)
|
||||
{
|
||||
{
|
||||
if (n == 2 && _msk[0] != NULL)
|
||||
{
|
||||
delete _msk[0];
|
||||
_msk[0] = NULL;
|
||||
}
|
||||
|
||||
if (_msk[n] != NULL)
|
||||
return _msk[n];
|
||||
|
||||
if (n < 3)
|
||||
if (n == 1 || n == 2)
|
||||
{
|
||||
for (int i = 3; i >= 0; i--)
|
||||
for (int i = 3; i > 0; i--)
|
||||
{
|
||||
if (_msk[i] != NULL)
|
||||
{
|
||||
@ -97,8 +104,10 @@ TMask* TPrimanota_application::load_mask(int n)
|
||||
// add saldaconto
|
||||
TSheet_field& ps = (TSheet_field&)m->field(FS_RATESHEET);
|
||||
ps.set_notify(pag_notify);
|
||||
m->set_handler(FS_RATESHEET, pag_sheet_handler);
|
||||
m->set_handler(FS_RESET, reset_handler);
|
||||
m->set_handler(FS_NRATE, nrate_handler);
|
||||
m->set_handler(FS_RECALC, recalc_handler);
|
||||
m->set_handler(FS_NSCAB, codcab_handler);
|
||||
m->set_handler(FS_VSCAB, codcab_handler);
|
||||
}
|
||||
@ -138,26 +147,28 @@ TMask* TPrimanota_application::load_mask(int n)
|
||||
CHECKD(0, "Che ca$$o di maschera e' la ", n);
|
||||
break;
|
||||
}
|
||||
|
||||
return _msk[n] = m;
|
||||
|
||||
_msk[n] = m;
|
||||
return m;
|
||||
}
|
||||
|
||||
void TPrimanota_application::open_files(int logicnum, ...)
|
||||
{
|
||||
va_list marker;
|
||||
va_start(marker, logicnum);
|
||||
while (logicnum > 0)
|
||||
{
|
||||
CHECKD(_file.objptr(logicnum) == NULL, "File gia' aperto: ", logicnum);
|
||||
_file.add(new TLocalisamfile(logicnum), logicnum);
|
||||
logicnum = va_arg(marker, int);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
_pagamenti = new TLocalisamfile(LF_PAGSCA);
|
||||
open_files(LF_TABCOM, LF_TAB, LF_CAUSALI, LF_RCAUSALI, LF_CLIFO, LF_PCON, 0);
|
||||
open_files(LF_ATTIV, LF_SALDI, LF_COMUNI, LF_OCCAS, LF_NDITTE, 0);
|
||||
open_files(LF_SCADENZE, LF_PAGSCA, 0);
|
||||
|
||||
_rel = new TMovimentoPN;
|
||||
_rel->add(LF_PARTITE, "NREG=NUMREG", 2); // Collega la partita aperta dalla fattura
|
||||
@ -191,20 +202,8 @@ bool TPrimanota_application::user_destroy()
|
||||
delete _giornale;
|
||||
delete _causale;
|
||||
delete _rel;
|
||||
|
||||
delete _scadenze;
|
||||
delete _nditte;
|
||||
delete _occas;
|
||||
delete _comuni;
|
||||
delete _saldo;
|
||||
delete _attiv;
|
||||
delete _pcon;
|
||||
delete _clifo;
|
||||
delete _rcaus;
|
||||
delete _caus;
|
||||
delete _tab;
|
||||
delete _tabcom;
|
||||
|
||||
close_files();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -452,6 +451,18 @@ void TPrimanota_application::init_mask(TMask& m)
|
||||
m.show(-4, valintra);
|
||||
|
||||
m.show(F_CODIVA, m.mode() == MODE_INS); // Codice IVA standard
|
||||
|
||||
const TPartita* game = partite().first();
|
||||
const bool scad_free = game == NULL || !game->esistono_abbuoni_diffcam(m.get_long(F_NUMREG));
|
||||
|
||||
m.enable(DLG_DELREC, scad_free); // Disabilita tasto cancella
|
||||
m.enable(-1, scad_free); // Disabilita cliente
|
||||
m.enable(-2, scad_free);
|
||||
|
||||
m.enable(F_CODPAG, scad_free); // Disabilita codice pagamento
|
||||
m.enable(FS_RESET, scad_free); // Disabilita tasto di reset
|
||||
if (!scad_free) m.set(FS_RECALC, "", TRUE);
|
||||
m.enable(FS_RECALC, scad_free); // Disabilita ricalcolo automatico
|
||||
}
|
||||
|
||||
// Show/Hide campi valuta: F_VALUTA, F_CAMBIO, F_DATACAMBIO (GROUP 3)
|
||||
@ -463,10 +474,8 @@ void TPrimanota_application::init_query_mode(TMask& m)
|
||||
{
|
||||
enable_menu_item(M_FILE_PRINT);
|
||||
|
||||
const TDate inco(TODAY);
|
||||
const char* oggi = inco.string();
|
||||
m.set(F_DATAREG, oggi);
|
||||
m.set(F_DATACOMP, oggi);
|
||||
m.set(F_DATAREG, _last_dreg);
|
||||
m.set(F_DATACOMP, _last_dcom);
|
||||
}
|
||||
|
||||
|
||||
@ -483,7 +492,7 @@ void TPrimanota_application::fill_sheet(TMask& m) const
|
||||
TSheet_field& ivas = (TSheet_field&)m.field(F_SHEETIVA);
|
||||
for (int r = ivas.items(); r < 16; r++) ivas.row(r);
|
||||
ivas.enable_column(2, _iva == iva_acquisti); // Tipo detrazione
|
||||
ivas.enable_column(4, !m.insert_mode()); // Tipo costo ricavo
|
||||
ivas.enable_column(4, !m.insert_mode()); // Tipo costo ricavo
|
||||
}
|
||||
}
|
||||
|
||||
@ -552,11 +561,6 @@ void TPrimanota_application::init_modify_mode(TMask& m)
|
||||
{
|
||||
const long numreg = m.get_long(F_NUMREG);
|
||||
partite().add_numreg(numreg);
|
||||
if (iva() != nessuna_iva)
|
||||
{
|
||||
const TPartita* game = partite().first();
|
||||
m.enable(DLG_DELREC, game == NULL || !game->esistono_abbuoni_diffcam());
|
||||
}
|
||||
}
|
||||
|
||||
calcola_saldo(); // Verifica eventuali sbilanci contabili
|
||||
@ -671,8 +675,9 @@ int TPrimanota_application::read(TMask& m)
|
||||
const int tm = causale().tipomov();
|
||||
if (tm != 0 && tm != 2) // Ci sono scadenze
|
||||
{
|
||||
const TString16 cp(m.get(F_CODPAG));
|
||||
const TString16 dt(m.get(F_DATAREG));
|
||||
set_pagamento(m.get(F_CODPAG), dt);
|
||||
set_pagamento(cp, dt);
|
||||
if (!read_scadenze(m))
|
||||
set_scadenze(m);
|
||||
}
|
||||
@ -846,6 +851,9 @@ int TPrimanota_application::write(const TMask& m)
|
||||
if (lasterr == NOERR)
|
||||
mask2rel(m); // Altrimenti raddoppia i saldi!
|
||||
|
||||
_last_dreg = m.get(F_DATAREG);
|
||||
_last_dcom = m.get(F_DATACOMP);
|
||||
|
||||
const int err = _rel->write(TRUE);
|
||||
if (err == NOERR)
|
||||
{
|
||||
|
@ -49,7 +49,6 @@ DATE F_DATAREG
|
||||
BEGIN
|
||||
PROMPT 1 6 "Data operazione "
|
||||
CHECKTYPE REQUIRED
|
||||
FLAGS "A"
|
||||
HELP "Data in cui viene registrata l'operazione"
|
||||
MESSAGE COPY,F_ANNOIVA,7,10
|
||||
END
|
||||
@ -65,7 +64,6 @@ BEGIN
|
||||
PROMPT 1 7 "Data di competenza "
|
||||
HELP "Data di competenza dell'operazione"
|
||||
CHECKTYPE REQUIRED
|
||||
FLAGS "A"
|
||||
END
|
||||
|
||||
NUMBER F_ANNOES 4
|
||||
|
@ -106,7 +106,6 @@ BEGIN
|
||||
FIELD PROVVIS
|
||||
ITEM " |No (movimento normale)"
|
||||
ITEM "P|Si (cancellabile)"
|
||||
MESSAGE COPY,K_PROVVISORIO
|
||||
END
|
||||
|
||||
STRING F_TIPODOC 2
|
||||
|
109
cg/cg2100n.uml
Executable file
109
cg/cg2100n.uml
Executable file
@ -0,0 +1,109 @@
|
||||
#include "cg2100p.h"
|
||||
|
||||
PAGE "Nuova partita" -1 -1 48 10
|
||||
|
||||
RADIOBUTTON P_NUOVO 1 21
|
||||
BEGIN
|
||||
PROMPT 0 0 "@BTipo movimento"
|
||||
ITEM "1|Fattura"
|
||||
MESSAGE ENABLE,P_CODPAG
|
||||
ITEM "2|Nota credito"
|
||||
MESSAGE DISABLE,P_CODPAG
|
||||
ITEM "3|Incasso/pagamento "
|
||||
MESSAGE DISABLE,P_CODPAG
|
||||
ITEM "5|Insoluto"
|
||||
MESSAGE DISABLE,P_CODPAG
|
||||
ITEM "6|Pagamento insoluto"
|
||||
MESSAGE DISABLE,P_CODPAG
|
||||
GROUP 1
|
||||
END
|
||||
|
||||
NUMBER P_ANNO 4
|
||||
BEGIN
|
||||
PROMPT 22 1 "Partita "
|
||||
FLAGS "A"
|
||||
CHECKTYPE REQUIRED
|
||||
WARNING "Inserire l'anno di riferimento partita"
|
||||
END
|
||||
|
||||
STRING P_NUMERO 7
|
||||
BEGIN
|
||||
PROMPT 40 1 ""
|
||||
FLAGS "U"
|
||||
CHECKTYPE REQUIRED
|
||||
WARNING "Inserire il numero di riferimento partita"
|
||||
END
|
||||
|
||||
TEXT DLG_NULL
|
||||
BEGIN
|
||||
PROMPT 22 2 "Sezione"
|
||||
END
|
||||
|
||||
RADIOBUTTON P_SEZIONE 1 20
|
||||
BEGIN
|
||||
PROMPT 31 1 ""
|
||||
ITEM "D|Dare"
|
||||
ITEM "A|Avere"
|
||||
FLAGS "Z"
|
||||
GROUP 1
|
||||
END
|
||||
|
||||
NUMBER P_RESIDUO 15
|
||||
BEGIN
|
||||
PROMPT 22 3 "Importo "
|
||||
PICTURE "."
|
||||
GROUP 1
|
||||
END
|
||||
|
||||
STRING P_CODPAG 4
|
||||
BEGIN
|
||||
PROMPT 22 4 "Pagamento "
|
||||
FLAGS "UZ"
|
||||
USE %CPG
|
||||
INPUT CODTAB P_CODPAG
|
||||
DISPLAY "Codice" CODTAB
|
||||
DISPLAY "Descrizione@50" S0
|
||||
OUTPUT P_CODPAG CODTAB
|
||||
CHECKTYPE REQUIRED
|
||||
ADD RUN ba3 -6
|
||||
GROUP 1
|
||||
WARNING "Codice pagamento assente"
|
||||
END
|
||||
|
||||
STRING P_NUMDOC 7
|
||||
BEGIN
|
||||
PROMPT 22 5 "Documento "
|
||||
FLAGS "U"
|
||||
GROUP 1
|
||||
END
|
||||
|
||||
DATE P_DATADOC
|
||||
BEGIN
|
||||
PROMPT 22 6 "Data "
|
||||
FLAGS "A"
|
||||
CHECKTYPE REQUIRED
|
||||
WARNING "Inserire una data per il movimento extra-contabile"
|
||||
GROUP 1
|
||||
END
|
||||
|
||||
STRING P_DESCR 50 34
|
||||
BEGIN
|
||||
PROMPT 1 7 "Descrizione "
|
||||
WARNING "Inserire una descrizione per il movimento extra-contabile"
|
||||
CHECKTYPE REQUIRED
|
||||
GROUP 1
|
||||
END
|
||||
|
||||
BUTTON DLG_OK 10 2
|
||||
BEGIN
|
||||
PROMPT -12 -1 ""
|
||||
END
|
||||
|
||||
BUTTON DLG_CANCEL 10 2
|
||||
BEGIN
|
||||
PROMPT -22 -1 ""
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
@ -9,12 +9,19 @@
|
||||
#define P_VALUTA 109
|
||||
#define P_DATACAMBIO 110
|
||||
#define P_CAMBIO 111
|
||||
|
||||
#define P_SHOWALL 180
|
||||
#define P_SCAMBIO 181
|
||||
#define P_NUOVO 182
|
||||
#define P_PARTITE 201
|
||||
#define P_SCADENZE 202
|
||||
|
||||
// Campi aggiuntivi per extra-contabile
|
||||
#define P_DATADOC 112
|
||||
#define P_SEZIONE 113
|
||||
#define P_CODPAG 114
|
||||
#define P_NUMDOC 115
|
||||
|
||||
|
||||
// Scadenze
|
||||
|
||||
#define S_ANNO 101
|
||||
|
@ -209,12 +209,12 @@ ENDMASK
|
||||
|
||||
PAGE "Sheet Scadenze" -1 -1 68 10
|
||||
|
||||
STRING 101 4
|
||||
NUMBER 101 4
|
||||
BEGIN
|
||||
PROMPT 1 1 "Numero riga "
|
||||
END
|
||||
|
||||
STRING 102 4
|
||||
NUMBER 102 4
|
||||
BEGIN
|
||||
PROMPT 41 1 "Numero rata "
|
||||
END
|
||||
|
@ -260,6 +260,7 @@ BEGIN
|
||||
DISPLAY "Descrizione@50" S0
|
||||
OUTPUT S_CODDESC CODTAB
|
||||
OUTPUT S_DESCAGG S0
|
||||
CHECKTYPE NORMAL
|
||||
END
|
||||
|
||||
STRING S_DESCAGG 50
|
||||
|
@ -888,7 +888,7 @@ bool TPrimanota_application::imponibile_handler(TMask_field& f, KEY key)
|
||||
const real imponibile(f.get());
|
||||
real imposta = abs(imponibile) * percent / 100.0; imposta.ceil();
|
||||
if (imponibile.sign() < 0) imposta = -imposta;
|
||||
m.set(104, imposta.string());
|
||||
m.set(104, imposta);
|
||||
}
|
||||
}
|
||||
|
||||
@ -947,7 +947,7 @@ bool TPrimanota_application::detrazione_handler(TMask_field& f, KEY key)
|
||||
|
||||
bool TPrimanota_application::imposta_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
if (key == K_ENTER || key == K_TAB)
|
||||
if ((key == K_ENTER || key == K_TAB) && f.dirty())
|
||||
{
|
||||
const real imponibile(f.mask().get(101));
|
||||
const real& percent = app().causale().corrispettivi() ? ZERO : cod2IVA(f.mask());
|
||||
|
30
cg/cg2102.h
30
cg/cg2102.h
@ -26,23 +26,11 @@
|
||||
#endif
|
||||
|
||||
class TPrimanota_application : public TRelation_application
|
||||
{
|
||||
TMovimentoPN* _rel;
|
||||
TLocalisamfile* _tabcom;
|
||||
TLocalisamfile* _tab;
|
||||
TLocalisamfile* _caus;
|
||||
TLocalisamfile* _rcaus;
|
||||
TLocalisamfile* _clifo;
|
||||
TLocalisamfile* _pcon;
|
||||
TLocalisamfile* _attiv;
|
||||
TLocalisamfile* _saldo;
|
||||
TLocalisamfile* _comuni;
|
||||
TLocalisamfile* _occas;
|
||||
TLocalisamfile* _nditte;
|
||||
TLocalisamfile* _scadenze;
|
||||
TLocalisamfile* _pagamenti;
|
||||
{
|
||||
TArray _file; // Tutti i fiels da usare
|
||||
TMovimentoPN* _rel; // Relazione principale
|
||||
|
||||
TPagamento* _pag;
|
||||
TPagamento* _pag;
|
||||
|
||||
TCausale* _causale; // Causale corrente
|
||||
TLibro_giornale* _giornale; // Libro giornale corrente
|
||||
@ -68,6 +56,9 @@ class TPrimanota_application : public TRelation_application
|
||||
long _lastreg; // Numero ultima registrazione
|
||||
int _mode; // Modo maschera corrente
|
||||
|
||||
TDate _last_dreg; // Ultima data registrazione inserita
|
||||
TDate _last_dcom; // Ultima data competenza inserita
|
||||
|
||||
TBill _conto_ricavo; // Conto di ricavo del clifo
|
||||
|
||||
TString_array _pag_rows;
|
||||
@ -114,14 +105,17 @@ class TPrimanota_application : public TRelation_application
|
||||
static bool cambio_handler(TMask_field& f, KEY key);
|
||||
static bool reset_handler(TMask_field& f, KEY key);
|
||||
static bool nrate_handler(TMask_field& f, KEY key);
|
||||
static bool recalc_handler(TMask_field& f, KEY key);
|
||||
static bool codcab_handler(TMask_field& f, 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(TSheet_field& s, int r, KEY key);
|
||||
static bool cg_handler(TMask_field& f, KEY key);
|
||||
static bool pag_notify(TSheet_field& s, int r, KEY key);
|
||||
|
||||
static bool pag_notify(TSheet_field& s, int r, KEY key);
|
||||
static bool pag_sheet_handler(TMask_field& f, KEY key);
|
||||
|
||||
void reset_sheet_row(TSheet_field& s, int n);
|
||||
|
||||
protected: // TApplication
|
||||
@ -152,6 +146,8 @@ protected:
|
||||
|
||||
TMask* load_mask(int n);
|
||||
TMask& occas_mask() { return *load_mask(3); }
|
||||
void open_files(int logicnum, ...);
|
||||
void close_files() { _file.destroy(); }
|
||||
|
||||
void mask2rel(const TMask& m);
|
||||
|
||||
|
132
cg/cg2104.cpp
132
cg/cg2104.cpp
@ -17,15 +17,14 @@
|
||||
#include <scadenze.h>
|
||||
#include <pagsca.h>
|
||||
|
||||
bool TPrimanota_application::pag_notify(TSheet_field&, int r, KEY k)
|
||||
bool TPrimanota_application::pag_notify(TSheet_field& ps, int r, KEY k)
|
||||
{
|
||||
TPagamento* pg = app().pagamento();
|
||||
if (pg == NULL)
|
||||
return TRUE;
|
||||
|
||||
TPagamento& pag = *pg;
|
||||
TSheet_field& ps = app().pags();
|
||||
TMask* msk = &(app().curr_mask());
|
||||
TMask* msk = &(ps.mask());
|
||||
TString_array& rws = app().pag_rows();
|
||||
|
||||
const int rdiff = atoi(msk->get(FS_RDIFFER));
|
||||
@ -105,34 +104,30 @@ bool TPrimanota_application::pag_notify(TSheet_field&, int r, KEY k)
|
||||
// put data as they are
|
||||
TToken_string& trw = pag.rata(r);
|
||||
TToken_string srw = trw;
|
||||
if (m_perc) trw.add(newp,1);
|
||||
if (m_tipo) trw.add(newt,2);
|
||||
if (m_scad) trw.add(news,3);
|
||||
if (m_imp) trw.add(newi,4);
|
||||
// validate the payment
|
||||
if ((ahiahi = pag.validate()) != P_OK)
|
||||
pag.rata(r) = srw;
|
||||
if (m_imp)
|
||||
{
|
||||
trw.add(newi,4);
|
||||
const real p = pag.recalc_percrata(r);
|
||||
ps.row(r).add(p.string(), 3);
|
||||
rws.row(r) = ps.row(r);
|
||||
ps.force_update(r);
|
||||
}
|
||||
}
|
||||
if (ahiahi) // any error? Rimetti le righe com'erano prima
|
||||
{
|
||||
beep();
|
||||
|
||||
// se gli errori sono voluti, spiegali
|
||||
if (!recalc)
|
||||
{
|
||||
TString256 s;
|
||||
pag.strerr(ahiahi,s);
|
||||
warning_box(s);
|
||||
}
|
||||
|
||||
ps.row(r) = rws.row(r);
|
||||
ps.force_update(r);
|
||||
{
|
||||
if (recalc)
|
||||
{
|
||||
beep();
|
||||
ps.row(r) = rws.row(r);
|
||||
ps.force_update(r);
|
||||
}
|
||||
}
|
||||
else if (recalc && mod && need_recalc)
|
||||
{
|
||||
// ridefinisci lo sheet sulla base delle nuove rate
|
||||
pag.set_sheet(ps);
|
||||
ps.force_update();
|
||||
rws = ps.rows_array();
|
||||
}
|
||||
}
|
||||
@ -140,6 +135,28 @@ bool TPrimanota_application::pag_notify(TSheet_field&, int r, KEY k)
|
||||
return doit;
|
||||
}
|
||||
|
||||
bool TPrimanota_application::pag_sheet_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
bool ok = TRUE;
|
||||
if (key == K_TAB || key == K_ENTER)
|
||||
{
|
||||
TPagamento* pag = app().pagamento();
|
||||
if (pag != NULL)
|
||||
{
|
||||
const word err = pag->validate();
|
||||
if (err != P_OK)
|
||||
{
|
||||
TString256 s;
|
||||
pag->strerr(err, s);
|
||||
error_box(s);
|
||||
ok = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
bool TPrimanota_application::codpag_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
TMask& m = f.mask();
|
||||
@ -183,6 +200,19 @@ bool TPrimanota_application::reset_handler(TMask_field& f, KEY key)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TPrimanota_application::recalc_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
if (key == K_SPACE)
|
||||
{
|
||||
const bool on = f.get().not_empty();
|
||||
const TMask& m = f.mask();
|
||||
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
|
||||
ps.enable_column(3, on);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TPrimanota_application::nrate_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
const TMask& m = f.mask();
|
||||
@ -262,15 +292,16 @@ void TPrimanota_application::set_scadenze(TMask& m)
|
||||
|
||||
pag.set_total(imponibile, imposta, spese);
|
||||
pag.set_rate_auto();
|
||||
|
||||
m.set(FS_RDIFFER, pag.rate_differenziate() ? "1" : "2");
|
||||
m.set(FS_NAMEPAG, pag.name());
|
||||
m.set(FS_TIPOPR, pag.desc_tpr());
|
||||
m.set(FS_MCOMM, pag.mese_commerciale() ? "X" : "");
|
||||
m.set(FS_RECALC, "X", TRUE);
|
||||
m.set(FS_NRATE, pag.n_rate());
|
||||
|
||||
bool new_part = TRUE;
|
||||
|
||||
if (m.field(FS_RECALC).enabled())
|
||||
{
|
||||
m.set(FS_RDIFFER, pag.rate_differenziate() ? "1" : "2");
|
||||
m.set(FS_NAMEPAG, pag.name());
|
||||
m.set(FS_TIPOPR, pag.desc_tpr());
|
||||
m.set(FS_MCOMM, pag.mese_commerciale() ? "X" : "");
|
||||
m.set(FS_RECALC, "X", TRUE);
|
||||
m.set(FS_NRATE, pag.n_rate());
|
||||
}
|
||||
|
||||
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
|
||||
pag.set_sheet(ps); // prepara lo sheet
|
||||
@ -325,13 +356,11 @@ bool TPrimanota_application::read_scadenze(TMask& m)
|
||||
|
||||
int npart = part.prima_fattura(nreg);
|
||||
bool fromscratch = FALSE;
|
||||
bool scad_locked = FALSE;
|
||||
|
||||
if (npart > 0) // la gh'e'
|
||||
{
|
||||
const TRiga_partite& partita = part.riga(npart);
|
||||
const TRiga_scadenze& primarata = partita.rata(1);
|
||||
scad_locked = partita.ultima_ratapagata() > 0;
|
||||
|
||||
// se si e' specificato un codice pagamento diverso si rifa' da capo
|
||||
// la follia e' che e' sulle SCADENZE, non sulle partite, naturalmente
|
||||
@ -352,7 +381,7 @@ bool TPrimanota_application::read_scadenze(TMask& m)
|
||||
" all'ultima registrazione. Si desidera mantenere"
|
||||
" comunque la rateazione precedente");
|
||||
// nel qual caso, of course, si disabilitano gli automatismi
|
||||
if(!fromscratch) m.field(FS_RECALC).set("");
|
||||
if(!fromscratch) m.set(FS_RECALC, "", TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -410,17 +439,6 @@ bool TPrimanota_application::read_scadenze(TMask& m)
|
||||
// se la prima rata e' fissa non si tocca
|
||||
if (pag.tipo_prima_rata() > 3)
|
||||
ps.disable_cell(0,-1);
|
||||
|
||||
if (scad_locked)
|
||||
{
|
||||
m.disable(-1); // Disabilita cliente
|
||||
m.disable(-2); // Disabilita fornitore
|
||||
m.disable(-3); // Disabilita cambio
|
||||
m.disable(F_CODPAG); // Disabilita codice pagamento
|
||||
m.disable(FS_RESET); // Disabilita tasto di reset
|
||||
m.set(FS_RECALC, "", TRUE); // Disabilita ricalcolo automatico
|
||||
m.disable(FS_RECALC);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -450,7 +468,7 @@ void TPrimanota_application::write_scadenze(const TMask& m)
|
||||
const real cambio (m.get(S_CAMBIO));
|
||||
const TString16 agente (m.get(FS_AGENTE));
|
||||
const char sezione = get_cgs_imp(0).sezione(); // Dare/Avere
|
||||
|
||||
|
||||
const TBill clifo(cgs().row(0), 2, 0x3);
|
||||
newgame = new TPartita(clifo, anno, numpart);
|
||||
|
||||
@ -571,12 +589,12 @@ bool TPrimanota_application::showpartite_handler(TMask_field& f, KEY k)
|
||||
if (k == K_SPACE)
|
||||
{
|
||||
const bool ok = app().edit_partite(m, riga);
|
||||
if (ok)
|
||||
if (ok && riga < s.items())
|
||||
k = K_ENTER;
|
||||
}
|
||||
|
||||
if (k == K_ENTER)
|
||||
{
|
||||
{
|
||||
const long curreg = app().curr_mask().get_long(F_NUMREG);
|
||||
const TImporto importo(app().get_cgs_imp(riga));
|
||||
const TImporto speso(app().partite().importo_speso(curreg, riga+1));
|
||||
@ -666,7 +684,7 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa
|
||||
TImporto old_abbuono, new_abbuono, old_diffcam, new_diffcam;
|
||||
const bool empty = p.modifica_pagamento(new_pag, valuta,
|
||||
old_ap, old_abbuono, old_diffcam,
|
||||
new_ap, new_abbuono, new_diffcam);
|
||||
new_ap, new_abbuono, new_diffcam, TRUE);
|
||||
|
||||
if (deleting >= 0)
|
||||
{
|
||||
@ -677,19 +695,23 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa
|
||||
{
|
||||
const int riga_abb = type2pos(old_ap);
|
||||
CHECK(riga_abb >= 0, "Chiss'e' fregato gli abbuoni?");
|
||||
const bool empty = sub_cgs_imp(riga_abb, old_abbuono);
|
||||
const bool empty = add_cgs_imp(riga_abb, old_abbuono);
|
||||
if (empty && new_ap != old_ap)
|
||||
reset_cgs_row(riga_abb);
|
||||
cgs().destroy(riga_abb);
|
||||
|
||||
if (deleting != riga_contabile)
|
||||
{
|
||||
// Sottrae l'abbuono con la sezione invertita dalla riga contabile
|
||||
add_cgs_imp(riga_contabile-1, old_abbuono);
|
||||
sub_cgs_imp(riga_contabile-1, old_abbuono);
|
||||
}
|
||||
}
|
||||
if (new_ap != ' ') // Se ci sono abbuoni
|
||||
{
|
||||
const riga_abb = type2pos(new_ap);
|
||||
|
||||
new_abbuono.swap_section();
|
||||
new_abbuono.normalize();
|
||||
|
||||
if (riga_abb < 0)
|
||||
{
|
||||
const int rc = new_ap == 'A' ? 9 : 8;
|
||||
@ -712,8 +734,8 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa
|
||||
if (old_diffcam != new_diffcam)
|
||||
{
|
||||
const int riga_diffcam = type2pos('C');
|
||||
TImporto grow_diffcam(new_diffcam);
|
||||
grow_diffcam -= old_diffcam;
|
||||
TImporto grow_diffcam(old_diffcam);
|
||||
grow_diffcam -= new_diffcam;
|
||||
grow_diffcam.normalize();
|
||||
|
||||
if (riga_diffcam < 0)
|
||||
@ -725,7 +747,7 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa
|
||||
else
|
||||
{
|
||||
const bool empty = add_cgs_imp(riga_diffcam, grow_diffcam);
|
||||
if (empty) reset_cgs_row(riga_diffcam);
|
||||
if (empty) cgs().destroy(riga_diffcam);
|
||||
}
|
||||
|
||||
if (deleting != riga_contabile)
|
||||
|
459
cg/cg2105.cpp
459
cg/cg2105.cpp
@ -1,8 +1,9 @@
|
||||
#include <execp.h>
|
||||
#include <mailbox.h>
|
||||
|
||||
#include <defmask.h> // Serve per DLG_NEWREC
|
||||
|
||||
#ifdef __EXTRA__
|
||||
|
||||
#else
|
||||
#ifndef __EXTRA__
|
||||
|
||||
#include "cg2102.h" // Applicazione di prima nota
|
||||
#include "cg2100.h" // Campi maschere prima nota
|
||||
@ -140,13 +141,13 @@ bool TPay_mask::importo_handler(TMask_field& f, KEY k)
|
||||
const real i(f.get());
|
||||
if (i >= m._da_pagare && m.field(S_SALDOACC).active())
|
||||
m.set(S_SALDOACC, "S");
|
||||
|
||||
|
||||
const real residuo(m._da_pagare - i);
|
||||
m.set(S_RESIDUORATA, residuo.string());
|
||||
|
||||
const real residuopag(m._pagabile - i);
|
||||
m.set(S_RESIDUOPAG, residuopag.string());
|
||||
|
||||
|
||||
if (f.dlg() == S_IMPORTOVAL)
|
||||
{
|
||||
const real lit = m.valuta().val2lit(i);
|
||||
@ -168,17 +169,24 @@ class TGame_mask : public TMask
|
||||
int _numrig; // Riga contabile corrente (prima = 1!)
|
||||
TImporto _importo; // Importo riga contabile
|
||||
int _riga_partite; // Riga corrente delle partite
|
||||
bool _changed;
|
||||
|
||||
int _tipomov; // Dati per la creazione di un nuovo movimento
|
||||
char _sezione;
|
||||
TDate _datadoc;
|
||||
TString _codpag, _descr, _numdoc;
|
||||
|
||||
protected:
|
||||
static bool annopart_handler(TMask_field& f, KEY k);
|
||||
static bool numpart_handler(TMask_field& f, KEY k);
|
||||
static bool partite_notify(TSheet_field& partite, int r, KEY k);
|
||||
static bool scadenze_notify(TSheet_field& partite, int r, KEY k);
|
||||
static bool show_all_handler(TMask_field& f, KEY k);
|
||||
static bool edit_scadenza_handler(TMask_field& f, KEY k);
|
||||
static bool nuovo_handler(TMask_field& f, KEY k);
|
||||
static bool cambio_handler(TMask_field& f, KEY k);
|
||||
|
||||
static void add_importo(TToken_string& s, const TImporto& i, int dec = 0);
|
||||
static void add_importo(TToken_string& s, const TImporto& i, bool val = FALSE, int pos = -1);
|
||||
TImporto get_importo(TToken_string& s, int pos) const;
|
||||
|
||||
void fill_partite(int anno = 0, const char* numero = "");
|
||||
@ -186,23 +194,31 @@ protected:
|
||||
|
||||
int update_partita(const TPartita& game, int prow);
|
||||
void update_saldo_clifo();
|
||||
int nuova_riga(TPartita& partita) const;
|
||||
int nuovo_pagamento(TPartita& partita, int nriga, int rata) const;
|
||||
bool edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) const;
|
||||
#ifdef __EXTRA__
|
||||
bool edit_fattura(TPartita& p, int nriga);
|
||||
#endif
|
||||
|
||||
bool cerca_valuta(TValuta& val) const;
|
||||
void aggiorna_valuta(const TValuta& val);
|
||||
|
||||
|
||||
public:
|
||||
TSheet_field& partite() const { return (TSheet_field&)field(P_PARTITE); }
|
||||
TSheet_field& scadenze() const { return (TSheet_field&)field(P_SCADENZE); }
|
||||
const TBill& conto() const { return _conto; }
|
||||
|
||||
bool changed() const { return _changed; }
|
||||
|
||||
TGame_mask(const TBill& bill, long numreg, int riga);
|
||||
virtual ~TGame_mask() {}
|
||||
};
|
||||
|
||||
TGame_mask::TGame_mask(const TBill& bill, long numreg, int riga)
|
||||
: TMask("cg2100p"), _conto(bill), _numreg(numreg), _numrig(riga)
|
||||
: TMask("cg2100p"), _conto(bill), _numreg(numreg), _numrig(riga),
|
||||
_changed(FALSE)
|
||||
|
||||
{
|
||||
const char tipocf[2] = { _conto.tipo(), '\0' };
|
||||
set(P_TIPOC, tipocf);
|
||||
@ -227,6 +243,7 @@ TGame_mask::TGame_mask(const TBill& bill, long numreg, int riga)
|
||||
set_handler(P_CAMBIO, cambio_handler);
|
||||
|
||||
partite().set_notify(partite_notify);
|
||||
scadenze().set_notify(scadenze_notify);
|
||||
scadenze().sheet_mask().set_handler(100, edit_scadenza_handler);
|
||||
}
|
||||
|
||||
@ -302,7 +319,7 @@ bool TGame_mask::cambio_handler(TMask_field& f, KEY k)
|
||||
|
||||
real TGame_mask::aggiorna_residuo()
|
||||
{
|
||||
#ifdef EXTRA
|
||||
#ifdef __EXTRA__
|
||||
return ZERO;
|
||||
#else
|
||||
_importo = app().get_cgs_imp(_numrig-1);
|
||||
@ -361,7 +378,7 @@ void TGame_mask::aggiorna_valuta(const TValuta& val)
|
||||
val.val2lit(imp);
|
||||
pag.put(PAGSCA_IMPORTO, imp); // Converte in lire l'importo in valuta
|
||||
#ifdef __EXTRA__
|
||||
game->modifica_pagamento(pag, val);
|
||||
game->modifica_pagamento(pag);
|
||||
#else
|
||||
app().notify_edit_pagamento(*game, pag, val);
|
||||
#endif
|
||||
@ -371,13 +388,10 @@ void TGame_mask::aggiorna_valuta(const TValuta& val)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __EXTRA__
|
||||
if (annorif != 0)
|
||||
{
|
||||
#ifdef __EXTRA__
|
||||
const bool proponi = RUE;
|
||||
#else
|
||||
const bool proponi = app().causale().tipomov() == 2;
|
||||
#endif
|
||||
if (proponi)
|
||||
{
|
||||
const TMask& cm = app().curr_mask();
|
||||
@ -389,14 +403,16 @@ void TGame_mask::aggiorna_valuta(const TValuta& val)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
fill_partite(annorif, numrif);
|
||||
}
|
||||
|
||||
bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
{
|
||||
TGame_mask& gm = (TGame_mask&)partite.mask();
|
||||
|
||||
if (k == K_TAB)
|
||||
{
|
||||
TGame_mask& gm = (TGame_mask&)partite.mask();
|
||||
gm._riga_partite = r;
|
||||
|
||||
TString_array& scadenze = gm.scadenze().rows_array();
|
||||
@ -415,32 +431,43 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
game = new TPartita(zio, anno, num); // ... creane una temporanea
|
||||
|
||||
TImporto tot_lit, tot_val;
|
||||
|
||||
TToken_string riga_fattura;
|
||||
|
||||
const int lastrow = game->last();
|
||||
for (int ri = game->first(); ri <= lastrow; ri = game->succ(ri))
|
||||
{
|
||||
const TRiga_partite& riga = game->riga(ri);
|
||||
const bool in_valuta = riga.in_valuta();
|
||||
|
||||
|
||||
if (riga.rate() != 0)
|
||||
{
|
||||
riga_fattura.add(ri);
|
||||
riga_fattura.add("");
|
||||
riga_fattura.add("");
|
||||
riga_fattura.add(riga.get(PART_DATADOC));
|
||||
riga_fattura.add(riga.get(PART_DESCR));
|
||||
add_importo(riga_fattura, TImporto(riga.sezione(), riga.get_real(SCAD_IMPORTO)));
|
||||
if (in_valuta)
|
||||
add_importo(riga_fattura, TImporto(riga.sezione(), riga.get_real(SCAD_IMPORTOVAL)), TRUE);
|
||||
else
|
||||
riga_fattura.add("");
|
||||
riga_fattura.add(riga.get(PART_NREG));
|
||||
riga_fattura.add(riga.get(PART_DATAREG));
|
||||
riga_fattura.add(riga.get(PART_NUMDOC));
|
||||
riga_fattura.add(riga.get(PART_PROTIVA));
|
||||
scadenze.add(riga_fattura);
|
||||
}
|
||||
|
||||
for (int ra = 1; ra <= riga.rate(); ra++)
|
||||
{
|
||||
const TRiga_scadenze& scad = riga.rata(ra);
|
||||
|
||||
TToken_string& row = scadenze.row(scadenze.add(""));
|
||||
row.add(ri);
|
||||
row.add(ra);
|
||||
row.add(scad.get(SCAD_DATASCAD));
|
||||
row.add(riga.get(PART_DATADOC));
|
||||
row.add(riga.get(PART_DESCR));
|
||||
add_importo(row, TImporto(riga.sezione(), scad.get_real(SCAD_IMPORTO)));
|
||||
TToken_string& row = scadenze.row(scadenze.add(riga_fattura));
|
||||
row.add(ra, 1);
|
||||
row.add(scad.get(SCAD_DATASCAD), 2);
|
||||
add_importo(row, TImporto(riga.sezione(), scad.get_real(SCAD_IMPORTO)), FALSE, 5);
|
||||
if (in_valuta)
|
||||
add_importo(row, TImporto(riga.sezione(), scad.get_real(SCAD_IMPORTOVAL)), 2);
|
||||
else
|
||||
row.add("");
|
||||
row.add(riga.get(PART_NREG));
|
||||
row.add(riga.get(PART_DATAREG));
|
||||
row.add(riga.get(PART_NUMDOC));
|
||||
row.add(riga.get(PART_PROTIVA));
|
||||
add_importo(row, TImporto(riga.sezione(), scad.get_real(SCAD_IMPORTOVAL)), TRUE, 6);
|
||||
|
||||
const int lastp = scad.last();
|
||||
for (int pa = scad.first(); pa <= lastp; pa = scad.succ(pa))
|
||||
@ -479,7 +506,7 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
}
|
||||
else
|
||||
{
|
||||
add_importo(rabb, abb, 2);
|
||||
add_importo(rabb, abb, TRUE);
|
||||
rabb.add("");
|
||||
}
|
||||
}
|
||||
@ -508,7 +535,7 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
{
|
||||
sl = scad.residuo(TRUE, 0x3);
|
||||
sl.normalize();
|
||||
add_importo(rsal, sl, 2);
|
||||
add_importo(rsal, sl, TRUE);
|
||||
tot_val += sl;
|
||||
}
|
||||
}
|
||||
@ -523,7 +550,9 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
TImporto imp(sum.sezione(), ZERO);
|
||||
|
||||
TToken_string& row = scadenze.row(scadenze.add(""));
|
||||
row.add("9999|9999| ");
|
||||
row.add(pag.get(PAGSCA_NRIGA));
|
||||
row.add(pag.get(PAGSCA_NRATA));
|
||||
row.add("");
|
||||
row.add(sum.get(PART_DATADOC));
|
||||
row.add(sum.get(PART_DESCR));
|
||||
TImporto i(sum.sezione(), pag.get_real(PAGSCA_IMPORTO));
|
||||
@ -535,7 +564,7 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
i = TImporto(sum.sezione(), pag.get_real(PAGSCA_IMPORTOVAL));
|
||||
tot_val += i;
|
||||
i.normalize();
|
||||
add_importo(row, i, 2);
|
||||
add_importo(row, i, TRUE);
|
||||
}
|
||||
else
|
||||
row.add("");
|
||||
@ -552,82 +581,117 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
TToken_string& sp = scadenze.row(scadenze.add(""));
|
||||
sp.add("Saldo ", 4); sp << anno << ' ' << num;
|
||||
add_importo(sp, tot_lit.normalize());
|
||||
add_importo(sp, tot_val.normalize(), 2);
|
||||
add_importo(sp, tot_val.normalize(), TRUE);
|
||||
}
|
||||
|
||||
gm.scadenze().force_update();
|
||||
if (should_delete_game)
|
||||
delete game;
|
||||
}
|
||||
if (k == K_INS)
|
||||
{
|
||||
gm.send_key(K_CTRL + 'N', 0, &partite); // Simula la pressione del tasto nuovo
|
||||
return FALSE; // Rifiuta l'aggiunta di una riga
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TGame_mask::scadenze_notify(TSheet_field& scadenze, int r, KEY k)
|
||||
{
|
||||
if (k == K_INS)
|
||||
{
|
||||
TGame_mask& gm = (TGame_mask&)scadenze.mask();
|
||||
gm.send_key(K_CTRL + 'N', 0, &scadenze); // Simula la pressione del tasto nuovo
|
||||
return FALSE; // Rifiuta l'aggiunta di una riga
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int TGame_mask::nuova_riga(TPartita& partita) const
|
||||
{
|
||||
TRiga_partite& part = partita.new_row(); // Creazione nuova riga vuota
|
||||
const int nriga = part.get_int(PART_NRIGA);
|
||||
|
||||
// Copia dati movimento corrente
|
||||
part.put(PART_NREG, _numreg); // Numero operazione
|
||||
part.put(PART_NUMRIG, _numrig); // Riga su cui ho cliccato
|
||||
|
||||
const real cambio(get(P_CAMBIO));
|
||||
part.put(PART_CAMBIO, cambio);
|
||||
part.put(PART_CODVAL, get(P_VALUTA));
|
||||
part.put(PART_DATACAM, get(P_DATACAMBIO));
|
||||
|
||||
#ifdef __EXTRA__
|
||||
part.put(PART_TIPOMOV, _tipomov);
|
||||
part.put(PART_DESCR, _descr);
|
||||
part.put(PART_NUMDOC, _numdoc);
|
||||
part.put(PART_DATADOC, _datadoc);
|
||||
part.put(PART_DATAREG, TDate(TODAY));
|
||||
part.put(PART_SEZ, _sezione);
|
||||
part.put(PART_SEZABB, _sezione);
|
||||
part.put(PART_SEZDIFCAM,_sezione);
|
||||
if (_tipomov == 1)
|
||||
{
|
||||
part.put(PART_IMPORTO, _importo.valore());
|
||||
if (!cambio.is_zero())
|
||||
{
|
||||
real impval = _importo.valore();
|
||||
impval /= cambio;
|
||||
impval.round(2);
|
||||
part.put(PART_IMPORTOVAL, impval);
|
||||
}
|
||||
}
|
||||
#else
|
||||
TMask& cm = app().curr_mask();
|
||||
const TCausale& causale = app().causale();
|
||||
const int tipomov = causale.tipomov();
|
||||
part.put(PART_TIPOMOV, tipomov);
|
||||
part.put(PART_DESCR, cm.get(F_DESCR));
|
||||
part.put(PART_NUMDOC, cm.get(F_NUMDOC));
|
||||
part.put(PART_DATADOC, cm.get(F_DATADOC));
|
||||
part.put(PART_DATAREG, cm.get(F_DATAREG));
|
||||
|
||||
// Copia dati causale corrente
|
||||
part.put(PART_CODCAUS, causale.codice());
|
||||
if (causale.iva() != nessuna_iva)
|
||||
{
|
||||
part.put(PART_REG, cm.get(F_CODREG));
|
||||
part.put(PART_PROTIVA, cm.get(F_PROTIVA));
|
||||
}
|
||||
|
||||
const char tipoc = conto().tipo();
|
||||
// Complesso algoritmo per calcolare la sezione di una nuova riga partita
|
||||
char sezione = causale.sezione(1); // Usa la sezione della causale
|
||||
if (sezione <= ' ') // Se non c'e' la sezione bell'e' ch'e' pronta
|
||||
{
|
||||
if (tipomov == 1 || tipomov == 5) // calcola in base al tipo movimento e
|
||||
sezione = (tipoc == 'C') ? 'D' : 'A'; // al tipo cliente/fornitore
|
||||
else
|
||||
sezione = (tipoc == 'C') ? 'A' : 'D';
|
||||
}
|
||||
if (tipoc > ' ') // Se il tipo e' C o F
|
||||
{
|
||||
TBill bill; causale.bill(1, bill); // Legge primo conto causale
|
||||
if (bill.tipo() != tipoc)
|
||||
sezione = (sezione == 'D') ? 'A' : 'D'; // scambia segno
|
||||
}
|
||||
// Memorizza solo la sezione (importi nulli)
|
||||
part.put(PART_SEZ, sezione);
|
||||
part.put(PART_SEZABB, sezione);
|
||||
part.put(PART_SEZDIFCAM, sezione);
|
||||
#endif
|
||||
|
||||
return nriga;
|
||||
}
|
||||
|
||||
int TGame_mask::nuovo_pagamento(TPartita& partita, int nriga, int rata) const
|
||||
{
|
||||
const TBill& conto = partita.conto(); // Legge conto principale
|
||||
int nrigp = partita.mov2rig(_numreg, _numrig); // Cerca riga partita relativa alla riga rmov
|
||||
TMask& cm = app().curr_mask();
|
||||
|
||||
#ifndef __EXTRA__
|
||||
const TCausale& causale = app().causale();
|
||||
#endif
|
||||
|
||||
if (nrigp <= 0) // Devo creare una nuova riga di partita
|
||||
{
|
||||
TRiga_partite& part = partita.new_row(); // Creazione nuova riga vuota
|
||||
nrigp = part.get_int(PART_NRIGA);
|
||||
|
||||
// Copia dati movimento corrente
|
||||
part.put(PART_NREG, _numreg); // Numero operazione
|
||||
part.put(PART_NUMRIG, _numrig); // Riga su cui ho cliccato
|
||||
part.put(PART_DATADOC, cm.get(F_DATADOC));
|
||||
part.put(PART_DESCR, cm.get(F_DESCR));
|
||||
part.put(PART_CODVAL, get(P_VALUTA));
|
||||
part.put(PART_CAMBIO, get(P_CAMBIO));
|
||||
part.put(PART_DATACAM, get(P_DATACAMBIO));
|
||||
#ifdef __EXTRA__
|
||||
part.zero(PART_DATAREG);
|
||||
part.zero(PART_NUMDOC);
|
||||
|
||||
// Complesso algoritmo per calcolare la sezione di una nuova riga partita
|
||||
const char sezione = (conto.tipo() == 'C') ? 'A' : 'D';
|
||||
#else
|
||||
part.put(PART_DATAREG, cm.get(F_DATAREG));
|
||||
part.put(PART_NUMDOC, cm.get(F_NUMDOC));
|
||||
|
||||
// Copia dati causale corrente
|
||||
const int tipomov = causale.tipomov();
|
||||
part.put(PART_TIPOMOV, tipomov);
|
||||
part.put(PART_CODCAUS, causale.codice());
|
||||
if (causale.iva() != nessuna_iva)
|
||||
{
|
||||
part.put(PART_REG, cm.get(F_CODREG));
|
||||
part.put(PART_PROTIVA, cm.get(F_PROTIVA));
|
||||
}
|
||||
|
||||
// Complesso algoritmo per calcolare la sezione di una nuova riga partita
|
||||
char sezione = causale.sezione(1); // Usa la sezione della causale
|
||||
if (sezione <= ' ') // Se non c'e' la sezione bell'e' ch'e' pronta
|
||||
{
|
||||
if (tipomov == 1 || tipomov == 5) // calcola in base al tipo movimento e
|
||||
sezione = (conto.tipo() == 'C') ? 'D' : 'A'; // al tipo cliente/fornitore
|
||||
else
|
||||
sezione = (conto.tipo() == 'C') ? 'A' : 'D';
|
||||
}
|
||||
|
||||
if (conto.tipo() > ' ') // Se il tipo e' C o F
|
||||
{
|
||||
TBill bill; causale.bill(1, bill); // Legge primo conto causale
|
||||
if (bill.tipo() != conto.tipo())
|
||||
sezione = (sezione == 'D') ? 'A' : 'D'; // scambia segno
|
||||
}
|
||||
#endif
|
||||
|
||||
part.put(PART_SEZ, sezione); // Memorizza solo la sezione (importi nulli)
|
||||
part.put(PART_SEZABB, sezione);
|
||||
part.put(PART_SEZDIFCAM, sezione);
|
||||
}
|
||||
nrigp = nuova_riga(partita);
|
||||
|
||||
TRectype& pagamento = partita.pagamento(nriga, rata, nrigp); // Crea nuovo pagamento
|
||||
|
||||
@ -662,10 +726,11 @@ int TGame_mask::nuovo_pagamento(TPartita& partita, int nriga, int rata) const
|
||||
pagamento.put(PAGSCA_CODABI, scad.get(SCAD_CODABI));
|
||||
pagamento.put(PAGSCA_CODCAB, scad.get(SCAD_CODCAB));
|
||||
pagamento.put(PAGSCA_CODAG, scad.get(SCAD_CODAG));
|
||||
pagamento.put(PAGSCA_DATAPAG, cm.get(F_DATADOC));
|
||||
pagamento.put(PAGSCA_DATAPAG, _datadoc);
|
||||
}
|
||||
|
||||
#ifndef __EXTRA__
|
||||
const TCausale& causale = app().causale();
|
||||
TBill contro; causale.bill(caus, contro); // Legge conto contropartita
|
||||
if (caus != 2 && contro.empty()) // Se non specificato ...
|
||||
causale.bill(caus = 2, contro); // ... prende il primo
|
||||
@ -675,16 +740,17 @@ int TGame_mask::nuovo_pagamento(TPartita& partita, int nriga, int rata) const
|
||||
return nrigp;
|
||||
}
|
||||
|
||||
|
||||
bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
if (k == K_SPACE)
|
||||
{
|
||||
TMask& m = f.mask();
|
||||
const int nriga = m.get_int(101);
|
||||
const int nrata = m.get_int(102);
|
||||
if (nriga == 0 || nrata == 0)
|
||||
return FALSE; // Ho cliccato su di un saldo (per sbaglio!)
|
||||
|
||||
if (nriga == 0)
|
||||
return FALSE; // Ho cliccato su di un saldo (per sbaglio!)
|
||||
|
||||
TGame_mask& gm = (TGame_mask&)(m.get_sheet()->mask());
|
||||
TMask_field& cambio = gm.field(P_CAMBIO);
|
||||
if (cambio.active() && cambio.get().empty())
|
||||
@ -695,24 +761,68 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
|
||||
const TString16 numero = gm.get(P_NUMERO);
|
||||
|
||||
TPartita& game = app().partite().partita(bill, anno, numero);
|
||||
|
||||
int nrigp = m.get_int(112);
|
||||
if (nrigp == 0)
|
||||
{
|
||||
|
||||
const int nrata = m.get_int(102); // Rata selezionata (puo' essere 0)
|
||||
int nrigp = m.get_int(112); // Pagamento selezionato (puo' essere 0)
|
||||
if (nrata != 0 && nrigp == 0)
|
||||
nrigp = gm.nuovo_pagamento(game, nriga, nrata);
|
||||
}
|
||||
else
|
||||
{
|
||||
const long nreg = m.get_long(108);
|
||||
if (nreg != gm._numreg)
|
||||
return f.error_box("Modificare il movimento %ld", nreg);
|
||||
}
|
||||
|
||||
const bool dirty = gm.edit_pagamento(game, nriga, nrata, nrigp);
|
||||
if (dirty)
|
||||
{
|
||||
gm.update_partita(game, gm._riga_partite);
|
||||
partite_notify(gm.partite(), gm._riga_partite, K_TAB);
|
||||
if (nrigp > 0) // Si vuole editare un pagamento
|
||||
{
|
||||
const bool dirty = gm.edit_pagamento(game, nriga, nrata, nrigp);
|
||||
if (dirty)
|
||||
{
|
||||
gm.update_partita(game, gm._riga_partite);
|
||||
partite_notify(gm.partite(), gm._riga_partite, K_TAB);
|
||||
gm._changed = TRUE;
|
||||
|
||||
if (!game.esiste(nriga, nrata, nrigp))
|
||||
m.stop_run(K_ESC);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // Si vogliono editare le rate
|
||||
const long nreg = m.get_long(108);
|
||||
#ifdef __EXTRA__
|
||||
if (nreg > 0)
|
||||
{
|
||||
bool can_run = TRUE;
|
||||
if (gm._changed)
|
||||
{
|
||||
can_run = yesno_box("Salvare le parite modificate?");
|
||||
if (can_run)
|
||||
{
|
||||
app().partite().rewrite();
|
||||
gm._changed = FALSE; // Resetta flag di cambiato
|
||||
}
|
||||
}
|
||||
if (can_run)
|
||||
{
|
||||
const char* pn = "cg2 -0";
|
||||
TExternal_app prima_nota(pn);
|
||||
TString16 numreg; numreg << "1|" << nreg;
|
||||
TMessage msg(pn, MSG_LN, numreg);
|
||||
msg.send(); // Messaggio di collegamento al movimento nreg
|
||||
app().partite().destroy(); // Distrugge tutte le partite in memoria
|
||||
prima_nota.run(); // Lancia la prima nota
|
||||
|
||||
const int anno = gm.get_int(P_ANNO);
|
||||
const TString16 numero = gm.get(P_NUMERO);
|
||||
gm.fill_partite(anno, numero); // Ripristina partite
|
||||
}
|
||||
}
|
||||
else
|
||||
gm.edit_fattura(game, nriga);
|
||||
#else
|
||||
if (nreg != gm._numreg || nrata == 0)
|
||||
{
|
||||
if (nreg == 0)
|
||||
f.error_box("Utilizzare la gestione extra-contabile");
|
||||
else
|
||||
f.error_box("Modificare il movimento %ld", nreg);
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
@ -722,48 +832,72 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
|
||||
bool TGame_mask::nuovo_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
if (k == K_SPACE)
|
||||
{
|
||||
{
|
||||
TGame_mask& gm = (TGame_mask&)f.mask();
|
||||
int anno;
|
||||
TString16 numero;
|
||||
TString numero;
|
||||
|
||||
// Graffa tattica per distruggere la maschera new_game alla fine del blocco
|
||||
{
|
||||
TMask new_game("Nuova partita", 1, 24, 5);
|
||||
new_game.add_number(P_ANNO, 0, "Anno ", 1, 1, 4, "A");
|
||||
new_game.add_string(P_NUMERO, 0, "Partita ", 1, 2, 7, "U");
|
||||
new_game.add_button(DLG_OK, 0, "" , -12, 3, 8, 2);
|
||||
new_game.add_button(DLG_CANCEL, 0, "" , -22, 3, 8, 2);
|
||||
TMask new_game("cg2100n");
|
||||
new_game.first_focus(P_NUMERO);
|
||||
|
||||
#ifdef __EXTRA__
|
||||
const bool proponi = TRUE;
|
||||
#else
|
||||
const bool proponi = app().causale().tipomov() == 2;
|
||||
#endif
|
||||
if (proponi)
|
||||
#ifndef __EXTRA__
|
||||
const TMask& cm = app().curr_mask();
|
||||
new_game.disable(-1);
|
||||
gm._tipomov = app().causale().tipomov();
|
||||
new_game.set(P_NUOVO, gm._tipomov);
|
||||
new_game.set(P_SEZIONE, gm._importo.sezione());
|
||||
new_game.set(P_RESIDUO, gm._importo.valore());
|
||||
new_game.set(P_DATADOC, cm.get(F_DATADOC));
|
||||
new_game.set(P_NUMDOC, cm.get(F_NUMDOC));
|
||||
new_game.set(P_DESCR, cm.get(F_DESCR));
|
||||
if (gm._tipomov < 3)
|
||||
new_game.set(P_CODPAG,cm.get(F_CODPAG));
|
||||
if (gm._tipomov == 2)
|
||||
{
|
||||
const TMask& cm = app().curr_mask();
|
||||
new_game.set(P_ANNO, cm.get(F_ANNORIF));
|
||||
new_game.set(P_NUMERO, cm.get(F_NUMRIF));
|
||||
}
|
||||
#endif
|
||||
|
||||
k = new_game.run();
|
||||
anno = new_game.get_int(P_ANNO);
|
||||
anno = new_game.get_int(P_ANNO);
|
||||
numero = new_game.get(P_NUMERO);
|
||||
|
||||
gm._tipomov = new_game.get_int(P_NUOVO);
|
||||
gm._codpag = new_game.get(P_CODPAG);
|
||||
gm._sezione = new_game.get(P_SEZIONE)[0];
|
||||
gm._importo.set(gm._sezione, real(new_game.get(P_RESIDUO)));
|
||||
gm._numdoc = new_game.get(P_NUMDOC);
|
||||
gm._datadoc = new_game.get(P_DATADOC);
|
||||
gm._descr = new_game.get(P_DESCR);
|
||||
}
|
||||
|
||||
if (k == K_ENTER)
|
||||
{
|
||||
TGame_mask& gm = (TGame_mask&)f.mask();
|
||||
TPartita& game = app().partite().partita(gm.conto(), anno, numero);
|
||||
if (game.ok())
|
||||
return error_box("La partita %d %s esiste gia'.", anno, (const char*)numero);
|
||||
|
||||
const int nriga = TPartita::UNASSIGNED;
|
||||
const int nrata = TPartita::UNASSIGNED;
|
||||
const int nrigp = gm.nuovo_pagamento(game, nriga, nrata);
|
||||
gm.edit_pagamento(game, nriga, nrata, nrigp);
|
||||
if (game.ok())
|
||||
if (gm._tipomov > 1)
|
||||
{
|
||||
const int nriga = TPartita::UNASSIGNED;
|
||||
const int nrata = TPartita::UNASSIGNED;
|
||||
const int nrigp = gm.nuovo_pagamento(game, nriga, nrata);
|
||||
gm.edit_pagamento(game, nriga, nrata, nrigp);
|
||||
}
|
||||
#ifdef __EXTRA__
|
||||
else
|
||||
{
|
||||
gm.edit_fattura(game, 0);
|
||||
}
|
||||
#endif
|
||||
if (game.ok())
|
||||
{
|
||||
gm.fill_partite(anno, numero); // Aggiorna sheet partite
|
||||
gm._changed = TRUE;
|
||||
}
|
||||
else
|
||||
app().partite().destroy(gm.conto(), anno, numero);
|
||||
}
|
||||
@ -777,14 +911,15 @@ bool TGame_mask::nuovo_handler(TMask_field& f, KEY k)
|
||||
// Metodi della maschera delle partite
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
void TGame_mask::add_importo(TToken_string& s, const TImporto& i, int dec)
|
||||
void TGame_mask::add_importo(TToken_string& s, const TImporto& i, bool valuta, int pos)
|
||||
{
|
||||
if (i.is_zero())
|
||||
s.add("");
|
||||
s.add("", pos);
|
||||
else
|
||||
{
|
||||
s.add(i.valore().string(dec));
|
||||
s << ' ' << i.sezione();
|
||||
{
|
||||
TString80 v;
|
||||
v << i.valore().string(valuta ? 2 : 0) << ' ' << i.sezione();
|
||||
s.add(v, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@ -867,16 +1002,17 @@ void TGame_mask::update_saldo_clifo()
|
||||
r.add("");
|
||||
r.add(TDate(TODAY).string());
|
||||
r.add("");
|
||||
add_importo(r, sal);
|
||||
add_importo(r, doc);
|
||||
add_importo(r, pag);
|
||||
add_importo(r, imp);
|
||||
add_importo(r, sal.normalize());
|
||||
add_importo(r, doc.normalize());
|
||||
add_importo(r, pag.normalize());
|
||||
add_importo(r, imp.normalize());
|
||||
r.add("Saldo ");
|
||||
|
||||
if (get(P_TIPOC)[0] == 'C')
|
||||
r << "cliente";
|
||||
else
|
||||
r << "fornitore";
|
||||
r << conto().sottoconto();
|
||||
}
|
||||
|
||||
void TGame_mask::fill_partite(int annorif, const char* numrif)
|
||||
@ -954,19 +1090,18 @@ bool TGame_mask::edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) co
|
||||
|
||||
TPay_mask m;
|
||||
|
||||
// Dati della scadenza che ha generato la partita
|
||||
if (nriga != TPartita::UNASSIGNED)
|
||||
{
|
||||
const TRiga_scadenze& scaden = p.rata(nriga, nrata);
|
||||
m.set_pag(oldpag, scaden, _importo);
|
||||
}
|
||||
else
|
||||
if (nriga == TPartita::UNASSIGNED)
|
||||
{
|
||||
nriga = p.primo_pagamento();
|
||||
TRiga_partite& riga = p.riga(nriga);
|
||||
TRiga_scadenze& scaden = riga.new_row();
|
||||
m.set_pag(oldpag, scaden, _importo);
|
||||
riga.destroy_rows();
|
||||
}
|
||||
else
|
||||
{
|
||||
const TRiga_scadenze& scaden = p.rata(nriga, nrata);
|
||||
m.set_pag(oldpag, scaden, _importo);
|
||||
}
|
||||
m.set(S_DESCAGG, somma.get(PART_DESCR));
|
||||
|
||||
@ -988,15 +1123,17 @@ else
|
||||
|
||||
const TValuta val; // Non cambiare valuta!
|
||||
#ifdef __EXTRA__
|
||||
p.modifica_pagamento(newpag, val);
|
||||
p.modifica_pagamento(newpag);
|
||||
#else
|
||||
app().notify_edit_pagamento(p, newpag, val);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
return key != K_ESC;
|
||||
}
|
||||
|
||||
#ifndef __EXTRA__
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Edit delle partite
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -1018,11 +1155,15 @@ bool TPrimanota_application::edit_partite(const TMask& m, int riga)
|
||||
|
||||
// Esecuzione maschera di selezione partite
|
||||
TGame_mask mask(b, mov.get_long(MOV_NUMREG), riga+1);
|
||||
mask.run();
|
||||
cgs().force_update(); // Aggiornamento righe contabili
|
||||
calcola_saldo();
|
||||
mask.run();
|
||||
|
||||
return TRUE;
|
||||
const bool changed = mask.changed();
|
||||
if (changed)
|
||||
{
|
||||
cgs().force_update(); // Aggiornamento righe contabili
|
||||
calcola_saldo();
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
2791
cg/pagament.cpp
2791
cg/pagament.cpp
File diff suppressed because it is too large
Load Diff
@ -21,6 +21,7 @@ const word P_SCAD = 0x0004; // scadenze non consecutive
|
||||
const word P_INIZIO = 0x0008; // data 1a rata < data inizio pagamenti
|
||||
const word P_NEG = 0x0010; // importo specificato < minimo possibile
|
||||
const word P_TROP = 0x0020; // importo specificato > massimo possibile
|
||||
const word P_TOTNC = 0x0040; // totale importi != totale pagamento
|
||||
|
||||
class TPagamento : public TObject
|
||||
{
|
||||
@ -98,6 +99,7 @@ public:
|
||||
void set_rate_differenziate(int v);
|
||||
void set_tipo_prima_rata(int v, int sscad = -1);
|
||||
void set_percrata(int n, real r);
|
||||
real recalc_percrata(int i);
|
||||
void set_numero_rate(int n, int sscad = -1, int rdiff = 1);
|
||||
|
||||
void set_inizio_scadenza(char v) { _inscad = v; }
|
||||
|
173
cg/saldacon.cpp
173
cg/saldacon.cpp
@ -318,35 +318,52 @@ TImporto TRiga_scadenze::importo_da_pagare(bool val) const
|
||||
|
||||
// Calcola l'abbuono in valuta della rata e ritorna il suo tipo:
|
||||
// 'A' abbuono attivo; 'P' abbuono passivo
|
||||
// La sezione dell'abbuono calcolato e' quella della riga contabile in cui finira'
|
||||
char TRiga_scadenze::calcola_abbuono(int p, TImporto& abbuono) const
|
||||
char TRiga_scadenze::calcola_abbuono(int p, TImporto& abbuono, bool update)
|
||||
{
|
||||
bool ap = ' ';
|
||||
|
||||
const TRectype& pag = row(p);
|
||||
if (pag.get_char(PAGSCA_ACCSAL) == 'S')
|
||||
{
|
||||
abbuono = importo_da_pagare(TRUE);
|
||||
abbuono += importo_pagato(TRUE);
|
||||
|
||||
for (int r = last(); r > 0; r = pred(r)) if (r != p)
|
||||
{
|
||||
const TRiga_partite& sum = partita().riga(r); // Riga partite
|
||||
const TImporto imp(sum.sezione(), row(r).get_real(PAGSCA_ABBUONI));
|
||||
abbuono += imp;
|
||||
}
|
||||
char ap = ' ';
|
||||
TRectype& pag = row(p);
|
||||
|
||||
const int sign = abbuono.valore().sign();
|
||||
if (sign != 0)
|
||||
const char sez = partita().riga(p).sezione();
|
||||
|
||||
if (update)
|
||||
{
|
||||
if (pag.get_char(PAGSCA_ACCSAL) == 'S')
|
||||
{
|
||||
abbuono = importo_da_pagare(TRUE);
|
||||
pag.zero(PAGSCA_ABBUONI);
|
||||
abbuono += importo_pagato(TRUE, 0x3); // Conta anche altri abbuoni
|
||||
abbuono.swap_section();
|
||||
|
||||
const int sign = abbuono.valore().sign();
|
||||
if (sign != 0)
|
||||
{
|
||||
if (sign > 0)
|
||||
ap = abbuono.sezione() == 'D' ? 'A' : 'P';
|
||||
else
|
||||
ap = abbuono.sezione() == 'D' ? 'P' : 'A';
|
||||
}
|
||||
}
|
||||
else
|
||||
abbuono.valore() = ZERO;
|
||||
|
||||
if (ap > ' ')
|
||||
{
|
||||
abbuono.normalize(sez);
|
||||
pag.put(PAGSCA_ABBUONI, abbuono.valore());
|
||||
pag.put(PAGSCA_PASSATT, ap);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sign > 0)
|
||||
ap = abbuono.sezione() == 'D' ? 'P' : 'A';
|
||||
else
|
||||
ap = abbuono.sezione() == 'D' ? 'A' : 'P';
|
||||
}
|
||||
pag.zero(PAGSCA_ABBUONI);
|
||||
pag.zero(PAGSCA_PASSATT);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
abbuono.set(sez, pag.get_real(PAGSCA_ABBUONI));
|
||||
ap = pag.get_char(PAGSCA_PASSATT);
|
||||
if (ap < ' ') ap = ' ';
|
||||
}
|
||||
else
|
||||
abbuono.valore() = ZERO;
|
||||
|
||||
return ap;
|
||||
}
|
||||
@ -364,15 +381,15 @@ TImporto TRiga_scadenze::calcola_differenza_cambio(int p, bool update)
|
||||
if (update)
|
||||
{
|
||||
diffcam = importo_da_pagare(FALSE);
|
||||
diffcam += importo_pagato(FALSE, 0x3); // Conta anche gli abbuoni
|
||||
pag.zero(PAGSCA_DIFFCAM);
|
||||
diffcam += importo_pagato(FALSE, 0x7); // Conta anche gli abbuoni e le altre diffcam
|
||||
diffcam.swap_section();
|
||||
diffcam.normalize(sez);
|
||||
|
||||
const TImporto gir(sez, -diffcam.valore());
|
||||
pag.put(PAGSCA_DIFFCAM, gir.valore());
|
||||
pag.put(PAGSCA_DIFFCAM, diffcam.valore());
|
||||
}
|
||||
else
|
||||
{
|
||||
diffcam.set(sez, -pag.get_real(PAGSCA_DIFFCAM));
|
||||
diffcam.set(sez, pag.get_real(PAGSCA_DIFFCAM));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -381,7 +398,7 @@ TImporto TRiga_scadenze::calcola_differenza_cambio(int p, bool update)
|
||||
pag.zero(PAGSCA_DIFFCAM);
|
||||
}
|
||||
|
||||
return diffcam.normalize();
|
||||
return diffcam;
|
||||
}
|
||||
|
||||
TImporto TRiga_scadenze::residuo(bool val, int mode) const
|
||||
@ -394,7 +411,8 @@ TImporto TRiga_scadenze::residuo(bool val, int mode) const
|
||||
|
||||
bool TRiga_scadenze::modifica_pagamento(const TRectype& new_pag, const TValuta& valuta,
|
||||
char& old_ap, TImporto& old_abb, TImporto& old_diffcam,
|
||||
char& new_ap, TImporto& new_abb, TImporto& new_diffcam)
|
||||
char& new_ap, TImporto& new_abb, TImporto& new_diffcam,
|
||||
bool update)
|
||||
{
|
||||
const bool in_val = in_valuta();
|
||||
const int nrigp = new_pag.get_int(PAGSCA_NRIGP);
|
||||
@ -402,48 +420,35 @@ bool TRiga_scadenze::modifica_pagamento(const TRectype& new_pag, const TValuta&
|
||||
TRiga_partite& sum = partita().riga(nrigp);
|
||||
|
||||
TImporto old_abbuono;
|
||||
old_ap = calcola_abbuono(nrigp, old_abbuono); // Vecchio abbuono in valuta
|
||||
old_ap = calcola_abbuono(nrigp, old_abbuono, FALSE); // Vecchio abbuono in valuta
|
||||
old_abb = old_abbuono; // Vecchio abbuono in lire
|
||||
if (in_val)
|
||||
{
|
||||
old_abb.valore() *= sum.get_real(PART_CAMBIO);
|
||||
old_abb.valore().round();
|
||||
}
|
||||
|
||||
old_diffcam = calcola_differenza_cambio(nrigp, FALSE);
|
||||
|
||||
if (in_val && !valuta.in_lire())
|
||||
valuta.put(sum);
|
||||
|
||||
row(nrigp) = new_pag;
|
||||
row(nrigp).zero(PAGSCA_ABBUONI); // Azzera abbuoni per ricalcolo
|
||||
row(nrigp).zero(PAGSCA_DIFFCAM); // Azzera differenza cambio per ricalcolo
|
||||
|
||||
TImporto new_abbuono;
|
||||
new_ap = calcola_abbuono(nrigp, new_abbuono); // Calcolo abbuono in valuta
|
||||
|
||||
new_abb = new_abbuono; // Calcola nuovo abbuono in lire
|
||||
new_ap = calcola_abbuono(nrigp, new_abbuono, update); // Calcolo abbuono in valuta
|
||||
|
||||
new_abb = new_abbuono; // Calcola nuovo abbuono in lire
|
||||
if (in_valuta())
|
||||
{
|
||||
new_abb.valore() *= sum.get_real(PART_CAMBIO);
|
||||
new_abb.valore().round();
|
||||
}
|
||||
new_abb.normalize();
|
||||
|
||||
// Scambia sezione per registrazione contabile
|
||||
old_abbuono.swap_section();
|
||||
new_abbuono.swap_section();
|
||||
new_abbuono.normalize(sum.sezione());
|
||||
if (new_ap != ' ')
|
||||
row(nrigp).put(PAGSCA_ABBUONI, new_abbuono.valore());
|
||||
else
|
||||
row(nrigp).zero(PAGSCA_ABBUONI);
|
||||
|
||||
new_diffcam = calcola_differenza_cambio(nrigp, update);
|
||||
|
||||
sum.update(old_abbuono, new_abbuono, PART_SEZABB, PART_ABBUONI);
|
||||
|
||||
new_diffcam = calcola_differenza_cambio(nrigp, TRUE);
|
||||
// Memorizza differenza cambi invertita, mettendo new_diffcam prima di old_diffcam!
|
||||
sum.update(new_diffcam, old_diffcam, PART_SEZDIFCAM, PART_DIFFCAM);
|
||||
|
||||
sum.update(old_diffcam, new_diffcam, PART_SEZDIFCAM, PART_DIFFCAM);
|
||||
sum.update(old_pag, new_pag, PART_IMPORTO);
|
||||
sum.update(old_pag, new_pag, PART_IMPORTOVAL);
|
||||
sum.update(old_pag, new_pag, PART_RITENUTE);
|
||||
@ -572,7 +577,24 @@ bool TRiga_partite::update(const TImporto& vec, const TImporto& nuo,
|
||||
return zero;
|
||||
}
|
||||
|
||||
|
||||
int TRiga_partite::rata_con_abbuoni_diffcam() const
|
||||
{
|
||||
int found = 0;
|
||||
for (int s = rate(); s > 0 && found == 0; s--)
|
||||
{
|
||||
const TRiga_scadenze& scad = rata(s);
|
||||
for (int p = scad.last(); p > 0; p = scad.pred(p))
|
||||
{
|
||||
const TRectype& pag = scad.row(p);
|
||||
if (!pag.get_real(PART_ABBUONI).is_zero() || !pag.get_real(PART_DIFFCAM).is_zero())
|
||||
{
|
||||
found = s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TPartita
|
||||
@ -679,7 +701,7 @@ TRiga_partite& TPartita::new_row(int r)
|
||||
|
||||
TRiga_scadenze& TPartita::rata(int nriga, int nrata) const
|
||||
{
|
||||
if (nriga <= 0) nriga = prima_fattura();
|
||||
// if (nriga <= 0) nriga = prima_fattura();
|
||||
const TRiga_partite& r = riga(nriga);
|
||||
return r.rata(nrata);
|
||||
}
|
||||
@ -695,6 +717,15 @@ bool TPartita::rata_chiusa(int nriga, int nrata) const
|
||||
return pag;
|
||||
}
|
||||
|
||||
bool TPartita::esistono_abbuoni_diffcam(long nreg) const
|
||||
{
|
||||
int nrata = 0;
|
||||
const int nriga = prima_fattura(nreg);
|
||||
if (_part.exist(nriga))
|
||||
nrata = riga(nriga).rata_con_abbuoni_diffcam();
|
||||
return nrata > 0;
|
||||
}
|
||||
|
||||
TRectype& TPartita::pagamento(int nriga, int nrata, int nrigp)
|
||||
{
|
||||
if (nriga == UNASSIGNED)
|
||||
@ -877,22 +908,10 @@ bool TPartita::utilizzata(int nrigp) const
|
||||
return _unassigned.exist(nrigp);
|
||||
}
|
||||
|
||||
|
||||
bool TPartita::esistono_abbuoni_diffcam() const
|
||||
{
|
||||
for (int r = last(); r > 0; r = pred(r))
|
||||
{
|
||||
const TRiga_partite& row = riga(r);
|
||||
if (!row.get_real(PART_ABBUONI).is_zero() || !row.get_real(PART_DIFFCAM).is_zero())
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
bool TPartita::modifica_pagamento(const TRectype& new_pag, const TValuta& valuta,
|
||||
char& old_ap, TImporto& old_abb, TImporto& old_diffcam,
|
||||
char& new_ap, TImporto& new_abb, TImporto& new_diffcam)
|
||||
char& new_ap, TImporto& new_abb, TImporto& new_diffcam,
|
||||
bool update)
|
||||
{
|
||||
const int nriga = new_pag.get_int(PAGSCA_NRIGA);
|
||||
const int nrata = new_pag.get_int(PAGSCA_NRATA);
|
||||
@ -905,7 +924,7 @@ bool TPartita::modifica_pagamento(const TRectype& new_pag, const TValuta& valuta
|
||||
TRiga_scadenze& scaden = rata(nriga, nrata);
|
||||
empty = scaden.modifica_pagamento(new_pag, valuta,
|
||||
old_ap, old_abb, old_diffcam,
|
||||
new_ap, new_abb, new_diffcam);
|
||||
new_ap, new_abb, new_diffcam, update);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -940,7 +959,7 @@ bool TPartita::modifica_pagamento(const TRectype& new_pag)
|
||||
TValuta valuta;
|
||||
return modifica_pagamento(new_pag, valuta,
|
||||
old_ap, old_abbuono, old_diffcam,
|
||||
new_ap, new_abbuono, new_diffcam);
|
||||
new_ap, new_abbuono, new_diffcam, FALSE);
|
||||
}
|
||||
|
||||
|
||||
@ -1021,7 +1040,7 @@ void TPartita::sposta_riga(int r, TPartita& part)
|
||||
int* address = new int[address_size];
|
||||
memset(address, 0, address_size*sizeof(int));
|
||||
|
||||
TToken_string knames(256);
|
||||
TToken_string knames(64);
|
||||
knames.add(PART_TIPOCF);
|
||||
knames.add(PART_GRUPPO);
|
||||
knames.add(PART_CONTO);
|
||||
@ -1062,11 +1081,9 @@ void TPartita::sposta_riga(int r, TPartita& part)
|
||||
if (part.esiste(r, i, nrigp))
|
||||
{
|
||||
npg = part.pagamento(r, i, nrigp);
|
||||
CHECK(npg.get_char(PAGSCA_ACCSAL) != 'S', "Can't add to soldered payment");
|
||||
somma(pag, npg, PART_IMPORTO);
|
||||
somma(pag, npg, PART_IMPORTOVAL);
|
||||
somma(pag, npg, PART_ABBUONI);
|
||||
somma(pag, npg, PART_DIFFCAM);
|
||||
npg.put(PAGSCA_ACCSAL, 'A');
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1102,11 +1119,11 @@ void TPartita::scollega_pagamenti(int r, int s)
|
||||
for (int j = sc.last(); j > 0; j = sc.pred(j))
|
||||
{
|
||||
TRectype& pag = sc.row(j);
|
||||
CHECK(pag.get_real(PAGSCA_ABBUONI).is_zero(), "Can't remove payment with ABBUONI");
|
||||
CHECK(pag.get_real(PAGSCA_DIFFCAM).is_zero(), "Can't remove payment with DIFFCAM");
|
||||
pag.put(PAGSCA_ACCSAL, 'A');
|
||||
CHECK(pag.get_real(PAGSCA_ABBUONI).is_zero(), "Can't detach payment with ABBUONI");
|
||||
CHECK(pag.get_real(PAGSCA_DIFFCAM).is_zero(), "Can't detach payment with DIFFCAM");
|
||||
pag.put(PAGSCA_NRIGA, (int)TPartita::UNASSIGNED);
|
||||
pag.put(PAGSCA_NRATA, (int)TPartita::UNASSIGNED);
|
||||
pag.put(PAGSCA_ACCSAL, 'A');
|
||||
if (_unassigned.exist(j))
|
||||
{
|
||||
TRectype& unas = _unassigned.row(j, FALSE);
|
||||
|
@ -114,12 +114,12 @@ class TRiga_scadenze : public TTree_rectype
|
||||
TRiga_partite* _riga;
|
||||
|
||||
protected:
|
||||
char calcola_abbuono(int p, TImporto& abbuono) const;
|
||||
char calcola_abbuono(int p, TImporto& abbuono, bool update);
|
||||
TImporto calcola_differenza_cambio(int p, bool update);
|
||||
|
||||
bool modifica_pagamento(const TRectype& new_pag, const TValuta& valuta,
|
||||
char& old_ap, TImporto& old_abb, TImporto& old_diffcam,
|
||||
char& new_ap, TImporto& new_abb, TImporto& new_diffcam);
|
||||
char& new_ap, TImporto& new_abb, TImporto& new_diffcam, bool update);
|
||||
bool elimina_pagamento(int p);
|
||||
|
||||
protected: // TRecord_tree
|
||||
@ -163,6 +163,8 @@ public:
|
||||
|
||||
int ultima_ratapagata() const;
|
||||
int ultimo_pagamento(int rata) const;
|
||||
int rata_con_abbuoni_diffcam() const;
|
||||
|
||||
char sezione() const { return get_char(PART_SEZ); }
|
||||
bool in_valuta() const { return get(PART_CODVAL).not_empty(); }
|
||||
|
||||
@ -202,7 +204,7 @@ public:
|
||||
TRectype& pagamento(int nriga, int nrata, int nrigp);
|
||||
bool rata_chiusa(int nriga, int nrata) const;
|
||||
bool esiste(int nriga, int nrata = 0, int nrigp = 0) const;
|
||||
bool esistono_abbuoni_diffcam() const;
|
||||
bool esistono_abbuoni_diffcam(long nreg = 0) const;
|
||||
|
||||
// assegna riga e figli ad altra partita
|
||||
void sposta_riga(int r, TPartita& part);
|
||||
@ -222,8 +224,8 @@ public:
|
||||
|
||||
int mov2rig(long nreg, int rmov) const;
|
||||
int rig2mov(int rmov) const;
|
||||
int prima_fattura(long nreg = -1l) const;
|
||||
int primo_pagamento(long nreg = -1l) const;
|
||||
int prima_fattura(long nreg = -1) const;
|
||||
int primo_pagamento(long nreg = -1) const;
|
||||
|
||||
bool utilizzata(int r) const; // Controlla se esistono pagamenti sommati alla riga r
|
||||
TRecord_array& unassigned() { return _unassigned; }
|
||||
@ -241,7 +243,8 @@ public:
|
||||
|
||||
bool modifica_pagamento(const TRectype& new_pag, const TValuta& valuta,
|
||||
char& old_ap, TImporto& old_abb, TImporto& old_diffcam,
|
||||
char& new_ap, TImporto& new_abb, TImporto& new_diffcam);
|
||||
char& new_ap, TImporto& new_abb, TImporto& new_diffcam,
|
||||
bool update);
|
||||
bool modifica_pagamento(const TRectype& new_pag);
|
||||
|
||||
TPartita(const TBill& clifo, int anno, const char* num);
|
||||
@ -251,7 +254,7 @@ public:
|
||||
class TPartite_array : private TAssoc_array
|
||||
{
|
||||
TString80 _key; // Work string
|
||||
long _numreg; // Last registration loaded
|
||||
long _numreg; // Last registration loaded
|
||||
|
||||
protected:
|
||||
const TString& key(const TBill& clifo, int anno, const char* num); // Build key for TAssoc_array
|
||||
|
Loading…
x
Reference in New Issue
Block a user