Personalizzazioni:
Esporatzione CBA per Cigno Generazione rimanenze finali per Cigno git-svn-id: svn://10.65.10.50/branches/R_10_00@22796 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
79f6f95cda
commit
bdd0b0e608
@ -10,6 +10,7 @@ int main(int argc, char** argv)
|
|||||||
case 1: ps0430200(argc, argv); break; // Configurazione campi per utente
|
case 1: ps0430200(argc, argv); break; // Configurazione campi per utente
|
||||||
//case 2: ps0430300(argc, argv); break; // generazione ordini (è or1400 per il cigno)
|
//case 2: ps0430300(argc, argv); break; // generazione ordini (è or1400 per il cigno)
|
||||||
case 3: ps0430400(argc, argv); break; // Importazione clienti e fatture
|
case 3: ps0430400(argc, argv); break; // Importazione clienti e fatture
|
||||||
|
case 4: ps0430500(argc, argv); break; // Generazione rimanenze finali
|
||||||
default: ps0430100(argc, argv); break; // Correlazioni articoli utenti
|
default: ps0430100(argc, argv); break; // Correlazioni articoli utenti
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
int ps0430100(int argc, char* argv[]);
|
int ps0430100(int argc, char* argv[]);
|
||||||
int ps0430200(int argc, char* argv[]);
|
int ps0430200(int argc, char* argv[]);
|
||||||
int ps0430300(int argc, char* argv[]);
|
//int ps0430300(int argc, char* argv[]);
|
||||||
int ps0430400(int argc, char* argv[]);
|
int ps0430400(int argc, char* argv[]);
|
||||||
|
int ps0430500(int argc, char* argv[]);
|
208
ps/ps0430400.cpp
208
ps/ps0430400.cpp
@ -11,6 +11,7 @@
|
|||||||
#include "../ve/velib.h"
|
#include "../ve/velib.h"
|
||||||
|
|
||||||
#include "../cg/cfban.h"
|
#include "../cg/cfban.h"
|
||||||
|
#include "cfven.h"
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// TCBA_recset
|
// TCBA_recset
|
||||||
@ -101,10 +102,14 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
long find_clifo(const TString& cf_pi, TLocalisamfile& clifo) const;
|
long find_clifo(const TString& cf_pi, TLocalisamfile& clifo) const;
|
||||||
const TString& find_codart(const TString& codart) const;
|
const TRectype& find_codart(TString& codart) const;
|
||||||
bool find_or_create_clifo(const TCBA_recset& cli, TLocalisamfile& clifo, TLog_report& log) const;
|
bool find_or_create_clifo(const TCBA_recset& cli, TLocalisamfile& clifo,
|
||||||
bool importa_clienti(const TFilename& fname, TLog_report& log) const;
|
const TString& cdc, TLog_report& log) const;
|
||||||
bool importa_fatture(const TFilename& fname, const TString& codnum, TLog_report& log) const;
|
const TString& get_periodo(const TCBA_recset& fat) const;
|
||||||
|
void aggiorna_referente(long codcf, const char* ospite) const;
|
||||||
|
|
||||||
|
bool importa_clienti(const TFilename& fname, const TString& cdc, TLog_report& log) const;
|
||||||
|
bool importa_fatture(const TFilename& fname, const TString& codnum, const TString& cdc, TLog_report& log) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
long TImport_app::find_clifo(const TString& cf_pi, TLocalisamfile& clifo) const
|
long TImport_app::find_clifo(const TString& cf_pi, TLocalisamfile& clifo) const
|
||||||
@ -142,22 +147,14 @@ long TImport_app::find_clifo(const TString& cf_pi, TLocalisamfile& clifo) const
|
|||||||
return err == NOERR ? clifo.get_long(CLI_CODCF) : 0;
|
return err == NOERR ? clifo.get_long(CLI_CODCF) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TString& TImport_app::find_codart(const TString& codart) const
|
const TRectype& TImport_app::find_codart(TString& cod) const
|
||||||
{
|
{
|
||||||
TString80 cod = codart;
|
|
||||||
cod.trim(); cod.upper();
|
cod.trim(); cod.upper();
|
||||||
const TRectype& anamag = cache().get(LF_ANAMAG, cod);
|
const TRectype& anamag = cache().get(LF_ANAMAG, cod);
|
||||||
|
return anamag;
|
||||||
#ifdef DBG
|
|
||||||
if (anamag.empty())
|
|
||||||
cod = "45.01.06.052";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return get_tmp_string() = cod;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TImport_app::find_or_create_clifo(const TCBA_recset& cli, TLocalisamfile& clifo, const TString& cdc, TLog_report& log) const
|
||||||
bool TImport_app::find_or_create_clifo(const TCBA_recset& cli, TLocalisamfile& clifo, TLog_report& log) const
|
|
||||||
{
|
{
|
||||||
TString cofi = cli.get(2).as_string();
|
TString cofi = cli.get(2).as_string();
|
||||||
if (cofi.full() && find_clifo(cofi, clifo))
|
if (cofi.full() && find_clifo(cofi, clifo))
|
||||||
@ -206,12 +203,13 @@ bool TImport_app::find_or_create_clifo(const TCBA_recset& cli, TLocalisamfile& c
|
|||||||
return err == 0;
|
return err == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TImport_app::importa_clienti(const TFilename& fname, TLog_report& log) const
|
bool TImport_app::importa_clienti(const TFilename& fname, const TString& cdc, TLog_report& log) const
|
||||||
{
|
{
|
||||||
TString str = TR("Importazione clienti");
|
TString str = TR("Importazione clienti");
|
||||||
log.log(0, str);
|
log.log(0, str);
|
||||||
|
|
||||||
TLocalisamfile clifo(LF_CLIFO);
|
TLocalisamfile clifo(LF_CLIFO);
|
||||||
|
TLocalisamfile cfven(LF_CFVEN);
|
||||||
|
|
||||||
TCBA_recset cli;
|
TCBA_recset cli;
|
||||||
cli.load_file(fname);
|
cli.load_file(fname);
|
||||||
@ -230,16 +228,25 @@ bool TImport_app::importa_clienti(const TFilename& fname, TLog_report& log) cons
|
|||||||
if (cli.get(0).is_empty()) // Salta righe vuote
|
if (cli.get(0).is_empty()) // Salta righe vuote
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
done = find_or_create_clifo(cli, clifo, log);
|
done = find_or_create_clifo(cli, clifo, cdc, log);
|
||||||
if (!done)
|
if (!done)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Aggiorna dati cliente
|
// Aggiorna dati cliente
|
||||||
|
const TString16 piva = cli.get(1).as_string();
|
||||||
|
const TString16 cofi = cli.get(2).as_string();
|
||||||
const int privato = cli.get(27).as_int();
|
const int privato = cli.get(27).as_int();
|
||||||
|
|
||||||
TRectype& curr = clifo.curr();
|
TRectype& curr = clifo.curr();
|
||||||
|
|
||||||
|
curr.put(CLI_PAIV, piva);
|
||||||
|
curr.put(CLI_COFI, cofi);
|
||||||
|
if (cofi.len() == 16)
|
||||||
|
{
|
||||||
|
curr.put(CLI_SESSO, cofi.mid(9, 1) > "3" ? 'F': 'M');
|
||||||
|
curr.put(CLI_COMNASC, cofi.mid(11, 4));
|
||||||
|
}
|
||||||
|
|
||||||
TString rs1 = cli.get(6).as_string(); rs1.trim();
|
TString rs1 = cli.get(6).as_string(); rs1.trim();
|
||||||
TString rs2 = cli.get(7).as_string(); rs2.trim();
|
TString rs2 = cli.get(7).as_string(); rs2.trim();
|
||||||
|
|
||||||
@ -261,13 +268,14 @@ bool TImport_app::importa_clienti(const TFilename& fname, TLog_report& log) cons
|
|||||||
}
|
}
|
||||||
TParagraph_string ragsoc(str, 50);
|
TParagraph_string ragsoc(str, 50);
|
||||||
curr.put(CLI_RAGSOC, ragsoc.get());
|
curr.put(CLI_RAGSOC, ragsoc.get());
|
||||||
|
curr.put(CLI_REFERENTE, curr.get(CLI_RAGSOC));
|
||||||
|
|
||||||
curr.put(CLI_INDCF, cli.get(8).as_string());
|
curr.put(CLI_INDCF, cli.get(8).as_string());
|
||||||
|
|
||||||
const TString& loc = cli.get(10).as_string();
|
const TString80 loc = cli.get(10).as_string();
|
||||||
curr.put(CLI_LOCCF, loc);
|
curr.put(CLI_LOCCF, loc);
|
||||||
|
|
||||||
const TString& cap = cli.get(9).as_string();
|
const TString8 cap = cli.get(9).as_string();
|
||||||
curr.put(CLI_CAPCF, cap);
|
curr.put(CLI_CAPCF, cap);
|
||||||
|
|
||||||
const int naz = cli.get(16).as_int();
|
const int naz = cli.get(16).as_int();
|
||||||
@ -279,9 +287,18 @@ bool TImport_app::importa_clienti(const TFilename& fname, TLog_report& log) cons
|
|||||||
|
|
||||||
int alleg = 0;
|
int alleg = 0;
|
||||||
if (privato == 1)
|
if (privato == 1)
|
||||||
alleg = 6; else
|
alleg = 6;
|
||||||
|
else
|
||||||
|
{
|
||||||
if (naz > 0)
|
if (naz > 0)
|
||||||
alleg = naz == 1 ? 5 : 9;
|
alleg = naz == 1 ? 5 : 9;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (piva.empty())
|
||||||
|
alleg = 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
curr.put(CLI_ALLEG, alleg);
|
||||||
|
|
||||||
const TString8 abi = cli.get(17).as_string();
|
const TString8 abi = cli.get(17).as_string();
|
||||||
const TString8 cab = cli.get(18).as_string();
|
const TString8 cab = cli.get(18).as_string();
|
||||||
@ -325,6 +342,23 @@ bool TImport_app::importa_clienti(const TFilename& fname, TLog_report& log) cons
|
|||||||
log.log(2, str);
|
log.log(2, str);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cdc.full())
|
||||||
|
{
|
||||||
|
cfven.setkey(1);
|
||||||
|
cfven.zero();
|
||||||
|
cfven.put(CFV_TIPOCF, 'C');
|
||||||
|
cfven.put(CFV_CODCF, curr.get(CLI_CODCF));
|
||||||
|
if (cfven.read() != NOERR)
|
||||||
|
{
|
||||||
|
cfven.zero();
|
||||||
|
cfven.put(CFV_TIPOCF, 'C');
|
||||||
|
cfven.put(CFV_CODCF, curr.get(CLI_CODCF));
|
||||||
|
cfven.write();
|
||||||
|
}
|
||||||
|
cfven.put(CFV_CODPRCF, cdc.right(3));
|
||||||
|
cfven.rewrite();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.log(0, str.cut(0));
|
log.log(0, str.cut(0));
|
||||||
@ -335,7 +369,40 @@ bool TImport_app::importa_clienti(const TFilename& fname, TLog_report& log) cons
|
|||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TImport_app::importa_fatture(const TFilename& fname, const TString& codnum, TLog_report& log) const
|
void TImport_app::aggiorna_referente(long codcf, const char* ospite) const
|
||||||
|
{
|
||||||
|
TLocalisamfile clifo(LF_CLIFO);
|
||||||
|
clifo.put(CLI_TIPOCF, 'C');
|
||||||
|
clifo.put(CLI_CODCF, codcf);
|
||||||
|
if (clifo.read(_isequal, _lock) == NOERR)
|
||||||
|
{
|
||||||
|
clifo.put(CLI_REFERENTE, ospite);
|
||||||
|
clifo.rewrite();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const TString& TImport_app::get_periodo(const TCBA_recset& fat) const
|
||||||
|
{
|
||||||
|
TString80 periodo;
|
||||||
|
fat.get(10).as_string(periodo);
|
||||||
|
|
||||||
|
if (periodo[0] >= '0' && periodo[0] <= '9')
|
||||||
|
{
|
||||||
|
const int mese = atoi(periodo.left(6 - periodo.len()));
|
||||||
|
if (mese >= 1 && mese < 12)
|
||||||
|
{
|
||||||
|
int anno = atoi(periodo.right(4));
|
||||||
|
periodo = itom(mese);
|
||||||
|
if (anno < 2000)
|
||||||
|
anno = fat.get(9).as_int();
|
||||||
|
periodo << ' ' << anno;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return get_tmp_string() = periodo;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TImport_app::importa_fatture(const TFilename& fname, const TString& codnum, const TString& cdc, TLog_report& log) const
|
||||||
{
|
{
|
||||||
TString str = TR("Importazione documenti");
|
TString str = TR("Importazione documenti");
|
||||||
log.log(0, str);
|
log.log(0, str);
|
||||||
@ -353,6 +420,8 @@ bool TImport_app::importa_fatture(const TFilename& fname, const TString& codnum,
|
|||||||
|
|
||||||
long codcf = 0;
|
long codcf = 0;
|
||||||
TString4 codpag;
|
TString4 codpag;
|
||||||
|
TString periodo;
|
||||||
|
TToken_string ospiti(80, '@');
|
||||||
|
|
||||||
TProgind pi(fat.items(), str);
|
TProgind pi(fat.items(), str);
|
||||||
for (bool ok = fat.move_first(); ok && done; ok = fat.move_next())
|
for (bool ok = fat.move_first(); ok && done; ok = fat.move_next())
|
||||||
@ -374,7 +443,14 @@ bool TImport_app::importa_fatture(const TFilename& fname, const TString& codnum,
|
|||||||
(const char*)cofi_paiv, fat.current_row()+1);
|
(const char*)cofi_paiv, fat.current_row()+1);
|
||||||
log.log(2, str);
|
log.log(2, str);
|
||||||
}
|
}
|
||||||
codpag = fat.get(11).as_string();
|
periodo = get_periodo(fat); // 10 + 9
|
||||||
|
fat.get(11).as_string(codpag);
|
||||||
|
|
||||||
|
fat.get(15).as_string(ospiti);
|
||||||
|
const char* ospite = ospiti.get(0);
|
||||||
|
if (codcf > 0 && ospite && *ospite > ' ')
|
||||||
|
aggiorna_referente(codcf, ospite);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,19 +466,20 @@ bool TImport_app::importa_fatture(const TFilename& fname, const TString& codnum,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TString codart = find_codart(fat.get(12).as_string());
|
TString80 codart;
|
||||||
TString4 um;
|
codart << fat.get(12); codart.trim();
|
||||||
const TRectype& anamag = cache().get(LF_ANAMAG, codart);
|
codart << '.' << cdc.right(3);
|
||||||
|
|
||||||
|
const TRectype& anamag = find_codart(codart);
|
||||||
if (anamag.empty())
|
if (anamag.empty())
|
||||||
{
|
{
|
||||||
str.format("Articolo non valido '%s' alla riga %ld", (const char*)codart, fat.current_row()+1);
|
str.format("Articolo non valido '%s' alla riga %ld", (const char*)codart, fat.current_row()+1);
|
||||||
log.log(1, str);
|
log.log(1, str);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
str = codart; str << "|1";
|
str = codart; str << "|1";
|
||||||
um = cache().get(LF_UMART, str, UMART_UM);
|
const TString4 um = cache().get(LF_UMART, str, UMART_UM);
|
||||||
}
|
|
||||||
|
|
||||||
TDocumento doc('D', datadoc.year(), codnum, 0);
|
TDocumento doc('D', datadoc.year(), codnum, 0);
|
||||||
|
|
||||||
@ -412,10 +489,29 @@ bool TImport_app::importa_fatture(const TFilename& fname, const TString& codnum,
|
|||||||
doc.put(DOC_DOC1, ndoc);
|
doc.put(DOC_DOC1, ndoc);
|
||||||
doc.put(DOC_CODPAG, codpag);
|
doc.put(DOC_CODPAG, codpag);
|
||||||
doc.put(DOC_STATO, 1);
|
doc.put(DOC_STATO, 1);
|
||||||
|
doc.put(DOC_CODCMS, cdc);
|
||||||
|
|
||||||
str = fat.get(22).as_string();
|
TToken_string key;
|
||||||
str.right_just(20, '0');
|
key = "C";
|
||||||
doc.put(DOC_CODCMS, str);
|
key.add(codcf);
|
||||||
|
key.add("N");
|
||||||
|
TRecord_array nsban(key, LF_CFBAN);
|
||||||
|
if (nsban.rows() > 0)
|
||||||
|
{
|
||||||
|
const TRectype& rec = nsban.row(1);
|
||||||
|
doc.put(DOC_CODABIP, rec.get(CFBAN_ABI));
|
||||||
|
doc.put(DOC_CODCABP, rec.get(CFBAN_CAB));
|
||||||
|
}
|
||||||
|
|
||||||
|
key.add("V", 2);
|
||||||
|
TRecord_array vsban(key, LF_CFBAN);
|
||||||
|
if (vsban.rows() > 0)
|
||||||
|
{
|
||||||
|
const TRectype& rec = vsban.row(1);
|
||||||
|
doc.put(DOC_CODABIA, rec.get(CFBAN_ABI));
|
||||||
|
doc.put(DOC_CODCABA, rec.get(CFBAN_CAB));
|
||||||
|
doc.put(DOC_IBAN, rec.get(CFBAN_IBAN));
|
||||||
|
}
|
||||||
|
|
||||||
if (doc.rows() == 0) // Nuovo documento
|
if (doc.rows() == 0) // Nuovo documento
|
||||||
{
|
{
|
||||||
@ -428,12 +524,34 @@ bool TImport_app::importa_fatture(const TFilename& fname, const TString& codnum,
|
|||||||
rdoc.put(RDOC_CODART, codart);
|
rdoc.put(RDOC_CODART, codart);
|
||||||
rdoc.put(RDOC_CODARTMAG, codart);
|
rdoc.put(RDOC_CODARTMAG, codart);
|
||||||
rdoc.checked(true);
|
rdoc.checked(true);
|
||||||
rdoc.put(RDOC_DESCR, anamag.get(ANAMAG_DESCR));
|
|
||||||
rdoc.put(RDOC_UMQTA, um);
|
rdoc.put(RDOC_UMQTA, um);
|
||||||
rdoc.put(RDOC_QTA, UNO);
|
rdoc.put(RDOC_QTA, UNO);
|
||||||
rdoc.put(RDOC_PREZZO, fat.get(19).as_real());
|
rdoc.put(RDOC_PREZZO, fat.get(19).as_real());
|
||||||
rdoc.put(RDOC_CODIVA, anamag.get(ANAMAG_CODIVA));
|
rdoc.put(RDOC_CODIVA, anamag.get(ANAMAG_CODIVA));
|
||||||
|
|
||||||
|
TString desc = anamag.get(ANAMAG_DESCR);
|
||||||
|
desc << ' ' << periodo;
|
||||||
|
if (!ospiti.empty_items())
|
||||||
|
{
|
||||||
|
const char* sep = " ";
|
||||||
|
FOR_EACH_TOKEN(ospiti, o) if (o && *o > ' ')
|
||||||
|
{
|
||||||
|
desc << sep << o;
|
||||||
|
sep = ", ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (desc.len() > 50)
|
||||||
|
{
|
||||||
|
TParagraph_string p(desc, 50);
|
||||||
|
rdoc.put(RDOC_DESCR, p.get());
|
||||||
|
rdoc.put(RDOC_DESCLUNGA, "X");
|
||||||
|
rdoc.put(RDOC_DESCEST, p.get());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
rdoc.put(RDOC_DESCR, desc);
|
||||||
|
|
||||||
const int err = doc.write();
|
const int err = doc.write();
|
||||||
if (err == NOERR)
|
if (err == NOERR)
|
||||||
{
|
{
|
||||||
@ -448,11 +566,10 @@ bool TImport_app::importa_fatture(const TFilename& fname, const TString& codnum,
|
|||||||
(const char*)codnum, ndoc, fat.current_row()+1);
|
(const char*)codnum, ndoc, fat.current_row()+1);
|
||||||
log.log(2, str);
|
log.log(2, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.log(0, str.cut(0));
|
log.log(0, str.cut(0));
|
||||||
str << TR("Sono stati importati/aggiornati ") << ndocs << TR(" documenti ") << codnum
|
str << TR("Sono stati importati ") << ndocs << TR(" documenti ") << codnum
|
||||||
<< TR(" dal ") << mindoc << TR(" al ") << maxdoc;
|
<< TR(" dal ") << mindoc << TR(" al ") << maxdoc;
|
||||||
log.log(0, str);
|
log.log(0, str);
|
||||||
|
|
||||||
@ -461,7 +578,7 @@ bool TImport_app::importa_fatture(const TFilename& fname, const TString& codnum,
|
|||||||
|
|
||||||
void TImport_app::main_loop()
|
void TImport_app::main_loop()
|
||||||
{
|
{
|
||||||
open_files(LF_TAB, LF_TABCOM, LF_CLIFO, LF_DOC, LF_RIGHEDOC, LF_ANAMAG, LF_UMART, 0);
|
open_files(LF_TAB, LF_TABCOM, LF_CLIFO, LF_CFVEN, LF_DOC, LF_RIGHEDOC, LF_ANAMAG, LF_UMART, 0);
|
||||||
|
|
||||||
TImport_mask mask;
|
TImport_mask mask;
|
||||||
while (mask.run() == K_ENTER)
|
while (mask.run() == K_ENTER)
|
||||||
@ -469,12 +586,25 @@ void TImport_app::main_loop()
|
|||||||
TLog_report log;
|
TLog_report log;
|
||||||
TFilename fname = mask.get(F_DIR);
|
TFilename fname = mask.get(F_DIR);
|
||||||
fname.add(mask.get(F_CLI));
|
fname.add(mask.get(F_CLI));
|
||||||
if (importa_clienti(fname, log))
|
if (!fname.exist())
|
||||||
|
{
|
||||||
|
cantread_box(fname);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const TString& cdc = mask.get(F_CDC);
|
||||||
|
if (importa_clienti(fname, cdc, log))
|
||||||
{
|
{
|
||||||
const TString& codnum = mask.get(F_NUM);
|
const TString& codnum = mask.get(F_NUM);
|
||||||
fname = mask.get(F_DIR);
|
fname = mask.get(F_DIR);
|
||||||
fname.add(mask.get(F_FAT));
|
fname.add(mask.get(F_FAT));
|
||||||
importa_fatture(fname, codnum, log);
|
if (fname.exist())
|
||||||
|
importa_fatture(fname, codnum, cdc, log);
|
||||||
|
else
|
||||||
|
cantread_box(fname);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log.log(2, TR("E' necessario correggere i problemi segnalati prima di importare le fatture"));
|
||||||
}
|
}
|
||||||
|
|
||||||
log.preview();
|
log.preview();
|
||||||
|
@ -2,3 +2,4 @@
|
|||||||
#define F_CLI 102
|
#define F_CLI 102
|
||||||
#define F_FAT 103
|
#define F_FAT 103
|
||||||
#define F_NUM 104
|
#define F_NUM 104
|
||||||
|
#define F_CDC 105
|
@ -1,6 +1,6 @@
|
|||||||
#include "ps0430400a.h"
|
#include "ps0430400a.h"
|
||||||
|
|
||||||
PAGE "Importazione CBA" -1 -1 66 5
|
PAGE "Importazione CBA" -1 -1 66 7
|
||||||
|
|
||||||
STRING F_DIR 256 50
|
STRING F_DIR 256 50
|
||||||
BEGIN
|
BEGIN
|
||||||
@ -34,10 +34,21 @@ BEGIN
|
|||||||
CHECKTYPE REQUIRED
|
CHECKTYPE REQUIRED
|
||||||
END
|
END
|
||||||
|
|
||||||
|
STRING F_CDC 20
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 5 "Codice commessa "
|
||||||
|
USE LF_COMMESSE
|
||||||
|
INPUT CODCMS F_CDC
|
||||||
|
DISPLAY "Codice@20" CODCMS
|
||||||
|
DISPLAY "Descrizione@50" DESCRIZ
|
||||||
|
OUTPUT F_CDC CODCMS
|
||||||
|
CHECKTYPE REQUIRED
|
||||||
|
FLAGS "Z"
|
||||||
|
END
|
||||||
|
|
||||||
STRING DLG_PROFILE 256 50
|
STRING DLG_PROFILE 256 50
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 1 4 "Profilo "
|
PROMPT 1 6 "Profilo "
|
||||||
PSELECT
|
PSELECT
|
||||||
FLAGS "H"
|
FLAGS "H"
|
||||||
END
|
END
|
||||||
|
118
ps/ps0430500.cpp
Normal file
118
ps/ps0430500.cpp
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
#include <automask.h>
|
||||||
|
#include <applicat.h>
|
||||||
|
#include <progind.h>
|
||||||
|
#include <recset.h>
|
||||||
|
|
||||||
|
#include "../cg/cg2101.h"
|
||||||
|
#include "../cg/cglib01.h"
|
||||||
|
#include "../mg/mglib.h"
|
||||||
|
#include "ps0430500a.h"
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TRimfin_mask
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class TRimfin_mask : public TAutomask
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||||
|
|
||||||
|
public:
|
||||||
|
TRimfin_mask() : TAutomask("ps0430500a") {}
|
||||||
|
};
|
||||||
|
|
||||||
|
bool TRimfin_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TRimfin_app
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class TRimfin_app : public TSkeleton_application
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
virtual const char* extra_modules() const { return "ca"; }
|
||||||
|
virtual void main_loop();
|
||||||
|
|
||||||
|
public:
|
||||||
|
};
|
||||||
|
|
||||||
|
static bool scan_mag(const TRelation& rel, void* jolly)
|
||||||
|
{
|
||||||
|
const TRectype& rec = rel.curr();
|
||||||
|
|
||||||
|
const real qta = rec.get("R0");
|
||||||
|
if (qta.sign() <= 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
const TDate data = rec.get("D0");
|
||||||
|
const TString& codart = rec.get("CODTAB").mid(5, 20);
|
||||||
|
const TArticolo_giacenza& art = cached_article_balances(codart);
|
||||||
|
const real valore = art.ultimo_costo(data.year());
|
||||||
|
if (valore.is_zero())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
TBill bill;
|
||||||
|
bill.set(rec.get_int("I3"), rec.get_int("I4"), rec.get_long("I5"));
|
||||||
|
#ifdef DBG
|
||||||
|
if (!bill.ok())
|
||||||
|
bill.set(rec.get_int("I0"), rec.get_int("I1"), rec.get_long("I2"));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TString16 key;
|
||||||
|
key << rec.get("CODTAB").left(3) << '|' << bill.string(0x10);
|
||||||
|
|
||||||
|
TAssoc_array& saldi = *(TAssoc_array*)jolly;
|
||||||
|
real* imp = (real*)saldi.objptr(key);
|
||||||
|
if (imp == NULL)
|
||||||
|
{
|
||||||
|
imp = new real;
|
||||||
|
saldi.add(key, imp);
|
||||||
|
}
|
||||||
|
*imp += qta * valore;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TRimfin_app::main_loop()
|
||||||
|
{
|
||||||
|
TRimfin_mask m;
|
||||||
|
while (m.run() == K_ENTER)
|
||||||
|
{
|
||||||
|
TString query;
|
||||||
|
query << "USE &MGMAG"; // SELECT I5>0"
|
||||||
|
TISAM_recordset recset(query);
|
||||||
|
|
||||||
|
TAssoc_array saldi;
|
||||||
|
recset.cursor()->scan(scan_mag, &saldi, title());
|
||||||
|
|
||||||
|
TString_array a;
|
||||||
|
FOR_EACH_ASSOC_OBJECT(saldi, h, k, o)
|
||||||
|
{
|
||||||
|
const TFixed_string key(k);
|
||||||
|
TToken_string* r = new TToken_string;
|
||||||
|
*r = key.left(3);
|
||||||
|
r->add(key.mid(3));
|
||||||
|
r->add(((real*)o)->string(0, 2));
|
||||||
|
}
|
||||||
|
a.sort();
|
||||||
|
|
||||||
|
TMovimentoPN mov;
|
||||||
|
mov.curr().put(MOV_DATAREG, m.get(F_DATAREG));
|
||||||
|
mov.curr().put(MOV_CODCAUS, m.get(F_CODCAUS));
|
||||||
|
TString4 curmag;
|
||||||
|
real imp;
|
||||||
|
FOR_EACH_ARRAY_ROW(a, i, r)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int ps0430500(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
TRimfin_app a;
|
||||||
|
a.run(argc, argv, TR("Generazione rimanenze finali"));
|
||||||
|
return 0;
|
||||||
|
}
|
3
ps/ps0430500a.h
Normal file
3
ps/ps0430500a.h
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#define F_DATAREG 101
|
||||||
|
#define F_CODCAUS 102
|
||||||
|
#define F_DESCAUS 103
|
50
ps/ps0430500a.uml
Normal file
50
ps/ps0430500a.uml
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#include "ps0430500a.h"
|
||||||
|
|
||||||
|
PAGE "Generazione rimanenze finali" -1 -1 63 5
|
||||||
|
|
||||||
|
DATE F_DATAREG
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 1 "Data "
|
||||||
|
FLAGS "A"
|
||||||
|
CHECKTYPE REQUIRED
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_CODCAUS 3
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 2 "Causale "
|
||||||
|
USE LF_CAUSALI SELECT (REG="")&&(TIPOMOV="")&&(MOVAP="")&&(MOVIND!="")
|
||||||
|
INPUT CODCAUS F_CODCAUS
|
||||||
|
DISPLAY "Codice" CODCAUS
|
||||||
|
DISPLAY "Descrizione@50" DESCR
|
||||||
|
OUTPUT F_CODCAUS CODCAUS
|
||||||
|
OUTPUT F_DESCAUS DESCR
|
||||||
|
ADD RUN cg0 -4
|
||||||
|
CHECKTYPE REQUIRED
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_DESCAUS 50
|
||||||
|
BEGIN
|
||||||
|
PROMPT 9 3 ""
|
||||||
|
USE LF_CAUSALI KEY 2 SELECT (REG="")&&(TIPOMOV="")&&(MOVAP="")&&(MOVIND!="")
|
||||||
|
INPUT CODCAUS F_CODCAUS
|
||||||
|
DISPLAY "Descrizione@50" DESCR
|
||||||
|
DISPLAY "Codice" CODCAUS
|
||||||
|
COPY OUTPUT F_CODCAUS
|
||||||
|
ADD RUN cg0 -4
|
||||||
|
CHECKTYPE REQUIRED
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING DLG_PROFILE 256 50
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 4 "Profilo "
|
||||||
|
PSELECT
|
||||||
|
FLAGS "H"
|
||||||
|
END
|
||||||
|
|
||||||
|
ENDPAGE
|
||||||
|
|
||||||
|
TOOLBAR "" 0 0 0 2
|
||||||
|
#include <elabar.h>
|
||||||
|
ENDPAGE
|
||||||
|
|
||||||
|
ENDMASK
|
@ -173,7 +173,7 @@ protected:
|
|||||||
|
|
||||||
void sistema_date_cms(TDate& datainicms, TDate& datafinecms);
|
void sistema_date_cms(TDate& datainicms, TDate& datafinecms);
|
||||||
|
|
||||||
void trova_cms_supporto(const TString& codcms); //(load(),on_field()) riempie la lista con le commesse di supporto valide
|
void trova_cms_supporto(const TString& codcms, bool supp); //(load(),on_field()) riempie la lista con le commesse di supporto valide
|
||||||
int trova_riga_sullo_sheet(TSheet_field& sf_righe, const TString& cms, const TString& cdc,
|
int trova_riga_sullo_sheet(TSheet_field& sf_righe, const TString& cms, const TString& cdc,
|
||||||
const TString& conto, const TString& fase);
|
const TString& conto, const TString& fase);
|
||||||
void aggiorna_saldi_preventivi(TSheet_field& sf_righe, const int curr_riga); //(load()) crea i saldi preventivi in base agli importi
|
void aggiorna_saldi_preventivi(TSheet_field& sf_righe, const int curr_riga); //(load()) crea i saldi preventivi in base agli importi
|
||||||
@ -870,14 +870,16 @@ void TVariazione_budget_mask::aggiorna_saldi_preventivi(TSheet_field& sf_righe,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//in base alla commessa parametro, trova tutte le commesse di supporto
|
//in base alla commessa parametro, trova tutte le commesse di supporto
|
||||||
void TVariazione_budget_mask::trova_cms_supporto(const TString& codcms)
|
void TVariazione_budget_mask::trova_cms_supporto(const TString& codcms, bool supp)
|
||||||
|
{
|
||||||
|
//comunque la commessa selezionata ci va
|
||||||
|
_cms_supporto = codcms;
|
||||||
|
|
||||||
|
if (supp)
|
||||||
{
|
{
|
||||||
const TRectype& rec_cms = cache().get(LF_COMMESSE, codcms);
|
const TRectype& rec_cms = cache().get(LF_COMMESSE, codcms);
|
||||||
const bool is_cms_supporto = rec_cms.get_bool(COMMESSE_APPOGGIO);
|
const bool is_cms_supporto = rec_cms.get_bool(COMMESSE_APPOGGIO);
|
||||||
|
|
||||||
//comunque la commessa selezionata ci va
|
|
||||||
_cms_supporto = codcms;
|
|
||||||
|
|
||||||
//tutto il casino vale solo per le commesse normali; se viene selezionata una commessa di supporto..
|
//tutto il casino vale solo per le commesse normali; se viene selezionata una commessa di supporto..
|
||||||
//..si può agire solo su di lei!
|
//..si può agire solo su di lei!
|
||||||
if (!is_cms_supporto)
|
if (!is_cms_supporto)
|
||||||
@ -896,11 +898,10 @@ void TVariazione_budget_mask::trova_cms_supporto(const TString& codcms)
|
|||||||
TISAM_recordset commesse(query);
|
TISAM_recordset commesse(query);
|
||||||
commesse.set_var("#DATAFINECMS", cms_datafine);
|
commesse.set_var("#DATAFINECMS", cms_datafine);
|
||||||
commesse.set_var("#DATAINIZIOCMS", cms_dataini);
|
commesse.set_var("#DATAINIZIOCMS", cms_dataini);
|
||||||
|
|
||||||
const int items = commesse.items();
|
|
||||||
for(bool ok = commesse.move_first(); ok; ok = commesse.move_next())
|
for(bool ok = commesse.move_first(); ok; ok = commesse.move_next())
|
||||||
_cms_supporto.add(commesse.get(COMMESSE_CODCMS).as_string());
|
_cms_supporto.add(commesse.get(COMMESSE_CODCMS).as_string());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//alla fine assegna al campo lista S_CMS della maschera di riga i valori possibili della lista
|
//alla fine assegna al campo lista S_CMS della maschera di riga i valori possibili della lista
|
||||||
TMask& sheet_mask = sfield(F_RIGHE).sheet_mask();
|
TMask& sheet_mask = sfield(F_RIGHE).sheet_mask();
|
||||||
@ -1042,8 +1043,7 @@ long TVariazione_budget_mask::load_rmovana(const TString& cms, const bool includ
|
|||||||
|
|
||||||
//riempie lo string_array _cms_supporto in base ai parametri della commessa scelta..
|
//riempie lo string_array _cms_supporto in base ai parametri della commessa scelta..
|
||||||
//..e al fatto che l'utente lo voglia o meno...
|
//..e al fatto che l'utente lo voglia o meno...
|
||||||
if (include_cms_supp)
|
trova_cms_supporto(cms, include_cms_supp);
|
||||||
trova_cms_supporto(cms);
|
|
||||||
|
|
||||||
TAssoc_array numreg_cms;
|
TAssoc_array numreg_cms;
|
||||||
long max_numreg = 0L;
|
long max_numreg = 0L;
|
||||||
|
@ -168,7 +168,7 @@ END
|
|||||||
|
|
||||||
SPREADSHEET F_RIGHE
|
SPREADSHEET F_RIGHE
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 1 10 "Righe"
|
PROMPT 1 9 "Righe"
|
||||||
ITEM "@1C"
|
ITEM "@1C"
|
||||||
ITEM "Commessa@20"
|
ITEM "Commessa@20"
|
||||||
ITEM "Sede@4"
|
ITEM "Sede@4"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user