Corretta gestione dell causali contabili,
git-svn-id: svn://10.65.10.50/trunk@24 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									33be7ac1be
								
							
						
					
					
						commit
						10852c6b02
					
				| @ -70,7 +70,8 @@ const real& TPrimanota_application::cod2IVA(const char* codiva) | ||||
| 
 | ||||
| real TPrimanota_application::scorpora(real& imponibile, const real& percent) | ||||
| { | ||||
|  real imposta = imponibile * percent / (percent + 100.0); imposta.ceil(); | ||||
|   real imposta = abs(imponibile) * percent / (percent + 100.0); imposta.ceil(); | ||||
|   if (imponibile.sign() < 0) imposta = -imposta;  | ||||
|   imponibile -= imposta; | ||||
|   return imposta; | ||||
| }   | ||||
| @ -111,19 +112,7 @@ bool TPrimanota_application::detraibile(int tipodet) | ||||
| 
 | ||||
|   const TSheet_field& iva = app().ivas(); | ||||
| 
 | ||||
|  TString16 chiave; | ||||
|  chiave = iva.mask().get(F_ANNOIVA); | ||||
|  chiave << iva.mask().get(F_CODREG); | ||||
|  TTable reg("REG"); | ||||
|  reg.put("CODTAB", chiave); | ||||
|  reg.read(); | ||||
| #ifdef DBG | ||||
|  if(reg.status() != NOERR) | ||||
|   error_box("La minchia che trovo il registro '%s'", (const char*)chiave); | ||||
| #endif | ||||
| 
 | ||||
|  const char* att = reg.get("S8"); | ||||
|  chiave.cut(4); chiave << att; | ||||
|   TString16 chiave(iva.mask().get(F_ANNOIVA)); chiave << app().causale().reg().attivita(); | ||||
| 
 | ||||
|   TTable pla("PLA"); | ||||
|   pla.put("CODTAB", chiave); | ||||
| @ -186,6 +175,7 @@ int TPrimanota_application::bill2contr(const TConto& conto, char sezione) const | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| // Controlla se un conto e' usato nelle righe IVA                              
 | ||||
