git-svn-id: svn://10.65.10.50/branches/R_10_00@23092 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
f69454010a
commit
49319d0200
@ -5,16 +5,16 @@
|
|||||||
// (il mese 13 copia tutti i movimenti dell'anno).
|
// (il mese 13 copia tutti i movimenti dell'anno).
|
||||||
|
|
||||||
#include <applicat.h>
|
#include <applicat.h>
|
||||||
#include <tabutil.h>
|
|
||||||
#include <mask.h>
|
|
||||||
#include <sheet.h>
|
|
||||||
#include <prefix.h>
|
|
||||||
#include <relation.h>
|
|
||||||
#include <progind.h>
|
#include <progind.h>
|
||||||
|
#include <relation.h>
|
||||||
|
#include <sheet.h>
|
||||||
|
#include <tabutil.h>
|
||||||
#include <urldefid.h>
|
#include <urldefid.h>
|
||||||
|
|
||||||
#include <nditte.h>
|
#include <nditte.h>
|
||||||
#include <mov.h>
|
#include <mov.h>
|
||||||
#include <rmoviva.h>
|
#include <rmoviva.h>
|
||||||
|
|
||||||
#include "pd6142100a.h"
|
#include "pd6142100a.h"
|
||||||
|
|
||||||
// La parte di selezione delle ditte e' tratta dal programma di liquidazione IVA (cg4300.cpp)
|
// La parte di selezione delle ditte e' tratta dal programma di liquidazione IVA (cg4300.cpp)
|
||||||
@ -74,7 +74,7 @@ bool TCopia_movimenti::firm_handler(TMask_field& f, KEY k)
|
|||||||
const long codditta = atol(f.get());
|
const long codditta = atol(f.get());
|
||||||
const int anno = f.mask().get_int(F_ANNO);
|
const int anno = f.mask().get_int(F_ANNO);
|
||||||
if (!prefix().exist(codditta))
|
if (!prefix().exist(codditta))
|
||||||
return f.error_box("La ditta specificata non e' abilitata in contabilita'.");
|
return f.error_box("La ditta specificata non è abilitata in contabilità.");
|
||||||
if (!app().look_lia(codditta,anno))
|
if (!app().look_lia(codditta,anno))
|
||||||
return f.error_box("Non esistono i parametri di liquidazione per la ditta specificata.");
|
return f.error_box("Non esistono i parametri di liquidazione per la ditta specificata.");
|
||||||
}
|
}
|
||||||
@ -257,7 +257,7 @@ void TCopia_movimenti::main_loop()
|
|||||||
_anno = msk.get_int(F_ANNO);
|
_anno = msk.get_int(F_ANNO);
|
||||||
_mese = msk.get_int(F_MESE);
|
_mese = msk.get_int(F_MESE);
|
||||||
_rcv_firm = msk.get_long(F_RCVFIRM);
|
_rcv_firm = msk.get_long(F_RCVFIRM);
|
||||||
if (yesno_box("E' stata selezionata la ditta %ld come ditta ricevente. Continuo?",_rcv_firm))
|
if (yesno_box("E' stata selezionata la ditta %ld come ditta ricevente. Continuare?",_rcv_firm))
|
||||||
{
|
{
|
||||||
copia_mov();
|
copia_mov();
|
||||||
message_box("Copia movimenti completata.");
|
message_box("Copia movimenti completata.");
|
||||||
@ -403,8 +403,7 @@ void TCopia_movimenti::copia_mov()
|
|||||||
|
|
||||||
bool TCopia_movimenti::create()
|
bool TCopia_movimenti::create()
|
||||||
{
|
{
|
||||||
_ditte = new TArray_sheet(-1, -1, -4, -4, "Selezione Ditte",
|
_ditte = new TArray_sheet(-1, -1, -4, -4, "Selezione Ditte", "@1|Cod.@5R|Ragione Sociale@50");
|
||||||
"@1|Cod.@5R|Ragione Sociale@50");
|
|
||||||
_nditte = new TLocalisamfile(LF_NDITTE);
|
_nditte = new TLocalisamfile(LF_NDITTE);
|
||||||
_lia = new TTable("%LIA");
|
_lia = new TTable("%LIA");
|
||||||
_firm = TApplication::get_firm();
|
_firm = TApplication::get_firm();
|
||||||
@ -427,4 +426,3 @@ int pd6142100 (int argc, char** argv)
|
|||||||
a.run(argc,argv,"Liquidazione riepilogativa IVA");
|
a.run(argc,argv,"Liquidazione riepilogativa IVA");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
251
ps/ps0430400.cpp
251
ps/ps0430400.cpp
@ -98,7 +98,8 @@ protected:
|
|||||||
virtual void main_loop();
|
virtual void main_loop();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
long find_clifo(const TString& cf_pi, TLocalisamfile& clifo) const;
|
void cli_ragsoc(const TCBA_recset& cli, TString& ragsoc) const;
|
||||||
|
long find_customer(const TString& cf_pi, const TString& codpag, const TString& ragsoc) const;
|
||||||
const TRectype& find_codart(TString& codart) const;
|
const TRectype& find_codart(TString& codart) const;
|
||||||
bool find_or_create_clifo(const TCBA_recset& cli, TLocalisamfile& clifo,
|
bool find_or_create_clifo(const TCBA_recset& cli, TLocalisamfile& clifo,
|
||||||
const TString& cdc, TLog_report& log) const;
|
const TString& cdc, TLog_report& log) const;
|
||||||
@ -109,41 +110,82 @@ public:
|
|||||||
bool importa_fatture(const TFilename& fname, const TString& codnum, 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
|
static void normalize_code(TString& code)
|
||||||
{
|
{
|
||||||
if (cf_pi.blank() || cf_pi.len() < 9)
|
code.trim();
|
||||||
return 0;
|
if (code.not_empty())
|
||||||
|
{
|
||||||
|
code.upper();
|
||||||
|
if (code.len() < 11 && real::is_natural(code))
|
||||||
|
code.right_just(11, '0');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TString80 cod = cf_pi;
|
long TImport_app::find_customer(const TString& cf_pi, const TString& codpag, const TString& ragsoc) const
|
||||||
cod.trim();
|
{
|
||||||
cod.upper();
|
long codice = 0L;
|
||||||
|
if (cf_pi.blank() || cf_pi.len() < 9)
|
||||||
|
return codice;
|
||||||
|
|
||||||
|
TString20 cod = cf_pi;
|
||||||
|
normalize_code(cod);
|
||||||
|
const bool numeric = cod.len() < 16 && real::is_natural(cod);
|
||||||
|
|
||||||
// Tento prima il codice fiscale o la partita IVA?
|
// Tento prima il codice fiscale o la partita IVA?
|
||||||
const char* const cofi_paiv = cod.len() < 16 ? "PC" : "CP";
|
const char* const cofi_paiv = numeric ? "PC" : "CP";
|
||||||
|
for (int t = 0; t < 2 && codice <= 0; t++)
|
||||||
int err = 204;
|
|
||||||
for (int tentativo = 0; tentativo < 2; tentativo++)
|
|
||||||
{
|
{
|
||||||
clifo.zero();
|
const int key = cofi_paiv[t] == 'C' ? 4 : 5;
|
||||||
clifo.put(CLI_TIPOCF, 'C');
|
TString query;
|
||||||
if (cofi_paiv[tentativo] == 'C')
|
query << "USE " << LF_CLIFO << " KEY " << key;
|
||||||
|
for (int f = 0; f < 2; f++)
|
||||||
|
query << (f ? "\nTO " : "\nFROM ") << CLI_TIPOCF << "=C " << (key==4 ? CLI_COFI : CLI_PAIV) << '=' << cod;
|
||||||
|
|
||||||
|
TISAM_recordset recset(query);
|
||||||
|
if (recset.move_first())
|
||||||
{
|
{
|
||||||
clifo.setkey(4);
|
codice = recset.get(CLI_CODCF).as_int();
|
||||||
clifo.put(CLI_COFI, cod);
|
|
||||||
|
const TRecnotype candidates = recset.items();
|
||||||
|
if (candidates > 1) // Cliente ambiguo
|
||||||
|
{
|
||||||
|
if (ragsoc.full()) // Ricerca da clifo
|
||||||
|
{
|
||||||
|
codice = 0;
|
||||||
|
for (TRecnotype i = 0; recset.move_to(i); i++)
|
||||||
|
{
|
||||||
|
TString80 kr; recset.get(CLI_RAGSOC).as_string(kr);
|
||||||
|
if (ragsoc == kr)
|
||||||
|
{
|
||||||
|
codice = recset.get(CLI_CODCF).as_int();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (codpag.full()) // Ricerca da fatt
|
||||||
|
{
|
||||||
|
TRecnotype best = -1;
|
||||||
|
for (TRecnotype i = 0; recset.move_to(i); i++)
|
||||||
|
{
|
||||||
|
TString4 kp; recset.get(CLI_CODPAG).as_string(kp);
|
||||||
|
if (codpag == kp || (kp.blank() && best < 0))
|
||||||
|
{
|
||||||
|
best = i;
|
||||||
|
if (codpag == kp)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (best > 0)
|
||||||
|
{
|
||||||
|
recset.move_to(best);
|
||||||
|
codice = recset.get(CLI_CODCF).as_int();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
clifo.setkey(5);
|
|
||||||
if (cod.len() < 11 && real::is_natural(cod))
|
|
||||||
cod.right_just(11, '0');
|
|
||||||
clifo.put(CLI_PAIV, cod);
|
|
||||||
}
|
|
||||||
err = clifo.read();
|
|
||||||
if (err == NOERR)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return err == NOERR ? clifo.get_long(CLI_CODCF) : 0;
|
return codice;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TRectype& TImport_app::find_codart(TString& cod) const
|
const TRectype& TImport_app::find_codart(TString& cod) const
|
||||||
@ -153,17 +195,38 @@ const TRectype& TImport_app::find_codart(TString& cod) const
|
|||||||
return anamag;
|
return anamag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TImport_app::cli_ragsoc(const TCBA_recset& cli, TString& ragsoc) const
|
||||||
|
{
|
||||||
|
TString80 rs1, rs2;
|
||||||
|
cli.get(6).as_string(rs1); rs1.trim();
|
||||||
|
cli.get(7).as_string(rs2); rs2.trim();
|
||||||
|
|
||||||
|
TString80 str;
|
||||||
|
if (rs2.blank())
|
||||||
|
{
|
||||||
|
const int spc = rs1.find(' ');
|
||||||
|
if (spc > 0)
|
||||||
|
{
|
||||||
|
str = rs1.left(spc);
|
||||||
|
str.left_just(30);
|
||||||
|
str << rs1.mid(spc+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (str.blank())
|
||||||
|
{
|
||||||
|
str << rs1 << ' ' << rs2;
|
||||||
|
str.strip_double_spaces();
|
||||||
|
}
|
||||||
|
TParagraph_string ps(str, 50);
|
||||||
|
ragsoc = ps.get();
|
||||||
|
}
|
||||||
|
|
||||||
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, const TString& cdc, TLog_report& log) const
|
||||||
{
|
{
|
||||||
TString16 cofi = cli.get(2).as_string();
|
TString16 piva; cli.get(1).as_string(piva);
|
||||||
if (cofi.full() && find_clifo(cofi, clifo))
|
TString20 cofi; cli.get(2).as_string(cofi);
|
||||||
return true;
|
TString80 ragsoc; cli_ragsoc(cli, ragsoc);
|
||||||
|
TString4 codpag; cli.get(20).as_string(codpag);
|
||||||
TString16 piva = cli.get(1).as_string();
|
|
||||||
if (piva.full() && find_clifo(piva, clifo))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
const TString80 ragsoc = cli.get(6).as_string();
|
|
||||||
|
|
||||||
if (piva.blank() && cofi.blank())
|
if (piva.blank() && cofi.blank())
|
||||||
{
|
{
|
||||||
@ -174,6 +237,20 @@ bool TImport_app::find_or_create_clifo(const TCBA_recset& cli, TLocalisamfile& c
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long codcf = 0;
|
||||||
|
if (cofi.full())
|
||||||
|
codcf = find_customer(cofi, codpag, ragsoc);
|
||||||
|
if (codcf <= 0 && piva.full())
|
||||||
|
codcf = find_customer(piva, codpag, ragsoc);
|
||||||
|
if (codcf > 0)
|
||||||
|
{
|
||||||
|
clifo.setkey(1);
|
||||||
|
clifo.zero();
|
||||||
|
clifo.put(CLI_TIPOCF, 'C');
|
||||||
|
clifo.put(CLI_CODCF, codcf);
|
||||||
|
return clifo.read() == NOERR;
|
||||||
|
}
|
||||||
|
|
||||||
long next_clifo = 1;
|
long next_clifo = 1;
|
||||||
TISAM_recordset recset("USE CLIFO\tTO TIPOCF=C");
|
TISAM_recordset recset("USE CLIFO\tTO TIPOCF=C");
|
||||||
if (recset.move_last())
|
if (recset.move_last())
|
||||||
@ -185,12 +262,10 @@ bool TImport_app::find_or_create_clifo(const TCBA_recset& cli, TLocalisamfile& c
|
|||||||
clifo.put(CLI_CODCF, next_clifo);
|
clifo.put(CLI_CODCF, next_clifo);
|
||||||
clifo.put(CLI_RAGSOC, ragsoc);
|
clifo.put(CLI_RAGSOC, ragsoc);
|
||||||
|
|
||||||
cofi.trim(); cofi.upper();
|
normalize_code(cofi);
|
||||||
clifo.put(CLI_COFI, cofi);
|
clifo.put(CLI_COFI, cofi);
|
||||||
|
|
||||||
piva.trim(); piva.upper();
|
normalize_code(piva);
|
||||||
if (piva.len() < 11 && real::is_natural(piva))
|
|
||||||
piva.right_just(11, '0');
|
|
||||||
clifo.put(CLI_PAIV, piva);
|
clifo.put(CLI_PAIV, piva);
|
||||||
|
|
||||||
const int err = clifo.write();
|
const int err = clifo.write();
|
||||||
@ -219,13 +294,9 @@ bool TImport_app::importa_clienti(const TFilename& fname, const TString& cdc, TL
|
|||||||
|
|
||||||
bool done = true;
|
bool done = true;
|
||||||
|
|
||||||
TProgind pi(cli.items(), str);
|
TProgress_monitor pi(cli.items(), str);
|
||||||
for (bool ok = cli.move_first(); ok && done; ok = cli.move_next())
|
for (bool ok = cli.move_first(); ok && done; ok = cli.move_next())
|
||||||
{
|
{
|
||||||
done = pi.addstatus(1);
|
|
||||||
if (!done)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (cli.get(0).is_empty()) // Salta righe vuote
|
if (cli.get(0).is_empty()) // Salta righe vuote
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -234,13 +305,12 @@ bool TImport_app::importa_clienti(const TFilename& fname, const TString& cdc, TL
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// Aggiorna dati cliente
|
// Aggiorna dati cliente
|
||||||
TString16 piva = cli.get(1).as_string();
|
TString16 piva; cli.get(1).as_string(piva);
|
||||||
piva.upper();
|
normalize_code(piva);
|
||||||
if (piva.len() < 11 && real::is_natural(piva))
|
|
||||||
piva.right_just(11, '0');
|
|
||||||
|
|
||||||
TString16 cofi = cli.get(2).as_string();
|
TString20 cofi; cli.get(2).as_string(cofi);
|
||||||
cofi.upper();
|
normalize_code(cofi);
|
||||||
|
|
||||||
const int privato = cli.get(27).as_int();
|
const int privato = cli.get(27).as_int();
|
||||||
|
|
||||||
TRectype& curr = clifo.curr();
|
TRectype& curr = clifo.curr();
|
||||||
@ -249,31 +319,12 @@ bool TImport_app::importa_clienti(const TFilename& fname, const TString& cdc, TL
|
|||||||
curr.put(CLI_COFI, cofi);
|
curr.put(CLI_COFI, cofi);
|
||||||
if (cofi.len() == 16)
|
if (cofi.len() == 16)
|
||||||
{
|
{
|
||||||
curr.put(CLI_SESSO, cofi.mid(9, 1) > "3" ? 'F': 'M');
|
curr.put(CLI_SESSO, cofi[9] > '3' ? 'F': 'M');
|
||||||
curr.put(CLI_COMNASC, cofi.mid(11, 4));
|
curr.put(CLI_COMNASC, cofi.mid(11, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
TString rs1 = cli.get(6).as_string(); rs1.trim();
|
TString80 ragsoc; cli_ragsoc(cli, ragsoc);
|
||||||
TString rs2 = cli.get(7).as_string(); rs2.trim();
|
curr.put(CLI_RAGSOC, ragsoc);
|
||||||
|
|
||||||
str.cut(0);
|
|
||||||
if (rs2.blank())
|
|
||||||
{
|
|
||||||
const int spc = rs1.find(' ');
|
|
||||||
if (spc > 0)
|
|
||||||
{
|
|
||||||
str = rs1.left(spc);
|
|
||||||
str.left_just(30);
|
|
||||||
str << rs1.mid(spc+1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (str.empty())
|
|
||||||
{
|
|
||||||
str << rs1 << ' ' << rs2;
|
|
||||||
str.strip_double_spaces();
|
|
||||||
}
|
|
||||||
TParagraph_string ragsoc(str, 50);
|
|
||||||
curr.put(CLI_RAGSOC, ragsoc.get());
|
|
||||||
curr.put(CLI_REFERENTE, curr.get(CLI_RAGSOC));
|
curr.put(CLI_REFERENTE, curr.get(CLI_RAGSOC));
|
||||||
|
|
||||||
const TString& indir = cli.get(8).as_string();
|
const TString& indir = cli.get(8).as_string();
|
||||||
@ -303,8 +354,8 @@ bool TImport_app::importa_clienti(const TFilename& fname, const TString& cdc, TL
|
|||||||
alleg = naz == 1 ? 5 : 9;
|
alleg = naz == 1 ? 5 : 9;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (piva.empty())
|
if (piva.blank())
|
||||||
alleg = 6;
|
alleg = real::is_natural(cofi) ? 7 : 6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
curr.put(CLI_ALLEG, alleg);
|
curr.put(CLI_ALLEG, alleg);
|
||||||
@ -374,6 +425,8 @@ bool TImport_app::importa_clienti(const TFilename& fname, const TString& cdc, TL
|
|||||||
cfven.put(CFV_CODPRCF, cdc.right(3));
|
cfven.put(CFV_CODPRCF, cdc.right(3));
|
||||||
cfven.rewrite();
|
cfven.rewrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
done = pi.add_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
log.log(0, str.cut(0));
|
log.log(0, str.cut(0));
|
||||||
@ -463,8 +516,6 @@ bool TImport_app::importa_fatture(const TFilename& fname, const TString& codnum,
|
|||||||
TString str = TR("Importazione documenti");
|
TString str = TR("Importazione documenti");
|
||||||
log.log(0, str);
|
log.log(0, str);
|
||||||
|
|
||||||
TLocalisamfile clifo(LF_CLIFO);
|
|
||||||
|
|
||||||
TCBA_recset fat;
|
TCBA_recset fat;
|
||||||
fat.load_file(fname);
|
fat.load_file(fname);
|
||||||
|
|
||||||
@ -475,19 +526,16 @@ bool TImport_app::importa_fatture(const TFilename& fname, const TString& codnum,
|
|||||||
bool done = true;
|
bool done = true;
|
||||||
|
|
||||||
long codcf = 0;
|
long codcf = 0;
|
||||||
|
TString80 cofi_paiv;
|
||||||
TString4 codpag;
|
TString4 codpag;
|
||||||
TString periodo;
|
TString periodo;
|
||||||
TToken_string ospiti(256, '@');
|
TToken_string ospiti(256, '@');
|
||||||
|
|
||||||
TDocumento* doc = NULL;
|
TDocumento* doc = NULL;
|
||||||
|
|
||||||
TProgind pi(fat.items(), str);
|
TProgress_monitor 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())
|
||||||
{
|
{
|
||||||
done = pi.addstatus(1);
|
|
||||||
if (!done)
|
|
||||||
break;
|
|
||||||
|
|
||||||
const char tipo = fat.get(8).as_string()[0];
|
const char tipo = fat.get(8).as_string()[0];
|
||||||
|
|
||||||
if (tipo == 'T')
|
if (tipo == 'T')
|
||||||
@ -499,17 +547,17 @@ bool TImport_app::importa_fatture(const TFilename& fname, const TString& codnum,
|
|||||||
doc = NULL;
|
doc = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TString80 cofi_paiv = fat.get(14).as_string();
|
fat.get(11).as_string(codpag);
|
||||||
cofi_paiv.trim(); cofi_paiv.upper();
|
fat.get(14).as_string(cofi_paiv);
|
||||||
codcf = find_clifo(cofi_paiv, clifo);
|
normalize_code(cofi_paiv);
|
||||||
|
codcf = find_customer(cofi_paiv, codpag, EMPTY_STRING);
|
||||||
if (codcf <= 0)
|
if (codcf <= 0)
|
||||||
{
|
{
|
||||||
str.format("Impossibile associare un cliente al C.F./P.I '%s' alla riga %ld",
|
str.format("Impossibile associare un cliente al codice '%s' alla riga %ld",
|
||||||
(const char*)cofi_paiv, fat.current_row()+1);
|
(const char*)cofi_paiv, fat.current_row()+1);
|
||||||
log.log(2, str);
|
log.log(2, str);
|
||||||
}
|
}
|
||||||
periodo = get_periodo(fat); // 10 + 9
|
periodo = get_periodo(fat); // 10 + 9
|
||||||
fat.get(11).as_string(codpag);
|
|
||||||
|
|
||||||
fat.get(15).as_string(ospiti);
|
fat.get(15).as_string(ospiti);
|
||||||
const char* ospite = ospiti.get(0);
|
const char* ospite = ospiti.get(0);
|
||||||
@ -531,7 +579,7 @@ bool TImport_app::importa_fatture(const TFilename& fname, const TString& codnum,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
TString80 codart;
|
TCodice_articolo codart;
|
||||||
codart << fat.get(12); codart.trim();
|
codart << fat.get(12); codart.trim();
|
||||||
codart << '.' << cdc.right(3);
|
codart << '.' << cdc.right(3);
|
||||||
|
|
||||||
@ -548,8 +596,28 @@ bool TImport_app::importa_fatture(const TFilename& fname, const TString& codnum,
|
|||||||
|
|
||||||
if (doc == NULL)
|
if (doc == NULL)
|
||||||
{
|
{
|
||||||
doc = new TDocumento('D', datadoc.year(), codnum, 0);
|
TString4 numerazione = codnum;
|
||||||
doc->put(DOC_TIPODOC, "F01");
|
TToken_string key;
|
||||||
|
|
||||||
|
key << "C|" << codcf;
|
||||||
|
TString4 tipo_doc = cache().get(LF_CFVEN, key, CFV_TIPODOCFAT);
|
||||||
|
if (tipo_doc.full())
|
||||||
|
{
|
||||||
|
TString_array num_doc;
|
||||||
|
const int nd = numerazioni_documenti(num_doc, tipo_doc);
|
||||||
|
if (nd > 0 && num_doc.find(numerazione) < 0)
|
||||||
|
numerazione = num_doc.row(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const TCodice_numerazione& cn = cached_numerazione(codnum);
|
||||||
|
tipo_doc = "F01";
|
||||||
|
if (cn.find_tipo_doc(tipo_doc) < 0)
|
||||||
|
tipo_doc = cn.tipo_doc(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
doc = new TDocumento('D', datadoc.year(), numerazione, 0);
|
||||||
|
doc->put(DOC_TIPODOC, tipo_doc);
|
||||||
doc->put(DOC_STATO, 2); // Stampato
|
doc->put(DOC_STATO, 2); // Stampato
|
||||||
|
|
||||||
doc->put(DOC_TIPOCF, 'C');
|
doc->put(DOC_TIPOCF, 'C');
|
||||||
@ -560,7 +628,6 @@ bool TImport_app::importa_fatture(const TFilename& fname, const TString& codnum,
|
|||||||
doc->put(DOC_STATO, 1);
|
doc->put(DOC_STATO, 1);
|
||||||
doc->put(DOC_CODCMS, cdc);
|
doc->put(DOC_CODCMS, cdc);
|
||||||
|
|
||||||
TToken_string key;
|
|
||||||
key = "C";
|
key = "C";
|
||||||
key.add(codcf);
|
key.add(codcf);
|
||||||
key.add("N");
|
key.add("N");
|
||||||
@ -612,6 +679,8 @@ bool TImport_app::importa_fatture(const TFilename& fname, const TString& codnum,
|
|||||||
TRiga_documento& rdesc = doc->new_row("05");
|
TRiga_documento& rdesc = doc->new_row("05");
|
||||||
save_rdoc_desc(desc, rdesc);
|
save_rdoc_desc(desc, rdesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
done = pi.add_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doc != NULL)
|
if (doc != NULL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user