Patch level : 12.00 1386

Files correlati     : cg0.exe cg0700a.msk cg0700b.msk

Bug                 :

Commento:
Trasformazione occasionali in clienti/fornitori
This commit is contained in:
Alessandro Bonazzi 2025-03-30 00:45:19 +01:00
parent 5c80be8b71
commit 8eda0d2336
7 changed files with 699 additions and 161 deletions

View File

@ -4,7 +4,7 @@
#define CFBAN_NRIGA "NRIGA"
#define CFBAN_ABI "ABI"
#define CFBAN_CAB "CAB"
#define CFBAN_PROGPR "PROGPR"
#define CFBAN_PROGPR "PROGPR"
#define CFBAN_NUMCC "NUMCC"
#define CFBAN_IBAN "IBAN"

View File

@ -18,14 +18,17 @@
#include <cfven.h>
#include <clifo.h>
#include <comuni.h>
#include <cfspra.h>
#include <indsp.h>
#include <mov.h>
#include "cfban.h"
#define MAX_CONT_DOC 15
class TClifo_application : public TRelation_application
{
TMask* _msk;
TClifoVI* _rel;
TMask * _msk;
TClifoVI * _rel;
bool _lbcn, _gesven, _gessal, _has_cg, _liscatven, _geslv;
bool _savenew;
@ -48,7 +51,8 @@ protected:
////////////
static bool ban_notify(TSheet_field& ban, int r, KEY key);
static bool indsp_notify(TSheet_field& s, int r, KEY key);
static bool indsp_notify(TSheet_field& indsp, int r, KEY key);
static bool spese_notify(TSheet_field& spese, int r, KEY key);
static void indsp_sheet_rebuilder();
static bool effetti_notify(TSheet_field& s, int r, KEY key);
@ -66,6 +70,8 @@ protected:
virtual void mask2ini(const TMask& m, TConfig& ini);
TSheet_field& indsp_sheet() const;
TSheet_field& contatti_sheet() const;
TSheet_field& spese_sheet() const;
TString_array& field_sheet(short id) const;
void reset_sheet();
void indsp_pack();
@ -321,8 +327,8 @@ HIDDEN bool cofi_handler(TMask_field& f, KEY key)
m.set(F_TIPOPERS, isdigit(s1[0]) ? "G" : "F");
}
else
if (f.final_check(key))
return f.validate(key) && no_dup_fis(f, key) && almeno_cf_o_pi(f);
if (key == K_ENTER)
return f.validate(key) && no_dup_fis(f, key);
}
return true;
}
@ -331,7 +337,8 @@ HIDDEN bool paiv_handler(TMask_field& f, KEY key)
{
const TMask& m = f.mask();
if (!m.query_mode() && f.final_check(key))
if (!m.query_mode())
if (key == K_ENTER)
return f.validate(key) && no_dup_iva(f, key) && almeno_cf_o_pi(f);
return true;
}
@ -433,7 +440,7 @@ bool TClifo_application::crea_percipienti(TMask_field& f, KEY key)
TLocalisamfile anafis(LF_ANAGFIS);
anafis.put(ANF_CODANAGR, percip);
anafis.put(ANF_DATANASC, m.get(F_DATANASC));
anafis.put(ANF_SESSO, atoi(m.get(F_COFI).mid(9, 2)) > 31 ? 'F' : 'M');
anafis.put(ANF_SESSO, atoi(m.get(F_COFI).smid(9, 2)) > 31 ? 'F' : 'M');
anafis.put(ANF_COMNASC, m.get(F_COMNASC));
err = anafis.write();
if (err != NOERR)
@ -484,8 +491,8 @@ bool TClifo_application::percip_handler(TMask_field& f, KEY key)
if (key == K_TAB && m.field(F_RAGSOC).empty() &&
yesno_box(FR("Ragione sociale mancante: assumo %s"), (const char*)r))
{
m.set(F_RAGSOC, r.left(30), true);
m.set(F_RAGSOCA, r.mid(30), true);
m.set(F_RAGSOC, r.sleft(30), true);
m.set(F_RAGSOCA, r.smid(30), true);
}
if (m.get(F_INDCF).empty()) m.set(F_INDCF, anag.get(ANA_INDRES));
@ -739,6 +746,41 @@ HIDDEN bool altnewcli_handler(TMask_field& f, KEY key)
return true;
}
HIDDEN bool newclifor_handler(TMask_field& f, KEY key)
{
TMask& m = f.mask();
if (key == K_SPACE)
{
long cod = 0L;
TString tipo = m.get(F_TIPOCF) == "C" ? "F" : "C";
TToken_string key;
const long orig_cod = m.get_long(F_CODCF);
if (cod == 0L)
{
m.set(F_TIPOCF, tipo);
app().get_next_key(key);
cod = key.get_long(3);
m.set(F_TIPOCF, m.get(F_TIPOCF) == "C" ? "F" : "C");
m.set(F_CODASS, cod);
if (!app().pubsave(true))
return false;
}
if (cod > 0L)
{
m.set(F_TIPOCF, tipo);
m.set(F_CODCF, cod);
m.set(H_TIPOCF, m.get(F_TIPOCF) == "C" ? "F" : "C");
m.set(F_CODASS, orig_cod, 0x3);
}
else
return false;
}
return true;
}
HIDDEN bool contrlav_handler(TMask_field& f, KEY key)
{
if (key == K_SPACE)
@ -806,6 +848,7 @@ void TClifo_application::init_query_mode(TMask& m)
m.disable(DLG_CONTRLAV);
if (m.id2pos(DLG_ALTNEWCLI) >= 0)
m.enable(DLG_ALTNEWCLI);
m.disable(DLG_DUPL);
}
void TClifo_application::init_query_insert_mode(TMask& m)
@ -825,6 +868,7 @@ void TClifo_application::init_insert_mode(TMask& m)
}
if (m.id2pos(DLG_ALTNEWCLI) >= 0)
m.enable(DLG_ALTNEWCLI);
m.enable(DLG_DUPL);
}
void TClifo_application::init_modify_mode(TMask& m)
@ -835,6 +879,7 @@ void TClifo_application::init_modify_mode(TMask& m)
m.enable(DLG_CONTRLAV, _geslv && m.get(F_TIPOCF) == "C");
if (m.id2pos(DLG_ALTNEWCLI) >= 0)
m.disable(DLG_ALTNEWCLI);
m.enable(DLG_DUPL);
}
void TClifo_application::set_pnae(TMask& m, TToken_string& nonacc, TToken_string& nonscd)
@ -945,24 +990,23 @@ int TClifo_application::read(TMask& m)
if (_gesven)
{
TToken_string riga(240);
indsp_sheet().reset();
for (i = 0; i < _rel->indirizzi(); i++)
for (i = 1; i <= _rel->indirizzi().rows(); i++)
{
TRectype& rec=_rel->indirizzo(i);
riga.cut(0);
riga.add(rec.get(IND_RAGSOC));
riga.add(rec.get(IND_INDIR));
riga.add(rec.get(IND_CIV));
riga.add(rec.get(IND_LOCALITA));
riga.add(rec.get(IND_CAP));
riga.add(rec.get(IND_STATO));
riga.add(rec.get(IND_COM));
riga.add(rec.get(IND_PTEL));
riga.add(rec.get(IND_TEL));
riga.add(rec.get(IND_PFAX));
riga.add(rec.get(IND_FAX));
riga.add(rec.get(IND_IVARID));
const TRectype& rec = _rel->indirizzi()[i];
const int r = indsp_sheet().set_row_cell(F_RAGSOCI, rec.get(IND_RAGSOC));
indsp_sheet().set_row_cell(F_INDIRI, rec.get(IND_INDIR), r);
indsp_sheet().set_row_cell(F_CIVI, rec.get(IND_CIV), r);
indsp_sheet().set_row_cell(F_LOCALI, rec.get(IND_LOCALITA), r);
indsp_sheet().set_row_cell(F_CAPI, rec.get(IND_CAP), r);
indsp_sheet().set_row_cell(F_STATOI, rec.get(IND_STATO), r);
indsp_sheet().set_row_cell(F_COMI, rec.get(IND_COM), r);
indsp_sheet().set_row_cell(F_PTELI, rec.get(IND_PTEL), r);
indsp_sheet().set_row_cell(F_TELI, rec.get(IND_TEL), r);
indsp_sheet().set_row_cell(F_PFAXI, rec.get(IND_PFAX), r);
indsp_sheet().set_row_cell(F_FAXI, rec.get(IND_FAX), r);
indsp_sheet().set_row_cell(F_IVARIDI, rec.get(IND_IVARID), r);
TString8 key;
@ -971,16 +1015,16 @@ int TClifo_application::read(TMask& m)
const TRectype& com = cache().get(LF_COMUNI, key);
riga.add(com.get(COM_DENCOM));
riga.add(rec.get(IND_INDIR2));
riga.add(rec.get(IND_PADESTIN));
riga.add(rec.get(IND_PARIFAMM));
riga.add(rec.get(IND_CODIND));
indsp_sheet().row(i)=riga;
indsp_sheet().set_row_cell(F_DENCOMI, com.get(COM_DENCOM), r);
indsp_sheet().set_row_cell(F_INDIR2, rec.get(IND_INDIR2), r);
indsp_sheet().set_row_cell(F_CODDEST, rec.get(IND_CODDEST), r);
indsp_sheet().set_row_cell(F_PADESTINI, rec.get(IND_PADESTIN), r);
indsp_sheet().set_row_cell(F_PARIFAMMI, rec.get(IND_PARIFAMM), r);
// Load the sheets of CODINDDOC, CODINDSP, CODINDEFF.
riga.cut(0);
TToken_string riga;
riga.add(rec.get(IND_CODIND));
riga.add(rec.get(IND_RAGSOC));
riga.add(rec.get(IND_INDIR));
@ -990,20 +1034,31 @@ int TClifo_application::read(TMask& m)
field_sheet(F_CODINDSP).add(riga);
field_sheet(F_CODINDEFF).add(riga);
}
TSheet_field& s = m.sfield(F_SHEET_CONT);
s.destroy();
for (int c = 0; c < _rel->contatti(); c++)
contatti_sheet().reset();
for (int i = 1; i <= _rel->contatti().rows(); i++)
{
const TRectype& contact = _rel->contatto(c);
TToken_string& row = s.row(-1);
row = contact.get("SECOND");
row << "|||" << contact.get("DATA");
s.check_row(c);
const TRectype& contact = _rel->contatti()[i];
TAuto_token_string data = contact.get("DATA");
const int r = contatti_sheet().set_row_cell(F_CONTACT, data.get(0));
for (int j = 0; j < MAX_CONT_DOC; j++)
contatti_sheet().set_row_cell(F_TIPO1 + j, data.get(), r);
contatti_sheet().check_row(r);
}
spese_sheet().reset();
for (int i = 1; i <= _rel->cfspra().rows(); i++)
{
const TRectype& cfspra = _rel->cfspra()[i];
const int r = spese_sheet().set_row_cell(F_CONTACT, cfspra.get(CFSPRA_TIPOSPRA));
spese_sheet().set_row_cell(F_CODSP, cfspra.get(CFSPRA_CODSPRA), r);
spese_sheet().set_row_cell(F_QTADEF, cfspra.get(CFSPRA_QTADEF), r);
spese_sheet().check_row(r);
}
}
TToken_string key;
key.add(m.get(F_TIPOCF));
key.add(m.get(F_CODCF));
key.add("V");
@ -1075,37 +1130,40 @@ void TClifo_application::ini2mask(TConfig& ini, TMask& m, bool query)
{
TToken_string riga(240);
TString16 para;
indsp_sheet().reset();
for (i = 0; ; i++)
{
para.format("%d,%d", LF_INDSP, i+1);
if (!ini.set_paragraph(para))
break;
if (i == 0)
indsp_sheet().reset();
if (ini.set_paragraph(para))
{
const int r = indsp_sheet().set_row_cell(F_RAGSOCI, ini.get(IND_RAGSOC));
riga.cut(0);
riga.add(ini.get(IND_RAGSOC));
riga.add(ini.get(IND_INDIR));
riga.add(ini.get(IND_CIV));
riga.add(ini.get(IND_LOCALITA));
riga.add(ini.get(IND_CAP));
riga.add(ini.get(IND_STATO));
riga.add(ini.get(IND_COM));
riga.add(ini.get(IND_PTEL));
riga.add(ini.get(IND_TEL));
riga.add(ini.get(IND_PFAX));
riga.add(ini.get(IND_FAX));
riga.add(ini.get(IND_IVARID));
indsp_sheet().set_row_cell(F_INDIRI, ini.get(IND_INDIR), r);
indsp_sheet().set_row_cell(F_CIVI, ini.get(IND_CIV), r);
indsp_sheet().set_row_cell(F_LOCALI, ini.get(IND_LOCALITA), r);
indsp_sheet().set_row_cell(F_CAPI, ini.get(IND_CAP), r);
indsp_sheet().set_row_cell(F_STATOI, ini.get(IND_STATO), r);
indsp_sheet().set_row_cell(F_COMI, ini.get(IND_COM), r);
indsp_sheet().set_row_cell(F_PTELI, ini.get(IND_PTEL), r);
indsp_sheet().set_row_cell(F_TELI, ini.get(IND_TEL), r);
indsp_sheet().set_row_cell(F_PFAXI, ini.get(IND_PFAX), r);
indsp_sheet().set_row_cell(F_FAXI, ini.get(IND_FAX), r);
indsp_sheet().set_row_cell(F_IVARIDI, ini.get(IND_IVARID), r);
TString16 key;
key << ini.get(IND_STATO);
key << '|' << ini.get(IND_COM);
const TRectype & com = cache().get(LF_COMUNI, key);
riga.add(com.get(COM_DENCOM));
riga.add(ini.get(IND_INDIR2));
riga.add(ini.get(IND_CODIND));
indsp_sheet().row(i)=riga;
const TRectype & com = cache().get(LF_COMUNI, key);
indsp_sheet().set_row_cell(F_DENCOMI, com.get(COM_DENCOM), r);
indsp_sheet().set_row_cell(F_INDIR2, ini.get(IND_INDIR2), r);
indsp_sheet().set_row_cell(F_CODDEST, ini.get(IND_CODDEST), r);
indsp_sheet().set_row_cell(F_PADESTINI, ini.get(IND_PADESTIN), r);
indsp_sheet().set_row_cell(F_PARIFAMMI, ini.get(IND_PARIFAMM), r);
indsp_sheet().set_row_cell(F_CODIND, ini.get(IND_CODIND), r);
// Load the sheets of CODINDDOC, CODINDSP, CODINDEFF.
riga.cut(0);
@ -1118,8 +1176,42 @@ void TClifo_application::ini2mask(TConfig& ini, TMask& m, bool query)
field_sheet(F_CODINDSP).add(riga);
field_sheet(F_CODINDEFF).add(riga);
}
else
break;
}
contatti_sheet().reset();
for (i = 0; ; i++)
{
para.format("%d,%d", LF_MULTIREL, i + 1);
if (ini.set_paragraph(para))
{
TAuto_token_string data = ini.get("DATA");
const int r = contatti_sheet().set_row_cell(F_CONTACT, data.get(0));
for (int i = 0; i < MAX_CONT_DOC; i++)
contatti_sheet().set_row_cell(F_TIPO1 + i, data.get(), r);
}
else
break;
}
spese_sheet().reset();
for (i = 0; ; i++)
{
para.format("%d,%d", LF_CFSPRA, i + 1);
if (ini.set_paragraph(para))
{
const int r = spese_sheet().set_row_cell(F_CONTACT, ini.get(CFSPRA_TIPOSPRA));
spese_sheet().set_row_cell(F_CODSP, ini.get(CFSPRA_CODSPRA), r);
spese_sheet().set_row_cell(F_QTADEF, ini.get(CFSPRA_QTADEF), r);
}
else
break;
}
}
TString p;
p << LF_CFBAN << ",V";
TSheet_field & ns_sh = m.sfield(F_BANA);
@ -1176,9 +1268,9 @@ int TClifo_application::write(const TMask& m)
bool TClifo_application::remove()
{
int err = TRelation_application::remove();
bool ok = TRelation_application::remove();
if (err == NOERR)
if (ok)
{
TRelation * r = get_relation();
TToken_string key;
@ -1200,7 +1292,7 @@ bool TClifo_application::remove()
vs_ban.remove();
}
return err == NOERR;
return ok;
}
void TClifo_application::mask2ini(const TMask& m, TConfig& ini)
@ -1313,7 +1405,19 @@ TString_array& TClifo_application::field_sheet(short id) const
TSheet_field& TClifo_application::indsp_sheet() const
{
TSheet_field& o_sheet=_msk->sfield(F_SHEET_G_VEN);
TSheet_field& o_sheet = _msk->sfield(F_SHEET_G_VEN);
return o_sheet;
}
TSheet_field& TClifo_application::contatti_sheet() const
{
TSheet_field& o_sheet = _msk->sfield(F_SHEET_CONT);
return o_sheet;
}
TSheet_field& TClifo_application::spese_sheet() const
{
TSheet_field& o_sheet = _msk->sfield(F_SHEET_SPESE);
return o_sheet;
}
@ -1373,7 +1477,7 @@ void TClifo_application::common_f(const TMask& m)
{
const TString& alter = m.get(F_RICALT);
if (alter.blank() && m.mode() == MODE_INS)
((TMask &)m).set(F_RICALT, m.get(F_RAGSOC).left(m.field(F_RICALT).size()));
((TMask &)m).set(F_RICALT, m.get(F_RAGSOC).sleft(m.field(F_RICALT).size()));
TToken_string nonacceff(30, ';'), nonscadeff(30, ';');
get_pnae(m, nonacceff, nonscadeff);
@ -1385,63 +1489,119 @@ void TClifo_application::common_f(const TMask& m)
{
const char tipocf = m.get(F_TIPOCF)[0];
const long codcf = m.get_long(F_CODCF);
TRectype recind(LF_INDSP);
_rel->destroy_rows();
indsp_pack();
TArray& rows=indsp_sheet().rows_array();
int n_items = rows.items();
for (int i = 0; i < n_items; i++)
if (_rel->indirizzi().key().empty())
{
TToken_string& row=(TToken_string&)rows[i];
TRectype& rec=_rel->indirizzo(i);
row.restart();
rec.zero();
rec.put(IND_TIPOCF,tipocf);
rec.put(IND_CODCF,codcf);
rec.put(IND_RAGSOC,row.get());
rec.put(IND_INDIR,row.get());
rec.put(IND_CIV,row.get());
rec.put(IND_LOCALITA,row.get());
rec.put(IND_CAP,row.get());
rec.put(IND_STATO,row.get());
rec.put(IND_COM,row.get());
rec.put(IND_PTEL,row.get());
rec.put(IND_TEL,row.get());
rec.put(IND_PFAX,row.get());
rec.put(IND_FAX,row.get());
rec.put(IND_IVARID,row.get());
row.get();
rec.put(IND_INDIR2,row.get());
rec.put(IND_PADESTIN, row.get());
rec.put(IND_PARIFAMM, row.get());
rec.put(IND_CODIND,i+1);
}
TToken_string data;
TString8 first, second;
first.format("%c%06ld", m.get(F_TIPOCF)[0], m.get_long(F_CODCF));
TSheet_field& s = m.sfield(F_SHEET_CONT);
FOR_EACH_SHEET_ROW(s, r, row)
{
TRectype& rec=_rel->contatto(r);
rec.put("COD", "BACON");
rec.put("FIRST", first);
second.format("%06ld", row->get_long(0));
rec.put("SECOND", second);
row->get(2);
data.cut(0);
const char* d = NULL;
while ((d = row->get()))
{
if (*d > ' ')
data.add(d);
recind.put(IND_TIPOCF, tipocf);
recind.put(IND_CODCF, codcf);
_rel->indirizzi().set_key(&recind);
}
FOR_EACH_SHEET_ROW_LOOP(indsp_sheet(), r)
{
recind.zero();
recind.put(IND_TIPOCF,tipocf);
recind.put(IND_CODCF,codcf);
recind.put(IND_CODIND, r + 1);
recind.put(IND_RAGSOC, indsp_sheet().get_str_row_cell(r, F_RAGSOCI));
recind.put(IND_INDIR, indsp_sheet().get_str_row_cell(r, F_INDIRI));
recind.put(IND_CIV, indsp_sheet().get_str_row_cell(r, F_CIVI));
recind.put(IND_LOCALITA, indsp_sheet().get_str_row_cell(r, F_LOCALI));
recind.put(IND_CAP, indsp_sheet().get_str_row_cell(r, F_CAPI));
recind.put(IND_STATO, indsp_sheet().get_str_row_cell(r, F_STATOI));
recind.put(IND_COM, indsp_sheet().get_str_row_cell(r, F_COMI));
recind.put(IND_PTEL, indsp_sheet().get_str_row_cell(r, F_PTELI));
recind.put(IND_TEL, indsp_sheet().get_str_row_cell(r, F_TELI));
recind.put(IND_PFAX, indsp_sheet().get_str_row_cell(r, F_PFAXI));
recind.put(IND_FAX, indsp_sheet().get_str_row_cell(r, F_FAXI));
recind.put(IND_IVARID, indsp_sheet().get_str_row_cell(r, F_IVARIDI));
recind.put(IND_INDIR2, indsp_sheet().get_str_row_cell(r, F_DENCOMI));
recind.put(IND_PADESTIN, indsp_sheet().get_str_row_cell(r, F_PADESTINI));
recind.put(IND_CODDEST, indsp_sheet().get_str_row_cell(r, F_CODDEST));
recind.put(IND_PARIFAMM, indsp_sheet().get_str_row_cell(r, F_PARIFAMMI));
_rel->indirizzi().add_row(recind);
}
int err = _rel->indirizzi().write(true);
if (err != NOERR)
{
error_box(FR("Errore %d nella scrittura indirizzi"), err);
return;
}
TRectype recsp(LF_CFSPRA);
if (_rel->cfspra().key().empty())
{
recsp.put(CFSPRA_TIPOCF, tipocf);
recsp.put(CFSPRA_CODCF, codcf);
_rel->cfspra().set_key(&recsp);
}
FOR_EACH_SHEET_ROW_LOOP(spese_sheet(), rs)
{
recsp.zero();
recsp.put(CFSPRA_TIPOCF, tipocf);
recsp.put(CFSPRA_CODCF, codcf);
recsp.put(CFSPRA_NRIGA, rs + 1);
recsp.put(CFSPRA_TIPOSPRA, spese_sheet().get_str_row_cell(rs, F_TIPOSPRA));
recsp.put(CFSPRA_CODSPRA, spese_sheet().get_str_row_cell(rs, F_CODSP));
recsp.put(CFSPRA_QTADEF, spese_sheet().get_str_row_cell(rs, F_QTADEF));
_rel->cfspra().add_row(recsp);
}
err = _rel->cfspra().write(true);
if (err != NOERR)
{
error_box(FR("Errore %d nella scrittura spese"), err);
return;
}
rec.put("DATA", data);
}
TRectype reccon(LF_MULTIREL);
TString first, second;
int len = reccon.rec_des().field("SECOND").len();
if (_rel->contatti().key().empty())
{
reccon.put("COD", "BACON");
first.format("%s%06ld", (const char *)m.get(F_TIPOCF), m.get_long(F_CODCF));
reccon.put("FIRST", first);
_rel->contatti().set_key(&reccon);
}
FOR_EACH_SHEET_ROW_LOOP(contatti_sheet(), rc)
{
reccon.put("COD", "BACON");
first.format("%s%06ld", (const char *)m.get(F_TIPOCF), m.get_long(F_CODCF));
reccon.put("FIRST", first);
second.cut(0);
second << rc + 1;
second.right_just(len, '0');
reccon.put("SECOND", second);
TToken_string data(contatti_sheet().get_str_row_cell(rc, F_CONTACT), ',');
for (int i = 0; i < MAX_CONT_DOC; i++)
{
const TString & tipo = contatti_sheet().get_str_row_cell(rc, F_TIPO1 + i);
if (tipo.full())
data.add(tipo);
}
reccon.put("DATA", data);
_rel->contatti().add_row(reccon);
}
int err = _rel->contatti().write(true);
if (err != NOERR)
{
error_box(FR("Errore %d nella scrittura contatto"), err);
return;
}
TToken_string key;
key.add(m.get(F_TIPOCF));
key.add(m.get(F_CODCF));
key.add("V");
@ -1568,6 +1728,22 @@ bool TClifo_application::indsp_notify(TSheet_field& indsp, int r, KEY key)
return true;
}
bool TClifo_application::spese_notify(TSheet_field& spese, int r, KEY key)
{
switch (key)
{
case K_CTRL + K_INS:
// request to add the row #r
// Set tipo to S
spese.set_row_cell(F_TIPOSPRA, "S", r);
spese.check_row(r);
break;
default:
break;
}
return true;
}
bool TClifo_application::effetti_notify(TSheet_field& pnae, int r, KEY key)
{
if (key == K_INS)
@ -1616,9 +1792,7 @@ bool TClifo_application::user_create() // initvar e arrmask
//gestisce i campi salvati sulla tabella di modulo lv020 (lvclifo)
_rel->add("&LV020" ,"CODTAB==" CLI_TIPOCF "+" CLI_CODCF, 1, LF_CLIFO, LVAUT);
_rel->write_enable(-LVAUT); //abilita la lettura / scrittura sul record collegato
_msk = new TMask("cg0200a") ;
_msk->set_handler(F_TIPOCF, tipocf_handler);
_msk->set_handler(F_COFI, cofi_handler);
_msk->set_handler(F_PAIV, paiv_handler);
@ -1634,6 +1808,7 @@ bool TClifo_application::user_create() // initvar e arrmask
_msk->set_handler(LST_TIPO_RFSO, rfso_handler);
_msk->set_handler(F_STATOCF, stato_handler);
_msk->set_handler(F_PADESTIN, coddest_handler);
_msk->set_handler(DLG_DUPL, newclifor_handler);
TSheet_field & ns_sh = _msk->sfield(F_BANA);
@ -1642,22 +1817,23 @@ bool TClifo_application::user_create() // initvar e arrmask
TSheet_field& ind = _msk->sfield(F_SHEET_G_VEN);
ind.set_notify(indsp_notify);
TSheet_field& spese = _msk->sfield(F_SHEET_SPESE);
spese.set_notify(spese_notify);
ind.sheet_mask().set_handler(F_COMI, comi_handler);
ind.sheet_mask().set_handler(F_PADESTINI, coddest_handler);
TSheet_field& pnae = _msk->sfield(F_NONACCEFF);
pnae.set_notify(effetti_notify);
_savenew = !ini_get_bool(CONFIG_STUDIO, "cg", "Cg02SN");
return true;
}
bool TClifo_application::user_destroy() // releasev e arrmask
{
delete _rel;
// da errore in inserimento da controllare safe_delete(_rel);
return true;
}

View File

@ -1,12 +1,21 @@
#include <execp.h>
#include <progind.h>
#include <recarray.h>
#include <relapp.h>
#include "..\ve\velib.h"
#include "cg0.h"
#include "cg0700a.h"
#include "cg0700b.h"
#include <comuni.h>
#include <clifo.h>
#include <cfven.h>
#include "cfban.h"
#include <doc.h>
#include <occas.h>
#include <pconti.h>
#include <postman.h>
#include <saldi.h>
#include <automask.h>
#include <validate.h>
@ -15,15 +24,281 @@
// TCheck_PIVA_mask
///////////////////////////////////////////////////////////
class TOccas_mask : public TAutomask
class TOccasionali_mask : public TAutomask
{
protected:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
public:
TOccas_mask() : TAutomask("cg0700a") { }
void update_ban(const char * tipo, long codcf, const TRectype & recdoc);
void occ2clifor(const char * tipo);
TOccasionali_mask() : TAutomask("cg0700a") { }
};
bool TOccas_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
void TOccasionali_mask::update_ban(const char * tipo, long codcf, const TRectype & recdoc)
{
TString iban = recdoc.get(DOC_IBAN);
if (iban.full())
{
TToken_string key;
bool updated = false;
key.add(tipo);
key.add(codcf);
key.add(tipo == "C" ? "N" : "V");
TRecord_array vs_ban(key, LF_CFBAN);
const int vsrow = vs_ban.rows();
bool found = false;
for (int i = 1; !found && i <= vsrow; i++)
{
TRectype & ban = (TRectype &)vs_ban.row(i);
found = ban.get(CFBAN_IBAN) == recdoc.get(DOC_IBAN);
}
if (!found)
{
TRectype recban = vs_ban.key();
recban.put(CFBAN_ABI, recdoc.get(DOC_CODABIA));
recban.put(CFBAN_CAB, recdoc.get(DOC_CODCABA));
recban.put(CFBAN_NUMCC, recdoc.get(DOC_IBAN).smid(14));
recban.put(CFBAN_IBAN, recdoc.get(DOC_IBAN));
vs_ban.add_row(recban);
vs_ban.write(true);
}
}
TString abip = recdoc.get(DOC_CODABIP);
if (abip.full())
{
TToken_string key;
bool found = false;
key.add(tipo);
key.add(codcf);
key.add(tipo == "C" ? "V" : "N");
TRecord_array ns_ban(key, LF_CFBAN);
const int nsrow = ns_ban.rows();
for (int i = 1; !found && i < nsrow; i++)
{
TRectype & ban = (TRectype &) ns_ban.row(i);
found = ban.get(CFBAN_ABI) == recdoc.get(DOC_CODABIP) &&
ban.get(CFBAN_CAB) == recdoc.get(DOC_CODCABP) &&
ban.get(CFBAN_PROGPR) == recdoc.get(DOC_PROGBNP);
}
if (!found)
{
TRectype recban = ns_ban.key();
recban.put(CFBAN_ABI, recdoc.get(DOC_CODABIP));
recban.put(CFBAN_CAB, recdoc.get(DOC_CODCABP));
recban.put(CFBAN_PROGPR, recdoc.get(DOC_PROGBNP));
key = recdoc.get(DOC_CODABIP);
key << recdoc.get(DOC_CODCABP) << recdoc.get(DOC_PROGBNP);
const TRectype & banp = cache().get("BNP", key);
recban.put(CFBAN_NUMCC, banp.get("S3").smid(14));
recban.put(CFBAN_IBAN, banp.get("S3"));
ns_ban.add_row(recban);
ns_ban.write(true);
}
}
}
void TOccasionali_mask::occ2clifor(const char * tipo)
{
TToken_string key = tipo;
bool italian = get(O_STATOPAIV).blank();
bool found = false;
long codcf = 0L;
TString8 para;
TString ragsoc;
if (get(O_PAIV).full())
{
key.add(get(O_STATOPAIV));
key.add(get(O_PAIV));
const TRectype & clifor = cache().get(LF_CLIFO, key, 5);
ragsoc = clifor.get(CLI_RAGSOC);
codcf = clifor.get_long(CLI_CODCF);
found = clifor.full();
if (italian && !found)
{
key.add("IT", 1);
const TRectype & clifor = cache().get(LF_CLIFO, key, 5);
found = clifor.full();
ragsoc = clifor.get(CLI_RAGSOC);
codcf = clifor.get_long(CLI_CODCF);
}
if (found)
{
TString message = tipo == "C" ? TR("Il cliente ") : TR("Il fornitore "); message << ragsoc << TR(" ha la stessa partita IVA, devo uilizzarlo");
found = yesno_box(message);
}
}
if (!found && get(O_COFI).full())
{
key = tipo;
key.add(get(O_COFI));
const TRectype & clifor = cache().get(LF_CLIFO, key, 4);
found = clifor.full();
codcf = clifor.get_long(CLI_CODCF);
ragsoc = clifor.get(CLI_RAGSOC);
if (found)
{
TString message = tipo == "C" ? TR("Il cliente ") : TR("Il fornitore "); message << ragsoc << TR(" ha lo stesso codice fiscale, devo utilizzarlo");
found = yesno_box(message);
}
}
if (!found)
{
TFilename tmp;
tmp.temp("occ", "ini");
{
TConfig ini(tmp, "Transaction");
ini.set("Firm", main_app().get_firm());
ini.set("User", user());
ini.set("HostName", get_hostname());
int year, release, tag, patch;
if (main_app().get_version_info(year, release, tag, patch))
{
TString80 ver;
ver.format("%d %d.%d-%d", year, release, tag, patch);
ini.set("Version", ver);
}
char mode[2] = { transaction_mode_automatic, '\0' };
ini.set("Action", TRANSACTION_INSERT);
ini.set("Mode", mode);
para.format("%d", LF_CLIFO);
ini.set(CLI_RAGSOC, get(O_RAGSOC), para);
ini.set(CLI_STATOCF, get(O_STATO));
ini.set(CLI_COMCF, get(O_COMUNE));
ini.set(CLI_CAPCF, get(O_CAP));
ini.set(CLI_INDCF, get(O_INDIRIZZO));
ini.set(CLI_CIVCF, get(O_NUMERO));
ini.set(CLI_COFI, get(O_COFI));
ini.set(CLI_STATOPAIV, get(O_STATOPAIV));
ini.set(CLI_PAIV, get(O_PAIV));
ini.set(CLI_SESSO, get(O_SESSO));
ini.set(CLI_DATANASC, get(O_DATANAS));
ini.set(CLI_STATONASC, get(O_STATONAS));
ini.set(CLI_COMNASC, get(O_COMUNENAS));
ini.set(CLI_LOCCF, get(O_LOCALITA));
ini.set(CLI_REFERENTE, get(O_REFERENTE));
ini.set(CLI_BYMAIL, get(O_BYMAIL));
ini.set(CLI_MAIL, get(O_MAIL));
ini.set(CLI_DOCMAIL, get(O_DOCMAIL));
ini.set(CLI_PEC, get(O_PEC));
ini.set(CLI_PTEL, get(O_PTEL));
ini.set(CLI_TEL, get(O_TEL));
ini.set(CLI_PTEL2, get(O_PTEL2));
ini.set(CLI_TEL2, get(O_TEL2));
ini.set(CLI_PTEL3, get(O_PTEL3));
ini.set(CLI_TEL3, get(O_TEL3));
ini.set(CLI_TIPOPERS, get(O_TIPOPERS));
ini.set(CLI_ALLEG, get(O_ALLEG));
ini.set(CLI_PFAX, get(O_PFAX));
ini.set(CLI_FAX, get(O_FAX));
para.format("%d", LF_CFVEN);
ini.set(CFV_PADESTIN, get(O_PADESTIN), para);
}
TString cmd("cg0 -1 -i"); cmd << tmp;
TExternal_app app(cmd);
app.run();
para.format("%d", LF_CLIFO);
TConfig ini(tmp, para);
codcf = ini.get_long(CLI_CODCF);
tmp.fremove();
}
if (codcf > 0L)
{
TMask m("cg0700b");
TDate from = today;
m.set(F_CODICE, get(O_CODICE));
m.set(F_CODCF, codcf);
m.set(F_RAGSOC, ragsoc);
from.set_start_year();
m.set(F_FROM, from);
if (m.run() == K_ENTER)
{
TString query("USE ");
query << LF_DOC << " SELECT " << DOC_OCFPI << "==\"" << get(O_CODICE) << "\"\n";
query << "FROM " << DOC_ANNO << "=" << from.year();
TISAM_recordset clifor_recset(query);
const int items = clifor_recset.items();
clifor_recset.freeze();
if (items == 0)
message_box(TR("Nessun documento trovato"));
else
{
TProgress_monitor p(items, "Aggiornamento documenti");
const TRectype & recdoc = clifor_recset.curr();
for (clifor_recset.move_first(); p.addstatus() && !clifor_recset.eof(); clifor_recset.move_next())
{
TDocumento doc(recdoc);
doc.put(DOC_CODCF, codcf);
doc.zero(DOC_OCFPI);
doc.zero(DOC_OCCAS);
doc.rewrite();
}
key = tipo;
key.add(codcf);
TRectype & clifor = (TRectype &) cache().get(LF_CLIFO, key);
clifor_recset.move_last();
clifor.put(CLI_CODVAL, recdoc.get(DOC_CODVAL));
clifor.put(CLI_CODLIN, recdoc.get(DOC_CODLIN));
clifor.put(CLI_CODPAG, recdoc.get(DOC_CODPAG));
clifor.rewrite();
update_ban(tipo, codcf, recdoc);
TRectype & cfven = (TRectype &)cache().get(LF_CFVEN, key);
cfven.put(CFV_CATVEN, recdoc.get(DOC_CATVEN));
cfven.put(CFV_CODLIST, recdoc.get(DOC_CODLIST));
cfven.put(CFV_CODZONA, recdoc.get(DOC_ZONA));
cfven.put(CFV_CODAG, recdoc.get(DOC_CODAG));
cfven.put(CFV_CODAG1, recdoc.get(DOC_CODAGVIS));
cfven.put(CFV_CODSPMEZZO, recdoc.get(DOC_CODSPMEZZO));
cfven.put(CFV_CODPORTO, recdoc.get(DOC_CODPORTO));
cfven.put(CFV_CODVETT1, recdoc.get(DOC_CODVETT1));
cfven.put(CFV_CODVETT2, recdoc.get(DOC_CODVETT2));
cfven.put(CFV_CODVETT3, recdoc.get(DOC_CODVETT3));
cfven.write_rewrite();
}
}
}
}
bool TOccasionali_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
{
switch (o.dlg())
{
@ -32,22 +307,23 @@ bool TOccas_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
{
TMask& m = o.mask();
TString16 cofi = m.get(O_COFI);
if (cofi.blank())
cofi = m.get(O_CODICE);
if (cf_check(m.get(O_STATONAS), cofi))
{
int giorno = atoi(cofi.mid(9,2));
int giorno = atoi(cofi.smid(9,2));
m.set(O_SESSO, giorno > 40 ? "F" : "M");
if (m.field(O_COMUNENAS).empty())
m.set(O_COMUNENAS, cofi.mid(11,4), 0x2);
m.set(O_COMUNENAS, cofi.smid(11,4), 0x2);
if (m.field(O_DATANAS).empty())
{
const TFixed_string mesi("ABCDEHLMPRST");
const int mese = mesi.find(cofi[8])+1;
int anno = atoi(cofi.mid(6,2));
int anno = atoi(cofi.smid(6,2));
if (giorno > 0 && mese > 0 && anno > 0)
{
giorno %= 40;
@ -58,20 +334,33 @@ bool TOccas_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
}
}
break;
default: break;
case DLG_CLI:
if (e == fe_button)
occ2clifor("C");
break;
case DLG_FOR:
if (e == fe_button)
occ2clifor("F");
break;
default: break;
}
return true;
}
class TOccasionali_app : public TRelation_application
{
TOccas_mask * _msk;
TRelation *_rel;
TOccasionali_mask * _msk;
TRelation * _rel;
bool user_create();
bool user_destroy();
virtual void init_query_mode(TMask&) override;
// @cmember Inizializza la maschera per il modo inserimento
virtual void init_insert_mode(TMask&) override;
// @cmember Inizializza la maschera per il modo modifica
virtual void init_modify_mode(TMask&) override;
virtual TMask* _get_mask(int mode) {return _msk;}
virtual bool changing_mask(int mode) {return FALSE;}
virtual bool changing_mask(int mode) {return false;}
void ini2mask(TConfig& ini, TMask& m, bool query);
public:
@ -82,20 +371,37 @@ public:
HIDDEN inline TOccasionali_app& app() { return (TOccasionali_app&) main_app();}
void TOccasionali_app::init_query_mode(TMask& m)
{
m.disable(DLG_CLI);
m.disable(DLG_FOR);
TRelation_application::init_query_mode(m);
}
void TOccasionali_app::init_insert_mode(TMask& m)
{
m.disable(DLG_CLI);
m.disable(DLG_FOR);
}
void TOccasionali_app::init_modify_mode(TMask& m)
{
m.enable(DLG_CLI);
m.enable(DLG_FOR);
}
bool TOccasionali_app::user_create()
{
open_files(LF_OCCAS, 0);
open_files(LF_OCCAS, LF_CLIFO, LF_CFVEN, LF_DOC, LF_RIGHEDOC, LF_CFBAN, 0);
_rel = new TRelation(LF_OCCAS);
_msk = new TOccas_mask() ;
_msk = new TOccasionali_mask() ;
return true;
}
bool TOccasionali_app::user_destroy()
{
delete _rel;
delete _msk;
safe_delete(_rel);
safe_delete(_msk);
return true;
}

View File

@ -34,4 +34,7 @@
#define O_PFAX 131
#define O_FAX 132
#include <occas.h>
#define DLG_CLI 200
#define DLG_FOR 201
#include <occas.h>

View File

@ -4,8 +4,19 @@ TOOLBAR "topbar" 0 0 0 2
#include <relapbar.h>
ENDPAGE
BUTTON DLG_CLI 2 2
BEGIN
PROMPT 13 1 "->~Cliente"
PICTURE TOOL_EDIT
END
BUTTON DLG_FOR 2 2
BEGIN
PROMPT 13 1 "->~Fornitore"
PICTURE TOOL_EDIT
END
ENDPAGE
PAGE "Clienti/Fornitori occasionali" 0 0 0 0
@ -252,20 +263,15 @@ BEGIN
FIELD OCC_PADESTIN
END
TEXT DLG_NULL
BEGIN
PROMPT 2 16 "E-Mail"
END
STRING O_MAIL 50 25
BEGIN
PROMPT 2 17 "Normale "
PROMPT 2 16 "E-Mail Normale "
FIELD OCC_MAIL
END
BOOLEAN O_BYMAIL
BEGIN
PROMPT 40 17 "Consenso spedizione doc tramite email"
PROMPT 47 16 "Consenso spedizione doc tramite email"
FIELD OCC_BYMAIL
MESSAGE FALSE CLEAR,O_DOCMAIL
MESSAGE TRUE ENABLE,O_DOCMAIL
@ -273,70 +279,69 @@ END
STRING O_DOCMAIL 50 25
BEGIN
PROMPT 2 18 "Documenti "
PROMPT 2 17 "E-Mail Documenti "
FIELD OCC_DOCMAIL
CHECKTYPE REQUIRED
END
STRING O_PEC 80 45
BEGIN
PROMPT 2 19 "Pec "
PROMPT 2 18 "Pec "
FIELD OCC_PEC
END
STRING O_PTEL 5
BEGIN
PROMPT 2 20 "Telefono "
PROMPT 2 19 "Telefono "
FIELD OCC_PTEL
HELP "Prefisso telefonico primo recapito"
END
STRING O_TEL 20 15
BEGIN
PROMPT 18 20 "/"
PROMPT 18 19 "/"
FIELD OCC_TEL
HELP "Numero telefonico primo recapito"
END
STRING O_PTEL2 5
BEGIN
PROMPT 11 21 " "
PROMPT 11 20 " "
FIELD OCC_PTEL2
HELP "Prefisso telefonico secondo recapito"
END
STRING O_TEL2 20 15
BEGIN
PROMPT 18 21 "/"
PROMPT 18 20 "/"
FIELD OCC_TEL2
HELP "Numero telefonico secondo recapito"
END
STRING O_PTEL3 5
BEGIN
PROMPT 11 22 " "
PROMPT 11 21 " "
FIELD OCC_PTEL3
HELP "Prefisso telefonico terzo recapito"
END
STRING O_TEL3 20 15
BEGIN
PROMPT 18 22 "/"
PROMPT 18 21 "/"
FIELD OCC_TEL3
HELP "Numero telefonico terzo recapito"
END
STRING O_PFAX 5
BEGIN
PROMPT 2 23 "FAX "
PROMPT 2 22 "FAX "
FIELD OCC_PFAX
HELP "Prefisso telefonico fax"
END
STRING O_FAX 23 15
BEGIN
PROMPT 18 23 "/"
PROMPT 18 22 "/"
FIELD OCC_FAX
HELP "Numero telefonico fax"
END

6
src/cg/cg0700b.h Normal file
View File

@ -0,0 +1,6 @@
// Maschera clienti/fornitori occasionali
#define F_CODICE 100
#define F_CODCF 101
#define F_RAGSOC 102
#define F_FROM 103

42
src/cg/cg0700b.uml Normal file
View File

@ -0,0 +1,42 @@
#include "cg0700b.h"
TOOLBAR "topbar" 0 0 0 2
#include <stdbar.h>
ENDPAGE
PAGE "Occasionale --> Cliente/Fornitore" -1 -1 76 9
STRING F_CODICE 16
BEGIN
PROMPT 2 1 "Occasionale "
FLAGS "D"
END
NUMBER F_CODCF 6 0
BEGIN
PROMPT 2 2 "Codice "
FLAGS "D"
END
STRING F_RAGSOC 50
BEGIN
PROMPT 2 3 "Ragione sociale "
FLAGS "D"
END
GROUPBOX 300 71 3
BEGIN
PROMPT 1 4 "@BConverti documenti"
END
DATE F_FROM
BEGIN
PROMPT 2 5 "Dal "
CHECKTYPE REQUIRED
END
ENDPAGE
ENDMASK