diff --git a/ve/ve6700.cpp b/ve/ve6700.cpp index 71ef82e0b..d394a50e3 100755 --- a/ve/ve6700.cpp +++ b/ve/ve6700.cpp @@ -88,7 +88,7 @@ bool TCopia_interattiva::load() TConfig ini(_ini_name, "Transaction"); const char provv = ini.get_char("ProvvOut"); const int anno = ini.get_int("AnnoOut"); - const TString16 codnum(ini.get("CodNumOut")); + const TString4 codnum = ini.get("CodNumOut"); const long numdoc = ini.get_long("NDocOut"); const TElaborazione_esterna ee(ini.get("Action")); diff --git a/ve/velib04.cpp b/ve/velib04.cpp index 2a6d6a734..ece18635a 100755 --- a/ve/velib04.cpp +++ b/ve/velib04.cpp @@ -395,25 +395,33 @@ int TLista_clifo::add(long cod) // TParametri_elaborazione /////////////////////////////////////////////////////////// -void TParametri_elaborazione::set(const char * name, const char * val) +void TParametri_elaborazione::set(const char* name, const char* val) { - _par.add(name, new TString(val), TRUE); + _par.add(name, new TString(val), true); } const TString & TParametri_elaborazione::get(const char * name) const { - TObject *val = _par.objptr(name); - - if (val == NULL) - return EMPTY_STRING; - else - return (const TString &) *val; + const TObject* val = _par.objptr(name); + return val ? *(const TString*)val : EMPTY_STRING; } /////////////////////////////////////////////////////////// // TElaborazione /////////////////////////////////////////////////////////// +const TString& TElaborazione::tipo_iniziale(int i) const +{ + if (i >= 0 && i < 10) + { + const TString& t = get("S2").mid(i*4, 4); + if (t.full()) + return ((TString&)t).rtrim(); + } + return EMPTY_STRING; +} + + bool TElaborazione::elabora(TLista_documenti& doc_in, TLista_documenti& doc_out, const TDate& data_elab, bool interattivo) { SORRY_BOX(); @@ -430,17 +438,13 @@ TElaborazione::TElaborazione(const char* cod) : TRectype(LF_TABCOM) int TElaborazione::read(const char* cod) { int err = NOERR; - TRectype::operator=(cache().get("%ELD", cod)); if (empty()) - { - yesnofatal_box("Codice elaborazione non valido: %s", cod); err = _iskeynotfound; - } return err; } -bool TElaborazione::is_document_ok(const TRectype & doc) const +bool TElaborazione::is_document_ok(const TRectype& doc) const { bool ok = false; const TString4 codnum(doc.get(DOC_CODNUM)); diff --git a/ve/velib04.h b/ve/velib04.h index 0c7dd9287..be7c32405 100755 --- a/ve/velib04.h +++ b/ve/velib04.h @@ -189,12 +189,12 @@ public: bool calcola_scarti() const { return get_bool("B11"); } bool reload_prices() const { return get_bool("B13"); } bool reload_descriptions() const { return reload_prices() && get_bool("B14"); } - const TString & num_riferimenti_in() const { return get("S11"); } + const TString& num_riferimenti_in() const { return get("S11"); } int intestazioni_sheet() const { return get_int("I1"); } const TString& codice_numerazione_iniziale() const { return get("S5"); } - const TString tipo_iniziale(int i) const { return get("S2").smid(i*4, 4).rtrim(); } + const TString& tipo_iniziale(int i) const; const char stato_iniziale(int i) const { return i < 5 ? get("S7")[i] : get("S10")[i - 5]; } const TString& tipo_finale() const { return get("S8"); } const TString& stato_finale_doc_iniziale() const { return get("S4"); } @@ -502,6 +502,7 @@ protected: bool valid_row_type(const char* rt) const; virtual void export_movimento(TMovimentoPN_VE & mov, TViswin & v) {}; virtual bool exporting() { return false; } + bool dispatch_transaction(TMovimentoPN& movimento, const char* action) const; public: // Cambia lo stato del documento diff --git a/ve/velib04b.cpp b/ve/velib04b.cpp index 80e683cee..650a37275 100755 --- a/ve/velib04b.cpp +++ b/ve/velib04b.cpp @@ -16,8 +16,10 @@ #include #include +#include #include #include +#include void TMovimentoPN_VE::destroy_iva_row(int i) { @@ -3013,6 +3015,74 @@ error_type TContabilizzazione::write_scadenze(TDocumento& doc, bool recontabiliz return _error; } +static void rec2ini(const TRectype& rec, TConfig& ini) +{ + for (int i = 0; i < rec.items(); i++) + { + const char* fname = rec.fieldname(i); + const TString& val = rec.get(fname); + if (val.full()) + { + if (val.find(' ') >= 0 && rec.type(fname) == _alfafld) + { + TString quoted; quoted << '"' << val << '"'; + ini.set(fname, quoted); + } + else + ini.set(fname, val); + } + } +} + +bool TContabilizzazione::dispatch_transaction(TMovimentoPN& movimento, const char* action) const +{ + const TRectype& head = movimento.curr(); + bool done = ::can_dispatch_transaction(head); + if (!done) + return false; + + TFilename tmpini; tmpini.temp("cnt", "ini"); + + if (done) // dummy test + { + TConfig ini(tmpini, "Transaction"); + ini.set("Firm", prefix().get_codditta(), "Transaction"); + ini.set("User", user()); + ini.set("HostName", get_hostname()); + ini.set("Action", action); + ini.set("Mode", "Auto"); + int year, release, tag, patch; + if (TApplication::get_version_info(year, release, tag, patch)) + { + TString80 ver; + ver.format("%d %d.%d-%d", year, release, tag, patch); + ini.set("Version", ver); + } + + TString16 para; para << head.num(); + ini.set_paragraph(para); + rec2ini(head, ini); + + for (int i = 0; i < movimento.cg_items(); i++) + { + para.format("%d,%d", LF_RMOV, i+1); + ini.set_paragraph(para); + rec2ini(movimento.cg(i), ini); + } + for (int i = 0; i < movimento.iva_items(); i++) + { + para.format("%d,%d", LF_RMOVIVA, i+1); + ini.set_paragraph(para); + rec2ini(movimento.iva(i), ini); + } + } + + done = ::dispatch_transaction(head, tmpini); + tmpini.fremove(); + + return done; +} + error_type TContabilizzazione::write_all(TDocumento& doc, TMovimentoPN_VE & movimento) // Scrive il movimento e le scadenze, gestendo la rinumerazione se il movimento e' gia presente { @@ -3054,9 +3124,15 @@ error_type TContabilizzazione::write_all(TDocumento& doc, TMovimentoPN_VE & movi if (oldmov.read() == NOERR) aggiorna_saldi(saldo, oldmov, false); // Leggo i vecchi saldi err = movimento.rewrite(); + if (err == NOERR) + dispatch_transaction(movimento, "MODIFY"); } else + { err = movimento.write(); + if (err == NOERR) + dispatch_transaction(movimento, "INSERT"); + } if (err != NOERR) { error_box("*** Errore %d scrivendo il movimento contabile %ld.", err, numreg); @@ -3146,8 +3222,10 @@ error_type TContabilizzazione::write_all_re(TDocumento& doc, TMovimentoPN_VE & m error_box("*** Errore %d scrivendo il movimento contabile %ld.", err, numreg); return generic_error; } + // Aggiorno subito i saldi aggiorna_saldi(saldo, movimento, true); + dispatch_transaction(movimento, old_numreg > 0 ? "MODIFY": "INSERT"); if (good() && (dongle().active(CMAUT) || dongle().active(CAAUT))) write_anal(doc, movimento); @@ -3376,7 +3454,7 @@ error_type TContabilizzazione::write_pagamento_anticipo(TDocumento& doc) const TRectype& mov = _anticipo->curr(); const int anno = mov.get_date(MOV_DATAREG).year(); const long numreg = mov.get_long(MOV_NUMREG); - const TString8 numpart(mov.get(MOV_NUMDOC)); // Nessun controllo se prot.iva o numdoc xche' tanto proviene dal mov precedentemente scritto + const TString8 numpart = mov.get(MOV_NUMDOC); // Nessun controllo se prot.iva o numdoc xche' tanto proviene dal mov precedentemente scritto TPartita* partita = new TPartita(_co_cliente,anno,numpart); partita->allinea(); @@ -3587,9 +3665,15 @@ error_type TContabilizzazione::write_anticipo(TDocumento& doc) if (oldant.read() == NOERR) aggiorna_saldi(saldo, oldant, false); err = _anticipo->rewrite(); + if (err == NOERR) + dispatch_transaction(*_anticipo, "MODIFY"); } else + { err = _anticipo->write(); + if (err == NOERR) + dispatch_transaction(*_anticipo, "INSERT"); + } if (err != NOERR) { error_box("Errore %d scrivendo il movimento di anticipo pagamento %ld.", @@ -3597,6 +3681,8 @@ error_type TContabilizzazione::write_anticipo(TDocumento& doc) return generic_error; } aggiorna_saldi(saldo, *_anticipo, true); + + } delete _anticipo; _anticipo = NULL; @@ -4109,7 +4195,12 @@ error_type TContabilizzazione::write_regolarizzazione(const TDocumento& doc, TMo } } + const TString4 codcaus = _caus->causale_reg_iva(); + const TDate datareg = _movimento->curr().get(MOV_DATAREG); + const TCausale caus(codcaus, datareg.year()); + error_type error = no_error; + long protiva = 0; if (do_insert) { error = get_next_reg_num(nr); @@ -4119,9 +4210,6 @@ error_type TContabilizzazione::write_regolarizzazione(const TDocumento& doc, TMo const TCli_for& clifor = doc.clifor(); - const TString4 codcaus = _caus->causale_reg_iva(); - const TDate datareg = _movimento->curr().get(MOV_DATAREG); - const TCausale caus(codcaus, datareg.year()); TRectype& head = mov.curr(); head.put(MOV_NUMREG,nr); @@ -4131,19 +4219,22 @@ error_type TContabilizzazione::write_regolarizzazione(const TDocumento& doc, TMo { mov.read(_isequal, _lock); aggiorna_saldi(saldo, mov, false); + protiva = head.get_long(MOV_PROTIVA); } + if (protiva <= 0) + protiva = caus.reg().protocol()+1; head.put(MOV_DATAREG, datareg); head.put(MOV_DATACOMP, _movimento->curr().get(MOV_DATACOMP)); head.put(MOV_ANNOES, _movimento->curr().get(MOV_ANNOES)); head.put(MOV_ANNOIVA, _movimento->curr().get(MOV_ANNOIVA)); head.put(MOV_REG, caus.reg().name()); - head.put(MOV_NUMDOC, doc.get(DOC_NDOC)); - head.put(MOV_DATADOC, doc.get(DOC_DATADOC)); + head.put(MOV_NUMDOC, doc.get(DOC_NUMDOCRIF)); + head.put(MOV_DATADOC, doc.get(DOC_DATADOCRIF)); head.put(MOV_CODCAUS, caus.codice()); head.put(MOV_TIPODOC, caus.tipo_doc()); - head.put(MOV_PROTIVA, caus.reg().protocol()); + head.put(MOV_PROTIVA, protiva); TString descr; descr << TR("Regolarizzazione ") << doc.get(DOC_CODNUM) << '/' << doc.numero() << TR(" del ") << doc.get(DOC_DATADOC); @@ -4171,6 +4262,7 @@ error_type TContabilizzazione::write_regolarizzazione(const TDocumento& doc, TMo if (err == NOERR) { aggiorna_saldi(saldo, mov, true); + dispatch_transaction(mov, do_insert ? "INSERT" : "MODIFY"); } else { diff --git a/ve/velib06.cpp b/ve/velib06.cpp index 1e90c0dc4..1ee03b1da 100755 --- a/ve/velib06.cpp +++ b/ve/velib06.cpp @@ -1787,7 +1787,15 @@ void TDocumento_mask::update_giacenza() } } } - const TString& annoes = get(F_ANNO); + + TString4 annoes = get(F_ANNO); + const TDate datadoc = get(F_DATADOC); + if (datadoc.ok()) + { + TEsercizi_contabili esc; + annoes.format("%04d", esc.date2esc(datadoc)); + } + TArticolo_giacenza& art = cached_article_balances(codart); giac = art.disponibilita(annoes, codmag, livello, TRUE); diff --git a/ve/vetbatr.h b/ve/vetbatr.h index 1b986e4b9..83214ded6 100755 --- a/ve/vetbatr.h +++ b/ve/vetbatr.h @@ -21,6 +21,11 @@ #define ATR_CODART 123 #define ATR_DESCART 124 +#define ATR_CODARTDISP 125 +#define ATR_DESCARTDISP 126 +#define ATR_TIPORADISP 127 +#define ATR_PREZZODISP 128 + #define ATR_CDC_V1 211 #define ATR_CDC_V2 212 #define ATR_CDC_V3 213 diff --git a/ve/vetbatr.uml b/ve/vetbatr.uml index 0d14ffeb0..9ea16607f 100755 --- a/ve/vetbatr.uml +++ b/ve/vetbatr.uml @@ -129,7 +129,7 @@ BEGIN OUTPUT ATR_DESCART DESCR CHECKTYPE NORMAL FLAGS "U" - FIELD S2 + FIELD S2[1,20] END STRING ATR_DESCART 50 34 @@ -245,6 +245,52 @@ BEGIN ADD RUN CG0 -0 END +STRING ATR_CODARTDISP 20 +BEGIN + PROMPT 2 15 "Art. dispon. " + COPY USE ATR_CODART + INPUT CODART ATR_CODARTDISP + COPY DISPLAY ATR_CODART + OUTPUT ATR_CODARTDISP CODART + OUTPUT ATR_DESCARTDISP DESCR + CHECKTYPE NORMAL + FLAGS "U" + FIELD S2[21,40] + MODULE ci +END + +STRING ATR_DESCARTDISP 50 34 +BEGIN + PROMPT 40 15 "" + COPY USE ATR_DESCART + INPUT DESCR ATR_DESCARTDISP + COPY DISPLAY ATR_DESCART + COPY OUTPUT ATR_CODARTDISP + CHECKTYPE NORMAL + FLAGS "U" + MODULE ci +END + +STRING ATR_TIPORADISP 2 +BEGIN + PROMPT 2 16 "Tipo ora " + USE &CIORE + DISPLAY "Codice" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT ATR_TIPORADISP CODTAB + CHECKTYPE NORMAL + MODULE ci + FIELD S9 +END + +CURRENCY ATR_PREZZODISP 12 +BEGIN + PROMPT 22 16 "Prezzo disponibilità " + FLAGS "U" + FIELD R11 + MODULE ci +END + ENDPAGE PAGE "Analitica" 11 60 14