Patch level : 12.00 1360
Files correlati : ve0.exe ve2400.msk Commento: Agiunto il flag OnlyOnePaIV nel paragrafo cg ddi ditta.ini per bloccare l'inserimento dei clienti/fornitori per gli utenti che non sono Risistemato il controllo clienti/fornitori.
This commit is contained in:
		
							parent
							
								
									1cc5cb6358
								
							
						
					
					
						commit
						e3d62c2245
					
				| @ -3,9 +3,11 @@ | ||||
| #define F_COFI   203 | ||||
| #define F_RESET  204 | ||||
| 
 | ||||
| #define S_DIRTY  101 | ||||
| #define S_CODCF  102 | ||||
| #define S_RAGSOC 103 | ||||
| #define S_PAIV   104 | ||||
| #define S_COFI   105 | ||||
| #define S_ERROR  106 | ||||
| #define S_DIRTY		 101 | ||||
| #define S_CODCF		 102 | ||||
| #define S_RAGSOC	 103 | ||||
| #define S_PAIV		 104 | ||||
| #define S_COFI		 105 | ||||
| #define S_ALLEG		 106 | ||||
| #define S_SOSPESO  107 | ||||
| #define S_ERROR		 108 | ||||
|  | ||||
| @ -40,6 +40,8 @@ BEGIN | ||||
|   ITEM "Ragione Sociale@50" | ||||
|   ITEM "Partita IVA" | ||||
|   ITEM "Codice Fiscale@16" | ||||
|   ITEM "Allegato@28" | ||||
|   ITEM "Sospeso" | ||||
|   ITEM "Problema riscontrato@50" | ||||
| END | ||||
| 
 | ||||
| @ -47,7 +49,7 @@ ENDPAGE | ||||
| 
 | ||||
| ENDMASK | ||||
| 
 | ||||
| PAGE "Dati" -1 -1 52 10  | ||||
| PAGE "Dati" -1 -1 52 14  | ||||
| 
 | ||||
| BOOLEAN S_DIRTY | ||||
| BEGIN | ||||
| @ -66,24 +68,42 @@ BEGIN | ||||
|   FLAGS "D" | ||||
| END | ||||
| 
 | ||||
| BOOLEAN S_SOSPESO | ||||
| BEGIN | ||||
|   PROMPT 1 6 "Sospeso" | ||||
| END | ||||
| 
 | ||||
| STRING S_PAIV 12 | ||||
| BEGIN | ||||
|   PROMPT 1 3 "Partita IVA    " | ||||
|   PROMPT 1 4 "Partita IVA    " | ||||
| END | ||||
| 
 | ||||
| STRING S_COFI 16 | ||||
| BEGIN | ||||
|   PROMPT 1 4 "Codice Fiscale " | ||||
|   PROMPT 1 5 "Codice Fiscale " | ||||
| END | ||||
| 
 | ||||
| BUTTON DLG_USER 10 2 | ||||
| BEGIN | ||||
|   PROMPT -1 3 "Allinea" | ||||
|   PROMPT -1 4 "Allinea" | ||||
| END | ||||
| 
 | ||||
| LIST_BOX S_ALLEG 1 28 | ||||
| BEGIN | ||||
|   PROMPT 1 6 "Allegato       " | ||||
|     ITEM "0|Valido per allegato IVA" | ||||
|     ITEM "1|Non valido per allegato IVA" | ||||
| 	ITEM "2|Occasionale" | ||||
| 	ITEM "3|Documenti riepilogativi" | ||||
| 	ITEM "4|Codice fiscale già inserito" | ||||
| 	ITEM "5|Estero CEE" | ||||
| 	ITEM "6|Privato" | ||||
| 	ITEM "7|Ente pubblico" | ||||
| END | ||||
| 
 | ||||
| MEMO S_ERROR 50 3 | ||||
| BEGIN | ||||
|   PROMPT 1 5 "Problema riscontrato" | ||||
|   PROMPT 1 7 "Problema riscontrato" | ||||
|   FLAGS "D" | ||||
| END | ||||
| 
 | ||||
|  | ||||
| @ -24,64 +24,114 @@ protected: | ||||
|   void dirty_sheet_row(); | ||||
| 
 | ||||
| public: | ||||
|   TCheck_PIVA_mask() : TAutomask("cg1300l") { } | ||||
| 
 | ||||
| 	TCheck_PIVA_mask() : TAutomask("cg1300l") {} | ||||
| }; | ||||
| 
 | ||||
