Files correlati : sc0.exe sc1.exe Ricompilazione Demo : [ ] Commento : EP20046 Inserendo movimento extracontabile incasso\pagamento nella maschera"pagamento" Non funziona il collegamento a tabella banche EP20047 cliccanbo sul bottone elabora Errore dell'applicazione SC2 (E' corretto che il bottone elabora sia attivo se non ci sono dati inseriti?) EP20048 Dando conferma ai messsaggi proposti Errore in compattamento dati file 28:-69 EP20062 non stampa su carta se stampante in visualizzazione git-svn-id: svn://10.65.10.50/trunk@11129 c028cbd2-c16b-5b4b-a496-9718f37d4682
323 lines
8.4 KiB
C++
Executable File
323 lines
8.4 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <mask.h>
|
|
#include <progind.h>
|
|
#include <relation.h>
|
|
|
|
#include "../cg/cglib02.h"
|
|
#include "../cg/cgsaldac.h"
|
|
|
|
#include "sc1200.h"
|
|
|
|
#include <saldi.h>
|
|
#include <pconti.h>
|
|
|
|
|
|
class TCreatepart_app : public TSkeleton_application
|
|
{
|
|
TEsercizi_contabili _esc;
|
|
bool _num_cli, _num_for;
|
|
TString _desccl, _descfo;
|
|
TDate _today;
|
|
|
|
protected: // Applicat
|
|
virtual void on_config_change();
|
|
|
|
virtual bool create();
|
|
virtual void main_loop();
|
|
|
|
protected:
|
|
static bool data_handler(TMask_field& f, KEY key);
|
|
|
|
bool is_full(int logicnum) const;
|
|
void zap_file(int logicnum) const;
|
|
bool zap_partite() const;
|
|
int crea_partite(int anno_es, int anno_rif, int next_anno_es);
|
|
|
|
public:
|
|
char is_clifo(int g, int c, long s, int& indbil);
|
|
TCreatepart_app() : _today(TODAY) {}
|
|
virtual ~TCreatepart_app() {}
|
|
};
|
|
|
|
inline TCreatepart_app& app() { return (TCreatepart_app&)main_app(); }
|
|
|
|
bool TCreatepart_app::create()
|
|
{
|
|
open_files(LF_TABCOM, LF_TAB, LF_PCON, LF_SALDI, LF_PARTITE, LF_PAGSCA, LF_SCADENZE, 0);
|
|
|
|
return TSkeleton_application::create();
|
|
}
|
|
|
|
void TCreatepart_app::on_config_change()
|
|
{
|
|
TConfig cd(CONFIG_DITTA, "cg");
|
|
_num_cli = cd.get_bool("NrCliDx");
|
|
_num_for = cd.get_bool("NrForDx");
|
|
TPartita::carica_allineamento();
|
|
}
|
|
|
|
bool TCreatepart_app::data_handler(TMask_field& f, KEY key)
|
|
{
|
|
TMask& m = f.mask();
|
|
|
|
bool ok = TRUE;
|
|
if ((key == K_TAB && (f.focusdirty() || !m.is_running())) ||
|
|
key == K_ENTER)
|
|
{
|
|
const int anno = m.get_int(F_ANNO);
|
|
const TDate oggi(f.get());
|
|
if (app()._esc.date2esc(oggi) != anno)
|
|
ok = f.error_box(FR("La data non appartiene all'esercizio %d"), anno);
|
|
|
|
if (ok && key == K_TAB)
|
|
{
|
|
TString desc(50);
|
|
TEdit_field& dc = m.efield(F_DESCCL);
|
|
if (dc.empty() || !dc.dirty())
|
|
{
|
|
desc = TR("Apertura clienti al "); desc << oggi;
|
|
dc.set(desc);
|
|
dc.set_dirty(FALSE);
|
|
}
|
|
|
|
TEdit_field& df = m.efield(F_DESCFO);
|
|
if (df.empty() || !df.dirty())
|
|
{
|
|
desc = TR("Apertura fornitori al "); desc << oggi;
|
|
df.set(desc);
|
|
df.set_dirty(FALSE);
|
|
}
|
|
}
|
|
}
|
|
return ok;
|
|
}
|
|
|
|
void TCreatepart_app::zap_file(int logicnum) const
|
|
{
|
|
TSystemisamfile f(logicnum);
|
|
f.zap();
|
|
}
|
|
|
|
bool TCreatepart_app::is_full(int logicnum) const
|
|
{
|
|
TLocalisamfile f(logicnum);
|
|
const int err = f.last();
|
|
return err == NOERR;
|
|
}
|
|
|
|
bool TCreatepart_app::zap_partite() const
|
|
{
|
|
bool ok = TRUE;
|
|
|
|
bool zap = is_full(LF_PARTITE);
|
|
if (zap)
|
|
{
|
|
zap = yesno_box(TR("Il saldaconto non e' vuoto.\n"
|
|
"La procedura lo azzera completamente.\n"
|
|
"Si desidera proseguire?"));
|
|
if (zap)
|
|
zap = yesno_box(TR("Confermare l'azzeramento del saldaconto esistente"));
|
|
|
|
if (zap)
|
|
{
|
|
zap_file(LF_PARTITE);
|
|
zap_file(LF_SCADENZE);
|
|
zap_file(LF_PAGSCA);
|
|
}
|
|
else
|
|
ok = FALSE;
|
|
}
|
|
|
|
return ok;
|
|
}
|
|
|
|
|
|
char TCreatepart_app::is_clifo(int g, int c, long s, int& indbil)
|
|
{
|
|
TString16 key;
|
|
key.format("%d|%d|0", g, c);
|
|
const TRectype& conti = cache().get(LF_PCON, key);
|
|
|
|
if (conti.empty())
|
|
{
|
|
warning_box(FR("Archivio saldi disallineato con il piano dei conti\n record saldi non elaborato : gruppo %d conto %d sottoconto %ld"), g, c, s);
|
|
return '\0';
|
|
}
|
|
|
|
const char cf = conti.get_char(PCN_TMCF);
|
|
indbil = conti.get_int(PCN_INDBIL);
|
|
|
|
return cf;
|
|
}
|
|
|
|
int TCreatepart_app::crea_partite(int anno_es, int anno_rif, int next_anno_es)
|
|
{
|
|
TWait_cursor hourglass;
|
|
|
|
const bool check = anno_es != next_anno_es;
|
|
TRelation saldi(LF_SALDI);
|
|
|
|
saldi.curr().put(SLD_ANNOES, anno_es);
|
|
|
|
TCursor cur(&saldi, "", 1, &saldi.curr(), &saldi.curr());
|
|
const long items = cur.items();
|
|
|
|
if (items == 0)
|
|
return 0;
|
|
|
|
// Apre i files per usarli con l'oggetto TPartita
|
|
TLocalisamfile partite(LF_PARTITE);
|
|
TLocalisamfile scadenze(LF_SCADENZE);
|
|
TLocalisamfile pagamenti(LF_PAGSCA);
|
|
|
|
int n_part = 0;
|
|
TProgind prind(items, TR("Creazione saldaconto"), FALSE, TRUE, 45);
|
|
|
|
for (cur = 0; cur.pos() < items; ++cur)
|
|
{
|
|
const int gruppo = cur.curr().get_int(SLD_GRUPPO);
|
|
const int conto = cur.curr().get_int(SLD_CONTO);
|
|
const long sottoc = cur.curr().get_long(SLD_SOTTOCONTO);
|
|
int indbil;
|
|
const char cf = is_clifo(gruppo, conto, sottoc, indbil);
|
|
if (check)
|
|
{
|
|
TLocalisamfile work_saldi(LF_SALDI);
|
|
work_saldi.zero();
|
|
work_saldi.put(SLD_GRUPPO, gruppo);
|
|
work_saldi.put(SLD_CONTO, conto);
|
|
work_saldi.put(SLD_SOTTOCONTO, sottoc);
|
|
work_saldi.put(SLD_ANNOES, next_anno_es);
|
|
work_saldi.put(SLD_FLSCA, "");
|
|
if (work_saldi.read() == NOERR)
|
|
continue;
|
|
}
|
|
if (cf > ' ')
|
|
{
|
|
TSaldo sld;
|
|
real s;
|
|
|
|
// ciuccia il saldo e vedi se e' movimentato nell'esercizio corrente
|
|
if (!sld.ultima_immissione_verifica(anno_es, gruppo, conto, sottoc, indbil, 1))
|
|
{
|
|
// non movimentato: se e' conto patrimoniale....
|
|
if (!(indbil == 1 || indbil == 2 || indbil == 5))
|
|
{
|
|
prind.addstatus(1);
|
|
continue;
|
|
}
|
|
// .. vedi saldo esercizio precedente, altrimenti inkul
|
|
s = sld.saldofin_esprec(anno_es, gruppo, conto, sottoc);
|
|
}
|
|
else
|
|
s = sld.saldo();
|
|
|
|
// genera importo con sezione appropriata
|
|
TImporto saldo('D', s);
|
|
saldo.normalize(); // Non togliere, serve per stabilire fattura/nota credito
|
|
|
|
if (!saldo.is_zero())
|
|
{
|
|
const TBill clifo(gruppo, conto, sottoc, cf);
|
|
TString16 numero("*");
|
|
if ((cf == 'C' && _num_cli) || (cf == 'F' && _num_for))
|
|
numero.right_just(7);
|
|
|
|
TPartita game(clifo, anno_rif, numero);
|
|
TRiga_partite& riga = game.new_row();
|
|
|
|
riga.put(PART_DATAREG, _today);
|
|
riga.put(PART_DATADOC, _today);
|
|
riga.put(PART_SEZ, saldo.sezione());
|
|
riga.put(PART_IMPORTO, saldo.valore());
|
|
riga.put(PART_IMPTOTDOC,saldo.valore());
|
|
riga.put(PART_DESCR, cf == 'C' ? _desccl : _descfo);
|
|
|
|
// cazzata dare/avere/fare/baciare/cagare
|
|
const tipo_movimento tipo = (cf == 'C') ^ (saldo.sezione() == 'A') ?
|
|
tm_fattura : tm_nota_credito;
|
|
riga.put(PART_TIPOMOV, (int)tipo);
|
|
|
|
if (tipo == tm_fattura)
|
|
{
|
|
TRiga_scadenze& scad = riga.new_row();
|
|
scad.put(SCAD_IMPORTO, saldo.valore());
|
|
scad.put(SCAD_DATASCAD, _today);
|
|
scad.put(SCAD_TIPOPAG, 1); // rimessa diretta
|
|
}
|
|
else
|
|
{
|
|
riga.put(PART_DATAPAG, _today);
|
|
const int r = riga.get_int(PART_NRIGA);
|
|
TRectype& unas = game.unassigned().row(r, TRUE);
|
|
unas.put(PAGSCA_IMPORTO, saldo.valore());
|
|
unas.put(PAGSCA_ACCSAL, 'A');
|
|
}
|
|
|
|
if (game.write())
|
|
n_part++;
|
|
else
|
|
{
|
|
error_box(FR("Impossibile scrivere la partita %d %s"),
|
|
anno_rif, (const char *)numero);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
prind.addstatus(1);
|
|
}
|
|
|
|
return n_part;
|
|
}
|
|
|
|
void TCreatepart_app::main_loop()
|
|
{
|
|
TMask m("sc1200a");
|
|
m.set_handler(F_DATA, data_handler);
|
|
|
|
int anno_es = _esc.last();
|
|
|
|
m.set(F_ANNO, anno_es);
|
|
if (_esc.date2esc(_today) != anno_es)
|
|
_today = _esc[anno_es].inizio();
|
|
m.set(F_DATA, _today);
|
|
|
|
while (m.run() == K_ENTER)
|
|
{
|
|
anno_es = m.get_int(F_ANNO);
|
|
_today = m.get(F_DATA);
|
|
_desccl = m.get(F_DESCCL);
|
|
_descfo = m.get(F_DESCFO);
|
|
|
|
if (!zap_partite())
|
|
continue;
|
|
|
|
const TEsercizio& selected_es = _esc.esercizio(anno_es);
|
|
const int anno_rif = selected_es.inizio().year();
|
|
int n_part = crea_partite(anno_es, anno_rif, selected_es.codice());
|
|
|
|
const int pred_es = _esc.pred(anno_es);
|
|
if (pred_es > 0)
|
|
{
|
|
const int p = crea_partite(pred_es, anno_rif, selected_es.codice());
|
|
if (p > 0) n_part += p;
|
|
}
|
|
|
|
if (n_part > 0)
|
|
{
|
|
TString msg(80);
|
|
msg << TR("Sono state create ") << n_part << TR(" partite");
|
|
message_box(msg);
|
|
break;
|
|
}
|
|
} // while run
|
|
}
|
|
|
|
|
|
int sc1200(int argc, char** argv)
|
|
{
|
|
TCreatepart_app a;
|
|
a.run(argc, argv, TR("Apertura scadenze da saldi"));
|
|
return 0;
|
|
}
|