401223fad3
Files correlati : Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/branches/R_10_00@21936 c028cbd2-c16b-5b4b-a496-9718f37d4682
497 lines
15 KiB
C++
Executable File
497 lines
15 KiB
C++
Executable File
|
|
#include "halib.h"
|
|
|
|
TString4 TContratto_premi::_tipo_ant;
|
|
TString4 TContratto_premi::_tipo_post;
|
|
TString4 TContratto_premi::_tipo_rifa;
|
|
|
|
//metodi della TContratto_premi
|
|
char TContratto_premi::tipo_contratto() const
|
|
{
|
|
//i tipi contratto vengono caricati solo al primo accesso, in modo da non dover rileggere tutte le volte..
|
|
//..il file di configurazione
|
|
if (_tipo_ant.blank())
|
|
{
|
|
TConfig config(CONFIG_DITTA, "ha");
|
|
_tipo_ant = config.get("CoAntTip");
|
|
_tipo_post = config.get("CoPostTip");
|
|
_tipo_rifa = config.get("CoRifaTip");
|
|
}
|
|
|
|
//ritorna il tipo contratto come carattere; se non lo trova -> tipo 'P'osticipo perchè..
|
|
//..è il tipo meno pericoloso (comunque non dovrebbe mai accadere in quanto il tipo è..
|
|
//..obbligatorio sia in immissione contratto che in configurazione modulo)
|
|
const TString& tipo_doc = get(DOC_TIPODOC);
|
|
if (tipo_doc == _tipo_ant)
|
|
return 'A';
|
|
else
|
|
{
|
|
if (tipo_doc == _tipo_rifa)
|
|
return 'R';
|
|
}
|
|
return 'P';
|
|
}
|
|
|
|
|
|
TContratto_premi::TContratto_premi(char provv, int anno, const char* codnum, long ndoc)
|
|
: TDocumento(provv, anno, codnum, ndoc)
|
|
{}
|
|
|
|
TContratto_premi::TContratto_premi(const TRectype& rec_doc)
|
|
: TDocumento(rec_doc)
|
|
{}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////
|
|
// Recordset specifici per i dati da trasferire OUTPUT
|
|
/////////////////////////////////////////////////////////////
|
|
//questo serve solo per l'ultima riga con il return (\r\n)
|
|
void THardy_recordset::add_eol_field()
|
|
{
|
|
create_field("ACapo", -1, 2, _alfafld, false, TVariant("\r\n"));
|
|
}
|
|
|
|
//questo è il metodo magico che vale per tutti
|
|
void THardy_recordset::add_field(const char* name, const char* tipo, int pos, int len)
|
|
{
|
|
const TFixed_string str_tipo(tipo);
|
|
if (str_tipo.ends_with("N"))
|
|
{
|
|
create_field(name, pos-1, len, _intzerofld);
|
|
return;
|
|
}
|
|
create_field(name, pos-1, len, _alfafld);
|
|
}
|
|
|
|
void THardy_recordset::add_trc_field(const char* tr, const char* name, const char* tipo, int pos, int len)
|
|
{
|
|
CHECK(tr && strlen(tr) == 2, "Lunghezza tipo record errata!!");
|
|
TString80 trc_name;
|
|
trc_name << tr << '.' << name;
|
|
add_field(trc_name, tipo, pos, len);
|
|
}
|
|
|
|
|
|
|
|
void THardy_recordset::insert_field(const char* name, const char* tipo, int pos, int len)
|
|
{
|
|
if (pos >= 1)
|
|
{
|
|
TArray& trc = (TArray&)*_trc.first_item();
|
|
FOR_EACH_ARRAY_ITEM(trc, r, itm)
|
|
{
|
|
TAS400_column_info& fld = (TAS400_column_info&)*itm;
|
|
if (fld._pos+1 >= pos)
|
|
{
|
|
fld._pos += len;
|
|
}
|
|
}
|
|
}
|
|
add_field(name, tipo, pos, len);
|
|
}
|
|
|
|
//al costruttore viene passato come parametro la lunghezza del tracciato
|
|
THardy_recordset::THardy_recordset(const int rec_lenght) : TAS400_recordset("AS400()")
|
|
{
|
|
TString16 query;
|
|
query << "AS400(" << rec_lenght << ")";
|
|
TFilename cazzone;
|
|
parse_query(query, cazzone);
|
|
}
|
|
|
|
|
|
//Agenti
|
|
//-------
|
|
TEsporta_agenti_recordset::TEsporta_agenti_recordset(int rec_length)
|
|
: THardy_recordset(rec_length)
|
|
{
|
|
add_field("CodiceTerminale", T_N, 1, 3); //x
|
|
add_field(AGE_CODAGE, T_N, 4, 3); //x
|
|
add_field("NonUsato", T_X, 7, 6);
|
|
add_field("Targa", T_X, 13, 8);
|
|
add_field("nDDT", T_N, 21, 5);
|
|
add_field("nFATT", T_N, 26, 5);
|
|
add_field("nBOLLA", T_N, 31, 5);
|
|
add_field(AGE_RAGSOC, T_X, 36, 30); //x
|
|
add_field("nORD", T_N, 66, 5);
|
|
add_field("nSAGIT", T_N, 71, 5);
|
|
add_eol_field();
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------
|
|
//Clienti
|
|
//-------
|
|
|
|
void TEsporta_clienti_recordset::set_fatt(const char* fld_name, const TVariant& value, const bool is_fatt)
|
|
{
|
|
TString80 new_fld_name = fld_name;
|
|
if (is_fatt)
|
|
new_fld_name << "Fatt";
|
|
|
|
THardy_recordset::set(new_fld_name, value);
|
|
}
|
|
|
|
TEsporta_clienti_recordset::TEsporta_clienti_recordset(int rec_length)
|
|
: THardy_recordset(rec_length)
|
|
{
|
|
add_field("CodiceTerminale", T_N, 1, 3); //x
|
|
add_field("CodiceCliente", T_N, 4, 6); //x
|
|
add_field("RagioneSociale", T_X, 10, 34); //x
|
|
add_field("Indirizzo", T_X, 44, 34); //x
|
|
add_field("Localita", T_X, 78, 20); //x
|
|
add_field("CAP", T_X, 98, 5); //x
|
|
add_field("Provincia", T_X, 103, 2); //x
|
|
add_field("PartitaIVA", T_X, 105, 11); //x
|
|
add_field("CodiceFiscale", T_X, 116, 16); //x
|
|
add_field("RagioneSocialeFatt", T_X, 132, 34); //x da qui i dati di codalleg
|
|
add_field("IndirizzoFatt", T_X, 166, 34); //x
|
|
add_field("LocalitaFatt", T_X, 200, 20); //x
|
|
add_field("CAPFatt", T_X, 220, 5); //x
|
|
add_field("ProvinciaFatt", T_X, 225, 2); //x
|
|
add_field("PartitaIVAFatt", T_X, 227, 11); //x
|
|
add_field("CodiceFiscaleFatt", T_X, 238, 16); //x //fine dati di codalleg
|
|
add_field("CodicePagamento", T_X, 254, 2); //x
|
|
add_field("CodiceListino", T_X, 256, 3); //x
|
|
add_field("CodicePromozione", T_X, 259, 3);
|
|
add_field("ScontoFineFattura", T_2Nv2N,262, 4); //x
|
|
add_field("Giro01", T_N, 266, 3);
|
|
add_field("Giro02", T_N, 269, 3);
|
|
add_field("Giro03", T_N, 272, 3);
|
|
add_field("Giro04", T_N, 275, 3);
|
|
add_field("Giro05", T_N, 278, 3);
|
|
add_field("Giro06", T_N, 281, 3);
|
|
add_field("NumeroTelefono", T_X, 284, 10); //x
|
|
add_field("EsenteIVA", T_X, 294, 2); //x
|
|
add_field("TipoDoc", T_X, 296, 1);
|
|
add_field("NoConsegna", T_X, 297, 1); //x
|
|
add_field("Fido", T_Nv2N, 298, 8); //x
|
|
|
|
add_eol_field();
|
|
}
|
|
//..e variazioni clienti
|
|
TEsporta_clientiVAR_recordset::TEsporta_clientiVAR_recordset()
|
|
: TEsporta_clienti_recordset(308)
|
|
{
|
|
insert_field("Segno", T_X, 4, 1); //x
|
|
}
|
|
|
|
//Prodotti
|
|
//--------
|
|
TEsporta_prodotti_recordset::TEsporta_prodotti_recordset(int rec_length)
|
|
: THardy_recordset(rec_length)
|
|
{
|
|
add_field(ANAMAG_CODART, T_X, 1, 5); //x
|
|
add_field(ANAMAG_DESCR, T_X, 6, 30); //x
|
|
add_field(UMART_PREZZO, T_Nv3N, 36, 7); //x
|
|
add_field(ANAMAG_CODIVA, T_N, 43, 2); //x //attenzione che è una aliquota!
|
|
add_field(UMART_UM, T_X, 45, 2); //x
|
|
add_field("NONusato", T_X, 47, 1);
|
|
add_field(ANAMAG_SCONTO, T_2Nv2N,48, 4); //x
|
|
add_field("ScontoArt2", T_2Nv2N,52, 4);
|
|
add_field("Fascia", T_X, 56, 1);
|
|
add_field("PrezzoMinimo", T_Nv3N, 57, 7);
|
|
add_eol_field();
|
|
}
|
|
//..e variazioni prodotti
|
|
TEsporta_prodottiVAR_recordset::TEsporta_prodottiVAR_recordset()
|
|
: TEsporta_prodotti_recordset(66)
|
|
{
|
|
insert_field("Segno", T_X, 1, 1); //x
|
|
}
|
|
|
|
//Linee
|
|
//-----
|
|
TEsporta_linee_recordset::TEsporta_linee_recordset(int rec_length)
|
|
: THardy_recordset(rec_length)
|
|
{
|
|
add_field("Fascia", T_X, 1, 1);
|
|
add_field("Descrizione", T_X, 2, 50);
|
|
add_eol_field();
|
|
}
|
|
|
|
|
|
//Righe Listini
|
|
//-------------
|
|
TEsporta_listini_recordset::TEsporta_listini_recordset(int rec_length)
|
|
: THardy_recordset(rec_length)
|
|
{
|
|
add_field("CodiceTerminale", T_N, 1, 3); //x
|
|
add_field(RCONDV_COD, T_X, 4, 3); //x
|
|
add_field(RCONDV_CODRIGA, T_X, 7, 5); //x
|
|
add_field(RCONDV_PREZZO, T_Nv3N, 12, 7); //x
|
|
add_field(RCONDV_SCONTO, T_2Nv2N,19, 4); //x
|
|
add_field("Sconto2", T_2Nv2N,23, 4);
|
|
add_field("Sconto3", T_2Nv2N,27, 4);
|
|
add_field("CasaMandante", T_NS, 31, 6);
|
|
add_eol_field();
|
|
}
|
|
//..e variazioni listini
|
|
TEsporta_listiniVAR_recordset::TEsporta_listiniVAR_recordset()
|
|
: TEsporta_listini_recordset(39)
|
|
{
|
|
insert_field("Segno", T_X, 4, 1); //x
|
|
}
|
|
|
|
|
|
//Offerte
|
|
//-------
|
|
TEsporta_offerte_recordset::TEsporta_offerte_recordset(int rec_length)
|
|
: THardy_recordset(rec_length)
|
|
{
|
|
add_field(CONDV_COD, T_X, 1, 3);
|
|
add_field(CONDV_COD, T_X, 4, 3);
|
|
add_field(CONDV_VALIN, T_X, 7, 8);
|
|
add_field(CONDV_VALFIN, T_X, 15, 8);
|
|
add_eol_field();
|
|
}
|
|
|
|
|
|
//Righe Contratti
|
|
//---------------
|
|
TEsporta_contratti_recordset::TEsporta_contratti_recordset(int rec_length)
|
|
: THardy_recordset(rec_length)
|
|
{
|
|
add_field("CodiceTerminale", T_N, 1, 3); //x
|
|
add_field(CONDV_CODCF, T_N, 4, 6); //x
|
|
add_field(RCONDV_CODRIGA, T_X, 10, 5); //x
|
|
add_field(RCONDV_PREZZO, T_Nv3N, 15, 7); //x
|
|
add_field(RCONDV_SCONTO, T_2Nv2N,22, 4); //x
|
|
add_field("Sconto2", T_2Nv2N,26, 4);
|
|
add_field("Sconto3", T_2Nv2N,30, 4);
|
|
add_field(CONDV_VALIN, T_X, 34, 8); //x
|
|
add_field(CONDV_VALFIN, T_X, 42, 8); //x
|
|
add_eol_field();
|
|
}
|
|
|
|
|
|
//Rdoc (Carico) è una riga di un documento o un movimento di magazzino nel caso del ripristino
|
|
//-------------
|
|
TEsporta_carico_recordset::TEsporta_carico_recordset(int rec_length)
|
|
: THardy_recordset(rec_length)
|
|
{
|
|
add_field("CodiceTerminale", T_N, 1, 3); //x
|
|
add_field("CodiceArticolo", T_X, 4, 5); //x
|
|
add_field("QuantitaCaricata",T_Nv2N,9, 7); //x
|
|
add_field("CodiceLotto", T_X, 16, 10);
|
|
add_eol_field();
|
|
}
|
|
|
|
//Sospesi
|
|
//-------
|
|
TEsporta_sospesi_recordset::TEsporta_sospesi_recordset(int rec_length)
|
|
: THardy_recordset(rec_length)
|
|
{
|
|
add_field("CodiceTerminale", T_N, 1, 3); //x
|
|
add_field("CodiceCliente", T_N, 4, 6); //x
|
|
add_field("NumeroFattura", T_X, 10, 12); //x
|
|
add_field("DataFattura", T_X, 22, 6); //x
|
|
add_field("ImportoResiduo", T_Nv2N, 28, 9); //x
|
|
add_field("ImpOriginalDoc", T_N, 37, 9); //x
|
|
add_field("DataScadenza", T_X, 46, 6); //x
|
|
add_field("Partita", T_X, 52, 15); //x
|
|
add_field("TipoDocumento", T_X, 67, 1); //x
|
|
add_eol_field();
|
|
}
|
|
//..e variazioni sospesi
|
|
TEsporta_sospesiVAR_recordset::TEsporta_sospesiVAR_recordset()
|
|
: TEsporta_sospesi_recordset(70)
|
|
{
|
|
insert_field("Segno", T_X, 4, 1); //x
|
|
}
|
|
|
|
|
|
//Decodart ()
|
|
//---------------
|
|
TEsporta_decodart_recordset::TEsporta_decodart_recordset(int rec_length)
|
|
: THardy_recordset(rec_length)
|
|
{
|
|
add_field(CODCORR_CODART, T_X, 1, 5); //x
|
|
add_field(CODCORR_CODCF, T_N, 6, 6); //x
|
|
add_field(CODCORR_CODARTALT, T_X, 12, 6); //x
|
|
add_eol_field();
|
|
}
|
|
|
|
|
|
//Barcode
|
|
//---------------
|
|
TEsporta_barcode_recordset::TEsporta_barcode_recordset(int rec_length)
|
|
: THardy_recordset(rec_length)
|
|
{
|
|
add_field(CODCORR_CODARTALT, T_X, 1, 20); //x
|
|
add_field(CODCORR_CODART, T_X, 21, 5); //x
|
|
add_eol_field();
|
|
}
|
|
|
|
|
|
//Attrezzature
|
|
//---------------
|
|
TEsporta_attrezzature_recordset::TEsporta_attrezzature_recordset(int rec_length)
|
|
: THardy_recordset(rec_length)
|
|
{
|
|
add_field("CodiceTerminale", T_N, 1, 3);
|
|
add_field("CodiceCliente", T_N, 4, 6);
|
|
add_field("CodiceArticolo", T_X, 10, 5);
|
|
add_field("MatricolaAttrezz", T_X, 15, 12);
|
|
add_field("DescrAttrezz", T_X, 27, 30);
|
|
add_field("DataConsegna", T_X, 57, 6);
|
|
add_field("Quantita", T_N, 63, 7);
|
|
add_eol_field();
|
|
}
|
|
|
|
|
|
//Pagamenti
|
|
//---------------
|
|
TEsporta_pagamenti_recordset::TEsporta_pagamenti_recordset(int rec_length)
|
|
: THardy_recordset(rec_length)
|
|
{
|
|
add_field("CodicePagamento", T_X, 1, 2); //x
|
|
add_field("DescrPagamento", T_X, 3, 20); //x
|
|
add_field("GiorniScadenza", T_N, 23, 3); //x
|
|
add_eol_field();
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TCodArtEsselunga_cache
|
|
///////////////////////////////////////////////////////////
|
|
|
|
TObject* TCodArtEsselunga_cache::key2obj(const char* key)
|
|
{
|
|
TToken_string code(key);
|
|
TString80 codart; code.get(0, codart);
|
|
const TString& codcf = ini_get_string(CONFIG_DITTA, "ha", "Esselunga_CodEsselunga");
|
|
TISAM_recordset codcorr("USE CODCORR\nSELECT CODCF=#CODCF\nFROM CODART=#COD\nTO CODART=#COD");
|
|
codcorr.set_var("#COD", TVariant(codart));
|
|
codcorr.set_var("#CODCF", TVariant(codcf));
|
|
if (codcorr.items()>0)
|
|
{
|
|
codcorr.move_first();
|
|
return new TString80(codcorr.get(CODCORR_CODARTALT).as_string());
|
|
}
|
|
else
|
|
return new TString80(codart);
|
|
}
|
|
|
|
const TString& TCodArtEsselunga_cache::decode(const TString& codart)
|
|
{
|
|
return *(const TString*)objptr(codart);
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////
|
|
// Metodi di utility
|
|
/////////////////////////////////////////////////////////////
|
|
real hd_find_sconto(const TString& str_sconto)
|
|
{
|
|
real val_perc;
|
|
if (str_sconto.full())
|
|
{
|
|
TString goodexp;
|
|
if (scontoexpr2perc(str_sconto, false, goodexp, val_perc))
|
|
{
|
|
val_perc = CENTO - (val_perc * CENTO);
|
|
val_perc *= CENTO;
|
|
val_perc.round();
|
|
}
|
|
}
|
|
return val_perc;
|
|
}
|
|
|
|
// Trova il codice agente Hardy (lungo 3) del cliente Campo
|
|
const TString& hd_find_codag(long codcf)
|
|
{
|
|
TString8 key_cfven;
|
|
key_cfven.format("C|%ld", codcf);
|
|
const TString& codag = cache().get(LF_CFVEN, key_cfven, CFV_CODAG);
|
|
return codag.right(3); //il loro codagente è lungo 3!!!
|
|
}
|
|
|
|
//il dio dei programmatori ci perdoni!
|
|
const TString& hd_format_date8(const TDate& data)
|
|
{
|
|
const int day = data.day();
|
|
const int month = data.month();
|
|
const int year = data.year();
|
|
TString& str_data = get_tmp_string();
|
|
str_data.format("%02d%02d%04d", day, month, year);
|
|
return str_data;
|
|
}
|
|
|
|
const TString& hd_format_date6(const TDate& data)
|
|
{
|
|
const int day = data.day();
|
|
const int month = data.month();
|
|
const int year = data.year();
|
|
TString& str_data = get_tmp_string();
|
|
str_data.format("%02d%02d%02d", day, month, year%100);
|
|
return str_data;
|
|
}
|
|
|
|
const TDate upload_format_date6(const TString& str_data)
|
|
{
|
|
int anno = 2000 + atoi(str_data.right(2));
|
|
const int mese = atoi(str_data.mid(2,2));
|
|
const int giorno = atoi(str_data.left(2));
|
|
TDate data(giorno, mese, anno);
|
|
return data;
|
|
}
|
|
|
|
// determina codice cliente campo a partire da codice hardy in base alle regole dettatemi da Robbi
|
|
|
|
long hd_key2cli(const TString& key)
|
|
{
|
|
const long cod_hardy = atol(key.mid(3,6));
|
|
const char first = key[0];
|
|
long codcf = 0;
|
|
switch (first)
|
|
{
|
|
case 'H':
|
|
codcf = 130000+cod_hardy;
|
|
break;
|
|
case 'P':
|
|
codcf = 140000+cod_hardy;
|
|
break;
|
|
case '0':
|
|
{
|
|
const char second = key[1];
|
|
if (second == '1')
|
|
codcf = 120000+cod_hardy;
|
|
else if (second == '0')
|
|
{
|
|
const char third = key[2];
|
|
if (third == '4')
|
|
codcf = 110000+cod_hardy;
|
|
else if (third == '3')
|
|
codcf = 100000+cod_hardy;
|
|
else if (third == '2')
|
|
codcf = 200000+cod_hardy;
|
|
else
|
|
codcf = cod_hardy;
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
codcf = cod_hardy;
|
|
}
|
|
if (codcf > 999999)
|
|
codcf = 0;
|
|
return codcf;
|
|
}
|
|
|
|
// determina codice fornitore campo a partire da codice hardy in base alle regole dettatemi da Robbi
|
|
|
|
long hd_key2forn(const TString& key)
|
|
{
|
|
const long codcf = atol(key.mid(3,6));
|
|
return codcf;
|
|
}
|
|
|
|
// determina tipoc, gruppo, conto e sottoconto a partire da tipoconto e idconto hardy
|
|
void hd_key2conto(const TString& key, int& gr, int& co, long& so)
|
|
{
|
|
gr = atoi(key.mid(1,2));
|
|
co = atoi(key.mid(3,2));
|
|
so = atoi(key.mid(5,3));
|
|
}
|