| // Carica lo sheet in base alle impostazioni correnti (F_CLIFO, F_COFI)
 | ||||
| void TCheck_PIVA_mask::load_sheet() | ||||
| { | ||||
|   const bool check_cofi = get_bool(F_COFI); | ||||
| 
 | ||||
|   TSheet_field& s = sfield(F_CLIFO); | ||||
|   s.destroy(); | ||||
| 
 | ||||
|   // Elenco di tutti i clienti (o fornitori)
 | ||||
|   TISAM_recordset clifo("USE CLIFO\nFROM TIPOCF=#TIPO\nTO TIPOCF=#TIPO"); | ||||
|   clifo.set_var("#TIPO", TVariant(get(F_TIPO))); | ||||
| 	 | ||||
| 	clifo.set_var("#TIPO", TVariant(get(F_TIPO))); | ||||
| 
 | ||||
|   TProgind pi(clifo.items(), TR("Scansione anagrafica")); | ||||
|   for (bool ok = clifo.move_first(); ok; ok = clifo.move_next()) | ||||
| 	TRectype paiv_rec(LF_CLIFO); | ||||
| 	TRectype cofi_rec(LF_CLIFO); | ||||
| 
 | ||||
| 	s.reset(); | ||||
|   for (bool ok = clifo.move_first(); pi.addstatus() && ok; ok = clifo.move_next()) | ||||
|   { | ||||
|     const TString& stato = clifo.get(CLI_STATOPAIV).as_string(); | ||||
|     if (stato.full() && stato != "IT") | ||||
|       continue;  // Ignoro gli esteri
 | ||||
| 		TToken_string msg(50, '\n'); | ||||
| 		const TString4 tipo =  clifo.get(CLI_TIPOCF).as_string(); | ||||
| 		const long codice = clifo.get(CLI_CODCF).as_int(); | ||||
| 		TString4  alleg = clifo.get(CLI_ALLEG).as_string(); | ||||
|     const TString4 stato = clifo.get(CLI_STATOPAIV).as_string(); | ||||
| 		const TString4 tipoana = clifo.get(CLI_TIPOAPER).as_string(); | ||||
|     const TString4 occas = clifo.get(CLI_OCCAS).as_string(); | ||||
| 
 | ||||
|     const TString& occas = clifo.get(CLI_OCCAS).as_string(); | ||||
|     if (occas.full()) | ||||
|       continue;  // Ignoro gli occasionali
 | ||||
| 		if (occas.blank()) | ||||
| 		{ | ||||
| 			const TString & paiv = clifo.get(CLI_PAIV).as_string(); | ||||
| 
 | ||||
|     const TString16 paiv = clifo.get(CLI_PAIV).as_string(); | ||||
|     if (paiv.full() && !real::is_natural(paiv)) | ||||
|       continue;  // Ignoro esteri
 | ||||
| 			if (stato.blank() || stato == "IT" || !real::is_natural(paiv)) | ||||
| 			{ | ||||
| 				if (tipoana != "F" && paiv.blank()) | ||||
| 				{ | ||||
| 					if (alleg != "6" && alleg != "7") | ||||
| 						msg.add(TR("Partita IVA mancante")); | ||||
| 				} | ||||
| 				else | ||||
| 					if (tipoana != "F" && !pi_check("", paiv)) | ||||
| 						msg.add(TR("Partita IVA errata")); | ||||
| 					else | ||||
| 					{ | ||||
| 						if (paiv.full()) | ||||
| 						{ | ||||
| 							paiv_rec.zero(); | ||||
| 							paiv_rec.put(CLI_TIPOCF, tipo); | ||||
| 							paiv_rec.put(CLI_PAIV, paiv); | ||||
| 
 | ||||
|     const TString16 cofi = clifo.get(CLI_COFI).as_string(); | ||||
| 							TCursor c(new TRelation(LF_CLIFO), "", 5, &paiv_rec, &paiv_rec); | ||||
| 							const int items = c.items(); | ||||
| 
 | ||||
|     const bool paiv_good = paiv.full() && pi_check("", paiv);   | ||||
|     const bool cofi_good = cofi.full() && cf_check("", cofi); | ||||
|     if (paiv_good && cofi_good) | ||||
|       continue;  // Ignoro chi sicuramente e' a posto
 | ||||
| 							if (items > 1) | ||||
| 							{ | ||||
| 								for (c = 0L; codice == c.curr().get_long(CLI_CODCF) && c.pos() < items; ++c); | ||||
| 
 | ||||
|     const char tipoana = clifo.get(CLI_TIPOAPER).as_string()[0]; | ||||
|     if (tipoana == 'F' && cofi_good) | ||||
|       continue; // Ignoro le persone fisiche col codice fiscale a posto
 | ||||
| 								msg.add(format(FR("Partita IVA già utilizzato per il codice %ld"), c.curr().get_long(CLI_CODCF))); | ||||
| 							} | ||||
| 						} | ||||
| 					} | ||||
| 
 | ||||
|     if (paiv_good && !cofi_good && !check_cofi) | ||||
|       continue;  // Ignoro CF se non voluto
 | ||||
| 				const TString cofi = clifo.get(CLI_COFI).as_string(); | ||||
| 
 | ||||
|     // Riga sheet: Selezione|Codice|RagioneSociale|P.IVA|C.Fiscale|Messaggio
 | ||||
|     TToken_string& tok = s.row(-1); | ||||
|     tok.add(clifo.get(CLI_CODCF).as_int(), 1); | ||||
|     tok.add(clifo.get(CLI_RAGSOC).as_string()); | ||||
|     tok.add(paiv); | ||||
|     tok.add(cofi); | ||||
| 				if (cofi.blank()) | ||||
| 					msg.add(TR("Codice Fiscale mancante")); | ||||
| 				else | ||||
| 					if (!cf_check("", cofi)) | ||||
| 						msg.add(TR("Codice Fiscale errato")); | ||||
| 					else | ||||
| 					{ | ||||
| 						if (cofi.full()) | ||||
| 						{ | ||||
| 
 | ||||
|     TToken_string msg(50, '\n'); | ||||
|     if (!paiv_good) msg.add(TR("P.I. errata o mancante")); | ||||
|     if (!cofi_good) msg.add(TR("C.F. errato o mancante")); | ||||
|     msg.trim(); | ||||
|     tok.add(msg);   | ||||
| 							cofi_rec.zero(); | ||||
| 							cofi_rec.put(CLI_TIPOCF, tipo); | ||||
| 							cofi_rec.put(CLI_COFI, cofi); | ||||
| 
 | ||||
| 							TCursor c(new TRelation(LF_CLIFO), "", 4, &cofi_rec, &cofi_rec); | ||||
| 							const int items = c.items(); | ||||
| 
 | ||||
| 							if (items > 1) | ||||
| 							{ | ||||
| 								for (c = 0L; codice == c.curr().get_long(CLI_CODCF) && c.pos() < items; ++c); | ||||
| 
 | ||||
| 								msg.add(format(FR("Codice fiscale già utilizzato per il codice %ld"), c.curr().get_long(CLI_CODCF))); | ||||
| 							} | ||||
| 						} | ||||
| 					} | ||||
| 				if (msg.full()) | ||||
| 				{ | ||||
| 					// Riga sheet: Selezione|Codice|RagioneSociale|P.IVA|C.Fiscale|Messaggio
 | ||||
| 					int r = s.set_row_cell(S_CODCF, codice); | ||||
| 
 | ||||
| 					s.set_row_cell(S_RAGSOC, clifo.get(CLI_RAGSOC).as_string(), r); | ||||
| 					s.set_row_cell(S_PAIV, paiv, r); | ||||
| 					s.set_row_cell(S_COFI, cofi, r); | ||||
| 					if (alleg.blank()) | ||||
| 						alleg = "0"; | ||||
| 					s.set_row_cell(S_ALLEG, alleg, r); | ||||
| 					s.set_row_cell(S_SOSPESO, clifo.get(CLI_SOSPESO).as_bool(), r); | ||||
| 					msg.trim(); | ||||
| 					s.set_row_cell(S_ERROR, msg, r); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|   } | ||||
| 
 | ||||
|   s.force_update(); | ||||
| } | ||||
| 
 | ||||
| @ -90,44 +140,40 @@ bool TCheck_PIVA_mask::save_sheet() | ||||
| { | ||||
|   // Tengo pronto il file per fare gli aggiornamenti
 | ||||
|   TLocalisamfile clifo(LF_CLIFO); | ||||
| 
 | ||||
|   bool first = true; // Sto per incontrare il primo cliente?
 | ||||
| 
 | ||||
|   TSheet_field& s = sfield(F_CLIFO); | ||||
| 	   | ||||
| 	if (s.items() > 0L && yesnocancel_box(TR("Si desidera salvare le modifiche?")) == K_YES) | ||||
| 	{ | ||||
| 		// Scandisco solo le righe "spuntate"
 | ||||
| 		FOR_EACH_SHEET_ROW_LOOP(s, r) | ||||
| 			if (s.get_bool_row_cell(r, S_DIRTY)) | ||||
| 			{ | ||||
| 				clifo.put(CLI_TIPOCF, get(F_TIPO)); | ||||
| 				 | ||||
| 				const long codcf = s.get_long_row_cell(r, S_CODCF); | ||||
| 				 | ||||
| 				clifo.put(CLI_CODCF, codcf); | ||||
| 				 | ||||
| 				int err = clifo.read(_isequal, _lock); // Locco il cliente da aggiornare
 | ||||
| 
 | ||||
|   // Mi tengo da parte le posizioni dei campi utili
 | ||||
|   const int pos_codcf = s.cid2index(S_CODCF); | ||||
|   const int pos_paiv = s.cid2index(S_PAIV); | ||||
|   const int pos_cofi = s.cid2index(S_COFI); | ||||
|    | ||||
|   // Scandisco solo le righe "spuntate"
 | ||||
|   FOR_EACH_SHEET_ROW(s, r, row) if ((*row)[0] == 'X')  | ||||
|   { | ||||
|     // Quando incontro il primo cliente selezionato, chiedo conferma
 | ||||
|     if (first) | ||||
|     { | ||||
|       const KEY k = yesnocancel_box(TR("Si desidera salvare le modifiche?")); | ||||
|       if (k != K_YES) | ||||
|         return k == K_NO; | ||||
|     } | ||||
|     first = false; // D'ora in poi non chiedo piu' conferma
 | ||||
|      | ||||
|     clifo.put(CLI_TIPOCF, get(F_TIPO)); | ||||
|     const long codcf = row->get_long(pos_codcf); | ||||
|     clifo.put(CLI_CODCF, codcf); | ||||
|     int err = clifo.read(_isequal, _lock); // Locco il cliente da aggiornare
 | ||||
|      | ||||
|     if (err == NOERR) | ||||
|     { | ||||
|       clifo.put(CLI_PAIV, row->get(pos_paiv)); | ||||
|       clifo.put(CLI_COFI, row->get(pos_cofi)); | ||||
|       err = clifo.rewrite();               // Aggiorno il record
 | ||||
|     } | ||||
|      | ||||
|     if (err != NOERR) | ||||
|       return error_box("Errore %d durante l'aggiornamento del codice %ld", err, codcf); | ||||
|   } | ||||
| 				if (err == NOERR) | ||||
| 				{ | ||||
| 					clifo.put(CLI_PAIV, s.get_str_row_cell(r, S_PAIV)); | ||||
| 					clifo.put(CLI_COFI, s.get_str_row_cell(r, S_COFI)); | ||||
| 					 | ||||
| 					TString alleg = s.get_str_row_cell(r, S_ALLEG); | ||||
| 
 | ||||
| 					if (alleg == "0") | ||||
| 						alleg.cut(0); | ||||
| 					clifo.put(CLI_ALLEG, alleg); | ||||
| 					clifo.put(CLI_SOSPESO, s.get_bool_row_cell(r, S_SOSPESO)); | ||||
| 					err = clifo.rewrite();               // Aggiorno il record
 | ||||
| 				} | ||||
| 
 | ||||
| 				if (err != NOERR) | ||||
| 					return error_box("Errore %d durante l'aggiornamento del codice %ld", err, codcf); | ||||
| 			} | ||||
| 	} | ||||
|   return true; | ||||
| } | ||||
| 
 | ||||
| @ -143,16 +189,9 @@ void TCheck_PIVA_mask::update_sheet() | ||||
| void TCheck_PIVA_mask::dirty_sheet_row() | ||||
| { | ||||
|   TSheet_field& s = sfield(F_CLIFO); | ||||
|   TMask& m = s.sheet_mask(); | ||||
|   m.set(S_DIRTY, "X"); | ||||
| 
 | ||||
|   // Sporco "giro" per aggiornare lo sheet
 | ||||
|   if (!m.is_running()) | ||||
|   { | ||||
|     const int sel = s.selected(); | ||||
|     s.update_row(sel); | ||||
|     s.force_update(sel); | ||||
|   } | ||||
|   s.set_row_cell(S_DIRTY, true, s.selected()); | ||||
| 	s.force_update(s.selected()); | ||||
| } | ||||
| 
 | ||||
| bool TCheck_PIVA_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) | ||||
| @ -171,14 +210,21 @@ bool TCheck_PIVA_mask::on_field_event(TOperable_field& o, TField_event e, long j | ||||
|     if (e == fe_button) | ||||
|     { | ||||
|       TSheet_field& s = sfield(F_CLIFO); | ||||
|       FOR_EACH_SHEET_ROW(s, r, row) | ||||
|         row->add(" ", 0); | ||||
| 
 | ||||
| 			FOR_EACH_SHEET_ROW_LOOP(s, r) | ||||
|         s.set_row_cell(S_DIRTY, false, r); | ||||
|       s.force_update(); | ||||
|     } | ||||
|     break; | ||||
|   case DLG_SAVEREC: | ||||
|     if (save_sheet()) | ||||
|       load_sheet(); | ||||
| 		if (e == fe_button) | ||||
| 		{ | ||||
| 			if (save_sheet()) | ||||
| 				load_sheet(); | ||||
| 		} | ||||
| 		else | ||||
| 			if (e == fe_close) | ||||
| 				save_sheet(); | ||||
|     break; | ||||
|   case S_PAIV: | ||||
|     if (e == fe_modify) | ||||
| @ -198,39 +244,20 @@ bool TCheck_PIVA_mask::on_field_event(TOperable_field& o, TField_event e, long j | ||||
|         return o.error_box("Codice fiscale errato"); | ||||
|     } | ||||
|     break; | ||||
| 	case S_ALLEG: | ||||
| 		if (e == fe_modify) | ||||
| 			dirty_sheet_row(); | ||||
| 		break; | ||||
| 	case S_SOSPESO: | ||||
| 		if (e == fe_modify) | ||||
| 			dirty_sheet_row(); | ||||
| 		break; | ||||
|   case DLG_USER: | ||||
|     if (e == fe_button) | ||||
|     { | ||||
|       TMask& m = o.mask(); | ||||
|       const TString& pi = m.get(S_PAIV);    // Leggo partita IVA e 
 | ||||
|       const TString& cf = m.get(S_COFI);    // codice fiscale
 | ||||
|       if (pi.blank())                       // Tento di compilare la PAIV vuota 
 | ||||
|       { | ||||
|         if (cf.full() && pi_check("", cf)) | ||||
|         { | ||||
|           m.set(S_PAIV, cf); | ||||
|           dirty_sheet_row(); | ||||
|         } | ||||
|         else | ||||
|           return o.error_box(TR("Il codice fiscale rappresenta una partita IVA errata")); | ||||
|       } else | ||||
|       if (cf.blank())                        // Tento di compilare il COFI vuoto
 | ||||
|       { | ||||
|         if (pi.full() && pi_check("", pi)) | ||||
|         { | ||||
|           m.set(S_COFI, pi); | ||||
|           dirty_sheet_row(); | ||||
|         } | ||||
|         else | ||||
|           return o.error_box(TR("Partita IVA errata")); | ||||
|       } | ||||
|     } | ||||
|     break; | ||||
|   case DLG_LINK: | ||||
|     if (e == fe_button) | ||||
|     { | ||||
|       TMask& m = o.mask(); | ||||
|       TLocalisamfile clifo(LF_CLIFO);             // Riempio la chiave 1 di CLIFO  
 | ||||
| 
 | ||||
|       clifo.put(CLI_TIPOCF, get(F_TIPO));          | ||||
|       clifo.put(CLI_CODCF, m.get(S_CODCF)); | ||||
|       if (clifo.curr().edit())                    // Modifica interattiva del cliente
 | ||||
| @ -245,7 +272,7 @@ bool TCheck_PIVA_mask::on_field_event(TOperable_field& o, TField_event e, long j | ||||
|       } | ||||
|     } | ||||
|     break; | ||||
|   default: break; | ||||
| 		default: break; | ||||
|   } | ||||
|   return true; | ||||
| } | ||||
| @ -262,12 +289,15 @@ public: | ||||
| 
 | ||||
| void TCheck_PIVA::main_loop() | ||||
| { | ||||
| 	TSheet_field::set_line_number_width(7); | ||||
|   TCheck_PIVA_mask m; | ||||
| 
 | ||||
|   m.run(); | ||||
| } | ||||
| 
 | ||||
| void controlla_PIVA(int argc, char* argv[]) | ||||
| { | ||||
|   TCheck_PIVA cp; | ||||
| 
 | ||||
|   cp.run(argc, argv, TR("Controllo Partita IVA")); | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user