ceb81b6181
Aggiunti cglib01.h git-svn-id: svn://10.65.10.50/trunk@4719 c028cbd2-c16b-5b4b-a496-9718f37d4682
165 lines
3.9 KiB
C++
Executable File
165 lines
3.9 KiB
C++
Executable File
//****************************
|
|
//* Aggiornamento Tipo Conto *
|
|
//****************************
|
|
#include <mov.h>
|
|
#include <rmoviva.h>
|
|
#include <nditte.h>
|
|
|
|
#include "cg1302.h"
|
|
#include "cglib01.h"
|
|
|
|
const int TAgg_tconto::look_reg (const char* cod, int anno)
|
|
{
|
|
TTable tab_reg("REG");
|
|
TString codtab;
|
|
codtab.format("%4d%-3s", anno, cod);
|
|
int tipo_reg;
|
|
|
|
tab_reg.zero();
|
|
tab_reg.put("CODTAB", codtab);
|
|
if (tab_reg.read() == NOERR)
|
|
tipo_reg = tab_reg.get_int("I0");
|
|
else
|
|
tipo_reg = 0;
|
|
|
|
return tipo_reg;
|
|
}
|
|
|
|
bool TAgg_tconto::user_create()
|
|
{
|
|
_rel = new TRelation(LF_MOV);
|
|
_rel->add(LF_RMOVIVA, "NUMREG=NUMREG",1);
|
|
_cur = new TCursor(_rel,"",1);
|
|
add_cursor(_cur);
|
|
|
|
add_file (LF_MOV);
|
|
add_file (LF_RMOVIVA);
|
|
|
|
_pcon = new TLocalisamfile(LF_PCON);
|
|
_nditte = new TLocalisamfile(LF_NDITTE);
|
|
_tabreg = new TTable("REG");
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool TAgg_tconto::user_destroy()
|
|
{
|
|
delete _rel;
|
|
delete _cur;
|
|
delete _pcon;
|
|
delete _nditte;
|
|
delete _tabreg;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool TAgg_tconto::set_print(int)
|
|
{
|
|
TMask msk("cg1300a");
|
|
|
|
while (msk.run() == K_ENTER)
|
|
{
|
|
setta_intestazione();
|
|
printer().footerlen(5);
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
void TAgg_tconto::postclose_print()
|
|
{
|
|
message_box("Aggiornamento tipo conto completato");
|
|
}
|
|
|
|
bool TAgg_tconto::preprocess_page(int file,int counter)
|
|
{
|
|
if (counter) return TRUE;
|
|
|
|
TCursor* cur = current_cursor();
|
|
if (file == LF_MOV)
|
|
{
|
|
TString16 reg = cur->curr().get(MOV_REG);
|
|
if (reg.empty()) return FALSE;
|
|
}
|
|
else if (file == LF_RMOVIVA)
|
|
{
|
|
TRectype pcon(LF_PCON);
|
|
int gruppo = cur->curr(LF_RMOVIVA).get_int(RMI_GRUPPO);
|
|
int conto = cur->curr(LF_RMOVIVA).get_int(RMI_CONTO);
|
|
long sottoconto = cur->curr(LF_RMOVIVA).get_long(RMI_SOTTOCONTO);
|
|
long numreg = cur->curr(LF_RMOVIVA).get_long(RMI_NUMREG);
|
|
int nrigimp = cur->curr(LF_RMOVIVA).get_int("RIGAIMP");
|
|
|
|
TBill tc (gruppo,conto,0L);
|
|
tc.read(pcon);
|
|
if (!pcon.empty())
|
|
if (pcon.get_char("TMCF") != '\0')
|
|
return FALSE;
|
|
|
|
tc.set(gruppo,conto,sottoconto);
|
|
tc.read(pcon);
|
|
if (!pcon.empty())
|
|
{
|
|
if (tc.sospeso())
|
|
{
|
|
set_row(1, "@4g%7ld@23g%3d@31g%3d@37g%3d@45g%6ld ** Conto sospeso **",
|
|
numreg, nrigimp, gruppo, conto, sottoconto);
|
|
return TRUE;
|
|
}
|
|
int t = tc.tipo_cr();
|
|
TString16 reg = cur->curr().get(MOV_REG);
|
|
int annoiva = cur->curr().get_int(MOV_ANNOIVA);
|
|
const int tipo = look_reg(reg, annoiva); //cerca il tipo del registro
|
|
//aggiorno sul movimento iva il tipo costo/ricavo
|
|
//con quello letto dal piano conti
|
|
_rel->lfile(LF_RMOVIVA).put(RMI_TIPOCR, t);
|
|
if (tipo == 1 && (t == 2 || t == 3))
|
|
_rel->lfile(LF_RMOVIVA).put(RMI_TIPOCR, 4);
|
|
_rel->lfile(LF_RMOVIVA).rewrite();
|
|
}
|
|
else
|
|
{
|
|
set_row(1, "@4g%7ld@23g%3d@31g%3d@37g%3d@45g%6ld ** Conto inesistente **",
|
|
numreg, nrigimp, gruppo, conto, sottoconto);
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
void TAgg_tconto::setta_intestazione()
|
|
{
|
|
int soh = 1;
|
|
TString sep(132);
|
|
TString ragsoc(50);
|
|
|
|
TLocalisamfile nditte(LF_NDITTE);
|
|
nditte.zero();
|
|
nditte.put(NDT_CODDITTA, get_firm());
|
|
if (nditte.read() == NOERR)
|
|
ragsoc = nditte.get(NDT_RAGSOC);
|
|
|
|
reset_header();
|
|
|
|
sep << "Ditta " << get_firm();
|
|
sep << " " << ragsoc;
|
|
|
|
sep.left_just(132);
|
|
|
|
set_header (soh++, (const char*) sep);
|
|
|
|
sep = "";
|
|
sep << "Data @< Pag. @#";
|
|
|
|
sep.right_just(127);
|
|
|
|
sep.overwrite ("AGGIORNAMENTO TIPO CONTO SU MOVIMENTI IVA - Lista errori");
|
|
set_header (soh++, (const char*)sep);
|
|
sep.fill('-');
|
|
set_header (soh++, (const char *) sep);
|
|
set_header (soh++, "Numero Registrazione Riga Gruppo Conto Sottoconto");
|
|
set_header (soh++, (const char *) sep);
|
|
set_header (soh, "");
|
|
}
|