| bool TPrimanota_application::bill_used(const TConto& conto) const | ||||
| { | ||||
|   const TArray& rows = ivas().rows_array(); | ||||
| @ -457,7 +447,7 @@ void TPrimanota_application::set_ivas_row(int nriga, const char* codiva, TConto& | ||||
|   TToken_string& riga = ivas().row(nriga); | ||||
|   riga = " ";                  // Importo
 | ||||
|   riga.add (codiva);           // codiva
 | ||||
|  riga.add (" | | ");          // Imposta - C/R - Det
 | ||||
|   riga.add (" | | ");          // Det - Imposta - C/R
 | ||||
|   riga.add(tc.string(0x3));    // Conto
 | ||||
|   riga.add(desc);              // Descrizione
 | ||||
| } | ||||
| @ -467,13 +457,19 @@ bool TPrimanota_application::imponibile_handler(TMask_field& f, KEY key) | ||||
| { | ||||
|   if (key == K_TAB && f.dirty()) | ||||
|   { | ||||
|   const TString& iva = f.mask().get(102);         | ||||
|     TString16 iva(f.mask().get(102));         | ||||
|     if (iva.empty()) | ||||
|     { | ||||
|       iva = app().mask().get(F_CODIVA); | ||||
|       f.mask().set(102, iva); | ||||
|     }   | ||||
|     if (iva.not_empty())                           // Se c'e' il codice IVA
 | ||||
|     { | ||||
|       const real& percent = cod2IVA(iva); | ||||
|       const real imponibile(f.get()); | ||||
|    real imposta = imponibile * percent / 100.0; imposta.ceil(); | ||||
|    f.mask().set(103, imposta.string()); | ||||
|       real imposta = abs(imponibile) * percent / 100.0; imposta.ceil(); | ||||
|       if (imponibile.sign() < 0) imposta = -imposta; | ||||
|       f.mask().set(104, imposta.string()); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| @ -499,15 +495,17 @@ bool TPrimanota_application::imposta_handler(TMask_field& f, KEY key) | ||||
|   { | ||||
|     const real imponibile(f.mask().get(101)); | ||||
|     const real& percent = cod2IVA(f.mask().get(102)); | ||||
|   real imposta = imponibile * percent / 100.0; imposta.ceil(); | ||||
|     real imposta = abs(imponibile) * percent / 100.0;  | ||||
|     imposta.ceil(); | ||||
|     if (imponibile.sign() < 0) imposta = -imposta; | ||||
|      | ||||
|     const real val(f.get()); | ||||
|     if (val != imposta) | ||||
|     { | ||||
|       const TString16 wrong(val.string(".")); | ||||
|       const TString16 right(imposta.string(".")); | ||||
|     if (f.yesno_box("Imposta di '%s' errata: modificare in '%s'?",  | ||||
|         (const char*)wrong, (const char*)right)) | ||||
|      f.set(imposta.string()); | ||||
|       if (f.warning_box("Imposta di '%s' errata: dovrebbe essere '%s'",  | ||||
|                         (const char*)wrong, (const char*)right)); | ||||
|     }    | ||||
|   } else | ||||
|     if (key == K_F8 && f.get().empty()) | ||||
| @ -515,8 +513,8 @@ bool TPrimanota_application::imposta_handler(TMask_field& f, KEY key) | ||||
|       real imponibile(f.mask().get(101)); | ||||
|       const real& percent = cod2IVA(f.mask().get(102)); | ||||
|       const real imposta = scorpora(imponibile, percent); | ||||
|   f.set(imposta.string()); | ||||
|       f.mask().set(101, imponibile.string()); | ||||
|       f.set(imposta.string()); | ||||
|     } | ||||
| 
 | ||||
|   return TRUE; | ||||
| @ -541,12 +539,12 @@ bool TPrimanota_application::iva_notify(int r, KEY k) | ||||
|     oldpos = bill2pos(oldconto, 'I'); | ||||
|     oldimp = imp2sez(real(row.get(0))); | ||||
|     oldposiva = type2pos(detraibile(row.get_int(4)) ? 'D' : 'N'); | ||||
|   oldiva = imp2sez(real(row.get(2))); | ||||
|     oldiva = imp2sez(real(row.get(3))); | ||||
|   } | ||||
|   if (k == K_DEL) | ||||
|   { | ||||
|     row.add("0", 0); // Azzera imponibile
 | ||||
|   row.add("0", 2);  // Azzera imposta
 | ||||
|     row.add("0", 3);  // Azzera imposta
 | ||||
|     k = K_ENTER;      // Elegante o Sporco trucco
 | ||||
|   } | ||||
|   if (k == K_ENTER) | ||||
| @ -575,7 +573,7 @@ bool TPrimanota_application::iva_notify(int r, KEY k) | ||||
|      | ||||
|     // Aggiorna conto IVA sulla riga contabile
 | ||||
| 
 | ||||
|   imp = imp2sez(real(row.get(2)));                    // Imposta
 | ||||
|     imp = imp2sez(real(row.get(3)));                    // Imposta
 | ||||
|     const bool detrarre = detraibile(row.get_int(4));   // Determina se IVA detraibile
 | ||||
|     app().causale().bill(detrarre ? 3 : 4, conto); | ||||
|     const char tipod = detrarre ? 'D' : 'N'; | ||||
| @ -605,8 +603,7 @@ bool TPrimanota_application::iva_handler(TMask_field& f, KEY k) | ||||
|   { | ||||
|     TToken_string& row = app().ivas().row(r); | ||||
|     imp += real(row.get(0));       // imponibile
 | ||||
|     row.get();                     // IVA
 | ||||
|     imp += real(row.get());        // imposta
 | ||||
|     imp += real(row.get(3));       // imposta
 | ||||
|   } | ||||
|    | ||||
|   const TMask& m = f.mask();          | ||||
| @ -619,7 +616,7 @@ bool TPrimanota_application::iva_handler(TMask_field& f, KEY k) | ||||
|     TString16 t(tot.string(".")); | ||||
|     TString16 i(imp.string(".")); | ||||
|     return error_box("La somma del totale documento e delle ritenute (%s) e' diverso dalla "  | ||||
|                      "somma degli imponibili e delle imposte (%s)", t, i); | ||||
|                      "somma degli imponibili e delle imposte (%s)", (const char*)t, (const char*)i); | ||||
|   }   | ||||
|    | ||||
|   return TRUE; | ||||
| @ -647,7 +644,7 @@ bool TPrimanota_application::num_handler(TMask_field& f, KEY key) | ||||
| 
 | ||||
| 
 | ||||
| // Handler of the F_CODCAUS field on the query mask
 | ||||
| // Certified 90%
 | ||||
| // Certified 99%
 | ||||
