Corretta gestione form per stamap ordini (mischiava Valore con Residuo)
git-svn-id: svn://10.65.10.50/branches/R_10_00@23007 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									30fb95bbaf
								
							
						
					
					
						commit
						b4795aed72
					
				| @ -309,6 +309,32 @@ void TStampa_ordini::add_tiporiga(TString& cond, const char tipo) | |||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | static void append_range_filter(TString& filter, int file, const char* field, long from, long to) | ||||||
|  | { | ||||||
|  |   if (from > 0 || to > 0) | ||||||
|  |   { | ||||||
|  |     filter << "&&(BETWEEN("; | ||||||
|  |     if (file > 0) filter << file << "->"; | ||||||
|  |     filter << field << ',' << from << ',' << to << "))";  | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static void append_range_filter(TString& filter, int file, const char* field, const TDate& from, const TDate& to) | ||||||
|  | { | ||||||
|  |   if (from.ok() || to.ok()) | ||||||
|  |     append_range_filter(filter, file, field, from.date2ansi(), to.date2ansi()); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static void append_range_filter(TString& filter, int file, const char* field, const TString& from, const TString& to) | ||||||
|  | { | ||||||
|  |   if (from.full() || to.full()) | ||||||
|  |   { | ||||||
|  |     filter << "&&(BETWEEN("; | ||||||
|  |     if (file > 0) filter << file << "->"; | ||||||
|  |     filter << field << ",\"" << from << "\",\"" << to << "\"))";  | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void TStampa_ordini::filter_for_number() | void TStampa_ordini::filter_for_number() | ||||||
| { | { | ||||||
|   CHECK(_frm, "Form non valido"); |   CHECK(_frm, "Form non valido"); | ||||||
| @ -383,6 +409,7 @@ void TStampa_ordini::filter_for_number() | |||||||
|   { |   { | ||||||
|     // In caso di dettaglio per righe non va settato il filtro per dataconsegnain quanto
 |     // In caso di dettaglio per righe non va settato il filtro per dataconsegnain quanto
 | ||||||
|     // già impostato sulla sottosezione (vedi sotto)
 |     // già impostato sulla sottosezione (vedi sotto)
 | ||||||
|  |     /*
 | ||||||
|     if (_from_cons.ok()) |     if (_from_cons.ok()) | ||||||
|     { |     { | ||||||
|       filter_expr << "&&"; |       filter_expr << "&&"; | ||||||
| @ -397,6 +424,8 @@ void TStampa_ordini::filter_for_number() | |||||||
|                    (const char*)_to_cons.string(ANSI)); |                    (const char*)_to_cons.string(ANSI)); | ||||||
|       filter_expr << s; |       filter_expr << s; | ||||||
|     } |     } | ||||||
|  |     */ | ||||||
|  |     append_range_filter(filter_expr, 0, DOC_DATACONS, _from_cons, _to_cons); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   if (filter_expr.starts_with("&&")) |   if (filter_expr.starts_with("&&")) | ||||||
| @ -459,6 +488,7 @@ void TStampa_ordini::filter_for_number() | |||||||
|     cond << s; |     cond << s; | ||||||
|      |      | ||||||
|     // Setta i range per la data di consegna
 |     // Setta i range per la data di consegna
 | ||||||
|  |     /*
 | ||||||
|     if (_from_cons.ok()) |     if (_from_cons.ok()) | ||||||
|     { |     { | ||||||
|       if (cond.not_empty()) |       if (cond.not_empty()) | ||||||
| @ -475,8 +505,11 @@ void TStampa_ordini::filter_for_number() | |||||||
|                    LF_RIGHEDOC, (const char*)_to_cons.string(ANSI)); |                    LF_RIGHEDOC, (const char*)_to_cons.string(ANSI)); | ||||||
|       cond << s; |       cond << s; | ||||||
|     } |     } | ||||||
|  |     */ | ||||||
|  |     append_range_filter(cond, LF_RIGHEDOC, RDOC_DATACONS, _from_cons, _to_cons); | ||||||
| 
 | 
 | ||||||
|     // Setta i range per il codice magazzino
 |     // Setta i range per il codice magazzino
 | ||||||
|  |     /*
 | ||||||
|     if (_from_mag.not_empty()) |     if (_from_mag.not_empty()) | ||||||
|     { |     { | ||||||
|       if (cond.not_empty()) |       if (cond.not_empty()) | ||||||
| @ -493,8 +526,11 @@ void TStampa_ordini::filter_for_number() | |||||||
|                    LF_RIGHEDOC, (const char*)_to_mag); |                    LF_RIGHEDOC, (const char*)_to_mag); | ||||||
|       cond << s; |       cond << s; | ||||||
|     } |     } | ||||||
|  |     */ | ||||||
|  |     append_range_filter(cond, LF_RIGHEDOC, RDOC_CODMAG, _from_mag, _to_mag); | ||||||
| 
 | 
 | ||||||
|     // Setta i range per il codice articolo
 |     // Setta i range per il codice articolo
 | ||||||
|  |     /*
 | ||||||
|     if (_from_art.not_empty()) |     if (_from_art.not_empty()) | ||||||
|     { |     { | ||||||
|       if (cond.not_empty()) |       if (cond.not_empty()) | ||||||
| @ -511,6 +547,8 @@ void TStampa_ordini::filter_for_number() | |||||||
|                    LF_RIGHEDOC, (const char*)_to_art); |                    LF_RIGHEDOC, (const char*)_to_art); | ||||||
|       cond << s; |       cond << s; | ||||||
|     } |     } | ||||||
|  |     */ | ||||||
|  |     append_range_filter(cond, LF_RIGHEDOC, RDOC_CODART, _from_art, _to_art); | ||||||
|      |      | ||||||
|     s.format("&&(%d->CODART!=\"\")", LF_RIGHEDOC); |     s.format("&&(%d->CODART!=\"\")", LF_RIGHEDOC); | ||||||
|     cond << s; |     cond << s; | ||||||
| @ -686,6 +724,7 @@ void TStampa_ordini::filter_for_clifo_agent() | |||||||
|   } |   } | ||||||
|    |    | ||||||
|   // Filtro sulla data ordine...
 |   // Filtro sulla data ordine...
 | ||||||
|  |   /*
 | ||||||
|   if (_from_date.ok()) |   if (_from_date.ok()) | ||||||
|   { |   { | ||||||
|     s.format("&&(ANSI(%d->DATADOC)>=\"%s\")", LF_DOC, |     s.format("&&(ANSI(%d->DATADOC)>=\"%s\")", LF_DOC, | ||||||
| @ -698,8 +737,11 @@ void TStampa_ordini::filter_for_clifo_agent() | |||||||
|                  (const char*)_to_date.string(ANSI)); |                  (const char*)_to_date.string(ANSI)); | ||||||
|     filter_expr << s; |     filter_expr << s; | ||||||
|   }  |   }  | ||||||
|  |   */ | ||||||
|  |   append_range_filter(filter_expr, LF_DOC, DOC_DATADOC, _from_date, _to_date); | ||||||
|                                                 |                                                 | ||||||
|   // Filtro sulla data consegna...
 |   // Filtro sulla data consegna...
 | ||||||
|  |   /*
 | ||||||
|   if (_from_cons.ok()) |   if (_from_cons.ok()) | ||||||
|   { |   { | ||||||
|     s.format("&&(ANSI(DATACONS)>=\"%s\")",  |     s.format("&&(ANSI(DATACONS)>=\"%s\")",  | ||||||
| @ -712,10 +754,13 @@ void TStampa_ordini::filter_for_clifo_agent() | |||||||
|                  (const char*)_to_cons.string(ANSI)); |                  (const char*)_to_cons.string(ANSI)); | ||||||
|     filter_expr << s; |     filter_expr << s; | ||||||
|   } |   } | ||||||
|  |   */ | ||||||
|  |   append_range_filter(filter_expr, 0, DOC_DATACONS, _from_cons, _to_cons); | ||||||
|    |    | ||||||
|   if (_detail_rows) |   if (_detail_rows) | ||||||
|   { |   { | ||||||
|     // Setta i range per il codice articolo
 |     // Setta i range per il codice articolo
 | ||||||
|  |     /*
 | ||||||
|     if (_from_art.full()) |     if (_from_art.full()) | ||||||
|     { |     { | ||||||
|       s.format("&&(%d->CODART>=\"%s\")",  |       s.format("&&(%d->CODART>=\"%s\")",  | ||||||
| @ -729,6 +774,9 @@ void TStampa_ordini::filter_for_clifo_agent() | |||||||
|                    LF_RIGHEDOC, (const char*)_to_art); |                    LF_RIGHEDOC, (const char*)_to_art); | ||||||
|       filter_expr << s; |       filter_expr << s; | ||||||
|     } |     } | ||||||
|  |     */ | ||||||
|  |     append_range_filter(filter_expr, LF_RIGHEDOC, RDOC_CODART, _from_art, _to_art); | ||||||
|  | 
 | ||||||
|     // Setta i range per i livelli di giacenza (da 1 a 4)
 |     // Setta i range per i livelli di giacenza (da 1 a 4)
 | ||||||
|     if (_detail_level > 0) |     if (_detail_level > 0) | ||||||
|       for (int lev=1, index=0; lev <= _detail_level; lev++) |       for (int lev=1, index=0; lev <= _detail_level; lev++) | ||||||
| @ -999,18 +1047,22 @@ void TStampa_ordini::filter_for_articolo() | |||||||
|   filter_expr << s; |   filter_expr << s; | ||||||
| 
 | 
 | ||||||
|   // Filtro su Cli/Fo
 |   // Filtro su Cli/Fo
 | ||||||
|  |   /*
 | ||||||
|   if (_from_cf > 0L) |   if (_from_cf > 0L) | ||||||
|   { |   { | ||||||
|     s.format("&&(STR(NUM(%d->CODCF)>=%ld))", LF_DOC, _from_cf); |     s.format("&&(STR(NUM(%d->CODCF)>=%ld))", LF_DOC, _from_cf); | ||||||
|     filter_expr << s; |     filter_expr << s; | ||||||
|   } |   } | ||||||
|      |  | ||||||
|   if (_to_cf > 0L) |   if (_to_cf > 0L) | ||||||
|   { |   { | ||||||
|     s.format("&&(STR(NUM(%d->CODCF)<=%ld))", LF_DOC, _to_cf); |     s.format("&&(STR(NUM(%d->CODCF)<=%ld))", LF_DOC, _to_cf); | ||||||
|     filter_expr << s; |     filter_expr << s; | ||||||
|   } |   } | ||||||
|  |   */ | ||||||
|  |   append_range_filter(filter_expr, LF_DOC, DOC_CODCF, _from_cf, _to_cf); | ||||||
|  |    | ||||||
|   // Filtro sulla data ordine...
 |   // Filtro sulla data ordine...
 | ||||||
|  |   /*
 | ||||||
|   if (_from_date.ok()) |   if (_from_date.ok()) | ||||||
|   {                                              |   {                                              | ||||||
|     s.format("&&(ANSI(%d->DATADOC)>=\"%s\")", LF_DOC, |     s.format("&&(ANSI(%d->DATADOC)>=\"%s\")", LF_DOC, | ||||||
| @ -1023,8 +1075,11 @@ void TStampa_ordini::filter_for_articolo() | |||||||
|                  (const char*)_to_date.string(ANSI)); |                  (const char*)_to_date.string(ANSI)); | ||||||
|     filter_expr << s; |     filter_expr << s; | ||||||
|   }  |   }  | ||||||
|  |   */ | ||||||
|  |   append_range_filter(filter_expr, LF_DOC, DOC_DATADOC, _from_date, _to_date); | ||||||
|                                                 |                                                 | ||||||
|   // Filtro sulla data consegna...
 |   // Filtro sulla data consegna...
 | ||||||
|  |   /*
 | ||||||
|   if (_from_cons.ok()) |   if (_from_cons.ok()) | ||||||
|   { |   { | ||||||
|     s.format("&&(ANSI(DATACONS)>=\"%s\")",  |     s.format("&&(ANSI(DATACONS)>=\"%s\")",  | ||||||
| @ -1037,6 +1092,8 @@ void TStampa_ordini::filter_for_articolo() | |||||||
|                  (const char*)_to_cons.string(ANSI)); |                  (const char*)_to_cons.string(ANSI)); | ||||||
|     filter_expr << s; |     filter_expr << s; | ||||||
|   } |   } | ||||||
|  |   */ | ||||||
|  |   append_range_filter(filter_expr, 0, DOC_DATACONS, _from_cons, _to_cons); | ||||||
|    |    | ||||||
|   // Setta i range per i livelli di giacenza (da 1 a 4)
 |   // Setta i range per i livelli di giacenza (da 1 a 4)
 | ||||||
|   if (_detail_level > 0) |   if (_detail_level > 0) | ||||||
| @ -1062,6 +1119,7 @@ void TStampa_ordini::filter_for_articolo() | |||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   // Setta i range per il codice magazzino (deposito incluso)
 |   // Setta i range per il codice magazzino (deposito incluso)
 | ||||||
|  |   /*
 | ||||||
|   if (_from_mag.not_empty()) |   if (_from_mag.not_empty()) | ||||||
|   { |   { | ||||||
|     s.format("&&(%d->CODMAG>=\"%s\")",  |     s.format("&&(%d->CODMAG>=\"%s\")",  | ||||||
| @ -1074,6 +1132,8 @@ void TStampa_ordini::filter_for_articolo() | |||||||
|                  LF_RIGHEDOC, (const char*)_to_mag); |                  LF_RIGHEDOC, (const char*)_to_mag); | ||||||
|     filter_expr << s; |     filter_expr << s; | ||||||
|   } |   } | ||||||
|  |   */ | ||||||
|  |   append_range_filter(filter_expr, LF_RIGHEDOC, RDOC_CODMAG, _from_mag, _to_mag); | ||||||
| 
 | 
 | ||||||
|   if (_TEA_rord > ' ') |   if (_TEA_rord > ' ') | ||||||
|   { |   { | ||||||
|  | |||||||
| @ -119,7 +119,8 @@ BEGIN | |||||||
|  SPECIAL STRINGA FINCATURA "XX" "Fincatura sinistra e destra" |  SPECIAL STRINGA FINCATURA "XX" "Fincatura sinistra e destra" | ||||||
|  KEY "Codice Valuta" |  KEY "Codice Valuta" | ||||||
|  PROMPT 7 1 "" |  PROMPT 7 1 "" | ||||||
|  FIELD CODVAL |  //FIELD CODVAL | ||||||
|  |  MESSAGE _ORDINE,CODVAL | ||||||
| END | END | ||||||
| 
 | 
 | ||||||
| DATA BODY_COL_DATACONS 10 | DATA BODY_COL_DATACONS 10 | ||||||
|  | |||||||
| @ -338,7 +338,7 @@ void TStampa_dettaglio_articoli::main_loop() | |||||||
| int or1200(int argc, char** argv) | int or1200(int argc, char** argv) | ||||||
| { | { | ||||||
|   TStampa_dettaglio_articoli a; |   TStampa_dettaglio_articoli a; | ||||||
|   a.run(argc,argv,TR("Stampa disponibilita' articoli")); |   a.run(argc,argv,TR("Stampa disponibilità articoli")); | ||||||
|   return 0; |   return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -40,10 +40,10 @@ BEGIN | |||||||
|  MESSAGE _PAGENO |  MESSAGE _PAGENO | ||||||
| END | END | ||||||
| 
 | 
 | ||||||
| NUMERO 4 40 | STRINGA 4 40 | ||||||
| BEGIN | BEGIN | ||||||
|  KEY "Intestazione stampa" |  KEY "Intestazione stampa" | ||||||
|  PROMPT  60 2 "Stampa dettaglio disponibilita' articoli" |  PROMPT  60 2 "Stampa dettaglio disponibilità articoli" | ||||||
| END | END | ||||||
| 
 | 
 | ||||||
| END //HEADER | END //HEADER | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ TOOLBAR "topbar" 0 0 0 2 | |||||||
| #include <printbar.h> | #include <printbar.h> | ||||||
| ENDPAGE | ENDPAGE | ||||||
| 
 | 
 | ||||||
| PAGE "Disponibilita' articoli" 0 0 0 0 | PAGE "Disponibilità articoli" 0 0 0 0 | ||||||
| 
 | 
 | ||||||
| GROUPBOX DLG_NULL 41 7 | GROUPBOX DLG_NULL 41 7 | ||||||
| BEGIN | BEGIN | ||||||
|  | |||||||
							
								
								
									
										337
									
								
								or/orlib01.cpp
									
									
									
									
									
								
							
							
						
						
									
										337
									
								
								or/orlib01.cpp
									
									
									
									
									
								
							| @ -173,187 +173,196 @@ bool TOrdine_form::validate(TForm_item &cf, TToken_string &s) | |||||||
| 
 | 
 | ||||||
|           cf.set(qt.string()); |           cf.set(qt.string()); | ||||||
|         } |         } | ||||||
|  |     } else | ||||||
|  |     if (action == "CODVAL") // Comandi per stampa riepilogo per valuta
 | ||||||
|  |     { | ||||||
|  |       const TString& codval = doc.get(DOC_CODVAL); | ||||||
|  |       if (is_firm_value(codval)) | ||||||
|  |         cf.set(""); | ||||||
|  |       else | ||||||
|  |         cf.set(codval); | ||||||
|  |     } else | ||||||
|  |     if (action == "VALTABLE") // Comandi per stampa riepilogo per valuta
 | ||||||
|  |     { | ||||||
|  |       TString subcommand(s.get(2)); | ||||||
|  |       if (subcommand == "RESET") | ||||||
|  |       { | ||||||
|  |         _totvaluta.destroy(); | ||||||
|  |         cf.find_field("TOTVAL1").disable(); | ||||||
|  |         cf.find_field("TOTVAL2").disable(); | ||||||
|  |         cf.find_field("TOTVAL3").disable(); | ||||||
|  |         cf.find_field("TOTVAL4").disable(); | ||||||
|  |       } | ||||||
|  |       else | ||||||
|  |       { | ||||||
|  |         const int valute = _totvaluta.items(); | ||||||
|  |         TString4 codval = doc.get(DOC_CODVAL); | ||||||
|  |         if (is_firm_value(codval)) codval.cut(0); | ||||||
|  | 
 | ||||||
|  |         const bool is_key = _totvaluta.is_key(codval); | ||||||
|  |         const bool is_new = !is_key && valute < 4; | ||||||
|  | 
 | ||||||
|  |         if (is_new) // Aggiunge l'elemento se non c'e'
 | ||||||
|  |           _totvaluta.add(codval,(_TTotale_valuta*)new _TTotale_valuta,is_key); | ||||||
|  |         // Controlla/stampa al massimo 4 valute
 | ||||||
|  |         if (is_key || is_new) | ||||||
|  |         { | ||||||
|  |           _TTotale_valuta& tv = (_TTotale_valuta&)_totvaluta[codval]; | ||||||
|  |           const bool is_valord = subcommand == "VALORD"; | ||||||
|  |           real& r =  is_valord ? tv.totord() : tv.totres(); | ||||||
|  |           TString s_id; | ||||||
|  |           int i_id; | ||||||
|  |    | ||||||
|  |           // Abilita la sezione corrispondente e setta i valori all'interno
 | ||||||
|  |           if (!is_key) | ||||||
|  |           { | ||||||
|  |             TString16 sec_name = "TOTVAL"; | ||||||
|  |             sec_name << valute+1; | ||||||
|  |             tv.secnum() = valute+1; | ||||||
|  |             cf.find_field(sec_name).enable(); | ||||||
|  |             // Setta anche il codice valuta
 | ||||||
|  |             i_id = BODY_CODVAL + valute*10; | ||||||
|  |             s_id.format("%d",i_id); | ||||||
|  |             cf.find_field(s_id).set(codval); | ||||||
|  |             if (valute == 0) | ||||||
|  |             { | ||||||
|  |               i_id--; | ||||||
|  |               s_id.format("%d",i_id); | ||||||
|  |               cf.find_field(s_id).set("@bTotali"); | ||||||
|  |             } | ||||||
|  |           } | ||||||
|  |           const int sn = tv.secnum(); | ||||||
|  |           i_id = is_valord ? BODY_TOTVALORD : BODY_TOTVALRES; | ||||||
|  |                | ||||||
|  |           i_id += (sn-1)*10; | ||||||
|  |           s_id.format("%d",i_id); | ||||||
|  |           r +=  ((real) cf.get()); // Somma il valore corrente
 | ||||||
|  |           cf.find_field(s_id).set(r.string()); | ||||||
|  |         } | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|       if (action == "VALTABLE") // Comandi per stampa riepilogo per valuta
 |     if (action == "CALCDISP") // messaggi per calcolo disponibilita'
 | ||||||
|  |     { | ||||||
|  |       TString command(s.get(2)); | ||||||
|  |       if (command == "RESET") // resetta la tabella
 | ||||||
|       { |       { | ||||||
|         TString subcommand(s.get(2)); |         _totdisp.destroy(); | ||||||
|         if (subcommand == "RESET") |         const real rz = ZERO; | ||||||
|  |         const int items = _date_array->items(); | ||||||
|  |         for (int i = 0; i<items; i++) | ||||||
|  |           _totdisp.add(rz); | ||||||
|  |         // Legge anche una volta per tutte il TArticolo_giacenza (uargh uargh)
 | ||||||
|  |         if (_art_giac->read(rdoc.get(RDOC_CODART)) == NOERR) | ||||||
|         { |         { | ||||||
|           _totvaluta.destroy(); |           _codmag  = rdoc.get(RDOC_CODMAG); | ||||||
|           cf.find_field("TOTVAL1").disable(); |           _livello = rdoc.get(RDOC_LIVELLO); | ||||||
|           cf.find_field("TOTVAL2").disable(); |         } | ||||||
|           cf.find_field("TOTVAL3").disable(); |         else | ||||||
|           cf.find_field("TOTVAL4").disable(); |           cf.set("Errore in lettura articolo"); | ||||||
|  |       } | ||||||
|  |       else | ||||||
|  |       if (command == "CALC") // Effettua il calcolo per questa riga articolo, 
 | ||||||
|  |         //cumulando nell'array le quantita', espresse sempre in UM principale
 | ||||||
|  |       { | ||||||
|  |         const bool is_ordine_cliente = doc.get(DOC_TIPOCF)[0] == 'C'; | ||||||
|  |         const TString16 causmag(doc.get(DOC_CAUSMAG)); | ||||||
|  |         const TString16 um(rdoc.get(RDOC_UMQTA)); | ||||||
|  |         const TDate datacons(rdoc.get_date(RDOC_DATACONS)); | ||||||
|  |         int segno = is_ordine_cliente ? -1 : +1; // default 
 | ||||||
|  |         if (causmag.not_empty()) // se la causale esiste consulta il segno 
 | ||||||
|  |         {                          | ||||||
|  |           TCausale_magazzino cm(causmag); | ||||||
|  |           segno *= cm.sgn(is_ordine_cliente ? s_ordc : s_ordf); | ||||||
|  |         } | ||||||
|  |         // Reperisce fattore di conversione per UM principale,
 | ||||||
|  |         // la quantita residua
 | ||||||
|  |         real qtares = rdoc.qtaresidua(); // ZIO PERA! ag völ la riga dal document       
 | ||||||
|  |         qtares = _art_giac->convert_to_um(qtares, "", um, true); | ||||||
|  |         qtares *= segno; // mette a posto il segno...
 | ||||||
|  |         // Trova il periodo giusto
 | ||||||
|  |         const int index = find_period(datacons); | ||||||
|  |         if (index >= _totdisp.items())  | ||||||
|  |           _totdisp.add(ZERO, index);    // Added by Guy!  Should never happen :-)
 | ||||||
|  |         real& rv = (real&) _totdisp[index]; | ||||||
|  |         rv += qtares; | ||||||
|  | 
 | ||||||
|  |         const TDate datascimp(doc.get_date("DATASCIMP")); | ||||||
|  | 						 | ||||||
|  | 				if (datascimp.ok()) | ||||||
|  | 				{ | ||||||
|  | 	        const int last_index = find_period(datascimp); | ||||||
|  | 					if (last_index >= 0) | ||||||
|  | 					{ | ||||||
|  | 						real& rv = (real&) _totdisp[last_index]; | ||||||
|  | 						rv -= qtares; | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  |       } | ||||||
|  |       else | ||||||
|  |         if (command == "PRNUM") // Stampa l'unita' di misura principale
 | ||||||
|  |         { | ||||||
|  |           const TRecord_array& um = _art_giac->um(); | ||||||
|  |           if (um.rows() > 0)             // Controlla che ci sia almeno una unita' di misura  
 | ||||||
|  |             cf.set(um.row(1).get("UM")); // UM principale
 | ||||||
|  |           else | ||||||
|  |             cf.set(""); | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|           const int valute = _totvaluta.items(); |           const int period = s.get_int(3); | ||||||
|           TString codval(doc.get(DOC_CODVAL)); |           //const int items  = _date_array->items();
 | ||||||
|           const bool is_key = _totvaluta.is_key(codval); |           TString16 annoes; | ||||||
|           const bool is_new = !is_key && valute < 4; |           real giacenza, scorta_min; | ||||||
| 
 | 
 | ||||||
|           if (is_new) // Aggiunge l'elemento se non c'e'
 |           TEsercizi_contabili esc; | ||||||
|             _totvaluta.add(codval,(_TTotale_valuta*)new _TTotale_valuta,is_key); |           annoes << esc.date2esc(doc.get_date(DOC_DATADOC)); | ||||||
|           // Controlla/stampa al massimo 4 valute
 |           //TString16 codmag(rdoc.get(RDOC_CODMAG));
 | ||||||
|           if (is_key || is_new) |           //TString16 livello(rdoc.get(RDOC_LIVELLO));
 | ||||||
|  |           const int codmag_len  = (_detail_dep || _detail_mag) ? _codmag.len() : 0; | ||||||
|  |           const int livello_len = _level > 0 ? _livello.len() : 0; | ||||||
|  |           //if (_art_giac->read(rdoc.get(RDOC_CODART)) == NOERR)
 | ||||||
|           { |           { | ||||||
|             _TTotale_valuta& tv = (_TTotale_valuta&)_totvaluta[codval]; |             // Serve l'anno esercizio del magazzino... 
 | ||||||
|             const bool is_valord = subcommand == "VALORD"; |  | ||||||
|             real& r =  is_valord ? tv.totord() : tv.totres(); |  | ||||||
|             TString s_id; |  | ||||||
|             int i_id; |  | ||||||
|                  |                  | ||||||
|             // Abilita la sezione corrispondente e setta i valori all'interno
 |             // Ciclo sulle giacenze di magazzino
 | ||||||
|             if (!is_key) |             TRecord_array& mmgg = _art_giac->mag(annoes); | ||||||
|  |             const int rows = mmgg.rows(); | ||||||
|  |             // Cumula raggruppando le giacenze per lo stesso mag/dep/liv.giac
 | ||||||
|  |             // Scurre alla ruvescia
 | ||||||
|  |             for (int i=mmgg.last_row();i>0;i--) | ||||||
|             { |             { | ||||||
|               TString16 sec_name = "TOTVAL"; |               const TRectype& rec = mmgg.row(i); // gosh!?
 | ||||||
|               sec_name << valute+1; |  | ||||||
|               tv.secnum() = valute+1; |  | ||||||
|               cf.find_field(sec_name).enable(); |  | ||||||
|               // Setta anche il codice valuta
 |  | ||||||
|               i_id = BODY_CODVAL + valute*10; |  | ||||||
|               s_id.format("%d",i_id); |  | ||||||
|               cf.find_field(s_id).set(codval); |  | ||||||
|               if (valute == 0) |  | ||||||
|               { |  | ||||||
|                 i_id--; |  | ||||||
|                 s_id.format("%d",i_id); |  | ||||||
|                 cf.find_field(s_id).set("@bTotali"); |  | ||||||
|               } |  | ||||||
|             } |  | ||||||
|             const int sn = tv.secnum(); |  | ||||||
|             i_id = is_valord ? BODY_TOTVALORD : BODY_TOTVALRES; |  | ||||||
|                    |                    | ||||||
|             i_id += (sn-1)*10; |               //checkka se trattasi di medesimo liv giac/mag/dep in caso sia stato spec. il dettaglio
 | ||||||
|             s_id.format("%d",i_id); |               // altrimenti cumula el todo
 | ||||||
|             r +=  ((real) cf.get()); // Somma il valore corrente
 |               if (codmag_len == 0 || (rec.get(MAG_CODMAG).compare(_codmag, codmag_len) == 0)) | ||||||
|             cf.find_field(s_id).set(r.string()); |                 if (livello_len == 0 || (rec.get(MAG_LIVELLO).compare(_livello, livello_len) == 0)) | ||||||
|           } |  | ||||||
|         } |  | ||||||
|       } |  | ||||||
|       else |  | ||||||
|         if (action == "CALCDISP") // messaggi per calcolo disponibilita'
 |  | ||||||
|         { |  | ||||||
|           TString command(s.get(2)); |  | ||||||
|           if (command == "RESET") // resetta la tabella
 |  | ||||||
|           { |  | ||||||
|             _totdisp.destroy(); |  | ||||||
|             const real rz = ZERO; |  | ||||||
|             const int items = _date_array->items(); |  | ||||||
|             for (int i = 0; i<items; i++) |  | ||||||
|               _totdisp.add(rz); |  | ||||||
|             // Legge anche una volta per tutte il TArticolo_giacenza (uargh uargh)
 |  | ||||||
|             if (_art_giac->read(rdoc.get(RDOC_CODART)) == NOERR) |  | ||||||
|             { |  | ||||||
|               _codmag  = rdoc.get(RDOC_CODMAG); |  | ||||||
|               _livello = rdoc.get(RDOC_LIVELLO); |  | ||||||
|             } |  | ||||||
|             else |  | ||||||
|               cf.set("Errore in lettura articolo"); |  | ||||||
|           } |  | ||||||
|           else |  | ||||||
|           if (command == "CALC") // Effettua il calcolo per questa riga articolo, 
 |  | ||||||
|            //cumulando nell'array le quantita', espresse sempre in UM principale
 |  | ||||||
|           { |  | ||||||
|             const bool is_ordine_cliente = doc.get(DOC_TIPOCF)[0] == 'C'; |  | ||||||
|             const TString16 causmag(doc.get(DOC_CAUSMAG)); |  | ||||||
|             const TString16 um(rdoc.get(RDOC_UMQTA)); |  | ||||||
|             const TDate datacons(rdoc.get_date(RDOC_DATACONS)); |  | ||||||
|             int segno = is_ordine_cliente ? -1 : +1; // default 
 |  | ||||||
|             if (causmag.not_empty()) // se la causale esiste consulta il segno 
 |  | ||||||
|             {                          |  | ||||||
|               TCausale_magazzino cm(causmag); |  | ||||||
|               segno *= cm.sgn(is_ordine_cliente ? s_ordc : s_ordf); |  | ||||||
|             } |  | ||||||
|             // Reperisce fattore di conversione per UM principale,
 |  | ||||||
|             // la quantita residua
 |  | ||||||
|             real qtares = rdoc.qtaresidua(); // ZIO PERA! ag völ la riga dal document       
 |  | ||||||
|             qtares = _art_giac->convert_to_um(qtares, "", um, true); |  | ||||||
|             qtares *= segno; // mette a posto il segno...
 |  | ||||||
|             // Trova il periodo giusto
 |  | ||||||
|             const int index = find_period(datacons); |  | ||||||
|             if (index >= _totdisp.items())  |  | ||||||
|               _totdisp.add(ZERO, index);    // Added by Guy!  Should never happen :-)
 |  | ||||||
|             real& rv = (real&) _totdisp[index]; |  | ||||||
|             rv += qtares; |  | ||||||
| 
 |  | ||||||
|             const TDate datascimp(doc.get_date("DATASCIMP")); |  | ||||||
| 						 |  | ||||||
| 						if (datascimp.ok()) |  | ||||||
| 						{ |  | ||||||
| 	            const int last_index = find_period(datascimp); |  | ||||||
| 							if (last_index >= 0) |  | ||||||
| 							{ |  | ||||||
| 								real& rv = (real&) _totdisp[last_index]; |  | ||||||
| 								rv -= qtares; |  | ||||||
| 							} |  | ||||||
| 						} |  | ||||||
|           } |  | ||||||
|           else |  | ||||||
|             if (command == "PRNUM") // Stampa l'unita' di misura principale
 |  | ||||||
|             { |  | ||||||
|               const TRecord_array& um = _art_giac->um(); |  | ||||||
|               if (um.rows() > 0)             // Controlla che ci sia almeno una unita' di misura  
 |  | ||||||
|                 cf.set(um.row(1).get("UM")); // UM principale
 |  | ||||||
|               else |  | ||||||
|                 cf.set(""); |  | ||||||
|             } |  | ||||||
|             else |  | ||||||
|             { |  | ||||||
|               const int period = s.get_int(3); |  | ||||||
|               //const int items  = _date_array->items();
 |  | ||||||
|               TString16 annoes; |  | ||||||
|               real giacenza, scorta_min; |  | ||||||
| 
 |  | ||||||
|               TEsercizi_contabili esc; |  | ||||||
|               annoes << esc.date2esc(doc.get_date(DOC_DATADOC)); |  | ||||||
|               //TString16 codmag(rdoc.get(RDOC_CODMAG));
 |  | ||||||
|               //TString16 livello(rdoc.get(RDOC_LIVELLO));
 |  | ||||||
|               const int codmag_len  = (_detail_dep || _detail_mag) ? _codmag.len() : 0; |  | ||||||
|               const int livello_len = _level > 0 ? _livello.len() : 0; |  | ||||||
|               //if (_art_giac->read(rdoc.get(RDOC_CODART)) == NOERR)
 |  | ||||||
|               { |  | ||||||
|                 // Serve l'anno esercizio del magazzino... 
 |  | ||||||
|                  |  | ||||||
|                 // Ciclo sulle giacenze di magazzino
 |  | ||||||
|                 TRecord_array& mmgg = _art_giac->mag(annoes); |  | ||||||
|                 const int rows = mmgg.rows(); |  | ||||||
|                 // Cumula raggruppando le giacenze per lo stesso mag/dep/liv.giac
 |  | ||||||
|                 // Scurre alla ruvescia
 |  | ||||||
|                 for (int i=mmgg.last_row();i>0;i--) |  | ||||||
|                 { |                 { | ||||||
|                   const TRectype& rec = mmgg.row(i); // gosh!?
 |                   giacenza       += _art_giac->giacenza_corretta(rec, _giac_eff, _val_comp); | ||||||
|                    |                   scorta_min     = rec.get_real(MAG_SCORTAMIN); | ||||||
|                   //checkka se trattasi di medesimo liv giac/mag/dep in caso sia stato spec. il dettaglio
 |  | ||||||
|                   // altrimenti cumula el todo
 |  | ||||||
|                   if (codmag_len == 0 || (rec.get(MAG_CODMAG).compare(_codmag, codmag_len) == 0)) |  | ||||||
|                     if (livello_len == 0 || (rec.get(MAG_LIVELLO).compare(_livello, livello_len) == 0)) |  | ||||||
|                     { |  | ||||||
|                       giacenza       += _art_giac->giacenza_corretta(rec, _giac_eff, _val_comp); |  | ||||||
|                       scorta_min     = rec.get_real(MAG_SCORTAMIN); |  | ||||||
|                     } |  | ||||||
|                 } |                 } | ||||||
|               } |             } | ||||||
|               for (int i = 0; i< period/*items*/; i++) |           } | ||||||
|                 giacenza += (real&)_totdisp[i]; |           for (int i = 0; i< period/*items*/; i++) | ||||||
|               if (command == "PRNGIAC") // Stampa la giacenza prevista
 |             giacenza += (real&)_totdisp[i]; | ||||||
|  |           if (command == "PRNGIAC") // Stampa la giacenza prevista
 | ||||||
|  |           { | ||||||
|  |             cf.set(giacenza.string()); | ||||||
|  |           } | ||||||
|  |           else | ||||||
|  |             if (command == "PRNSOTT") // Stampa il sottoscorta
 | ||||||
|  |             { | ||||||
|  |               if (giacenza < scorta_min) | ||||||
|               { |               { | ||||||
|  |                 giacenza = scorta_min - giacenza; | ||||||
|                 cf.set(giacenza.string()); |                 cf.set(giacenza.string()); | ||||||
|               } |               } | ||||||
|               else |               else | ||||||
|                 if (command == "PRNSOTT") // Stampa il sottoscorta
 |                 cf.set(""); | ||||||
|                 { |             } | ||||||
|                   if (giacenza < scorta_min) |             // Ignore any other command
 | ||||||
|                   { |           } | ||||||
|                     giacenza = scorta_min - giacenza; |  | ||||||
|                     cf.set(giacenza.string()); |  | ||||||
|                   } |  | ||||||
|                   else |  | ||||||
|                     cf.set(""); |  | ||||||
|                 } |  | ||||||
|                 // Ignore any other command
 |  | ||||||
|              } |  | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
|         if (action == "PREZZONS") |         if (action == "PREZZONS") | ||||||
| @ -402,7 +411,7 @@ bool TOrdine_form::validate(TForm_item &cf, TToken_string &s) | |||||||
|           } else |           } else | ||||||
|           if (action == "VALRES") |           if (action == "VALRES") | ||||||
|           { |           { | ||||||
|               cf.set(rdoc.valore(true, false, AUTO_DECIMALS).string()); |               cf.set(rdoc.valore(false, false, AUTO_DECIMALS).string()); // true -> false  totale -> residuo   22-10-2014
 | ||||||
|           } else |           } else | ||||||
|           if (action == "GIACENZA") |           if (action == "GIACENZA") | ||||||
|           {           |           {           | ||||||
|  | |||||||
| @ -4,6 +4,6 @@ Picture = <or00> | |||||||
| Module  = 33 | Module  = 33 | ||||||
| Flags   = "" | Flags   = "" | ||||||
| Item_01 = "Stampa ordini", "or1.exe -0","F" | Item_01 = "Stampa ordini", "or1.exe -0","F" | ||||||
| Item_02 = "Stampa disponibilita' articoli", "or1.exe -1","F" | Item_02 = "Stampa disponibilitŕ articoli", "or1.exe -1","F" | ||||||
| Item_03 = "Generazione ordini a fornitore", "or1.exe -3","F" | Item_03 = "Generazione ordini a fornitore", "or1.exe -3","F" | ||||||
| Item_04 = "Scarico e ripristino documenti", "ve5.exe -0","F" | Item_04 = "Scarico e ripristino documenti", "ve5.exe -0","F" | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user