From bdd0b0e608232e7b10ab9089365ca29cd754385e Mon Sep 17 00:00:00 2001 From: guy <guy@c028cbd2-c16b-5b4b-a496-9718f37d4682> Date: Thu, 7 Feb 2013 14:17:40 +0000 Subject: [PATCH] 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 --- ps/ps0430.cpp | 1 + ps/ps0430.h | 3 +- ps/ps0430400.cpp | 216 +++++++++++++++++++++++++++++++++++++--------- ps/ps0430400a.h | 3 +- ps/ps0430400a.uml | 15 +++- ps/ps0430500.cpp | 118 +++++++++++++++++++++++++ ps/ps0430500a.h | 3 + ps/ps0430500a.uml | 50 +++++++++++ ps/ps1001300.cpp | 52 +++++------ ps/ps1001300a.uml | 2 +- 10 files changed, 389 insertions(+), 74 deletions(-) create mode 100644 ps/ps0430500.cpp create mode 100644 ps/ps0430500a.h create mode 100644 ps/ps0430500a.uml diff --git a/ps/ps0430.cpp b/ps/ps0430.cpp index c1754846c..0595f60a3 100755 --- a/ps/ps0430.cpp +++ b/ps/ps0430.cpp @@ -10,6 +10,7 @@ int main(int argc, char** argv) case 1: ps0430200(argc, argv); break; // Configurazione campi per utente //case 2: ps0430300(argc, argv); break; // generazione ordini (� or1400 per il cigno) 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 } return 0; diff --git a/ps/ps0430.h b/ps/ps0430.h index 7dcf19c44..53c32d892 100755 --- a/ps/ps0430.h +++ b/ps/ps0430.h @@ -1,4 +1,5 @@ int ps0430100(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 ps0430500(int argc, char* argv[]); \ No newline at end of file diff --git a/ps/ps0430400.cpp b/ps/ps0430400.cpp index 31a5f1453..08a8f9bc9 100644 --- a/ps/ps0430400.cpp +++ b/ps/ps0430400.cpp @@ -11,6 +11,7 @@ #include "../ve/velib.h" #include "../cg/cfban.h" +#include "cfven.h" /////////////////////////////////////////////////////////// // TCBA_recset @@ -101,10 +102,14 @@ protected: public: long find_clifo(const TString& cf_pi, TLocalisamfile& clifo) const; - const TString& find_codart(const TString& codart) const; - bool find_or_create_clifo(const TCBA_recset& cli, TLocalisamfile& clifo, TLog_report& log) const; - bool importa_clienti(const TFilename& fname, TLog_report& log) const; - bool importa_fatture(const TFilename& fname, const TString& codnum, TLog_report& log) const; + const TRectype& find_codart(TString& codart) const; + bool find_or_create_clifo(const TCBA_recset& cli, TLocalisamfile& clifo, + const TString& cdc, 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 @@ -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; } -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(); const TRectype& anamag = cache().get(LF_ANAMAG, cod); - -#ifdef DBG - if (anamag.empty()) - cod = "45.01.06.052"; -#endif - - return get_tmp_string() = cod; + return anamag; } - -bool TImport_app::find_or_create_clifo(const TCBA_recset& cli, TLocalisamfile& clifo, TLog_report& log) const +bool TImport_app::find_or_create_clifo(const TCBA_recset& cli, TLocalisamfile& clifo, const TString& cdc, TLog_report& log) const { TString cofi = cli.get(2).as_string(); if (cofi.full() && find_clifo(cofi, clifo)) @@ -202,16 +199,17 @@ bool TImport_app::find_or_create_clifo(const TCBA_recset& cli, TLocalisamfile& c msg << TR("Impossibile creare l'anagrafica di ") << ragsoc << TR(" alla riga ") << (cli.current_row()+1); log.log(2, msg); } - + 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"); log.log(0, str); TLocalisamfile clifo(LF_CLIFO); + TLocalisamfile cfven(LF_CFVEN); TCBA_recset cli; cli.load_file(fname); @@ -230,15 +228,24 @@ bool TImport_app::importa_clienti(const TFilename& fname, TLog_report& log) cons if (cli.get(0).is_empty()) // Salta righe vuote continue; - done = find_or_create_clifo(cli, clifo, log); + done = find_or_create_clifo(cli, clifo, cdc, log); if (!done) break; // 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(); 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 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); curr.put(CLI_RAGSOC, ragsoc.get()); + curr.put(CLI_REFERENTE, curr.get(CLI_RAGSOC)); 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); - const TString& cap = cli.get(9).as_string(); + const TString8 cap = cli.get(9).as_string(); curr.put(CLI_CAPCF, cap); 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; if (privato == 1) - alleg = 6; else - if (naz > 0) - alleg = naz == 1 ? 5 : 9; + alleg = 6; + else + { + if (naz > 0) + 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 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); 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)); @@ -335,7 +369,40 @@ bool TImport_app::importa_clienti(const TFilename& fname, TLog_report& log) cons 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"); log.log(0, str); @@ -353,6 +420,8 @@ bool TImport_app::importa_fatture(const TFilename& fname, const TString& codnum, long codcf = 0; TString4 codpag; + TString periodo; + TToken_string ospiti(80, '@'); TProgind pi(fat.items(), str); 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); 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; } @@ -390,19 +466,20 @@ bool TImport_app::importa_fatture(const TFilename& fname, const TString& codnum, continue; } - const TString codart = find_codart(fat.get(12).as_string()); - TString4 um; - const TRectype& anamag = cache().get(LF_ANAMAG, codart); + TString80 codart; + codart << fat.get(12); codart.trim(); + codart << '.' << cdc.right(3); + + const TRectype& anamag = find_codart(codart); if (anamag.empty()) { str.format("Articolo non valido '%s' alla riga %ld", (const char*)codart, fat.current_row()+1); log.log(1, str); + continue; } - else - { - str = codart; str << "|1"; - um = cache().get(LF_UMART, str, UMART_UM); - } + + str = codart; str << "|1"; + const TString4 um = cache().get(LF_UMART, str, UMART_UM); 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_CODPAG, codpag); doc.put(DOC_STATO, 1); + doc.put(DOC_CODCMS, cdc); - str = fat.get(22).as_string(); - str.right_just(20, '0'); - doc.put(DOC_CODCMS, str); + TToken_string key; + key = "C"; + 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 { @@ -428,12 +524,34 @@ bool TImport_app::importa_fatture(const TFilename& fname, const TString& codnum, rdoc.put(RDOC_CODART, codart); rdoc.put(RDOC_CODARTMAG, codart); rdoc.checked(true); - rdoc.put(RDOC_DESCR, anamag.get(ANAMAG_DESCR)); + rdoc.put(RDOC_UMQTA, um); rdoc.put(RDOC_QTA, UNO); rdoc.put(RDOC_PREZZO, fat.get(19).as_real()); 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(); 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); log.log(2, str); } - } 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; log.log(0, str); @@ -461,7 +578,7 @@ bool TImport_app::importa_fatture(const TFilename& fname, const TString& codnum, 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; while (mask.run() == K_ENTER) @@ -469,12 +586,25 @@ void TImport_app::main_loop() TLog_report log; TFilename fname = mask.get(F_DIR); 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); fname = mask.get(F_DIR); 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(); diff --git a/ps/ps0430400a.h b/ps/ps0430400a.h index 3f1fa8a2d..ae03f0618 100644 --- a/ps/ps0430400a.h +++ b/ps/ps0430400a.h @@ -1,4 +1,5 @@ #define F_DIR 101 #define F_CLI 102 #define F_FAT 103 -#define F_NUM 104 \ No newline at end of file +#define F_NUM 104 +#define F_CDC 105 \ No newline at end of file diff --git a/ps/ps0430400a.uml b/ps/ps0430400a.uml index 35288f191..a261f13c1 100644 --- a/ps/ps0430400a.uml +++ b/ps/ps0430400a.uml @@ -1,6 +1,6 @@ #include "ps0430400a.h" -PAGE "Importazione CBA" -1 -1 66 5 +PAGE "Importazione CBA" -1 -1 66 7 STRING F_DIR 256 50 BEGIN @@ -34,10 +34,21 @@ BEGIN CHECKTYPE REQUIRED 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 BEGIN - PROMPT 1 4 "Profilo " + PROMPT 1 6 "Profilo " PSELECT FLAGS "H" END diff --git a/ps/ps0430500.cpp b/ps/ps0430500.cpp new file mode 100644 index 000000000..e84289025 --- /dev/null +++ b/ps/ps0430500.cpp @@ -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; +} diff --git a/ps/ps0430500a.h b/ps/ps0430500a.h new file mode 100644 index 000000000..3cc804973 --- /dev/null +++ b/ps/ps0430500a.h @@ -0,0 +1,3 @@ +#define F_DATAREG 101 +#define F_CODCAUS 102 +#define F_DESCAUS 103 diff --git a/ps/ps0430500a.uml b/ps/ps0430500a.uml new file mode 100644 index 000000000..79638d972 --- /dev/null +++ b/ps/ps0430500a.uml @@ -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 \ No newline at end of file diff --git a/ps/ps1001300.cpp b/ps/ps1001300.cpp index 474126685..b5d242c3f 100755 --- a/ps/ps1001300.cpp +++ b/ps/ps1001300.cpp @@ -173,7 +173,7 @@ protected: 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, 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 @@ -870,36 +870,37 @@ void TVariazione_budget_mask::aggiorna_saldi_preventivi(TSheet_field& sf_righe, } //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) { - const TRectype& rec_cms = cache().get(LF_COMMESSE, codcms); - 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.. - //..si pu� agire solo su di lei! - if (!is_cms_supporto) + if (supp) { - const TDate cms_dataini = rec_cms.get_date(COMMESSE_DATAINIZIO); - TDate cms_datafine; - const bool pro = rec_cms.get_bool(COMMESSE_PROROGA); - if (pro) - cms_datafine = rec_cms.get_date(COMMESSE_DATAPROR); - if (!pro || !cms_datafine.ok()) - cms_datafine = rec_cms.get_date(COMMESSE_DATAFINE); + const TRectype& rec_cms = cache().get(LF_COMMESSE, codcms); + const bool is_cms_supporto = rec_cms.get_bool(COMMESSE_APPOGGIO); - TString query; - query << "USE COMMESSE\n"; - query << "SELECT ((APPOGGIO=\"X\")&&((NUM(ANSI(DATAINIZIO)<=ANSI(#DATAFINECMS)))&&(NUM(ANSI(DATAFINE)>=ANSI(#DATAINIZIOCMS)))))\n"; - TISAM_recordset commesse(query); - commesse.set_var("#DATAFINECMS", cms_datafine); - commesse.set_var("#DATAINIZIOCMS", cms_dataini); + //tutto il casino vale solo per le commesse normali; se viene selezionata una commessa di supporto.. + //..si pu� agire solo su di lei! + if (!is_cms_supporto) + { + const TDate cms_dataini = rec_cms.get_date(COMMESSE_DATAINIZIO); + TDate cms_datafine; + const bool pro = rec_cms.get_bool(COMMESSE_PROROGA); + if (pro) + cms_datafine = rec_cms.get_date(COMMESSE_DATAPROR); + if (!pro || !cms_datafine.ok()) + cms_datafine = rec_cms.get_date(COMMESSE_DATAFINE); - const int items = commesse.items(); - for(bool ok = commesse.move_first(); ok; ok = commesse.move_next()) - _cms_supporto.add(commesse.get(COMMESSE_CODCMS).as_string()); + TString query; + query << "USE COMMESSE\n"; + query << "SELECT ((APPOGGIO=\"X\")&&((NUM(ANSI(DATAINIZIO)<=ANSI(#DATAFINECMS)))&&(NUM(ANSI(DATAFINE)>=ANSI(#DATAINIZIOCMS)))))\n"; + TISAM_recordset commesse(query); + commesse.set_var("#DATAFINECMS", cms_datafine); + commesse.set_var("#DATAINIZIOCMS", cms_dataini); + for(bool ok = commesse.move_first(); ok; ok = commesse.move_next()) + _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 @@ -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.. //..e al fatto che l'utente lo voglia o meno... - if (include_cms_supp) - trova_cms_supporto(cms); + trova_cms_supporto(cms, include_cms_supp); TAssoc_array numreg_cms; long max_numreg = 0L; diff --git a/ps/ps1001300a.uml b/ps/ps1001300a.uml index e1fada4e5..f8ce1f27d 100755 --- a/ps/ps1001300a.uml +++ b/ps/ps1001300a.uml @@ -168,7 +168,7 @@ END SPREADSHEET F_RIGHE BEGIN - PROMPT 1 10 "Righe" + PROMPT 1 9 "Righe" ITEM "@1C" ITEM "Commessa@20" ITEM "Sede@4"