diff --git a/src/mr/mr0400.h b/src/mr/mr0400.h index 4a243e8d8..cb46203dd 100755 --- a/src/mr/mr0400.h +++ b/src/mr/mr0400.h @@ -48,6 +48,7 @@ #define F_TIPONUM 145 #define F_TIPOTIP 146 #define F_USE_GIAC_CORRETTA 147 +#define F_EXPLODE_ARTACQ 148 #define F_YEAR 201 #define F_CALENDAR 202 diff --git a/src/mr/mr0400a.uml b/src/mr/mr0400a.uml index 511741dc4..906497a1d 100755 --- a/src/mr/mr0400a.uml +++ b/src/mr/mr0400a.uml @@ -437,6 +437,12 @@ BEGIN FIELD USE_GIAC_CORRETTA END +BOOLEAN F_EXPLODE_ARTACQ +BEGIN + PROMPT 2 17 "Esplodi gli articoli di acquisto" + FIELD EXPLODE_ARTACQ +END + ENDPAGE PAGE "Calendario" -1 -1 65 15 diff --git a/src/mr/mr1100.cpp b/src/mr/mr1100.cpp index b16e000a6..dc5ed71d7 100755 --- a/src/mr/mr1100.cpp +++ b/src/mr/mr1100.cpp @@ -499,37 +499,40 @@ bool TRepgen_mask::elabora() const // Calcoli per carico if (ts == carico) { - distinta.set_root(riga); - real ore,tot; + if (!is_buy_article(riga.get(RDOC_CODART))) + { + distinta.set_root(riga); + real ore,tot; - TRiga_esplosione * llav = distinta.first_labor(lav_array, raggr); - TLavorazione * lavorazione = TDistinta_tree::find_labor(llav); + TRiga_esplosione * llav = distinta.first_labor(lav_array, raggr); + TLavorazione * lavorazione = TDistinta_tree::find_labor(llav); - while (llav) - { - const int linea = lavorazione->find_linea(lin); + while (llav) + { + const int linea = lavorazione->find_linea(lin); - const real prod_linea = lavorazione->produttiv_linea(linea); - ore = (llav->val() * lavorazione->um_temporale().converti_in_ore()) / prod_linea; - if (carico_uomo) - ore *= lavorazione->numpers_linea(linea); + const real prod_linea = lavorazione->produttiv_linea(linea); + ore = (llav->val() * lavorazione->um_temporale().converti_in_ore()) / prod_linea; + if (carico_uomo) + ore *= lavorazione->numpers_linea(linea); - //rep.qta(bucket) += ore; - tot += ore; - llav = distinta.next_labor(lav_array); - } + //rep.qta(bucket) += ore; + tot += ore; + llav = distinta.next_labor(lav_array); + } - if (tot > ZERO) - { - TMRP_rep_line& rep = *articles.find(art, liv, imp, lin, ws, TRUE); - rep.qta(bucket) += tot; - } + if (tot > ZERO) + { + TMRP_rep_line& rep = *articles.find(art, liv, imp, lin, ws, TRUE); + rep.qta(bucket) += tot; + } - // Sbatte nella cache le linee di cui dopo calcolera' le capacita' minime e massime - // In modo che il calcolo venga effettuato una volta sola per ogni linea. - if (capacita.objptr(lin) == NULL) - capacita.add(lin, new _TCapacitaLinea); // Vuoto per ora... lo riempie poco piu' giu' + // Sbatte nella cache le linee di cui dopo calcolera' le capacita' minime e massime + // In modo che il calcolo venga effettuato una volta sola per ogni linea. + if (capacita.objptr(lin) == NULL) + capacita.add(lin, new _TCapacitaLinea); // Vuoto per ora... lo riempie poco piu' giu' + } } else // Produzione articoli nel tempo & scheduling linee { diff --git a/src/mr/mr2100.cpp b/src/mr/mr2100.cpp index 944fb5007..17b9d7ecd 100755 --- a/src/mr/mr2100.cpp +++ b/src/mr/mr2100.cpp @@ -20,21 +20,6 @@ #define NODIST "NODIST" -/////////////////////////////////////////////////////////// -// Utility -/////////////////////////////////////////////////////////// - -static bool is_production_article(const TCodice_articolo& codart) -{ - const TRectype& rec=cache().get(LF_DIST, codart); - bool art_prod = false; - if (rec.empty()) - art_prod = cache().get(LF_ANAMAG, codart).get_bool(ANAMAG_ARTPROD); - else - art_prod = rec.get_bool(ANAMAG_ARTPROD); - return art_prod; -} - /////////////////////////////////////////////////////////// // TMRP_record /////////////////////////////////////////////////////////// @@ -1411,8 +1396,8 @@ int TMatResMask::add_order_line(long forn, const TMRP_line& line, int bucket) TRiga_ordine* r = new TRiga_ordine(datadoc, datacons, forn, line, bucket, ZERO); // Setta un codice numerazione (provvisorio) in base al tipo di ordine const char ot = r->get_char(F_ORD_TYPE - FIRST_FIELD); - r->add(ot == 'F' ? num_forn : num_prod, F_DOCCODNUM - FIRST_FIELD); - + + r->add(ot == 'F' ? num_forn : num_prod, F_DOCCODNUM - FIRST_FIELD); nref--; if (nref >= 0) { @@ -2275,61 +2260,66 @@ bool TMatResPlanning::explode_articles() line.set_imp_lin(imp, lin); } - distinta.set_global("_DISTINTA", line.articolo()); - distinta.set_global("_MAGDEP" , line.codmagdep()); - distinta.set_global("_IMPIANTO", line.codimp()); - distinta.set_global("_LINEA" , line.codlin()); - if (distinta.set_root(line.articolo(), "", 1.0 , line.livgiac())) - { - line.set_final_product(FALSE); - - distinta.goto_root(); - if (distinta.scan_depth_first(cyclic, NULL)) + if (!is_buy_article(line.articolo())) + { + distinta.set_global("_DISTINTA", line.articolo()); + distinta.set_global("_MAGDEP" , line.codmagdep()); + distinta.set_global("_IMPIANTO", line.codimp()); + distinta.set_global("_LINEA" , line.codlin()); + if (distinta.set_root(line.articolo(), "", 1.0 , line.livgiac())) { - TToken_string & rdoc = (TToken_string &)line.da_rdoc_key(); - error_box ("Ordine %s %d/%ld riga n. %d - Distinta %s ciclica", (const char *) rdoc.left(4), atoi(rdoc.mid(4, 4)), atoi(rdoc.mid(9, 7)), atoi(rdoc.mid(16)), (const char *) line.articolo()); - continue; - } - distinta.explode(boom, FALSE, RAGGR_EXP_UMBASE, 1, "AV"); - for (int i = 0; i < boom.items(); i++) - { - const TRiga_esplosione& riga = (const TRiga_esplosione&)boom[i]; - const TCodice_articolo& art = riga.articolo(); - const TRectype& articolo=cache().get(LF_ANAMAG,art); - bool add=true; - if (articolo.get(ANAMAG_CODART).full()) - { - const char reorder_type=articolo.get_char(ANAMAG_RIORDINO); - if (reorder_type!='F' && reorder_type!=' ' && reorder_type!='\0') // e' a riordino - add=false; - } - if (add) - { - // articolo gestito dall'MRP - TString8 mag = line.codmagdep(); - TString8 imp = line.codimp(); - TString8 lin = line.codlin(); - _artinfo.art2magimpline(art, mag, imp, lin); - - // GUY was here with Koki - const long codcli = is_production_article(art) ? line.codclifor() : 0L; - const TString& rdoc_key = line.da_rdoc_key(); - - TMRP_line* son = _articles.find(art, riga.giacenza(), mag, EMPTY_STRING, imp, lin, codcli, rdoc_key); - if (son == NULL) - { - son = _articles.find(art, riga.giacenza(), mag, EMPTY_STRING, imp, lin, codcli, rdoc_key, true); - son->set_description(distinta.describe(art)); - } - const int son_depth = line.explosion_depth()+1; - if (son_depth > son->explosion_depth()) - son->set_explosion_depth(son_depth); + line.set_final_product(false); - line.add_son(riga.val(), son); - distinta.describe(art); - } + distinta.goto_root(); + if (distinta.scan_depth_first(cyclic, NULL)) + { + TToken_string & rdoc = (TToken_string &)line.da_rdoc_key(); + error_box ("Ordine %s %d/%ld riga n. %d - Distinta %s ciclica", (const char *) rdoc.left(4), atoi(rdoc.mid(4, 4)), atoi(rdoc.mid(9, 7)), atoi(rdoc.mid(16)), (const char *) line.articolo()); + continue; + } + distinta.explode(boom, FALSE, RAGGR_EXP_UMBASE, 1, "AV"); + for (int i = 0; i < boom.items(); i++) + { + const TRiga_esplosione& riga = (const TRiga_esplosione&)boom[i]; + const TCodice_articolo& art = riga.articolo(); + const TRectype& articolo=cache().get(LF_ANAMAG,art); + bool add=true; + if (articolo.get(ANAMAG_CODART).full()) + { + const char reorder_type=articolo.get_char(ANAMAG_RIORDINO); + if (reorder_type!='F' && reorder_type!=' ' && reorder_type!='\0') // e' a riordino + add=false; + } + if (add) + { + // articolo gestito dall'MRP + TString8 mag = line.codmagdep(); + TString8 imp = line.codimp(); + TString8 lin = line.codlin(); + _artinfo.art2magimpline(art, mag, imp, lin); + + // GUY was here with Koki + const long codcli = is_production_article(art) ? line.codclifor() : 0L; + const TString& rdoc_key = line.da_rdoc_key(); + + TMRP_line* son = _articles.find(art, riga.giacenza(), mag, EMPTY_STRING, imp, lin, codcli, rdoc_key); + if (son == NULL) + { + son = _articles.find(art, riga.giacenza(), mag, EMPTY_STRING, imp, lin, codcli, rdoc_key, true); + son->set_description(distinta.describe(art)); + } + const int son_depth = line.explosion_depth()+1; + if (son_depth > son->explosion_depth()) + son->set_explosion_depth(son_depth); + + line.add_son(riga.val(), son); + distinta.describe(art); + } + } } } + else + line.set_final_product(true); } if (pi != NULL) delete pi; @@ -2696,7 +2686,6 @@ bool TMatResPlanning::build_orders() { pi.addstatus(1); const TMRP_line& line = _articles[a]; - const bool prod = is_production_article(line.articolo()); long codforn = 0; if (!prod) // Se l'articolo NON e' di produzione ... @@ -2750,19 +2739,9 @@ bool TMatResPlanning::build_orders() row->get(F_QUANTITA - FIRST_FIELD,qta); row->get(F_ARTICOLO - FIRST_FIELD,codart); const long codforn=row->get_long(F_FORNITORE - FIRST_FIELD); - const TRectype& rec=cache().get(LF_DIST, codart); - bool art_prod, art_acq; + const bool art_prod = is_production_article(codart); + const bool art_acq = is_buy_article(codart) || codforn != 0L; - if (rec.empty()) - { - art_acq=TRUE; - art_prod = is_production_article(codart); - } - else - { - art_prod = rec.get_bool("ARTPROD"); - art_acq = rec.get_bool("ARTACQ") || codforn != 0L; - } TString4 tipoord = art_prod ? "P" : "F" ; row->add(tipoord, F_ORD_TYPE - FIRST_FIELD); sf.check_row(n); diff --git a/src/mr/mr2200.cpp b/src/mr/mr2200.cpp index c3a597519..2b8af14e6 100755 --- a/src/mr/mr2200.cpp +++ b/src/mr/mr2200.cpp @@ -14,6 +14,10 @@ #include "../ve/veconf.h" +/////////////////////////////////////////////////////////// +// Utility +/////////////////////////////////////////////////////////// + class TMSPCheck_mask : public TAutomask { protected: @@ -1535,6 +1539,8 @@ void TPlanning_mask::review_cell(long mrp_row, int bucket, bool check_machine, b codlin = row->get(F_CODLIN-FIRST_FIELD); codimp = row->get(F_CODIMP-FIRST_FIELD); } + if (!is_production_article(mrpline.articolo())) + return; dist_tree().set_global("_LIVELLO",livello_di_giacenza); dist_tree().set_global("_IMPIANTO",codimp); dist_tree().set_global("_LINEA",codlin); diff --git a/src/mr/mr2200a.uml b/src/mr/mr2200a.uml index 46446668e..c2bd58515 100755 --- a/src/mr/mr2200a.uml +++ b/src/mr/mr2200a.uml @@ -790,7 +790,7 @@ END //BUTTON F_CHECK_MSP 9 2 //BEGIN // PROMPT 64 3 "Controlla" -// PICTURE USER_BMP_CHECK +// PICTURE BMP_CHECK // GROUP G_POSTPROCESS //END @@ -936,7 +936,7 @@ END BUTTON F_PRIORITY_HI 2 2 BEGIN PROMPT -1 11 "^" - PICTURE USER_BMP_ARROWUP + PICTURE BMP_ARROWUP END BUTTON F_PRIORITY_ST 2 2 @@ -948,7 +948,7 @@ END BUTTON F_PRIORITY_LO 2 2 BEGIN PROMPT -1 15 "v" - PICTURE USER_BMP_ARROWDOWN + PICTURE BMP_ARROWDOWN END BUTTON F_SHRINK_ALL 17 1 @@ -2215,7 +2215,7 @@ END BUTTON F_CHECKLINE 10 2 BEGIN PROMPT 33 -1 "" - PICTURE USER_BMP_CHECK + PICTURE BMP_CHECK END BUTTON F_DOCUMENTI_OUT 3 2 diff --git a/src/mr/mr2200b.uml b/src/mr/mr2200b.uml index 6c0686827..b72141185 100755 --- a/src/mr/mr2200b.uml +++ b/src/mr/mr2200b.uml @@ -322,80 +322,80 @@ END BUTTON FC_RIGHT_BAD 4 2 BEGIN PROMPT 46 19 "" - PICTURE USER_BMP_ARROWRIGHT_RED + PICTURE BMP_DARROWR GROUP G_MOVIMENTO END BUTTON FC_DOWN_BAD 4 2 BEGIN PROMPT 40 20 "" - PICTURE USER_BMP_ARROWDOWN_RED + PICTURE BMP_DARROWDR GROUP G_MOVIMENTO END BUTTON FC_LEFT_BAD 4 2 BEGIN PROMPT 34 19 "" - PICTURE USER_BMP_ARROWLEFT_RED + PICTURE BMP_DARROWL2 GROUP G_MOVIMENTO END BUTTON FC_UP_BAD 4 2 BEGIN PROMPT 40 18 "" - PICTURE USER_BMP_ARROWUP_RED + PICTURE BMP_DARROWU2 GROUP G_MOVIMENTO END BUTTON FC_UPLEFT 4 2 BEGIN PROMPT 4 16 "<" - PICTURE USER_BMP_ARROWUPLEFT + PICTURE BMP_DARROWUL GROUP G_MOVIMENTO END BUTTON FC_UP 4 2 BEGIN PROMPT 10 16 "Su'" - PICTURE USER_BMP_ARROWUP + PICTURE BMP_DARROWU GROUP G_MOVIMENTO END BUTTON FC_UPRIGHT 4 2 BEGIN PROMPT 16 16 ">" - PICTURE USER_BMP_ARROWUPRIGHT + PICTURE BMP_DARROWUR GROUP G_MOVIMENTO END BUTTON FC_RIGHT 4 2 BEGIN PROMPT 16 18 ">" - PICTURE USER_BMP_ARROWRIGHT + PICTURE BMP_DARROWR END BUTTON FC_DOWNRIGHT 4 2 BEGIN PROMPT 16 20 ">" - PICTURE USER_BMP_ARROWDOWNRIGHT + PICTURE BMP_DARROWDR GROUP G_MOVIMENTO END BUTTON FC_DOWN 4 2 BEGIN PROMPT 10 20 "Giu'" - PICTURE USER_BMP_ARROWDOWN + PICTURE BMP_DARROWD GROUP G_MOVIMENTO END BUTTON FC_DOWNLEFT 4 2 BEGIN PROMPT 4 20 "<" - PICTURE USER_BMP_ARROWDOWNLEFT + PICTURE BMP_DARROWDL GROUP G_MOVIMENTO END BUTTON FC_LEFT 4 2 BEGIN PROMPT 4 18 "<" - PICTURE USER_BMP_ARROWLEFT + PICTURE BMP_DARROWL END diff --git a/src/mr/mr2200c.uml b/src/mr/mr2200c.uml index 75f0628ae..26faef3f6 100755 --- a/src/mr/mr2200c.uml +++ b/src/mr/mr2200c.uml @@ -185,70 +185,70 @@ END BUTTON FC_RIGHT_BAD 4 2 BEGIN PROMPT 46 17 "" - PICTURE USER_BMP_ARROWRIGHT_RED + PICTURE BMP_DARROWR2 END BUTTON FC_DOWN_BAD 4 2 BEGIN PROMPT 40 18 "" - PICTURE USER_BMP_ARROWDOWN_RED + PICTURE BMP_DARROWD2 END BUTTON FC_LEFT_BAD 4 2 BEGIN PROMPT 34 17 "" - PICTURE USER_BMP_ARROWLEFT_RED + PICTURE BMP_DARROWL2 END BUTTON FC_UP_BAD 4 2 BEGIN PROMPT 40 16 "" - PICTURE USER_BMP_ARROWUP_RED + PICTUREBMP_DARROWU2 END BUTTON FC_UPLEFT 4 2 BEGIN PROMPT 4 14 "<" - PICTURE USER_BMP_ARROWUPLEFT + PICTURE BMP_DARROWUL END BUTTON FC_UP 4 2 BEGIN PROMPT 10 14 "Su'" - PICTURE USER_BMP_ARROWUP + PICTURE BMP_DARROWU END BUTTON FC_UPRIGHT 4 2 BEGIN PROMPT 16 14 ">" - PICTURE USER_BMP_ARROWUPRIGHT + PICTURE BMP_DARROWUR END BUTTON FC_RIGHT 4 2 BEGIN PROMPT 16 16 ">" - PICTURE USER_BMP_ARROWRIGHT + PICTURE BMP_DARROWR END BUTTON FC_DOWNRIGHT 4 2 BEGIN PROMPT 16 18 ">" - PICTURE USER_BMP_ARROWDOWNRIGHT + PICTURE BMP_DARROWDR END BUTTON FC_DOWN 4 2 BEGIN - PROMPT 10 18 "Giu'" - PICTURE USER_BMP_ARROWDOWN + PROMPT 10 18 "Giu'"6 + PICTURE BMP_DARROWD END BUTTON FC_DOWNLEFT 4 2 BEGIN PROMPT 4 18 "<" - PICTURE USER_BMP_ARROWDOWNLEFT + PICTURE BMP_DARROWDL END BUTTON FC_LEFT 4 2 BEGIN PROMPT 4 16 "<" - PICTURE USER_BMP_ARROWLEFT + PICTURE BMP_DARROWL END diff --git a/src/mr/mr2201.cpp b/src/mr/mr2201.cpp index 78fafd853..22ed05b26 100755 --- a/src/mr/mr2201.cpp +++ b/src/mr/mr2201.cpp @@ -6,6 +6,7 @@ #include "../mg/mglib.h" #include "../ve/veconf.h" +#include "mrplib.h" #include "mr2100.h" #include "mr2200.h" @@ -290,9 +291,10 @@ void complete_codlinea(TToken_string &r2, bool ignore_imp) r2.get(F_SORTCODLIN-FIRST_FIELD, codlin); // if (codlin.blank()) // r2.get(F_CODLIN-FIRST_FIELD, codlin); // F_CODLIN == F_SORTCODLIN - if (codlin.blank()) + const TString codart = r2.get(F_ARTICOLO-FIRST_FIELD); + if (codlin.blank() && !is_production_article(codart)) { - if (dist_tree().set_root(r2.get(F_ARTICOLO-FIRST_FIELD))) + if (dist_tree().set_root(codart)) { dist_tree().set_global("_IMPIANTO",codimp); dist_tree().set_global("_LINEA",""); @@ -1021,7 +1023,7 @@ int TMSP_constraint::find_distinta_master(const TMSP_constraint & constr, TStrin dist_tree().set_global("_IMPIANTO",constr.codimp()); dist_tree().set_global("_LINEA",constr.codlin()); dist_tree().set_global("_MAGDEP",constr.codmagdep()); - if (dist_tree().set_root(constr.articolo())) + if (dist_tree().set_root(constr.articolo())) // verificare { TArray sons; dist_tree().explode(sons, FALSE, RAGGR_EXP_NONE, 1, "AV"); diff --git a/src/mr/mrplib.cpp b/src/mr/mrplib.cpp index 3f530d8f2..e859735eb 100755 --- a/src/mr/mrplib.cpp +++ b/src/mr/mrplib.cpp @@ -12,6 +12,7 @@ #include #include +#include "..\db\dist.h" #include "..\mg\anamag.h" @@ -1630,3 +1631,30 @@ void TProduzione::copy_contents(const TProduzione& src) } } +/////////////////////////////////////////////////////////// +// Utility +/////////////////////////////////////////////////////////// + +bool is_production_article(const TCodice_articolo& codart) +{ + const TRectype& rec=cache().get(LF_DIST, codart); + bool art_prod = false; + if (rec.empty()) + art_prod = cache().get(LF_ANAMAG, codart).get_bool(ANAMAG_ARTPROD); + else + art_prod = rec.get_bool(ANAMAG_ARTPROD) && (!is_buy_article(codart)); + + return art_prod; +} + +bool is_buy_article(const TCodice_articolo& codart) +{ + const TRectype& rec=cache().get(LF_DIST, codart); + bool art_acq = false; + if (rec.full()) + art_acq = rec.get_bool(DIST_ARTACQ) && !ini_get_bool(CONFIG_DITTA, "mr", "EXPLODE_ARTACQ"); + else + art_acq = !cache().get(LF_ANAMAG, codart).get_bool(ANAMAG_ARTPROD); + return art_acq; +} + diff --git a/src/mr/mrplib.h b/src/mr/mrplib.h index 8e2f4dcfe..af4e0ac7a 100755 --- a/src/mr/mrplib.h +++ b/src/mr/mrplib.h @@ -310,6 +310,13 @@ TLinea_prod* get_linea(const char * codice); void find_price(const TString &tipocv, const TString &codcv, const TString &codcatven, const char * tipocf, long codcf, const char * codice, const real & qta, real & price); +/////////////////////////////////////////////////////////// +// Utility +/////////////////////////////////////////////////////////// + +bool is_production_article(const TCodice_articolo& codart); +bool is_buy_article(const TCodice_articolo& codart); + class TProduzione : public TMultiple_rectype {