| bool TPrimanota_application::caus_query_handler(TMask_field& f, KEY key) | ||||
| { | ||||
|   if (!f.mask().is_running()) return TRUE; | ||||
| @ -657,12 +654,12 @@ bool TPrimanota_application::caus_query_handler(TMask_field& f, KEY key) | ||||
|     const int ann = f.mask().get_int(F_ANNOIVA); | ||||
|     const char* cau = f.get(); | ||||
|      | ||||
|   const TipoIVA i = cau2IVA(cau, ann); | ||||
|     const TipoIVA i = cau2IVA(cau, ann);          // Cerca causale e suo tipo
 | ||||
|     if (i != iva_errata) | ||||
|     { | ||||
|     const bool ok = suspended_handler(f, key); | ||||
|       const bool ok = suspended_handler(f, key);  // Controlla sospensione
 | ||||
|       if (ok) | ||||
|      dispatch_e_char(f.parent(), K_INS); | ||||
|         dispatch_e_char(f.parent(), K_INS);        // Entra in modo inserimento
 | ||||
|     }  | ||||
|   } | ||||
| 
 | ||||
| @ -711,9 +708,11 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key) | ||||
|      | ||||
|     if (m.query_mode()) | ||||
|     { | ||||
|       if (ae == 0) return f.error_box("La data dell'operazione non appartiene a nessun esercizio"); | ||||
|       if (ae == 0)  | ||||
|         return f.error_box("La data dell'operazione non appartiene a nessun esercizio"); | ||||
|       ok = app().giornale().read(ae); | ||||
|       if (!ok) return f.error_box("Non esiste il libro giornale dell'esercizio %d", ae); | ||||
|       if (!ok)  | ||||
|         return f.error_box("Non esiste il libro giornale dell'esercizio %d", ae); | ||||
|     }   | ||||
|     if (dr < app().giornale().last_print()) | ||||
|       return f.error_box("La data dell'operazione e' antecedente alla " | ||||
| @ -738,7 +737,7 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key) | ||||
| } | ||||
| 
 | ||||
| // Handler of the F_DATACOMP field on the modify mask
 | ||||
| // Certified 70%
 | ||||
| // Certified 90%
 | ||||
| bool TPrimanota_application::datacomp_handler(TMask_field& f, KEY key) | ||||
| {                           | ||||
|   if (!f.to_check(key, TRUE))  | ||||
| @ -771,7 +770,7 @@ bool TPrimanota_application::datacomp_handler(TMask_field& f, KEY key) | ||||
| } | ||||
| 
 | ||||
| // Handler of the F_DATA74TER field on the modify mask
 | ||||
| // Certified 70%
 | ||||
| // Certified 90%
 | ||||
| bool TPrimanota_application::data74ter_handler(TMask_field& f, KEY key) | ||||
| {                           | ||||
|   if (!f.to_check(key)) return TRUE; | ||||
| @ -885,10 +884,10 @@ void TPrimanota_application::add_cgs_tot(TMask& m) | ||||
|   { | ||||
|     iva_notify(0, K_SPACE); | ||||
|     const real imposta = scorpora(tot, iva.percentuale()); | ||||
|     row.add(tot.string(), 0); | ||||
|     row.add(iva.codice(), 1); | ||||
|     row.add(imposta.string(), 2); | ||||
|     row.add(" | "); | ||||
|      | ||||
|     row.add(tot.string(), 0);                   // imponibile
 | ||||
|     row.add(iva.codice(), 1);                   // imposta
 | ||||
|     row.add(imposta.string(), 3);               // imposta
 | ||||
|      | ||||
|     TConto bill;                                // Conto della prima riga IVA
 | ||||
|     const TString& tipo = iva.tipo(); | ||||
| @ -903,7 +902,12 @@ void TPrimanota_application::add_cgs_tot(TMask& m) | ||||
|     if (!bill.ok())  | ||||
|       _causale.bill(2, bill); | ||||
| 
 | ||||
|     row.add(bill.string(0x3)); | ||||
|     row.add(bill.tipo(), 5); | ||||
|     row.add(bill.gruppo(), 6); | ||||
|     row.add(bill.conto(), 7); | ||||
|     row.add(bill.sottoconto(), 8); | ||||
|     row.add(bill.descrizione(), 9); | ||||
|      | ||||
|     app().ivas().force_update(0); | ||||
|     iva_notify(0, K_ENTER); | ||||
|   }   | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user