b5da2ff050
git-svn-id: svn://10.65.10.50/trunk@1713 c028cbd2-c16b-5b4b-a496-9718f37d4682
665 lines
23 KiB
C++
Executable File
665 lines
23 KiB
C++
Executable File
#include "cg2102.h" // Applicazione di prima nota
|
|
|
|
#include "cg2100.h" // Campi maschere prima nota
|
|
#include "cg2100p.h" // Campi maschere partite e pagamenti
|
|
|
|
#include <clifo.h> // Archivio clienti/fornitori
|
|
#include <partite.h> // Archivio partite
|
|
#include <scadenze.h> // Archivio scadenze
|
|
#include <pagsca.h> // Archivio pagamenti
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Maschera partite
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TGame_mask : public TMask
|
|
{
|
|
const TBill _conto; // Conto fisso
|
|
|
|
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 show_all_handler(TMask_field& f, KEY k);
|
|
static bool scambio_handler(TMask_field& f, KEY k);
|
|
static bool edit_scadenza_handler(TMask_field& f, KEY k);
|
|
|
|
void add_importo(TToken_string& s, const TImporto& i) const;
|
|
void fill_partite(bool all) const;
|
|
|
|
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; }
|
|
|
|
TGame_mask(const TBill& bill);
|
|
virtual ~TGame_mask() {}
|
|
};
|
|
|
|
TGame_mask::TGame_mask(const TBill& bill)
|
|
: TMask("cg2100p"), _conto(bill)
|
|
{
|
|
const char tipocf[2] = { bill.tipo(), '\0' };
|
|
set(P_TIPOC, tipocf);
|
|
set(P_GRUPPO, bill.gruppo());
|
|
set(P_CONTO, bill.conto());
|
|
set(P_SOTTOCONTO, bill.sottoconto());
|
|
set(P_DESCR, ((TBill&)bill).descrizione());
|
|
|
|
set_handler(P_ANNO, annopart_handler);
|
|
set_handler(P_NUMERO, numpart_handler);
|
|
set_handler(P_SHOWALL, show_all_handler);
|
|
set_handler(P_SCAMBIO, scambio_handler);
|
|
|
|
partite().set_notify(partite_notify);
|
|
scadenze().sheet_mask().set_handler(100, edit_scadenza_handler);
|
|
}
|
|
|
|
bool TGame_mask::annopart_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_TAB && f.dirty() && f.get().not_empty())
|
|
{
|
|
TMask_field& n = f.mask().field(P_NUMERO);
|
|
n.set_dirty();
|
|
numpart_handler(f, k);
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool TGame_mask::numpart_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_TAB && f.dirty())
|
|
{
|
|
const TGame_mask& m = (const TGame_mask&)f.mask();
|
|
|
|
const int anno = m.get_int(P_ANNO);
|
|
const TString16 num = f.get();
|
|
if (anno > 0 && num.not_empty())
|
|
{
|
|
TSheet_field& sheet = m.partite();
|
|
for (int i = 0; i < sheet.items(); i++)
|
|
{
|
|
TToken_string& row = sheet.row(i);
|
|
if (anno == row.get_int(0)) // Se corrisponde l'anno e ...
|
|
if (num == row.get()) // corrisponde il numero partita ...
|
|
{
|
|
sheet.select(i); // ... seleziona la partita
|
|
partite_notify(sheet, i, K_TAB); // ed esplodi le sue righe
|
|
break;
|
|
}
|
|
}
|
|
if (i >= sheet.items())
|
|
f.warning_box("Partita inesistente");
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool TGame_mask::show_all_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_SPACE)
|
|
{
|
|
const TGame_mask& gm = (const TGame_mask&)f.mask();
|
|
const bool all = f.get().not_empty();
|
|
gm.fill_partite(all);
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool TGame_mask::scambio_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_SPACE)
|
|
{
|
|
const TGame_mask& gm = (const TGame_mask&)f.mask();
|
|
const TSheet_field& sheet = gm.scadenze();
|
|
sheet.swap_columns(103, 109);
|
|
sheet.swap_columns(104, 110);
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
|
{
|
|
if (k == K_TAB)
|
|
{
|
|
TGame_mask& gm = (TGame_mask&)partite.mask();
|
|
TSheet_field& scadenze = gm.scadenze();
|
|
scadenze.destroy();
|
|
|
|
const TBill& zio = gm.conto(); // Conto cliente/fornitore
|
|
TToken_string& row = partite.row(r);
|
|
const int anno = row.get_int(0); // Anno partita
|
|
const TString16 num = row.get(); // Numero partita
|
|
gm.set(P_ANNO, anno); // Aggiorna campi di ricerca
|
|
gm.set(P_NUMERO, num);
|
|
|
|
TPartita* game = app().partite().exist(zio, anno, num); // Cerca la partita tra quelle editate
|
|
const bool should_delete_game = (game == NULL); // Ricorda di fare delete
|
|
if (should_delete_game) // Se non c'era ...
|
|
game = new TPartita(zio, anno, num); // ... creane una temporanea
|
|
|
|
const int lastrow = game->last();
|
|
for (int ri = game->first(); ri <= lastrow; ri = game->succ(ri))
|
|
{
|
|
const TRiga_partite& riga = game->riga(ri);
|
|
for (int ra = 1; ra <= riga.rate(); ra++)
|
|
{
|
|
const TRiga_scadenze& scad = riga.rata(ra);
|
|
TToken_string& row = scadenze.row(-1);
|
|
row.add(ri);
|
|
row.add(ra);
|
|
row.add(riga.get(PART_DATADOC));
|
|
row.add(riga.get(PART_NREG));
|
|
row.add(riga.get(PART_DATAREG));
|
|
row.add(scad.get(SCAD_DATASCAD));
|
|
row.add(scad.get(SCAD_IMPORTO));
|
|
row.add(scad.get_real(SCAD_IMPORTOVAL).string(0, 2));
|
|
row.add(riga.get(PART_DESCR));
|
|
row.add(riga.get(PART_NUMDOC));
|
|
row.add(riga.get(PART_PROTIVA));
|
|
|
|
const TRecord_array& ap = scad.rows_array();
|
|
const int lastp = ap.last_row();
|
|
for (int pa = ap.first_row(); pa < lastp; pa++) if (ap.exist(pa))
|
|
{
|
|
const TRiga_partite& rigp = game->riga(pa);
|
|
const TRectype& pag = ap.row(pa);
|
|
|
|
TToken_string& row = scadenze.row(-1);
|
|
row.add(ri);
|
|
row.add(ra);
|
|
row.add(rigp.get(PART_DATADOC));
|
|
row.add(rigp.get(PART_NREG));
|
|
row.add(rigp.get(PART_DATAREG));
|
|
row.add(scad.get(SCAD_DATASCAD));
|
|
row.add(pag.get_real(SCAD_IMPORTO).string());
|
|
row.add(pag.get_real(SCAD_IMPORTOVAL).string(0, 2));
|
|
row.add(rigp.get(PART_DESCR));
|
|
row.add(rigp.get(PART_NUMDOC));
|
|
row.add(rigp.get(PART_PROTIVA));
|
|
row.add(pa);
|
|
}
|
|
}
|
|
}
|
|
scadenze.force_update();
|
|
if (should_delete_game)
|
|
delete game;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_SPACE)
|
|
{
|
|
TMask& m = f.mask();
|
|
TGame_mask& gm = (TGame_mask&)(m.get_sheet()->mask());
|
|
|
|
const TBill& bill = gm.conto();
|
|
const int anno = gm.get_int(P_ANNO);
|
|
const TString16 numero = gm.get(P_NUMERO);
|
|
const int nriga = m.get_int(101);
|
|
const int nrata = m.get_int(102);
|
|
const int rmov = app().cgs().selected()+1;
|
|
|
|
CHECK(nriga && nrata, "La riga della scadenza sembra vuota, ma tutti sanno che e' una balla!");
|
|
|
|
int nrigp = m.get_int(112);
|
|
if (nrigp == 0)
|
|
{
|
|
TPartita& game = app().partite().partita(bill, anno, numero);
|
|
nrigp = app().nuovo_pagamento(game, nriga, nrata, rmov);
|
|
if (nrigp < 1)
|
|
return f.error_box("La rata %d e' gia' stata pagata", nrata);
|
|
}
|
|
else
|
|
{
|
|
const TMask& cm = app().curr_mask();
|
|
const long cur_reg = cm.get_long(F_NUMREG);
|
|
const long nreg = m.get_long(104);
|
|
if (cur_reg != nreg)
|
|
return f.error_box("Non si possono modificare pagamenti di movimenti diversi dal %ld",
|
|
cur_reg);
|
|
}
|
|
|
|
TPartita& game = app().partite().partita(bill, anno, numero);
|
|
app().edit_pagamento(game, nriga, nrata, nrigp);
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
void TGame_mask::add_importo(TToken_string& s, const TImporto& i) const
|
|
{
|
|
if (i.is_zero())
|
|
s.add("");
|
|
else
|
|
{
|
|
s.add(i.valore().string());
|
|
s << ' ' << i.sezione();
|
|
}
|
|
}
|
|
|
|
void TGame_mask::fill_partite(bool all) const
|
|
{
|
|
TString_array& a = partite().rows_array();
|
|
a.destroy();
|
|
|
|
app().begin_wait();
|
|
|
|
TLocalisamfile partita(LF_PARTITE);
|
|
partita.zero();
|
|
if (conto().tipo() > ' ') // Ignora gruppo e conto dei clifo
|
|
{
|
|
partita.put(PART_TIPOCF, conto().tipo());
|
|
partita.put(PART_SOTTOCONTO, conto().sottoconto());
|
|
}
|
|
else conto().put(partita.curr()); // Scrive completamente i conti normali
|
|
|
|
const TRectype filter(partita.curr()); // Record campione
|
|
|
|
int ultimo_anno = 0, anno; // Anno ultima partita
|
|
TString16 ultimo_num, num; // Ultimo numero partita
|
|
TToken_string r(80);
|
|
|
|
for (int err = partita.read(_isgteq); err == NOERR && partita.curr() == filter; err = partita.next())
|
|
{
|
|
anno = partita.get_int(PART_ANNO);
|
|
num = partita.get(PART_NUMPART);
|
|
|
|
if (ultimo_anno != anno && ultimo_num != num)
|
|
{
|
|
TPartita* game = NULL;
|
|
bool should_delete_game = FALSE;
|
|
if (app().partite().exist(conto(), anno, num))
|
|
game = &app().partite().partita(conto(), anno, num);
|
|
else
|
|
{
|
|
game = new TPartita(conto(), anno, num);
|
|
should_delete_game = TRUE;
|
|
}
|
|
|
|
TImporto saldo, doc, pag, imp;
|
|
game->calcola_saldo(saldo, doc, pag, imp);
|
|
|
|
if (all || !saldo.is_zero())
|
|
{
|
|
int riga_fatt = game->prima_fattura();
|
|
if (riga_fatt < 1) riga_fatt = 1; // E' un anticipo
|
|
|
|
const TRiga_partite& riga = game->riga(riga_fatt);
|
|
const TString16 data_doc = riga.get(PART_DATADOC);
|
|
const TString16 num_doc = riga.get(PART_NUMDOC);
|
|
const char*descr = riga.get(PART_DESCR);
|
|
|
|
r.cut(0);
|
|
r.add(anno);
|
|
r.add(num);
|
|
r.add(data_doc);
|
|
r.add(num_doc);
|
|
add_importo(r, saldo);
|
|
add_importo(r, doc);
|
|
add_importo(r, pag);
|
|
add_importo(r, imp);
|
|
r.add(descr);
|
|
a.add(r); // Aggiunge partita alla lista
|
|
}
|
|
|
|
if (should_delete_game)
|
|
delete game;
|
|
|
|
ultimo_anno = anno;
|
|
ultimo_num = num;
|
|
}
|
|
}
|
|
|
|
partite().force_update();
|
|
if (a.items() > 0)
|
|
partite_notify(partite(), 0, K_TAB);
|
|
else
|
|
{
|
|
scadenze().destroy();
|
|
scadenze().force_update();
|
|
}
|
|
app().end_wait();
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Metodi di prima nota
|
|
///////////////////////////////////////////////////////////
|
|
|
|
bool TPrimanota_application::edit_partite(int riga)
|
|
{
|
|
TToken_string& cgr = cgs().row(riga);
|
|
const TBill b(cgr, 2, 0x3); // Legge il conto della riga selezionata
|
|
if (!b.ok()) return FALSE;
|
|
|
|
TGame_mask mask(b); // Inizializzazione maschera di selezione partite
|
|
mask.run();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
int TPrimanota_application::nuovo_pagamento(TPartita& partita, int nriga, int rata, int rmov)
|
|
{
|
|
const TRiga_partite& riga_part = partita.riga(nriga);
|
|
CHECKD(rata >= 1 && rata <= riga_part.rate(), "Rata errata ", rata);
|
|
|
|
TRiga_scadenze& riga_scad = riga_part.rata(rata);
|
|
if (riga_scad.pagata())
|
|
return -1;
|
|
|
|
TBill conto; partita.conto(conto); // Legge conto principale
|
|
|
|
const long numreg = curr_mask().get_long(F_NUMREG);
|
|
int nrigp = partita.mov2rig(numreg, rmov); // Cerca riga partita relativa alla riga rmov
|
|
|
|
if (nrigp < 1) // Devo creare una nuova riga di partita
|
|
{
|
|
TRiga_partite& part = partita.nuova_riga(); // 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, rmov); // Riga su cui ho cliccato
|
|
part.put(PART_DATAREG, curr_mask().get(F_DATAREG));
|
|
part.put(PART_DATADOC, curr_mask().get(F_DATADOC));
|
|
part.put(PART_NUMDOC, curr_mask().get(F_NUMDOC));
|
|
part.put(PART_DESCR, curr_mask().get(F_DESCR));
|
|
part.put(PART_CAMBIO, curr_mask().get(S_CAMBIO));
|
|
part.put(PART_DATACAM, curr_mask().get(S_DATACAMBIO));
|
|
|
|
// Copia dati causale corrente
|
|
const int tipomov = causale().tipomov();
|
|
part.put(PART_TIPOMOV, tipomov);
|
|
part.put(PART_CODCAUS, causale().codice());
|
|
const TRegistro& reg = causale().reg();
|
|
part.put(PART_REG, reg.name());
|
|
part.put(PART_PROTIVA, reg.protocol());
|
|
|
|
// Complesso algoritmo per calcolare la sezione di una nuova riga partita
|
|
char sezione = ' '; // Sezione nulla
|
|
TBill bill; causale().bill(1, bill); // Legge primo conto causale
|
|
if (bill.tipo() == conto.tipo()) // Se il tipo coincide ...
|
|
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 (bill.tipo() != conto.tipo()) // Compensazioni
|
|
sezione = (sezione == 'D') ? 'A' : 'D'; // scambia segno
|
|
}
|
|
part.put(PART_SEZ, sezione); // Memorizza solo la sezione (importi nulli)
|
|
}
|
|
|
|
TRectype& pagamento = riga_scad.row(nrigp, TRUE); // Crea nuovo pagamento
|
|
|
|
int caus = 2; // Calcola riga causale per la contropartita in base al tipo pagamento
|
|
switch (riga_scad.get_int(SCAD_TIPOPAG))
|
|
{
|
|
case 2: // Tratta
|
|
case 7: // Tratta accettata
|
|
caus = 3; break;
|
|
case 3: // Ricevuta bancaria
|
|
caus = 4; break;
|
|
case 4: // Cessione
|
|
caus = 5; break;
|
|
case 5: // Paghero'
|
|
caus = 6; break;
|
|
case 6: // Fattura di credito
|
|
caus = 7; break;
|
|
case 1: // Rimessa
|
|
case 8: // Rapporti interbancari diretti
|
|
case 9: // Bonifico
|
|
default:
|
|
caus = 2; break;
|
|
}
|
|
|
|
TBill contro; causale().bill(caus, contro); // Legge conto contropartita
|
|
if (contro.empty()) // Se non specificato ...
|
|
causale().bill(caus = 1, contro); // ... prende il primo
|
|
contro.put(pagamento, TRUE); // Scrive conto contropartita
|
|
|
|
if (conto.tipo() > ' ') // Se cliente o fornitore cerca sua banca
|
|
{
|
|
TRelation cliforel(LF_CLIFO);
|
|
cliforel.add(LF_CFVEN, "TIPOCF=TIPOCF|CODCF=CODCF");
|
|
TRectype& clifo = cliforel.lfile().curr();
|
|
|
|
clifo.put(CLI_TIPOCF, conto.tipo());
|
|
clifo.put(CLI_CODCF, conto.codclifo());
|
|
const int err = cliforel.read();
|
|
CHECK(err == NOERR, "Chiss'e' fregato il clifo");
|
|
|
|
pagamento.put(PAGSCA_CODABI, clifo.get(CLI_CODABI));
|
|
pagamento.put(PAGSCA_CODCAB, clifo.get(CLI_CODCAB));
|
|
pagamento.put(PAGSCA_CODAG, cliforel.lfile(LF_CFVEN).get(CLI_CODAG));
|
|
}
|
|
pagamento.put(PAGSCA_CODABIPR, riga_scad.get(SCAD_CODABIPR));
|
|
pagamento.put(PAGSCA_CODCABPR, riga_scad.get(SCAD_CODCABPR));
|
|
|
|
return nrigp;
|
|
}
|
|
|
|
HIDDEN bool importo_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_F8)
|
|
{
|
|
TMask& m = f.mask();
|
|
f.set(m.get(S_IMPORTO));
|
|
k = K_TAB;
|
|
}
|
|
|
|
if (f.to_check(k))
|
|
{
|
|
TMask& m = f.mask();
|
|
real i(f.get());
|
|
const real tot(m.get(S_IMPORTO));
|
|
if (i > tot)
|
|
{
|
|
warning_box("Non e' possibile inserire un importo superiore a ", tot.string("."));
|
|
i = tot;
|
|
f.set(i.string());
|
|
}
|
|
if (i == tot)
|
|
m.set(S_SALDOACC, "S");
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
bool TPrimanota_application::edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp)
|
|
{
|
|
TMask m("cg2100s");
|
|
m.set_handler(S_IMPORTO, importo_handler);
|
|
|
|
const TRiga_partite& parbas = p.riga(nriga);
|
|
TRiga_scadenze& scaden = parbas.rata(nrata);
|
|
const TRectype& oldpag = scaden.row(nrigp);
|
|
TRiga_partite& somma = p.riga(nrigp);
|
|
|
|
const bool in_valuta = scaden.get(SCAD_CODVAL).not_empty();
|
|
m.show(S_IMPORTOVAL_SCAD, in_valuta);
|
|
m.show(S_IMPORTOVAL, in_valuta);
|
|
|
|
TRelation rel(LF_PAGSCA); // Working relation
|
|
rel.lfile().curr() = oldpag;
|
|
m.autoload(&rel); // Load current record on mask
|
|
|
|
m.set(S_DESCAGG, somma.get(PART_DESCR));
|
|
|
|
// Dati del documento (fattura) che ha generato la scadenza
|
|
m.set(S_NUMDOC, parbas.get(PART_NUMDOC)); // Numero documento
|
|
m.set(S_DATADOC, parbas.get(PART_DATADOC)); // Data documento
|
|
m.set(S_NUMPROT, parbas.get(PART_PROTIVA)); // Protocollo IVA
|
|
m.set(S_DESCR, parbas.get(PART_DESCR)); // Descrizione documento
|
|
|
|
// Dati della scadenza che ha generato la partita
|
|
TReal_field& residuo = (TReal_field&)m.field(S_RESIDUO);
|
|
residuo.set_decimals(in_valuta ? 2 : 0);
|
|
residuo.set(scaden.residuo().string()); // Residuo da pagare
|
|
m.set(S_DATASCAD, scaden.get(SCAD_DATASCAD)); // Data della scadenza
|
|
m.set(S_SEZIONE_SCAD, parbas.get(PART_SEZ)); // Sezione della rata
|
|
m.set(S_RATA, scaden.get(SCAD_NRATA));
|
|
m.set(S_IMPORTO_SCAD, scaden.get(SCAD_IMPORTO)); // Importo della rata
|
|
m.set(S_IMPORTOVAL_SCAD, scaden.get(SCAD_IMPORTOVAL)); // Importo in valuta
|
|
|
|
const char sez = parbas.get_char(PART_SEZ); // Sezione importo e rituenute
|
|
const char controsez = sez == 'D' ? 'A' : 'D'; // Sezione opposta (contropartita)
|
|
|
|
// Memorizza importi prima di eventuali variazioni
|
|
const TImporto old_importo(controsez, real(m.get(S_IMPORTO)));
|
|
const TImporto old_ritenute(controsez, real(m.get(S_RITENUTE)));
|
|
|
|
const TBill old_conto(m.get_int(S_GRUPPO), m.get_int(S_CONTO), m.get_long(S_SOTTOCONTO));
|
|
const int old_riga = old_conto.ok() ? bill2pos(old_conto, 'I') : -1;
|
|
|
|
const KEY key = m.run();
|
|
if (key == K_ENTER || key == K_DEL)
|
|
{
|
|
if (key == K_DEL)
|
|
{
|
|
m.reset(S_IMPORTO);
|
|
m.reset(S_IMPORTOVAL);
|
|
m.reset(S_RITENUTE);
|
|
}
|
|
else
|
|
{
|
|
somma.put(PART_DESCR, m.get(S_DESCAGG)); // Aggiorna descrizione (comune ai pagamenti)
|
|
}
|
|
|
|
m.autosave(&rel);
|
|
const TRectype& paga = rel.lfile().curr();
|
|
|
|
const TImporto new_importo(controsez, paga.get_real(PART_IMPORTO));
|
|
if (old_importo != new_importo)
|
|
{
|
|
if (old_riga >= 0)
|
|
sub_cgs_imp(old_riga, old_importo);
|
|
|
|
// Importo della contropartita
|
|
if (!new_importo.is_zero())
|
|
{
|
|
TBill new_conto; new_conto.get(paga, TRUE);
|
|
const int riga = bill2pos(new_conto, 'I');
|
|
if (riga < 0)
|
|
set_cgs_row(riga, new_importo, new_conto, m.get(S_DESCAGG), 'I');
|
|
else
|
|
add_cgs_imp(riga, new_importo);
|
|
}
|
|
}
|
|
|
|
const real rit(m.get(S_RITENUTE)); // Valore ritenute fiscali
|
|
const TImporto grow_ritenute(controsez, rit-old_ritenute.valore());
|
|
if (!grow_ritenute.is_zero())
|
|
{
|
|
const riga = type2pos('F');
|
|
if (riga < 0)
|
|
{
|
|
TBill conto_rit; causale().bill(11, conto_rit);
|
|
set_cgs_row(riga, grow_ritenute, conto_rit, "", 'F');
|
|
}
|
|
else
|
|
add_cgs_imp(riga, grow_ritenute);
|
|
}
|
|
|
|
char old_ap, new_ap;
|
|
TImporto old_abbuono, new_abbuono, old_diffcam, new_diffcam;
|
|
const bool empty = p.modifica_pagamento(paga,
|
|
old_ap, old_abbuono, new_abbuono,
|
|
new_ap, new_abbuono, new_diffcam);
|
|
|
|
// Se c'e' differenza negli abbuoni
|
|
if (old_abbuono != new_abbuono || old_ap != new_ap)
|
|
{
|
|
const int riga_contabile = app().cgs().selected();
|
|
if (old_ap != ' ') // Se c'era un abbuono ...
|
|
{
|
|
const int riga_abb = type2pos(old_ap);
|
|
CHECK(riga_abb >= 0, "Chiss'e' fregato gli abbuoni?");
|
|
sub_cgs_imp(riga_abb, old_abbuono);
|
|
|
|
// Sottrae l'abbuono con la sezione invertita dalla riga contabile
|
|
add_cgs_imp(riga_contabile, old_abbuono);
|
|
}
|
|
if (new_ap != ' ') // Se ci sono abbuoni
|
|
{
|
|
const riga_abb = type2pos(new_ap);
|
|
if (riga_abb < 0)
|
|
{
|
|
TBill conto_abb; causale().bill(new_ap == 'A' ? 9 : 8, conto_abb);
|
|
app().set_cgs_row(riga_abb, new_abbuono, conto_abb, "", new_ap);
|
|
}
|
|
else
|
|
add_cgs_imp(riga_abb, new_abbuono);
|
|
sub_cgs_imp(riga_contabile, new_abbuono); // Aggiunge l'abbuono con la sezione invertita
|
|
}
|
|
}
|
|
|
|
// Se c'e' variazione nella differenza cambi
|
|
if (old_diffcam != new_diffcam)
|
|
{
|
|
const int riga_diffcam = type2pos('C');
|
|
if (!old_diffcam.is_zero()) // Se c'era una differenza cambi
|
|
{
|
|
CHECK(riga_diffcam >= 0, "Chiss'e' fregato la differenza cambi?");
|
|
sub_cgs_imp(riga_diffcam, old_diffcam);
|
|
}
|
|
if (!new_diffcam.is_zero())
|
|
{
|
|
if (riga_diffcam < 0)
|
|
{
|
|
TBill conto_diffcam; causale().bill(12, conto_diffcam);
|
|
set_cgs_row(riga_diffcam, new_diffcam, conto_diffcam, "", 'C');
|
|
}
|
|
else
|
|
add_cgs_imp(riga_diffcam, new_diffcam);
|
|
}
|
|
}
|
|
}
|
|
|
|
return key != K_ESC;
|
|
}
|
|
|
|
bool TPrimanota_application::notify_cgline_deletion(TPartita& partita, long nreg, int numrig)
|
|
{
|
|
bool found = FALSE;
|
|
const int riga_ritenute = type2pos('F');
|
|
|
|
for (int r = partita.last(); r > 0; r = partita.pred(r))
|
|
{
|
|
TRiga_partite& part = partita.riga(r);
|
|
const long reg = part.get_long(PART_NREG);
|
|
if (reg == nreg) // Se la registrazione corrisponde
|
|
{
|
|
const int num = part.get_int(PART_NUMRIG);
|
|
if (numrig > 0)
|
|
{
|
|
}
|
|
else // numrig == 0
|
|
{
|
|
found = TRUE; // usata solo da ::remove
|
|
}
|
|
}
|
|
}
|
|
|
|
return found;
|
|
}
|
|
|
|
bool TPrimanota_application::notify_cgline_deletion(int numrig)
|
|
{
|
|
bool found = FALSE;
|
|
const long nreg = curr_mask().get_long(F_NUMREG);
|
|
_partite.add_reg_num(nreg, 0);
|
|
|
|
for (TPartita* game = _partite.first(); game; game = _partite.next())
|
|
found |= notify_cgline_deletion(*game, nreg, numrig);
|
|
|
|
return found;
|
|
} |