Patch level : 10.0
Files correlati : pi0001.exe pi0001100a.msk Ricompilazione Demo : [ ] Commento : Eliminati errori fatali in presenza di movimenti non ordinati git-svn-id: svn://10.65.10.50/trunk@19990 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
c9b212113a
commit
f5fe526fce
@ -7,14 +7,9 @@ int main(int argc, char** argv)
|
|||||||
int n = argc > 1 ? atoi(argv[1]+1) : 0;
|
int n = argc > 1 ? atoi(argv[1]+1) : 0;
|
||||||
switch(n)
|
switch(n)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1: pi0001200(argc, argv); break; //importazione saldaconto
|
||||||
pi0001200(argc, argv); break; //importazione saldaconto
|
case 2: pi0001300(argc, argv); break; //importazione cespiti
|
||||||
case 2:
|
default : pi0001100(argc, argv); break; //importazione movimenti contabili
|
||||||
pi0001300(argc, argv); break; //importazione cespiti
|
|
||||||
case 0:
|
|
||||||
default:
|
|
||||||
pi0001100(argc, argv); break; //importazione movimenti contabili
|
|
||||||
}
|
}
|
||||||
exit(0);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
193
ps/pi0001100.cpp
193
ps/pi0001100.cpp
@ -112,29 +112,25 @@ bool TImporta_mov_mask::on_field_event(TOperable_field& f, TField_event e, long
|
|||||||
{
|
{
|
||||||
switch (f.dlg())
|
switch (f.dlg())
|
||||||
{
|
{
|
||||||
//giochetto per avere la lista dei files validi nella directory di trasferimento!
|
//giochetto per avere la lista dei files validi nella directory di trasferimento!
|
||||||
case F_NAME:
|
case F_NAME:
|
||||||
if (e == fe_button)
|
if (e == fe_button)
|
||||||
|
{
|
||||||
|
TArray_sheet as(-1, -1, 72, 20, TR("Selezione file"), "File@32");
|
||||||
|
TFilename path = get(F_PATH); path.add("*.txt"); //files delle testate
|
||||||
|
list_files(path, as.rows_array());
|
||||||
|
TFilename name;
|
||||||
|
FOR_EACH_ARRAY_ROW(as.rows_array(), i, row)
|
||||||
{
|
{
|
||||||
TArray_sheet as(-1, -1, 72, 20, TR("Selezione file"),
|
name = *row;
|
||||||
"File@32");
|
*row = name.name();
|
||||||
TFilename path = get(F_PATH);
|
|
||||||
path.add("*.txt"); //files delle testate
|
|
||||||
list_files(path, as.rows_array());
|
|
||||||
TFilename name;
|
|
||||||
FOR_EACH_ARRAY_ROW(as.rows_array(), i, row)
|
|
||||||
{
|
|
||||||
name = *row;
|
|
||||||
*row = name.name();
|
|
||||||
}
|
|
||||||
if (as.run() == K_ENTER)
|
|
||||||
{
|
|
||||||
f.set(as.row(as.selected()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
if (as.run() == K_ENTER)
|
||||||
default:
|
f.set(as.row(as.selected()));
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -145,49 +141,55 @@ bool TImporta_mov_mask::on_field_event(TOperable_field& f, TField_event e, long
|
|||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
class TImporta_mov : public TSkeleton_application
|
class TImporta_mov : public TSkeleton_application
|
||||||
{
|
{
|
||||||
virtual bool check_autorization() const {return false;}
|
protected:
|
||||||
virtual const char * extra_modules() const {return "ba";}
|
virtual const char* extra_modules() const { return "cg"; }
|
||||||
|
void build_IVA(TConfig & conf, TArray & rows, TString_array & concg, TArray & impcg, int nrigai);
|
||||||
TImporta_mov_mask* _msk;
|
|
||||||
|
|
||||||
//protected:
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual bool create();
|
|
||||||
virtual bool destroy();
|
|
||||||
virtual void main_loop();
|
virtual void main_loop();
|
||||||
void build_IVA(TConfig & conf, TArray & rows, TString_array & concg, TArray & impcg, int nrigai);
|
void transfer(const TMask& msk);
|
||||||
void transfer(const TFilename& file);
|
|
||||||
|
|
||||||
TImporta_mov() {};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void TImporta_mov::build_IVA(TConfig & conf, TArray & rows, TString_array & concg, TArray & impcg, int nrigai)
|
void TImporta_mov::build_IVA(TConfig& conf, TArray& rows, TString_array& concg, TArray& impcg, int nrigai)
|
||||||
{
|
{
|
||||||
const int items = rows.items();
|
const int items = rows.items();
|
||||||
TString paragraph;
|
if (items > 0)
|
||||||
TToken_string key;
|
|
||||||
|
|
||||||
if (items > 0)
|
|
||||||
{
|
{
|
||||||
int i = 0;
|
TString paragraph;
|
||||||
TString *gcs = (TString *)concg.first_item();
|
TToken_string key;
|
||||||
real imptot = *((real *) impcg.first_item());
|
|
||||||
TString4 gruppo = gcs->left(2);
|
|
||||||
TString4 conto = gcs->mid(2, 2);
|
|
||||||
TString8 sottoconto = gcs->right(6);
|
|
||||||
|
|
||||||
|
int icg = 0;
|
||||||
|
|
||||||
|
TString4 gruppo, conto;
|
||||||
|
TString8 sottoconto;
|
||||||
|
|
||||||
|
if (icg < concg.items())
|
||||||
|
{
|
||||||
|
const TString& gcs = concg.row(icg);
|
||||||
|
gruppo = gcs.left(2);
|
||||||
|
conto = gcs.mid(2, 2);
|
||||||
|
sottoconto = gcs.right(6);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Non so come inventare il conto
|
||||||
|
}
|
||||||
|
|
||||||
|
real imptot;
|
||||||
|
if (icg < impcg.items())
|
||||||
|
imptot = (const real&)impcg[icg];
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
while (i < items)
|
while (i < items)
|
||||||
{
|
{
|
||||||
TRectype & rec = (TRectype &)rows[i];
|
TRectype& rec = (TRectype&)rows[i];
|
||||||
real imp = rec.get(RMI_IMPONIBILE);
|
real imp = rec.get(RMI_IMPONIBILE);
|
||||||
real iva = rec.get(RMI_IMPOSTA);
|
real iva = rec.get(RMI_IMPOSTA);
|
||||||
if (imp <= imptot)
|
if (imp <= imptot)
|
||||||
i++;
|
i++;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TCodiceIVA codiva(rec.get(RMI_CODIVA));
|
const TCodiceIVA codiva(rec.get(RMI_CODIVA));
|
||||||
|
|
||||||
imp -= imptot;
|
imp -= imptot;
|
||||||
rec.put(RMI_IMPONIBILE, imp);
|
rec.put(RMI_IMPONIBILE, imp);
|
||||||
@ -211,25 +213,32 @@ void TImporta_mov::build_IVA(TConfig & conf, TArray & rows, TString_array & conc
|
|||||||
conf.set(RMI_GRUPPO, gruppo);
|
conf.set(RMI_GRUPPO, gruppo);
|
||||||
conf.set(RMI_CONTO, conto);
|
conf.set(RMI_CONTO, conto);
|
||||||
conf.set(RMI_SOTTOCONTO, sottoconto);
|
conf.set(RMI_SOTTOCONTO, sottoconto);
|
||||||
if (imptot <= 0)
|
if (imptot <= ZERO)
|
||||||
{
|
{
|
||||||
gcs = (TString *)concg.succ_item();
|
if (++icg >= concg.items())
|
||||||
if (gcs == NULL)
|
break;
|
||||||
break;
|
const TString& gcs = concg.row(icg);
|
||||||
imptot = *((real *) impcg.succ_item());
|
gruppo = gcs.left(2);
|
||||||
gruppo = gcs->left(2);
|
conto = gcs.mid(2, 2);
|
||||||
conto = gcs->mid(2, 2);
|
sottoconto = gcs.right(6);
|
||||||
sottoconto = gcs->right(6);
|
|
||||||
|
if (icg < impcg.items())
|
||||||
|
imptot = (const real&)impcg[icg];
|
||||||
|
else
|
||||||
|
imptot = ZERO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TImporta_mov::transfer(const TFilename& file)
|
void TImporta_mov::transfer(const TMask& msk)
|
||||||
{
|
{
|
||||||
TFilename outdir(_msk->get(F_PATHOUT));
|
TFilename filename = msk.get(F_PATH); filename.add(msk.get(F_NAME));
|
||||||
TImporta_galileo_recset s(file);
|
TFilename outdir(msk.get(F_PATHOUT));
|
||||||
TProgind pi(s.items(),"Importazione movimenti in corso ...",true,true);
|
|
||||||
|
TImporta_galileo_recset s(filename);
|
||||||
|
|
||||||
|
TProgind pi(s.items(), TR("Importazione movimenti in corso..."));
|
||||||
TConfig * conf = NULL;
|
TConfig * conf = NULL;
|
||||||
long nmov = - 1;
|
long nmov = - 1;
|
||||||
int anno = 0;
|
int anno = 0;
|
||||||
@ -243,28 +252,25 @@ void TImporta_mov::transfer(const TFilename& file)
|
|||||||
TString4 conto;
|
TString4 conto;
|
||||||
TString8 sottoconto;
|
TString8 sottoconto;
|
||||||
TString descr(50);
|
TString descr(50);
|
||||||
const int codes = _msk->get_int(F_ANNOES);
|
const int codes = msk.get_int(F_ANNOES);
|
||||||
const long ditta = _msk->get_long(F_CODITTA);
|
const long ditta = msk.get_long(F_CODITTA);
|
||||||
const TEsercizi_contabili esc;
|
const TEsercizi_contabili esc;
|
||||||
TArray rows;
|
TArray rows;
|
||||||
TArray impcg;
|
TArray impcg;
|
||||||
TString_array concg;
|
TString_array concg;
|
||||||
TCausali_cache cache_causali;
|
TCausali_cache cache_causali;
|
||||||
|
|
||||||
|
|
||||||
for (bool ok=s.move_first();ok;ok=s.move_next())
|
for (bool ok=s.move_first();ok;ok=s.move_next())
|
||||||
{
|
{
|
||||||
if (!pi.addstatus(1))
|
if (!pi.addstatus(1))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const long dt = s.get(CDDTCM).as_int();
|
const long dt = s.get(CDDTCM).as_int();
|
||||||
|
|
||||||
if (ditta != dt)
|
if (ditta != dt)
|
||||||
continue;
|
continue;
|
||||||
const TDate datareg(s.get(DTRGCM).as_int());
|
|
||||||
if (datareg.year() == 2009)
|
const TDate datareg(s.get(DTRGCM).as_int());
|
||||||
int i = 1;
|
const int es = esc.date2esc(datareg);
|
||||||
const int es = esc.date2esc(datareg);
|
|
||||||
|
|
||||||
if (codes != es)
|
if (codes != es)
|
||||||
continue;
|
continue;
|
||||||
@ -282,7 +288,6 @@ void TImporta_mov::transfer(const TFilename& file)
|
|||||||
dataop = d;
|
dataop = d;
|
||||||
nmov = n;
|
nmov = n;
|
||||||
|
|
||||||
|
|
||||||
if (conf != NULL)
|
if (conf != NULL)
|
||||||
delete conf;
|
delete conf;
|
||||||
conf = NULL;
|
conf = NULL;
|
||||||
@ -290,22 +295,21 @@ void TImporta_mov::transfer(const TFilename& file)
|
|||||||
|
|
||||||
temp << '/' << format("%05ld", ntran++);
|
temp << '/' << format("%05ld", ntran++);
|
||||||
temp.ext("ini");
|
temp.ext("ini");
|
||||||
if (fexist(temp))
|
if (temp.exist())
|
||||||
remove_file(temp);
|
remove_file(temp);
|
||||||
conf = new TConfig(temp);
|
conf = new TConfig(temp);
|
||||||
conf->set_paragraph("Transaction"); //setto il paragrafo [Transaction] del file ini
|
conf->set_paragraph("Transaction"); //setto il paragrafo [Transaction] del file ini
|
||||||
conf->set("Action","INSERT");
|
conf->set("Action","INSERT");
|
||||||
conf->set("Mode","AUTO");
|
conf->set("Mode", "AUTO");
|
||||||
|
|
||||||
conf->set_paragraph("23"); //setto il paragrafo [23] del file ini (testata)
|
conf->set_paragraph("23"); //setto il paragrafo [23] del file ini (testata)
|
||||||
|
|
||||||
TString8 codcaus = s.get(CAUSCM).as_string();
|
TString4 codcaus = s.get(CAUSCM).as_string();
|
||||||
|
|
||||||
iva = s.get(TPMVCM).as_string() == "I";
|
iva = s.get(TPMVCM).as_string() == "I";
|
||||||
if (atoi(codcaus) != 0)
|
if (atoi(codcaus) != 0)
|
||||||
{
|
{
|
||||||
codcaus << '0';
|
codcaus << '0';
|
||||||
const TCausale & c = cache_causali.causale(codcaus, codes);
|
const TCausale& c = cache_causali.causale(codcaus, codes);
|
||||||
if (!iva && c.iva() != nessuna_iva)
|
if (!iva && c.iva() != nessuna_iva)
|
||||||
codcaus.cut(0);
|
codcaus.cut(0);
|
||||||
}
|
}
|
||||||
@ -369,11 +373,10 @@ void TImporta_mov::transfer(const TFilename& file)
|
|||||||
key.add(gruppo);
|
key.add(gruppo);
|
||||||
key.add(conto);
|
key.add(conto);
|
||||||
|
|
||||||
const TString4 tipocf = cache().get(LF_PCON, key, PCN_TMCF);
|
const char tipocf = cache().get(LF_PCON, key, PCN_TMCF)[0];
|
||||||
|
|
||||||
if (iva)
|
if (iva)
|
||||||
{
|
{
|
||||||
if (tipocf.full())
|
if (tipocf > ' ')
|
||||||
{
|
{
|
||||||
conf->set_paragraph("23"); //setto il paragrafo [23] del file ini (testata)
|
conf->set_paragraph("23"); //setto il paragrafo [23] del file ini (testata)
|
||||||
conf->set(MOV_TIPO, tipocf);
|
conf->set(MOV_TIPO, tipocf);
|
||||||
@ -427,8 +430,8 @@ void TImporta_mov::transfer(const TFilename& file)
|
|||||||
|
|
||||||
if (ind > ZERO && ind < CENTO)
|
if (ind > ZERO && ind < CENTO)
|
||||||
{
|
{
|
||||||
real impind = importo * ind / 100;
|
real impind = importo * ind / CENTO;
|
||||||
real ivaind = imposta * ind / 100;
|
real ivaind = imposta * ind / CENTO;
|
||||||
impind.round(2);
|
impind.round(2);
|
||||||
ivaind.round(2);
|
ivaind.round(2);
|
||||||
importo -= impind;
|
importo -= impind;
|
||||||
@ -494,44 +497,22 @@ void TImporta_mov::transfer(const TFilename& file)
|
|||||||
if (yesno_box(FR("Si desidera confermare l'importazione di %ld movimenti"), ntran -1))
|
if (yesno_box(FR("Si desidera confermare l'importazione di %ld movimenti"), ntran -1))
|
||||||
{
|
{
|
||||||
TString app;
|
TString app;
|
||||||
|
|
||||||
app << "cg2 -0 -i" << outdir << "/*.ini";
|
app << "cg2 -0 -i" << outdir << "/*.ini";
|
||||||
TExternal_app primanota(app);
|
TExternal_app primanota(app);
|
||||||
primanota.run(true);
|
primanota.run(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TImporta_mov::create()
|
|
||||||
{
|
|
||||||
_msk = new TImporta_mov_mask();
|
|
||||||
|
|
||||||
return TSkeleton_application::create();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TImporta_mov::destroy()
|
|
||||||
{
|
|
||||||
delete _msk;
|
|
||||||
return TApplication::destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TImporta_mov::main_loop()
|
void TImporta_mov::main_loop()
|
||||||
{
|
{
|
||||||
KEY tasto;
|
TImporta_mov_mask msk;
|
||||||
tasto = _msk->run();
|
while (msk.run() == K_ENTER)
|
||||||
if (tasto == K_ENTER)
|
|
||||||
{
|
{
|
||||||
//genero il nome del file da caricare
|
TWait_cursor hourglass;
|
||||||
TFilename name = _msk->get(F_PATH);
|
transfer(msk);
|
||||||
name.add(_msk->get(F_NAME));
|
}
|
||||||
transfer(name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TImporta_mov& app() { return (TImporta_mov&) main_app(); }
|
|
||||||
|
|
||||||
|
|
||||||
int pi0001100 (int argc, char* argv[])
|
int pi0001100 (int argc, char* argv[])
|
||||||
{
|
{
|
||||||
TImporta_mov main_app;
|
TImporta_mov main_app;
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
class TImporta_galileo_recset : public TCSV_recordset
|
class TImporta_galileo_recset : public TCSV_recordset
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual const TVariant& get(unsigned int column) const;
|
virtual const TVariant& get(unsigned int column) const;
|
||||||
|
|
||||||
TImporta_galileo_recset(const char* query = "") : TCSV_recordset(TString("CSV(\";)\n") << query) {}
|
TImporta_galileo_recset(const char* query = "") : TCSV_recordset(TString("CSV(\";)\n") << query) {}
|
||||||
virtual ~TImporta_galileo_recset() {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,17 +2,7 @@
|
|||||||
|
|
||||||
TOOLBAR "" 0 0 0 2
|
TOOLBAR "" 0 0 0 2
|
||||||
|
|
||||||
BUTTON DLG_ELABORA 10 2
|
#include <elabar.h>
|
||||||
BEGIN
|
|
||||||
PICTURE BMP_ELABORA
|
|
||||||
MESSAGE EXIT,K_ENTER
|
|
||||||
PROMPT -12 -1 "E~labora"
|
|
||||||
END
|
|
||||||
|
|
||||||
BUTTON DLG_QUIT 10 2
|
|
||||||
BEGIN
|
|
||||||
PROMPT -22 -1 ""
|
|
||||||
END
|
|
||||||
|
|
||||||
ENDPAGE
|
ENDPAGE
|
||||||
|
|
||||||
@ -60,6 +50,7 @@ BEGIN
|
|||||||
DSELECT
|
DSELECT
|
||||||
CHECKTYPE REQUIRED
|
CHECKTYPE REQUIRED
|
||||||
FIELD ComInPath
|
FIELD ComInPath
|
||||||
|
FLAGS "M"
|
||||||
END
|
END
|
||||||
|
|
||||||
STRING F_NAME 18
|
STRING F_NAME 18
|
||||||
@ -94,6 +85,7 @@ BEGIN
|
|||||||
DSELECT
|
DSELECT
|
||||||
CHECKTYPE REQUIRED
|
CHECKTYPE REQUIRED
|
||||||
FIELD ComOutPath
|
FIELD ComOutPath
|
||||||
|
FLAGS "M"
|
||||||
END
|
END
|
||||||
|
|
||||||
ENDPAGE
|
ENDPAGE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user