cg0500.cpp Corretto salvataggio righe

cg0500?.uml   Aggiustate maschere
cg2100.cpp    Gestione cespiti
cg2100?.uml   Aggiustate maschere
cg2103.cpp    Aggiunti metodo a TCausale per cespiti
cg2200.cpp    Gestione movimenti provvisori dei cespiti
cglib01.cpp   Aggiunstata indentazione


git-svn-id: svn://10.65.10.50/trunk@4852 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1997-07-09 10:05:15 +00:00
parent 25f1002027
commit 562a8987b0
14 changed files with 118 additions and 198 deletions

View File

@ -751,13 +751,13 @@ int TCaus_app::re_write(const TMask& m, bool re)
for (int i = 0; i < ss().items(); i++)
{
TToken_string &riga = ss().row(i);
const int g = riga.get_int();
const int g = riga.get_int(3);
if (g > 0)
{
TRectype & r = _rcaus_rec->row(i+1, TRUE);
const char sezione = riga.get_char(1);
const char tipo_cf = riga.get_char();
const int c = riga.get_int();
const int c = riga.get_int(4);
const long s = riga.get_long();
riga.get(); // Salta descrizione conto
const TString80 coddesc(riga.get());

View File

@ -311,7 +311,7 @@ END
LISTBOX F_COLL_CESP 1 40
BEGIN
PROMPT 2 16 "Collegamento cespiti "
PROMPT 2 16 "Collegamento cespiti "
FIELD COLLCESP
ITEM " |Nessuno"
ITEM "A|Acquisto cespite"

View File

@ -76,6 +76,7 @@ BEGIN
DISPLAY "Conto" CONTO
DISPLAY "Sottoconto" SOTTOCONTO
DISPLAY "Descrizione@50" DESCR
DISPLAY "C/R" TIPOCR
OUTPUT SS_SOTTOCONTO SOTTOCONTO
OUTPUT 206 SOTTOCONTO
OUTPUT 306 SOTTOCONTO
@ -159,6 +160,7 @@ BEGIN
DISPLAY "Gruppo" GRUPPO
DISPLAY "Conto" CONTO
DISPLAY "Sottoconto" SOTTOCONTO
DISPLAY "C/R" TIPOCR
OUTPUT SS_SOTTOCONTO SOTTOCONTO
OUTPUT SS_CONTO CONTO
OUTPUT SS_GRUPPO GRUPPO

View File

@ -1,5 +1,6 @@
#include <config.h>
#include <mailbox.h>
#include <modaut.h>
#include <msksheet.h>
#include <urldefid.h>
#include <execp.h>
@ -1074,6 +1075,7 @@ int TPrimanota_application::write(const TMask& m)
}
link_m770();
link_cesp(m, "Insert");
}
lasterr = err;
@ -1116,6 +1118,7 @@ int TPrimanota_application::rewrite(const TMask& m)
}
link_m770();
link_cesp(m, "Modify");
}
return err;
@ -1130,11 +1133,11 @@ bool TPrimanota_application::remove()
_saldi.registra();
check_saldi();
TMask& m = curr_mask();
if (is_saldaconto())
{
if (is_fattura())
{
TMask& m = curr_mask();
m.reset(F_ANNORIF);
m.reset(F_NUMRIF);
write_scadenze(m);
@ -1145,6 +1148,7 @@ bool TPrimanota_application::remove()
partite().rewrite();
}
}
link_cesp(m, "Remove");
}
return ok;
}
@ -1153,177 +1157,6 @@ bool TPrimanota_application::remove()
// Gestione incasso immediato
///////////////////////////////////////////////////////////
/*
HIDDEN bool incasso_handler(TMask_field& f, KEY k)
{
if (k == K_ENTER)
{
TMask& m = f.mask();
TImporto tot(m.get(I_SEZIONE1)[0], (real)m.get(F_TOTALE));
for (int i = 2; i < 5; i++)
{
const int sid = i == 2 ? I_SEZIONE2 : (i == 3 ? I_SEZIONE3 : I_SEZIONE4);
const real val(m.get(sid+1));
const TImporto imp(m.get(sid)[0], val);
tot += imp;
}
if (!tot.is_zero())
return f.error_box("Il movimento e' sbilanciato di %s", tot.valore().string("."));
}
return TRUE;
}
void TPrimanota_application::genera_incasso(const char* causimm)
{
TMask m("cg2100i");
if (iva() == iva_acquisti) m.set_caption("Movimento di pagamento immediato");
m.set_handler(F_DATAREG, datareg_handler);
m.set_handler(F_DATACOMP, datacomp_handler);
m.set_handler(F_TOTALE, incasso_handler);
TCausale caus(causimm); // Causale da usare
if (caus.data_doc()) m.efield(F_DATADOC).check_type(CHECK_REQUIRED);
if (caus.num_doc()) m.efield(F_NUMDOC).check_type(CHECK_REQUIRED);
m.set(F_DATAREG, curr_mask().get(F_DATAREG));
m.set(F_DATACOMP, curr_mask().get(F_DATACOMP));
m.set(F_DATADOC, curr_mask().get(F_DATADOC));
m.set(F_NUMDOC, curr_mask().get(F_NUMDOC));
m.set(F_NUMREG, _lastreg+1); // Incrementa numero di registrazione
m.set(F_DESCR, caus.desc_agg(1)); // Descrizione
m.set(F_CODCAUS, causimm); // Cambia causale
m.set(F_DESCRCAUS, caus.descrizione());
m.set(I_SEZIONE1, caus.sezione_clifo() == 'D' ? "D" : "A");
m.set(F_TOTALE, curr_mask().get(F_TOTALE));
m.set(F_CLIFO, _rel->cg(0).get("TIPOC"));
m.set(F_GRUPPOCLIFO, _rel->cg(0).get("GRUPPO"));
m.set(F_CONTOCLIFO, _rel->cg(0).get("CONTO"));
const TString& clifo = _rel->cg(0).get("SOTTOCONTO");
m.set(F_CLIENTE, clifo); m.set(F_FORNITORE, clifo); m.set(I_SOTTOCONTO, clifo);
TBill conto; caus.bill(2, conto); // Conto della seconda riga della causale
m.set(I_SEZIONE2, caus.sezione_clifo() == 'D' ? "A" : "D");
m.set(I_IMPORTO2, curr_mask().get(F_TOTALE));
m.set(I_GRUPPO2, conto.gruppo());
m.set(I_CONTO2, conto.conto());
m.set(I_SOTTOCONTO2, conto.sottoconto());
if (m.run() == K_SAVE)
{
TMovimentoPN inc; // Nuovo movimento di incasso immediato
TRectype& curr = inc.curr();
curr.zero();
m.autosave(inc);
curr.put("TIPODOC", caus.tipo_doc()); // Tipo documento
curr.put("REG", caus.reg().name()); // Registro
curr.zero(MOV_TIPO);
curr.zero(MOV_CODCF);
curr.zero(MOV_TOTDOC);
curr.zero(MOV_ANNOIVA);
const int annoes = m.get_int(F_ANNOES);
const TString16 datareg = m.get(F_DATAREG);
long num = m.get_long(F_NUMREG);
inc.destroy_rows(num);
TRectype& r = inc.cg(0);
r.zero();
r.put("NUMREG", num);
r.put("NUMRIG", 1);
r.put("DATAREG", datareg);
r.put("ANNOES", annoes);
r.put("SEZIONE", m.get(I_SEZIONE1));
r.put("IMPORTO", m.get(F_TOTALE));
r.put("TIPOC", m.get(F_CLIFO));
r.put("GRUPPO", m.get(F_GRUPPOCLIFO));
r.put("CONTO", m.get(F_CONTOCLIFO));
short clifo_id;
switch (m.get(F_CLIFO)[0])
{
case 'C':
clifo_id = F_CLIENTE; break;
case 'F':
clifo_id = F_FORNITORE; break;
default :
clifo_id = I_SOTTOCONTO; break;
}
r.put("SOTTOCONTO", m.get(clifo_id));
r.put("DESCR", m.get(F_DESCR));
r.put("TIPOCC", " ");
r.put("GRUPPOC", m.get(I_GRUPPO2));
r.put("CONTOC", m.get(I_CONTO2));
r.put("SOTTOCONTC", m.get(I_SOTTOCONTO2));
r.put("ROWTYPE", " ");
for (int i = 2; i < 5; i++)
{
const int sid = i == 2 ? I_SEZIONE2 : (i == 3 ? I_SEZIONE3 : I_SEZIONE4);
const TString& imp = m.get(sid+1);
if (imp.empty()) break;
TRectype& r = inc.cg(i-1);
r.zero();
r.put("IMPORTO", imp);
r.put("NUMREG", num);
r.put("NUMRIG", i);
r.put("DATAREG", datareg);
r.put("ANNOES", annoes);
r.put("SEZIONE", m.get(sid));
r.put("TIPOC", ' ');
r.put("GRUPPO", m.get(sid+2));
r.put("CONTO", m.get(sid+3));
r.put("SOTTOCONTO", m.get(sid+4));
if (i == 2)
r.put("DESCR", caus.desc_agg(2));
r.put("TIPOCC", m.get(F_CLIFO));
r.put("GRUPPOC", m.get(F_GRUPPOCLIFO));
r.put("CONTOC", m.get(F_CONTOCLIFO));
r.put("SOTTOCONTC", m.get(clifo_id));
r.put("ROWTYPE", " ");
}
while (inc.write() == _isreinsert) // In caso di riscrittura
{
num++; // Incrementa numero registrazione
inc.lfile().put("NUMREG", num);
}
if (inc.good())
{
if (num > _lastreg) _lastreg = num;
_saldi.reset(); // Inizializza saldi
_saldi.set_movprovv(FALSE);
_saldi.set_tipo_saldo(normale);
_saldi.set_anno_es(m.get_int(F_ANNOES));
_saldi.set_num_ulmov(_lastreg);
_saldi.set_data_ulmov((TDate)m.get(F_DATAREG));
for (int r = 0; r < inc.cg_items(); r++)
{
const TRectype& rec = inc.cg(r);
TBill c; c.get(rec);
const TImporto im(rec.get_char("SEZIONE"), rec.get_real("IMPORTO"));
_saldi.aggiorna(c, im, TRUE);
}
_saldi.registra();
check_saldi();
}
}
}
*/
void TPrimanota_application::genera_incasso(const char* causimm)
{
TMask& m = curr_mask();
@ -1699,11 +1532,14 @@ void TPrimanota_application::ini2mask(TConfig& ini, TMask& msk, bool query)
}
}
void TPrimanota_application::mask2ini(TMask& msk, TConfig& ini)
void TPrimanota_application::mask2ini(const TMask& msk, TConfig& ini)
{
TRelation_application::mask2ini(msk, ini);
ini.set("DESCRCAUS", msk.get(F_DESCRCAUS));
const TEsercizio& annoes = _esercizi[msk.get_int(F_ANNOES)];
ini.set("INIZIOES", annoes.inizio());
ini.set("FINEES", annoes.fine());
int i, f;
for (i = 0; i < _rel->cg_items(); i++)
@ -1719,6 +1555,7 @@ void TPrimanota_application::mask2ini(TMask& msk, TConfig& ini)
const TBill zio(rec);
ini.set("DESCRCONTO", zio.descrizione());
ini.set("TIPOCR", zio.tipo_cr());
const TBill french(rec, TRUE);
ini.set("DESCRCONTOC", french.descrizione());
@ -1761,6 +1598,43 @@ void TPrimanota_application::mask2ini(TMask& msk, TConfig& ini)
}
}
bool TPrimanota_application::link_cesp(const TMask& msk, const char* action)
{
// Controlla autorizzazione
if (!has_module(CEAUT))
return FALSE;
// Controlla flag sulla causale
if (causale().link_cespiti() <= ' ')
return FALSE;
// Cerca una riga con tipo costo/ricavo
for (int i = _rel->cg_items()-1; i >= 0; i--)
{
const TRectype& rec = _rel->cg(i);
const TBill zio(rec);
char tipo_cr = char('0' + zio.tipo_cr());
if (strchr("2348", tipo_cr))
break;
}
if (i < 0)
return FALSE;
TFilename cespini;
cespini.tempdir();
cespini.add("ActCsp.ini");
TConfig cespo(cespini, "Transaction");
cespo.set("Action", action);
mask2ini(msk, cespo);
TString appname;
appname << "cgcesp /i" << cespini;
TExternal_app app(appname);
bool ok = app.run() == 0;
return ok;
}
bool TPrimanota_application::protected_record(TRectype& mov)
{
bool ok = !TRelation_application::protected_record(mov);

View File

@ -106,6 +106,7 @@ BEGIN
FIELD PROVVIS
ITEM " |No (movimento normale)"
ITEM "P|Si (cancellabile)"
ITEM "C|Cespiti"
END
STRING F_TIPODOC 2

View File

@ -7,7 +7,7 @@ TOOLBAR "" 0 19 0 3
BUTTON F_ADJUST_PRORATA 40
BEGIN
PROMPT 1 -3 "Correzione ~automatica righe contabili"
PROMPT 1 -3 "Corre&zione automatica righe contabili"
FLAGS "H"
END
@ -167,6 +167,7 @@ BEGIN
ITEM " |No (movimento normale)"
ITEM "P|Si (cancellabile)"
ITEM "N|Si (Non cancellabile)"
ITEM "C|Cespiti"
FLAGS "DG"
END

View File

@ -9,7 +9,7 @@ END
BUTTON 102 10 2
BEGIN
PROMPT -13 -1 "~Azzera"
PROMPT -13 -1 "A~zzera"
END
BUTTON DLG_CANCEL 10 2

View File

@ -147,7 +147,7 @@ protected: // TApplication
virtual void print();
virtual bool menu(MENU_TAG m);
virtual void ini2mask(TConfig& ini, TMask& msk, bool query);
virtual void mask2ini(TMask& msk, TConfig& ini);
virtual void mask2ini(const TMask& msk, TConfig& ini);
protected: // TRelation_application
virtual bool user_create();
@ -265,6 +265,7 @@ protected:
bool is_percipient(long forn, char& tipper, long& codper) const;
long calcola_m770(int tipo_coll, real& spese, real& compenso, real& iva, real& ritfis);
bool link_m770();
bool link_cesp(const TMask& msk, const char* action);
public:
static char row_type(const TToken_string& s);

View File

@ -153,6 +153,9 @@ bool TCausale::saldaconto() const
int TCausale::link_m770() const
{ return _rec.get_int(CAU_M770); }
char TCausale::link_cespiti() const
{ return _rec.get_char(CAU_COLLCESP); }
bool TCausale::ok() const
{
if (iva() == iva_errata)

View File

@ -50,6 +50,7 @@ public:
int tipomov() const;
bool saldaconto() const;
int link_m770() const;
char link_cespiti() const;
bool similar(const TCausale& c) const;

View File

@ -40,7 +40,8 @@ class TProvvisori_app : public TApplication
TLocalisamfile* _cau;
TTable* _reg;
TString16 _from_caus, _to_caus;
char _provv; // Tipo provvisori da cancellare
TString16 _from_caus, _to_caus; // Causali movimenti da considerare
TSaldo_agg _saldi;
@ -61,7 +62,10 @@ public:
bool delete_provv(TCursor& cur, TProgind& pi);
static bool filter(const TRelation* rel);
void auto_delete(TCursor& cur);
TProvvisori_app() {};
virtual ~TProvvisori_app() {}
};
inline TProvvisori_app& app()
@ -230,14 +234,17 @@ bool TProvvisori_app::delete_provv(TCursor& cur, TProgind& pi)
bool TProvvisori_app::filter(const TRelation* rel)
{
bool ok = FALSE;
{
TProvvisori_app& a = app();
const TRectype& mov = rel->curr();
if (mov.get_char(MOV_PROVVIS) > ' ')
const char provv = mov.get_char(MOV_PROVVIS);
bool ok = (a._provv <= ' ' && provv > ' ' || a._provv == provv);
if (ok)
{
const char* caus = mov.get(MOV_CODCAUS);
ok = app()._from_caus <= caus && app()._to_caus >= caus;
ok = a._from_caus <= caus && a._to_caus >= caus;
}
return ok;
@ -256,13 +263,34 @@ bool TProvvisori_app::date_handler(TMask_field& f, KEY k)
return ok;
}
void TProvvisori_app::auto_delete(TCursor& cur)
{
_from_caus = "";
_to_caus = "ZZZ";
_provv = argv(2)[0];
cur.set_filterfunction(filter);
const long total = cur.items();
TProgind pi(total, "Cancellazione", FALSE, TRUE, 24);
cur.freeze(TRUE);
delete_provv(cur, pi);
cur.freeze(FALSE);
}
bool TProvvisori_app::menu(MENU_TAG)
{
TMask m("cg2200a");
m.set_handler(F_FROMDATE, date_handler);
TCursor& cur = *m.efield(F_FROMDATE).browse()->cursor();
if (argc() > 2)
{
auto_delete(cur);
return FALSE;
}
while (TRUE)
{
TRectype from(LF_MOV), to(LF_MOV);
@ -270,11 +298,8 @@ bool TProvvisori_app::menu(MENU_TAG)
cur.set_filterfunction(NULL);
m.reset();
const KEY key = m.run();
if (key == K_QUIT)
break;
KEY key = m.run();
TString16 from_d = m.get(F_FROMDATE);
TString16 to_d = m.get(F_TODATE);
@ -299,7 +324,8 @@ bool TProvvisori_app::menu(MENU_TAG)
}
}
if (from_d.not_empty()) from.put(MOV_DATAREG, from_d);
if (from_d.not_empty())
from.put(MOV_DATAREG, from_d);
const TString& from_r = m.get(F_FROMREG);
if (from_r.not_empty()) from.put(MOV_NUMREG, from_r);
@ -313,6 +339,8 @@ bool TProvvisori_app::menu(MENU_TAG)
_to_caus = m.get(F_TOCAUS);
_provv = m.get(F_PROVV)[0];
cur.setregion(from, to);
cur.set_filterfunction(filter);
@ -344,7 +372,7 @@ bool TProvvisori_app::menu(MENU_TAG)
confirm_provv(cur, pi);
else
delete_provv(cur, pi);
cur.freeze(FALSE);
}

View File

@ -2,6 +2,7 @@
#define F_FROMREG 102
#define F_FROMCAUS 103
#define F_FROMCAUSDESC 104
#define F_PROVV 105
#define F_TODATE 111
#define F_TOREG 112
#define F_TOCAUS 113

View File

@ -1,6 +1,6 @@
#include "cg2200.h"
PAGE "Gestione Movimenti Provvisori" -1 -1 52 11
PAGE "Gestione Movimenti Provvisori" -1 -1 52 12
GROUPBOX DLG_NULL 50 4
BEGIN
@ -11,13 +11,14 @@ DATE F_FROMDATE
BEGIN
PROMPT 2 2 "Data "
HELP "Data del primo movimento provvisorio"
USE LF_MOV KEY 2 SELECT PROVVIS="P"
USE LF_MOV KEY 2 SELECT PROVVIS!=""
INPUT DATAREG F_FROMDATE
INPUT NUMREG F_FROMREG
DISPLAY "Data@10" DATAREG
DISPLAY "Numero@6" NUMREG
DISPLAY "Causale" CODCAUS
DISPLAY "Documento" NUMDOC
DISPLAY "Documento" NUMDOC
DISPLAY "Tipo" PROVVIS
DISPLAY "Descrizione@50" DESCR
OUTPUT F_FROMDATE DATAREG
OUTPUT F_FROMREG NUMREG
@ -95,6 +96,13 @@ BEGIN
COPY OUTPUT F_TOCAUS
END
LIST F_PROVV 10
BEGIN
PROMPT 2 9 "Tipo "
ITEM " |Tutti"
ITEM "P|Contabili"
ITEM "C|Cespiti"
END
BUTTON DLG_OK 10 2
BEGIN

View File

@ -683,7 +683,7 @@ bool TBill::read(TRectype &r)
_tipo_cr = r.get_int("TIPOSPRIC");
_sezione = r.get_char("SEZSALDI");
set_description(r.get("DESCR"));
_sospeso = r.get_bool("SOSPESO");
_sospeso = r.get_bool("SOSPESO");
}
else
r.zero();
@ -713,7 +713,7 @@ int TBill::tipo_att()
const TString& TBill::descrizione() const
{
TBill& myself = (TBill&)*this;
// Se il conto e valido (c'e' almeno il gruppo) cerca la sua descrizione su file
// Se il conto e' valido (c'e' almeno il gruppo) cerca la sua descrizione su file
if ((_descrizione == NULL || _descrizione->blank()) && gruppo() != 0)
{
if (!myself.find())