Accorpato scadenzario nella maschera principale di prima nota
git-svn-id: svn://10.65.10.50/trunk@1040 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
8e8b843154
commit
de0de7175d
@ -4,8 +4,11 @@
|
||||
#include <urldefid.h>
|
||||
#include <execp.h>
|
||||
|
||||
#include "pagament.h"
|
||||
|
||||
#include "cg2100.h"
|
||||
#include "cg2102.h"
|
||||
#include "cg21sld.h"
|
||||
|
||||
// Nomi dei campi
|
||||
#include <mov.h>
|
||||
@ -75,6 +78,7 @@ TMask* TPrimanota_application::load_mask(int n)
|
||||
m->set_handler(F_OCCASEDIT, occas_handler);
|
||||
m->set_handler(F_SOLAIVA, solaiva_handler);
|
||||
m->set_handler(F_SHEETIVA, iva_handler);
|
||||
m->set_handler(F_CODPAG, codpag_handler);
|
||||
|
||||
TSheet_field& is = (TSheet_field&)m->field(F_SHEETIVA);
|
||||
is.set_notify(iva_notify);
|
||||
@ -85,7 +89,12 @@ TMask* TPrimanota_application::load_mask(int n)
|
||||
ism.set_handler(104, imposta_handler);
|
||||
ism.set_handler(109, iva_sottoconto_handler);
|
||||
ism.set_handler(209, sheet_clifo_handler);
|
||||
ism.set_handler(309, sheet_clifo_handler);
|
||||
ism.set_handler(309, sheet_clifo_handler);
|
||||
|
||||
// add saldaconto
|
||||
TSheet_field& ps = (TSheet_field&)m->field(FS_RATESHEET);
|
||||
ps.set_notify(pag_notify);
|
||||
|
||||
}
|
||||
_iva_showed = FALSE;
|
||||
case 1:
|
||||
@ -148,6 +157,11 @@ bool TPrimanota_application::user_create()
|
||||
_giornale = new TLibro_giornale();
|
||||
|
||||
set_search_field(F_NUMREG); // Set field for default search
|
||||
|
||||
_pag = NULL;
|
||||
_pag_rows = NULL;
|
||||
_is_saldaconto = FALSE;
|
||||
|
||||
load_mask(0);
|
||||
|
||||
return TRUE;
|
||||
@ -163,6 +177,9 @@ bool TPrimanota_application::user_destroy()
|
||||
for (int m = 3; m >= 0; m--)
|
||||
if (_msk[m] != NULL) delete _msk[m];
|
||||
|
||||
if (_pag != NULL) delete _pag;
|
||||
if (_pag_rows != NULL) delete _pag_rows;
|
||||
|
||||
delete _giornale;
|
||||
delete _causale;
|
||||
delete _rel;
|
||||
@ -176,7 +193,8 @@ bool TPrimanota_application::user_destroy()
|
||||
delete _rcaus;
|
||||
delete _caus;
|
||||
delete _tab;
|
||||
delete _tabcom;
|
||||
delete _tabcom;
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -195,7 +213,7 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
|
||||
|
||||
if (ok)
|
||||
{
|
||||
sal = gestione_saldaconto() && causale().saldaconto();
|
||||
_is_saldaconto = sal = gestione_saldaconto() && causale().saldaconto();
|
||||
dob = sal | causale().data_doc();
|
||||
nob = sal | causale().num_doc();
|
||||
iva = causale().iva();
|
||||
@ -211,6 +229,9 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
|
||||
|
||||
if (iva != nessuna_iva)
|
||||
{
|
||||
if (sal) m->enable_page(2);
|
||||
else m->disable_page(2);
|
||||
|
||||
m->efield(F_CODPAG).check_type(sal ? CHECK_REQUIRED : CHECK_NORMAL);// Cod. pag. obbligatorio
|
||||
const bool av = causale().reg().agenzia_viaggi();
|
||||
m->show(F_DATA74TER, av);
|
||||
@ -467,7 +488,11 @@ void TPrimanota_application::init_insert_mode(TMask& m)
|
||||
|
||||
init_mask(m);
|
||||
if (causale().reg().agenzia_viaggi())
|
||||
m.set(F_DATA74TER, m.get(F_DATAREG));
|
||||
m.set(F_DATA74TER, m.get(F_DATAREG));
|
||||
|
||||
TString dt(m.get(F_DATAREG));
|
||||
_pag = new Pagamento(NULL,dt);
|
||||
set_scadenze(m);
|
||||
_saldi.reset(); // Inizializza saldi
|
||||
}
|
||||
|
||||
@ -491,7 +516,7 @@ bool TPrimanota_application::get_conto(const TRectype& r, TBill& c) const
|
||||
return c.ok();
|
||||
}
|
||||
|
||||
// Scrive un conto su una riga di proma nota
|
||||
// Scrive un conto su una riga di prima nota
|
||||
void TPrimanota_application::put_conto(TRectype& r, const TBill& c) const
|
||||
{
|
||||
r.put("TIPOC", c.tipo());
|
||||
@ -545,6 +570,7 @@ int TPrimanota_application::read(TMask& m)
|
||||
_saldi.set_num_ulmov(m.get_long(F_NUMREG));
|
||||
_saldi.set_data_ulmov((TDate)m.get(F_DATAREG));
|
||||
|
||||
|
||||
TToken_string riga(255);
|
||||
|
||||
for (int i = 0; i < _rel->cg_items(); i++)
|
||||
@ -618,7 +644,11 @@ int TPrimanota_application::read(TMask& m)
|
||||
|
||||
ivas().row(i) = riga;
|
||||
}
|
||||
|
||||
TString dt(m.get(F_DATAREG));
|
||||
_pag = new Pagamento(m.get(F_CODPAG),dt);
|
||||
if (!read_scadenze(m))
|
||||
set_scadenze(m);
|
||||
|
||||
return _rel->status();
|
||||
}
|
||||
|
||||
@ -775,7 +805,7 @@ int TPrimanota_application::write(const TMask& m)
|
||||
}
|
||||
|
||||
if (gestione_saldaconto() && causale().saldaconto())
|
||||
aggiorna_scadenzario(m);
|
||||
write_scadenze(m);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
@ -788,7 +818,7 @@ int TPrimanota_application::rewrite(const TMask& m)
|
||||
if (err == NOERR)
|
||||
_saldi.registra();
|
||||
if (gestione_saldaconto() && causale().saldaconto())
|
||||
aggiorna_scadenzario(m);
|
||||
write_scadenze(m);
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -797,7 +827,8 @@ bool TPrimanota_application::remove()
|
||||
{
|
||||
const bool ok = TRelation_application::remove();
|
||||
if (ok)
|
||||
_saldi.registra();
|
||||
_saldi.registra();
|
||||
// TBI eliminazione partita
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "cg2100.h"
|
||||
#include "cg21sld.h"
|
||||
|
||||
TOOLBAR "" 0 20 0 2
|
||||
#include <toolbar.h>
|
||||
@ -634,7 +635,10 @@ END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
||||
#include "cg21sld.uml"
|
||||
|
||||
ENDMASK
|
||||
|
||||
#include "cg21iva.uml"
|
||||
#include "cg21cg.uml"
|
||||
#include "cg21rata.uml"
|
@ -5,14 +5,11 @@
|
||||
|
||||
#include "cg2100.h"
|
||||
#include "cg2102.h"
|
||||
#include "cg21sld.h"
|
||||
|
||||
#include <mov.h>
|
||||
#include <clifo.h>
|
||||
|
||||
// Certified 100%
|
||||
inline TPrimanota_application& app()
|
||||
{ return (TPrimanota_application&)main_app(); }
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Funzioni di decodifica/calcolo
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -668,6 +665,14 @@ bool TPrimanota_application::dareavere_handler(TMask_field& f, KEY k)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// cazzorate
|
||||
|
||||
TSheet_field& TPrimanota_application::pags() const
|
||||
{
|
||||
TSheet_field& s = (TSheet_field&)_msk[2]->field(FS_RATESHEET);
|
||||
return s;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Gestione sheet IVA
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -1607,6 +1612,8 @@ bool TPrimanota_application::totale_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
app().add_cgs_tot(f.mask());
|
||||
f.mask().field(F_CODIVA).on_hit();
|
||||
if (app().is_saldaconto() && !(f.mask().get(F_CODPAG).blank()))
|
||||
app().set_scadenze(f.mask());
|
||||
}
|
||||
|
||||
if (key == K_ENTER && f.get().empty())
|
||||
|
33
cg/cg2102.h
33
cg/cg2102.h
@ -21,6 +21,8 @@
|
||||
#include "cg2103.h"
|
||||
#endif
|
||||
|
||||
class Pagamento;
|
||||
|
||||
class TPrimanota_application : public TRelation_application
|
||||
{
|
||||
TMovimentoPN* _rel;
|
||||
@ -35,6 +37,7 @@ class TPrimanota_application : public TRelation_application
|
||||
TLocalisamfile* _comuni;
|
||||
TLocalisamfile* _occas;
|
||||
TLocalisamfile* _nditte;
|
||||
Pagamento* _pag;
|
||||
|
||||
TCausale* _causale; // Causale corrente
|
||||
TLibro_giornale* _giornale; // Libro giornale corrente
|
||||
@ -49,6 +52,8 @@ class TPrimanota_application : public TRelation_application
|
||||
short _firstfocus; // Primo campo della maschera a prendere il focus
|
||||
|
||||
bool _iva_showed; // Lo sheet IVA e' gia' stato visualizzato una volta?
|
||||
|
||||
bool _is_saldaconto; // saldaconto si/no (vede parametri e causale)
|
||||
|
||||
TSaldo_agg _saldi; // Saldi da aggiornare
|
||||
|
||||
@ -57,9 +62,8 @@ class TPrimanota_application : public TRelation_application
|
||||
int _mode; // Modo maschera corrente
|
||||
|
||||
TBill _conto_ricavo; // Conto di ricavo del clifo
|
||||
|
||||
void* _app_data;
|
||||
|
||||
TArray* _pag_rows;
|
||||
|
||||
static bool suspended_handler(TMask_field& f, KEY k);
|
||||
static bool num_handler(TMask_field& f, KEY key);
|
||||
static bool caus_query_handler(TMask_field& f, KEY key);
|
||||
@ -91,6 +95,7 @@ class TPrimanota_application : public TRelation_application
|
||||
static bool imposta_handler(TMask_field& f, KEY key);
|
||||
static bool dareavere_handler(TMask_field& f, KEY k);
|
||||
static bool cg_conto_handler(TMask_field& f, KEY key);
|
||||
static bool codpag_handler(TMask_field& f, KEY key);
|
||||
|
||||
static bool iva_notify(int r, KEY key);
|
||||
static bool iva_handler(TMask_field& f, KEY key);
|
||||
@ -120,7 +125,6 @@ protected:
|
||||
virtual bool remove();
|
||||
|
||||
void genera_incasso(const char* causimm);
|
||||
void aggiorna_scadenzario(const TMask& m);
|
||||
|
||||
TMask* load_mask(int n);
|
||||
TMask& occas_mask() { return *load_mask(3); }
|
||||
@ -134,14 +138,19 @@ protected:
|
||||
char clifo() const { return iva() == iva_vendite ? 'C' : 'F'; }
|
||||
bool gestione_valuta() const { return _ges_val; }
|
||||
bool gestione_saldaconto() const { return _ges_sal; }
|
||||
bool is_saldaconto() const { return _is_saldaconto; }
|
||||
void set_saldaconto(bool b) { _is_saldaconto = b; }
|
||||
|
||||
void fill_sheet(TMask& m) const;
|
||||
|
||||
void init_mask(TMask& m);
|
||||
|
||||
TSheet_field& cgs() const;
|
||||
TSheet_field& ivas() const;
|
||||
|
||||
TSheet_field& pags() const;
|
||||
TArray* pag_rows() const { return _pag_rows; }
|
||||
Pagamento* pagamento() const;
|
||||
|
||||
|
||||
static int bill2pos(const TBill& conto, char tipo);
|
||||
static TipoIVA reg2IVA(const char* registro, int anno);
|
||||
static TipoIVA cau2IVA(const char* causale, int anno);
|
||||
@ -184,9 +193,15 @@ protected:
|
||||
void reset_cgs_row(int n) { reset_sheet_row(cgs(), n); }
|
||||
void reset_ivas_row(int n) { reset_sheet_row(ivas(), n); }
|
||||
|
||||
void* get_app_data() { return _app_data; }
|
||||
void set_app_data(void* v) { _app_data = v; }
|
||||
|
||||
// skadenzarium
|
||||
Pagamento* pagamento() { return _pag; }
|
||||
void set_pagamento(const char* c, const char* d);
|
||||
void set_scadenze(TMask& m);
|
||||
bool read_scadenze(const TMask& m);
|
||||
void write_scadenze(const TMask& m);
|
||||
|
||||
static TPrimanota_application& app() { return (TPrimanota_application&)main_app(); }
|
||||
|
||||
public:
|
||||
TPrimanota_application();
|
||||
};
|
||||
|
368
cg/cg2104.cpp
368
cg/cg2104.cpp
@ -5,28 +5,18 @@
|
||||
|
||||
#include "cg2102.h"
|
||||
#include "cg2100.h"
|
||||
#include "cg2104a.h"
|
||||
#include "cg21sld.h"
|
||||
#include "pagament.h"
|
||||
|
||||
struct shuttle
|
||||
{
|
||||
Pagamento* _pag; // pagamento
|
||||
TSheet_field* _sheet; // sheet
|
||||
TMask* _mask; // maschera
|
||||
TArray* _rows; // righe spreadsheet nella versione originale
|
||||
};
|
||||
|
||||
bool TPrimanota_application::pag_notify(int r, KEY k)
|
||||
{
|
||||
// questo e' il bello
|
||||
shuttle* sh = (shuttle*)(((TPrimanota_application&)main_app()).get_app_data());
|
||||
|
||||
Pagamento* pag = sh->_pag;
|
||||
TSheet_field* ps = sh->_sheet;
|
||||
TMask* msk = sh->_mask;
|
||||
TArray* rws = sh->_rows;
|
||||
Pagamento* pag = app().pagamento();
|
||||
TSheet_field* ps = &(app().pags());
|
||||
TMask* msk = &(app().curr_mask());
|
||||
TArray* rws = app().pag_rows();
|
||||
|
||||
int rdiff = atoi(msk->get(F_RDIFFER));
|
||||
int rdiff = atoi(msk->get(FS_RDIFFER));
|
||||
|
||||
// ts contiene la vecchia riga, ns la nuova
|
||||
TToken_string ts(36), ns(36);
|
||||
@ -38,8 +28,8 @@ bool TPrimanota_application::pag_notify(int r, KEY k)
|
||||
|
||||
TString news(15), newi(15), newp(15), newt(2);
|
||||
|
||||
bool recalc = msk->get_bool(F_RECALC);
|
||||
bool mcomm = msk->get_bool(F_MCOMM);
|
||||
bool recalc = msk->get_bool(FS_RECALC);
|
||||
bool mcomm = msk->get_bool(FS_MCOMM);
|
||||
|
||||
switch (k)
|
||||
{
|
||||
@ -65,7 +55,8 @@ bool TPrimanota_application::pag_notify(int r, KEY k)
|
||||
}
|
||||
if (strcmp(ts.get(2),newi) != 0) // modificato importo
|
||||
{
|
||||
if ((recalc && !m_perc) || (!recalc)) // se si modifica la percentuale l'importo non viene cagato
|
||||
// se si modifica la percentuale l'importo non viene cagato
|
||||
if ((recalc && !m_perc) || (!recalc))
|
||||
{
|
||||
mod = m_imp = TRUE;
|
||||
}
|
||||
@ -101,7 +92,7 @@ bool TPrimanota_application::pag_notify(int r, KEY k)
|
||||
(m_tipo ? (const char*)newt : NULL),
|
||||
rdiff, mcomm, need_recalc);
|
||||
// see if rdiff changed
|
||||
msk->field(F_RDIFFER).set(pag->rate_differenziate() ? "1" : "2");
|
||||
msk->field(FS_RDIFFER).set(pag->rate_differenziate() ? "1" : "2");
|
||||
}
|
||||
if (!recalc)
|
||||
{
|
||||
@ -147,24 +138,43 @@ bool TPrimanota_application::pag_notify(int r, KEY k)
|
||||
return doit;
|
||||
}
|
||||
|
||||
void TPrimanota_application::aggiorna_scadenzario(const TMask& m)
|
||||
bool TPrimanota_application::codpag_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
if (key == K_TAB && f.focusdirty() && app().is_saldaconto())
|
||||
{
|
||||
TString dt(f.mask().get(F_DATAREG));
|
||||
app().set_pagamento(f.get(),dt);
|
||||
app().set_scadenze(f.mask());
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TPrimanota_application::set_pagamento(const char* c, const char* d)
|
||||
{
|
||||
if (_pag != NULL) delete _pag;
|
||||
_pag = new Pagamento(c,d);
|
||||
}
|
||||
|
||||
void TPrimanota_application::set_scadenze(TMask& m)
|
||||
{
|
||||
real imponibile(0.0);
|
||||
real imposta(0.0);
|
||||
real spese(0.0);
|
||||
TString dt(m.get(F_DATAREG));
|
||||
Pagamento pag(m.get(F_CODPAG), (const char*)dt);
|
||||
|
||||
if (pag.is_new()) return;
|
||||
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
|
||||
|
||||
TMask ms("cg2104a");
|
||||
TSheet_field& ps = (TSheet_field&)ms.field(F_RATESHEET);
|
||||
ps.set_notify(pag_notify);
|
||||
|
||||
ms.field(F_RDIFFER).set(pag.rate_differenziate() ? "1" : "2");
|
||||
ms.field(F_NAMEPAG).set(pag.name());
|
||||
ms.field(F_TIPOPR).set(pag.desc_tpr());
|
||||
ms.field(F_MCOMM).set(pag.mese_commerciale() ? "X" : "");
|
||||
if (_pag->is_new())
|
||||
{
|
||||
m.disable_page(2);
|
||||
return;
|
||||
}
|
||||
else m.enable_page(2);
|
||||
|
||||
m.field(FS_RDIFFER).set(_pag->rate_differenziate() ? "1" : "2");
|
||||
m.field(FS_NAMEPAG).set(_pag->name());
|
||||
m.field(FS_TIPOPR).set(_pag->desc_tpr());
|
||||
m.field(FS_MCOMM).set(_pag->mese_commerciale() ? "X" : "");
|
||||
|
||||
TSheet_field& iva_sh = ivas();
|
||||
|
||||
@ -175,23 +185,61 @@ void TPrimanota_application::aggiorna_scadenzario(const TMask& m)
|
||||
real imp(tt.get(3));
|
||||
imponibile += mpo;
|
||||
imposta += imp;
|
||||
// TBI: le spese che cazzo sono?
|
||||
// -----------------------------
|
||||
}
|
||||
|
||||
ms.field(F_IMPONIBILE).set(imponibile.string());
|
||||
ms.field(F_IMPOSTA).set(imposta.string());
|
||||
ms.field(F_SPESE).set(spese.string());
|
||||
ms.field(F_RECALC).set("X");
|
||||
m.field(FS_IMPONIBILE).set(imponibile.string());
|
||||
m.field(FS_IMPOSTA).set(imposta.string());
|
||||
m.field(FS_SPESE).set(spese.string());
|
||||
m.field(FS_RECALC).set("X");
|
||||
|
||||
pag.set_total(imponibile, imposta, spese);
|
||||
_pag->set_total(imponibile, imposta, spese);
|
||||
_pag->set_rate_auto();
|
||||
bool new_part = TRUE;
|
||||
|
||||
// prepara lo sheet
|
||||
_pag->set_sheet(ps);
|
||||
if (_pag_rows != NULL) delete _pag_rows;
|
||||
_pag_rows = new TArray(ps.rows_array());
|
||||
|
||||
// se c'e' una rateazione gia' registrata
|
||||
// zappettare e settare le rate a mano
|
||||
bool new_part = FALSE;
|
||||
// se la prima rata e' fissa non si tocca
|
||||
if (_pag->tipo_prima_rata() > 0)
|
||||
{
|
||||
ps.disable_cell(0,0);
|
||||
ps.disable_cell(0,1);
|
||||
ps.disable_cell(0,2);
|
||||
ps.disable_cell(0,3);
|
||||
}
|
||||
}
|
||||
|
||||
bool TPrimanota_application::read_scadenze(const TMask& m)
|
||||
{
|
||||
real imponibile(0.0);
|
||||
real imposta(0.0);
|
||||
real spese(0.0);
|
||||
TString dt(m.get(F_DATAREG));
|
||||
|
||||
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
|
||||
|
||||
// should never happen but it doesn't hurt
|
||||
if (_rel->cg(0).empty()) return;
|
||||
if (_rel->cg(0).empty()) return FALSE;
|
||||
|
||||
TSheet_field& iva_sh = ivas();
|
||||
|
||||
for (int i = 0; i < iva_sh.items(); i++)
|
||||
{
|
||||
TToken_string& tt = iva_sh.row(i);
|
||||
real mpo(tt.get(0));
|
||||
real imp(tt.get(3));
|
||||
imponibile += mpo;
|
||||
imposta += imp;
|
||||
}
|
||||
|
||||
m.field(FS_IMPONIBILE).set(imponibile.string());
|
||||
m.field(FS_IMPOSTA).set(imposta.string());
|
||||
m.field(FS_SPESE).set(spese.string());
|
||||
m.field(FS_RECALC).set("X");
|
||||
|
||||
_pag->set_total(imponibile, imposta, spese);
|
||||
|
||||
TLocalisamfile partita (LF_PARTITE);
|
||||
TLocalisamfile scadenza(LF_SCADENZE);
|
||||
@ -233,7 +281,7 @@ void TPrimanota_application::aggiorna_scadenzario(const TMask& m)
|
||||
if (partita.read() == NOERR)
|
||||
{
|
||||
// se si e' specificato un codice pagamento diverso si rifa' da capo
|
||||
if (pag.code() != partita.get("CODPAG"))
|
||||
if (_pag->code() != partita.get("CODPAG"))
|
||||
fromscratch = TRUE;
|
||||
// se invece la maschera contiene importi diversi da quelli
|
||||
// registrati si passa la palla al culano
|
||||
@ -241,17 +289,17 @@ void TPrimanota_application::aggiorna_scadenzario(const TMask& m)
|
||||
imposta != partita.get_real("IMPOSTA") ||
|
||||
spese != partita.get_real("SPESE"))
|
||||
{
|
||||
fromscratch = !yesno_box("Gli importi totali sono stati modificati rispetto"
|
||||
fromscratch = !yesno_box("Gli importi totali delle scadenze sono stati modificati rispetto"
|
||||
" all'ultima registrazione. Si desidera mantenere"
|
||||
" comunque la rateazione precedente");
|
||||
// nel caso, of course, si disabilitano gli automatismi
|
||||
if(!fromscratch) ms.field(F_RECALC).set("");
|
||||
if(!fromscratch) m.field(FS_RECALC).set("");
|
||||
}
|
||||
if (fromscratch)
|
||||
pag.set_rate_auto();
|
||||
_pag->set_rate_auto();
|
||||
else
|
||||
{
|
||||
pag.zap_rate();
|
||||
_pag->zap_rate();
|
||||
|
||||
for (int i = 0; ; i++)
|
||||
{
|
||||
@ -267,31 +315,28 @@ void TPrimanota_application::aggiorna_scadenzario(const TMask& m)
|
||||
|
||||
if (scadenza.read() == NOERR)
|
||||
{
|
||||
// TBI setta rate
|
||||
real importo = scadenza.get("IMPORTOVAL");
|
||||
TDate scad = scadenza.get("DATASCAD");
|
||||
int tipop = scadenza.get_int("TIPOPAG");
|
||||
bool paid = scadenza.get_bool("PAGATA");
|
||||
TString ulc(scadenza.get("ULTCLASS"));
|
||||
|
||||
pag.set_rata(i, importo, scad, tipop, ulc, paid);
|
||||
_pag->set_rata(i, importo, scad, tipop, ulc, paid);
|
||||
}
|
||||
else break;
|
||||
} // for
|
||||
} //else
|
||||
}
|
||||
else
|
||||
{
|
||||
pag.set_rate_auto();
|
||||
new_part = TRUE;
|
||||
}
|
||||
|
||||
// prepara lo sheet
|
||||
pag.set_sheet(ps);
|
||||
TArray rows(ps.rows_array());
|
||||
return FALSE;
|
||||
|
||||
_pag->set_sheet(ps);
|
||||
|
||||
if (_pag_rows != NULL) delete _pag_rows;
|
||||
_pag_rows = new TArray(ps.rows_array());
|
||||
|
||||
// se la prima rata e' fissa non si tocca
|
||||
if (pag.tipo_prima_rata() > 0)
|
||||
if (_pag->tipo_prima_rata() > 0)
|
||||
{
|
||||
ps.disable_cell(0,0);
|
||||
ps.disable_cell(0,1);
|
||||
@ -299,92 +344,115 @@ void TPrimanota_application::aggiorna_scadenzario(const TMask& m)
|
||||
ps.disable_cell(0,3);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TPrimanota_application::write_scadenze(const TMask& m)
|
||||
{
|
||||
real imponibile(0.0);
|
||||
real imposta(0.0);
|
||||
real spese(0.0);
|
||||
|
||||
// should never happen but it doesn't hurt
|
||||
if (_rel->cg(0).empty()) return;
|
||||
|
||||
TLocalisamfile partita (LF_PARTITE);
|
||||
TLocalisamfile scadenza(LF_SCADENZE);
|
||||
|
||||
shuttle sh;
|
||||
TString nreg(_rel->lfile().get("NUMREG"));
|
||||
TString ndoc(_rel->lfile().get("NUMDOC"));
|
||||
TString tmov(_rel->lfile().get("TIPOMOV"));
|
||||
TDate ddoc(_rel->lfile().get_date("DATADOC"));
|
||||
TDate dreg(_rel->lfile().get_date("DATAREG"));
|
||||
TString reg (_rel->lfile().get("REG"));
|
||||
TString protiva(_rel->lfile().get("PROTIVA"));
|
||||
TString codcaus(_rel->lfile().get("CODCAUS"));
|
||||
TString codval (_rel->lfile().get("CODVAL"));
|
||||
TString cambio (_rel->lfile().get("CAMBIO"));
|
||||
|
||||
sh._pag = &pag;
|
||||
sh._sheet = &ps;
|
||||
sh._mask = &ms;
|
||||
sh._rows = &rows;
|
||||
TString numpart = m.get(F_NUMRIF);
|
||||
TString anno = m.get(F_ANNORIF);
|
||||
|
||||
set_app_data(&sh);
|
||||
char sezione = _rel->cg(0).get_char("SEZIONE"); // Dare/Avere
|
||||
char tipocf = _rel->cg(0).get_char("TIPOC"); // Cliente || Fornitore || Uncazzo
|
||||
int gruppo = (tipocf == 'C' || tipocf == 'F') ? 0 :
|
||||
_rel->cg(0).get_char("GRUPPO");
|
||||
int conto = (tipocf == 'C' || tipocf == 'F') ? 0 :
|
||||
_rel->cg(0).get_char("fCONTO");
|
||||
long sottoconto = _rel->cg(0).get_long("SOTTOCONTO");
|
||||
int nriga = 1;
|
||||
int numrig = 1;
|
||||
|
||||
if (ms.run() == K_SAVE)
|
||||
partita.put("TIPOCF", tipocf);
|
||||
partita.put("GRUPPO", gruppo);
|
||||
partita.put("CONTO", conto);
|
||||
partita.put("SOTTOCONTO", sottoconto);
|
||||
partita.put("ANNO", anno);
|
||||
partita.put("NUMPART", numpart);
|
||||
partita.put("NRIGA", nriga);
|
||||
|
||||
bool fromscratch = FALSE, new_part = TRUE;
|
||||
|
||||
if (partita.read() == NOERR)
|
||||
{
|
||||
// se si e' specificato un codice pagamento diverso si rifa' da capo
|
||||
if (_pag->code() != partita.get("CODPAG"))
|
||||
fromscratch = TRUE;
|
||||
new_part = FALSE;
|
||||
}
|
||||
|
||||
// se modificato riaggiusta partite e scadenze
|
||||
if (_pag->dirty() || new_part)
|
||||
{
|
||||
// se modificato riaggiusta partite e scadenze
|
||||
if (pag.dirty() || new_part)
|
||||
if (new_part)
|
||||
{
|
||||
if (new_part)
|
||||
{
|
||||
partita.zero();
|
||||
partita.put("TIPOCF", tipocf);
|
||||
partita.put("GRUPPO", gruppo);
|
||||
partita.put("CONTO", conto);
|
||||
partita.put("SOTTOCONTO", sottoconto);
|
||||
partita.put("ANNO", anno);
|
||||
partita.put("NUMPART", numpart);
|
||||
partita.put("NRIGA", nriga);
|
||||
}
|
||||
// put data on partita
|
||||
partita.put("TIPOMOV",tmov);
|
||||
partita.put("NREG", nreg);
|
||||
partita.put("DATAREG",dreg);
|
||||
partita.put("DATADOC",ddoc);
|
||||
partita.put("REG", reg);
|
||||
partita.put("PROTIVA",protiva);
|
||||
partita.put("CODCAUS",codcaus);
|
||||
partita.put("SEZ", sezione);
|
||||
partita.put("CODPAG", pag.code());
|
||||
partita.put("CODVAL", codval);
|
||||
partita.put("CAMBIO", cambio);
|
||||
partita.put("IMPORTO",pag.imponibile());
|
||||
partita.put("IMPOSTA",pag.imposta());
|
||||
partita.put("SPESE", pag.spese());
|
||||
partita.put("NUMRIG", numrig);
|
||||
partita.zero();
|
||||
partita.put("TIPOCF", tipocf);
|
||||
partita.put("GRUPPO", gruppo);
|
||||
partita.put("CONTO", conto);
|
||||
partita.put("SOTTOCONTO", sottoconto);
|
||||
partita.put("ANNO", anno);
|
||||
partita.put("NUMPART", numpart);
|
||||
partita.put("NRIGA", nriga);
|
||||
}
|
||||
|
||||
// put data on partita
|
||||
partita.put("TIPOMOV",tmov);
|
||||
partita.put("NREG", nreg);
|
||||
partita.put("DATAREG",dreg);
|
||||
partita.put("DATADOC",ddoc);
|
||||
partita.put("REG", reg);
|
||||
partita.put("PROTIVA",protiva);
|
||||
partita.put("CODCAUS",codcaus);
|
||||
partita.put("SEZ", sezione);
|
||||
partita.put("CODPAG", _pag->code());
|
||||
partita.put("CODVAL", codval);
|
||||
partita.put("CAMBIO", cambio);
|
||||
partita.put("IMPORTO",_pag->imponibile());
|
||||
partita.put("IMPOSTA",_pag->imposta());
|
||||
partita.put("SPESE", _pag->spese());
|
||||
partita.put("NUMRIG", numrig);
|
||||
|
||||
if (new_part) partita.write();
|
||||
else partita.rewrite();
|
||||
if (new_part) partita.write();
|
||||
else partita.rewrite();
|
||||
|
||||
bool new_scad = FALSE;
|
||||
bool new_scad = FALSE;
|
||||
|
||||
for (int i = 0; i < pag.n_rate(); i++)
|
||||
{
|
||||
new_scad = FALSE;
|
||||
scadenza.zero();
|
||||
scadenza.put("TIPOCF", tipocf);
|
||||
scadenza.put("GRUPPO", gruppo);
|
||||
scadenza.put("CONTO", conto);
|
||||
scadenza.put("SOTTOCONTO", sottoconto);
|
||||
scadenza.put("ANNO", anno);
|
||||
scadenza.put("NUMPART", numpart);
|
||||
scadenza.put("NRATA", i+1);
|
||||
for (int i = 0; i < _pag->n_rate(); i++)
|
||||
{
|
||||
new_scad = FALSE;
|
||||
scadenza.zero();
|
||||
scadenza.put("TIPOCF", tipocf);
|
||||
scadenza.put("GRUPPO", gruppo);
|
||||
scadenza.put("CONTO", conto);
|
||||
scadenza.put("SOTTOCONTO", sottoconto);
|
||||
scadenza.put("ANNO", anno);
|
||||
scadenza.put("NUMPART", numpart);
|
||||
scadenza.put("NRATA", i+1);
|
||||
|
||||
if (scadenza.read() != NOERR)
|
||||
{
|
||||
new_scad = TRUE;
|
||||
scadenza.zero();
|
||||
scadenza.put("TIPOCF", tipocf);
|
||||
scadenza.put("GRUPPO", gruppo);
|
||||
scadenza.put("CONTO", conto);
|
||||
scadenza.put("SOTTOCONTO", sottoconto);
|
||||
scadenza.put("ANNO", anno);
|
||||
scadenza.put("NUMPART", numpart);
|
||||
scadenza.put("NRATA", i+1);
|
||||
}
|
||||
// set everything
|
||||
scadenza.put("CODPAG", pag.code());
|
||||
scadenza.put("TIPOPAG", pag.tipo_rata(i));
|
||||
scadenza.put("ULTCLASS", pag.ulc_rata(i));
|
||||
scadenza.put("IMPORTOVAL",pag.tpay_rata(i));
|
||||
scadenza.put("DATASCAD", pag.data_rata(i));
|
||||
scadenza.put("PAGATA", pag.ratapagata(i));
|
||||
|
||||
if (new_scad) scadenza.write();
|
||||
else scadenza.rewrite();
|
||||
}
|
||||
// elimina eventuali altre scadenze oltre l'ultima registrata
|
||||
for (; !new_scad ; i++)
|
||||
{
|
||||
if (scadenza.read() != NOERR)
|
||||
{
|
||||
new_scad = TRUE;
|
||||
scadenza.zero();
|
||||
scadenza.put("TIPOCF", tipocf);
|
||||
scadenza.put("GRUPPO", gruppo);
|
||||
@ -393,11 +461,33 @@ void TPrimanota_application::aggiorna_scadenzario(const TMask& m)
|
||||
scadenza.put("ANNO", anno);
|
||||
scadenza.put("NUMPART", numpart);
|
||||
scadenza.put("NRATA", i+1);
|
||||
|
||||
if (scadenza.read() == NOERR)
|
||||
scadenza.remove();
|
||||
else new_scad = TRUE;
|
||||
}
|
||||
// set everything
|
||||
scadenza.put("CODPAG", _pag->code());
|
||||
scadenza.put("TIPOPAG", _pag->tipo_rata(i));
|
||||
scadenza.put("ULTCLASS", _pag->ulc_rata(i));
|
||||
scadenza.put("IMPORTOVAL",_pag->tpay_rata(i));
|
||||
scadenza.put("DATASCAD", _pag->data_rata(i));
|
||||
scadenza.put("PAGATA", _pag->ratapagata(i));
|
||||
|
||||
if (new_scad) scadenza.write();
|
||||
else scadenza.rewrite();
|
||||
}
|
||||
// elimina eventuali altre scadenze oltre l'ultima registrata
|
||||
for (; !new_scad ; i++)
|
||||
{
|
||||
scadenza.zero();
|
||||
scadenza.put("TIPOCF", tipocf);
|
||||
scadenza.put("GRUPPO", gruppo);
|
||||
scadenza.put("CONTO", conto);
|
||||
scadenza.put("SOTTOCONTO", sottoconto);
|
||||
scadenza.put("ANNO", anno);
|
||||
scadenza.put("NUMPART", numpart);
|
||||
scadenza.put("NRATA", i+1);
|
||||
|
||||
if (scadenza.read() == NOERR)
|
||||
scadenza.remove();
|
||||
else new_scad = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
20
cg/cg2104a.h
20
cg/cg2104a.h
@ -1,10 +1,10 @@
|
||||
#define F_RATESHEET 101
|
||||
#define F_TOTAL 102
|
||||
#define F_RDIFFER 103
|
||||
#define F_IMPONIBILE 104
|
||||
#define F_IMPOSTA 105
|
||||
#define F_SPESE 106
|
||||
#define F_RECALC 107
|
||||
#define F_NAMEPAG 108
|
||||
#define F_TIPOPR 109
|
||||
#define F_MCOMM 110
|
||||
#define FS_RATESHEET 501
|
||||
#define FS_TOTAL 502
|
||||
#define FS_RDIFFER 503
|
||||
#define FS_IMPONIBILE 504
|
||||
#define FS_IMPOSTA 505
|
||||
#define FS_SPESE 506
|
||||
#define FS_RECALC 507
|
||||
#define FS_NAMEPAG 508
|
||||
#define FS_TIPOPR 509
|
||||
#define FS_MCOMM 510
|
@ -83,7 +83,8 @@ bool TLiquidazione_app::user_create()
|
||||
char rcl = *(subj.get(3));
|
||||
_recalc_only = rcl == 'C';
|
||||
_is_visliq = rcl == 'V';
|
||||
_isregis = (rcl == 'l' || rcl == 'L'); // stampa per registri
|
||||
_isregis = (rcl == 'l' || rcl == 'L'); // stampa per registri
|
||||
// TBI usare S s per stampa senza ricalcolo
|
||||
_isfinal = rcl == 'l'; // se l minuscolo, definitivo
|
||||
printdate = subj.get(4);
|
||||
filename = subj.get(5);
|
||||
|
@ -881,6 +881,10 @@ void Pagamento::set_total(real& imponibile, real& imposta, real& spese)
|
||||
_secndr = _imposta + _spese;
|
||||
break;
|
||||
}
|
||||
|
||||
real toslice = _tpr > 1 ? _secndr : _firstr;
|
||||
|
||||
_slicer.init(toslice, TRUE);
|
||||
|
||||
for (int i = 0; i < _rate.items(); i++)
|
||||
{
|
||||
@ -970,7 +974,7 @@ _spese(0.0), _code(codtab), _dirty(FALSE), _inited(FALSE)
|
||||
{
|
||||
if (data != NULL)
|
||||
_inizio = data;
|
||||
if (_code.empty() || !read())
|
||||
if (_code.blank() || !read())
|
||||
_new = TRUE;
|
||||
if (_new && data != NULL) error_box("Modalita' pagamento inesistente");
|
||||
// if (_new && data != NULL) error_box("Modalita' pagamento inesistente");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user