Nuova stampa registri IVA con IVA per cassa
Correzione nc in prima nota git-svn-id: svn://10.65.10.50/branches/R_10_00@22771 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									ab46443149
								
							
						
					
					
						commit
						948465ced7
					
				| @ -196,12 +196,13 @@ void TCaus_app::causale_vendite() | |||||||
|     set_descr(i++, TR("C Di ricavo")); |     set_descr(i++, TR("C Di ricavo")); | ||||||
|     set_descr(i++, TR("C Iva vendite")); |     set_descr(i++, TR("C Iva vendite")); | ||||||
|     set_descr(i++, TR("C Iva non detraibile")); |     set_descr(i++, TR("C Iva non detraibile")); | ||||||
|     set_descr(i++, TR("C Imp. esenti")); |     set_descr(i++, TR("C Imp. esenti"));         // 5
 | ||||||
|     set_descr(i++, TR("C Imp. non imponibili")); |     set_descr(i++, TR("C Imp. non imponibili")); | ||||||
|     set_descr(i++, TR("C Imp. non soggetti")); |     set_descr(i++, TR("C Imp. non soggetti")); | ||||||
|     set_descr(i++, TR("C Ritenute fiscali")); |     set_descr(i++, TR("C Ritenute fiscali")); | ||||||
|     set_descr(i++, TR("C Ritenute soc.")); |     set_descr(i++, TR("C Ritenute soc.")); | ||||||
|     set_descr(i++, TR("C Iva ad esig.diff.")); |     set_descr(i++, TR("C Iva ad esig.diff."));   // 10
 | ||||||
|  |     set_descr(i++, TR("C Iva per cassa")); | ||||||
|     _tipo_des = vendita; |     _tipo_des = vendita; | ||||||
|     carica_righe_libere(i);   |     carica_righe_libere(i);   | ||||||
|   }   |   }   | ||||||
| @ -217,12 +218,13 @@ void TCaus_app::causale_acquisti() | |||||||
|     set_descr(i++, TR("C Di costo")); |     set_descr(i++, TR("C Di costo")); | ||||||
|     set_descr(i++, TR("C Iva acquisti")); |     set_descr(i++, TR("C Iva acquisti")); | ||||||
|     set_descr(i++, TR("C Iva non detraibile"));   |     set_descr(i++, TR("C Iva non detraibile"));   | ||||||
|     set_descr(i++, TR("C Imp. esenti")); |     set_descr(i++, TR("C Imp. esenti"));         // 5
 | ||||||
|     set_descr(i++, TR("C Imp. non imponibili")); |     set_descr(i++, TR("C Imp. non imponibili")); | ||||||
|     set_descr(i++, TR("C Imp. non soggetti")); |     set_descr(i++, TR("C Imp. non soggetti")); | ||||||
|     set_descr(i++, TR("C Ritenute fiscali")); |     set_descr(i++, TR("C Ritenute fiscali")); | ||||||
|     set_descr(i++, TR("C Ritenute soc.")); |     set_descr(i++, TR("C Ritenute soc.")); | ||||||
|     set_descr(i++, TR("C Iva ad esig.diff.")); |     set_descr(i++, TR("C Iva ad esig.diff."));   // 10
 | ||||||
|  |     set_descr(i++, TR("C Iva per cassa")); | ||||||
|     _tipo_des = acquisto; |     _tipo_des = acquisto; | ||||||
|     carica_righe_libere(i);   |     carica_righe_libere(i);   | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -90,6 +90,7 @@ TMask* TPrimanota_application::load_mask(int n) | |||||||
|       m->set_handler(F_CODIVA, main_codiva_handler); |       m->set_handler(F_CODIVA, main_codiva_handler); | ||||||
| 			if (_liqdiff) | 			if (_liqdiff) | ||||||
| 	      m->set_handler(F_LIQDIFF, liqdiff_handler); | 	      m->set_handler(F_LIQDIFF, liqdiff_handler); | ||||||
|  |       m->set_handler(F_IVAXCASSA, ivaxcassa_handler); | ||||||
|       m->set_handler(F_OCCASEDIT, occas_handler); |       m->set_handler(F_OCCASEDIT, occas_handler); | ||||||
|       m->set_handler(F_SOLAIVA, solaiva_handler); |       m->set_handler(F_SOLAIVA, solaiva_handler); | ||||||
|       m->set_handler(F_SHEETIVA, iva_handler); |       m->set_handler(F_SHEETIVA, iva_handler); | ||||||
| @ -395,7 +396,7 @@ bool TPrimanota_application::read_caus(const char* cod, int year) | |||||||
|       } |       } | ||||||
|       else |       else | ||||||
|       { |       { | ||||||
|         if (nriga >= 2 && nriga <= RIGA_IVA_DIFFERITA) |         if (nriga >= 2 && nriga <= RIGA_IVA_PER_CASSA) | ||||||
|           continue;       // Conti per IVA detraibile e non, ritenute sociali e fiscali
 |           continue;       // Conti per IVA detraibile e non, ritenute sociali e fiscali
 | ||||||
| 
 | 
 | ||||||
|         const char tipo = nriga == 1 ? 'T' : ' '; |         const char tipo = nriga == 1 ? 'T' : ' '; | ||||||
| @ -800,7 +801,9 @@ void TPrimanota_application::init_insert_mode(TMask& m) | |||||||
|   { |   { | ||||||
|     occas_mask().reset(); |     occas_mask().reset(); | ||||||
|     m.hide(F_OCCASEDIT); |     m.hide(F_OCCASEDIT); | ||||||
|  | #ifdef PRORATA100     | ||||||
|     m.hide(F_ADJUST_PRORATA);  // In inserimento non puo' esistere un pro-rata errato!
 |     m.hide(F_ADJUST_PRORATA);  // In inserimento non puo' esistere un pro-rata errato!
 | ||||||
|  | #endif		 | ||||||
|     if (causale().soloiva()) |     if (causale().soloiva()) | ||||||
|       m.set(F_SOLAIVA, "X", true); // Propone movimento di sola iva
 |       m.set(F_SOLAIVA, "X", true); // Propone movimento di sola iva
 | ||||||
|  		if (iva() == iva_acquisti && causale().intra()) |  		if (iva() == iva_acquisti && causale().intra()) | ||||||
| @ -905,6 +908,7 @@ void TPrimanota_application::init_modify_mode(TMask& m) | |||||||
|     m.disable(SK_TIPORIGA);    // Disabilita la sua modifica
 |     m.disable(SK_TIPORIGA);    // Disabilita la sua modifica
 | ||||||
|   } |   } | ||||||
|    |    | ||||||
|  |   #ifdef PRORATA100     | ||||||
|   // Non controllare il prorata durante la cancellazione automatica
 |   // Non controllare il prorata durante la cancellazione automatica
 | ||||||
|   if (autodeleting() != 0x3) |   if (autodeleting() != 0x3) | ||||||
|   { |   { | ||||||
| @ -927,6 +931,7 @@ void TPrimanota_application::init_modify_mode(TMask& m) | |||||||
|       }   |       }   | ||||||
|     }   |     }   | ||||||
|   } |   } | ||||||
|  | #endif | ||||||
| 
 | 
 | ||||||
|   const TRectype& mov = get_relation()->curr(); |   const TRectype& mov = get_relation()->curr(); | ||||||
|   if (!mov.empty()) |   if (!mov.empty()) | ||||||
|  | |||||||
| @ -703,11 +703,13 @@ BEGIN | |||||||
|   CHECKTYPE NORMAL |   CHECKTYPE NORMAL | ||||||
| END | END | ||||||
| 
 | 
 | ||||||
|  | #ifdef PRORATA100     | ||||||
| BUTTON F_ADJUST_PRORATA 40 | BUTTON F_ADJUST_PRORATA 40 | ||||||
| BEGIN | BEGIN | ||||||
|   PROMPT 1 -1 "Corre~zione automatica righe contabili" |   PROMPT 1 -1 "Corre~zione automatica righe contabili" | ||||||
|   FLAGS "H" |   FLAGS "H" | ||||||
| END | END | ||||||
|  | #endif | ||||||
| 
 | 
 | ||||||
| ENDPAGE | ENDPAGE | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1487,7 +1487,9 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k) | |||||||
| 				if (d) | 				if (d) | ||||||
| 				{	 | 				{	 | ||||||
| 					if (iva.mask().get_bool(F_LIQDIFF)) | 					if (iva.mask().get_bool(F_LIQDIFF)) | ||||||
| 						cau.bill(ri = RIGA_IVA_DIFFERITA, c);  | 						cau.bill(ri = RIGA_IVA_DIFFERITA, c); else | ||||||
|  | 					if (iva.mask().get_bool(F_IVAXCASSA)) | ||||||
|  | 						cau.bill(ri = RIGA_IVA_PER_CASSA, c); | ||||||
| 					if (!c.ok()) | 					if (!c.ok()) | ||||||
| 						cau.bill(ri = RIGA_IVA_DETRAIBILE, c);  | 						cau.bill(ri = RIGA_IVA_DETRAIBILE, c);  | ||||||
| 				} | 				} | ||||||
| @ -1612,12 +1614,14 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k) | |||||||
|         if (!imposta.is_zero())                               // Se  c'e' imposta ...
 |         if (!imposta.is_zero())                               // Se  c'e' imposta ...
 | ||||||
|         {                                                     // ... crea nuova riga per l'IVA
 |         {                                                     // ... crea nuova riga per l'IVA
 | ||||||
| 					TBill contoiva;  | 					TBill contoiva;  | ||||||
| 					int ri; | 					int ri = 0; | ||||||
| 
 | 
 | ||||||
| 					if (d) | 					if (d) | ||||||
| 					{	 | 					{	 | ||||||
| 						if (iva.mask().get_bool(F_LIQDIFF)) | 						if (iva.mask().get_bool(F_LIQDIFF)) | ||||||
| 							cau.bill(ri = RIGA_IVA_DIFFERITA, contoiva);  | 							cau.bill(ri = RIGA_IVA_DIFFERITA, contoiva); else | ||||||
|  | 						if (iva.mask().get_bool(F_IVAXCASSA)) | ||||||
|  | 							cau.bill(ri = RIGA_IVA_PER_CASSA, contoiva); | ||||||
| 						if (!contoiva.ok()) | 						if (!contoiva.ok()) | ||||||
| 							cau.bill(ri = RIGA_IVA_DETRAIBILE, contoiva);  | 							cau.bill(ri = RIGA_IVA_DETRAIBILE, contoiva);  | ||||||
| 					} | 					} | ||||||
| @ -2242,7 +2246,14 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key) | |||||||
|     const TDate oggi(TODAY); |     const TDate oggi(TODAY); | ||||||
|     TDate dr(f.get());                         // Data dell'operazione
 |     TDate dr(f.get());                         // Data dell'operazione
 | ||||||
|     if (dr > oggi) |     if (dr > oggi) | ||||||
|  |     { | ||||||
|  | #ifdef DBG | ||||||
|  |       if (!yesno_box(TR("La data dell'operazione è superiore quella di sistema:\nContinuare ugualmente?"))) | ||||||
|  |         return false; | ||||||
|  | #else | ||||||
|       return f.error_box(TR("La data dell'operazione è superiore quella di sistema")); |       return f.error_box(TR("La data dell'operazione è superiore quella di sistema")); | ||||||
|  | #endif | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     TMask& m = f.mask();   |     TMask& m = f.mask();   | ||||||
|     if (dr == oggi && m.query_mode() && !m.field(F_NUMREG).empty()) |     if (dr == oggi && m.query_mode() && !m.field(F_NUMREG).empty()) | ||||||
| @ -2922,30 +2933,30 @@ bool TPrimanota_application::main_codiva_handler(TMask_field& f, KEY key) | |||||||
|   return true;   |   return true;   | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Handler of the F_LIQDIFF
 | // Scandisce le righe IVA detraibili e forza il conto corretto in base ai flag IVA in testata
 | ||||||
| // Certified 99%
 | static void force_iva_det_bill() | ||||||
| bool TPrimanota_application::liqdiff_handler(TMask_field& f, KEY key) |  | ||||||
| { |  | ||||||
| 	if (key == K_SPACE && f.mask().is_running()) |  | ||||||
| { | { | ||||||
| 	TSheet_field& cgs = app().cgs(); | 	TSheet_field& cgs = app().cgs(); | ||||||
| 		const bool liqdiff = f.get().full(); |   TMask& mask = cgs.mask(); | ||||||
|  | 
 | ||||||
|   const TCausale& cau = app().causale(); |   const TCausale& cau = app().causale(); | ||||||
|   TBill contoiva;  |   TBill contoiva;  | ||||||
| 		int ri; |   int ri = 0; | ||||||
| 
 | 	if (mask.get_bool(F_LIQDIFF)) | ||||||
| 		if (f.mask().get_bool(F_LIQDIFF)) | 		cau.bill(ri = RIGA_IVA_DIFFERITA, contoiva); else | ||||||
| 			cau.bill(ri = RIGA_IVA_DIFFERITA, contoiva);  | 	if (mask.get_bool(F_IVAXCASSA)) | ||||||
| 		if (!contoiva.ok()) | 		cau.bill(ri = RIGA_IVA_PER_CASSA, contoiva); | ||||||
|  | 	if (ri <= 0 || !contoiva.ok()) | ||||||
| 		cau.bill(ri = RIGA_IVA_DETRAIBILE, contoiva);  | 		cau.bill(ri = RIGA_IVA_DETRAIBILE, contoiva);  | ||||||
|  | 	 | ||||||
|   TToken_string conto(contoiva.string(0x3)); |   TToken_string conto(contoiva.string(0x3)); | ||||||
|   const TString80 descragg(cau.desc_agg(ri)); |   const TString80 descragg(cau.desc_agg(ri)); | ||||||
| 		int rowtype = cgs.cid2index(CG_ROWTYPE); | 	const int rowtype = cgs.cid2index(CG_ROWTYPE); | ||||||
| 		int tp = cgs.cid2index(CG_TIPO); | 	const int tp = cgs.cid2index(CG_TIPO); | ||||||
| 		int gr = cgs.cid2index(CG_GRUPPO); | 	const int gr = cgs.cid2index(CG_GRUPPO); | ||||||
| 		int co = cgs.cid2index(CG_CONTO); | 	const int co = cgs.cid2index(CG_CONTO); | ||||||
| 		int sc = cgs.cid2index(CG_SOTTOCONTO); | 	const int sc = cgs.cid2index(CG_SOTTOCONTO); | ||||||
| 		int des = cgs.cid2index(CG_DESCR); | 	const int des = cgs.cid2index(CG_DESCR); | ||||||
| 
 | 
 | ||||||
| 	FOR_EACH_SHEET_ROW(cgs, r, row) | 	FOR_EACH_SHEET_ROW(cgs, r, row) | ||||||
| 	{ | 	{ | ||||||
| @ -2963,6 +2974,13 @@ bool TPrimanota_application::liqdiff_handler(TMask_field& f, KEY key) | |||||||
| 	cgs.force_update(); | 	cgs.force_update(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // Handler of the F_LIQDIFF
 | ||||||
|  | // Certified 99%
 | ||||||
|  | bool TPrimanota_application::liqdiff_handler(TMask_field& f, KEY key) | ||||||
|  | { | ||||||
|  | 	if (key == K_SPACE && f.mask().is_running()) | ||||||
|  |     force_iva_det_bill(); | ||||||
|  | 
 | ||||||
|   if (key == K_ENTER) |   if (key == K_ENTER) | ||||||
|   { |   { | ||||||
|     if (f.get().full() && f.mask().get_bool(F_IVAXCASSA)) |     if (f.get().full() && f.mask().get_bool(F_IVAXCASSA)) | ||||||
| @ -2972,6 +2990,23 @@ bool TPrimanota_application::liqdiff_handler(TMask_field& f, KEY key) | |||||||
|   return true;   |   return true;   | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // Handler of the F_IVAXCASSA
 | ||||||
|  | // Certified 99%
 | ||||||
|  | bool TPrimanota_application::ivaxcassa_handler(TMask_field& f, KEY key) | ||||||
|  | { | ||||||
|  | 	if (key == K_SPACE && f.mask().is_running()) | ||||||
|  |     force_iva_det_bill(); | ||||||
|  | 
 | ||||||
|  |   if (key == K_ENTER) | ||||||
|  |   { | ||||||
|  |     if (f.get().full() && f.mask().get_bool(F_LIQDIFF)) | ||||||
|  |       return f.error_box(TR("Non è ammesso selezionare IVA per cassa e liquidazione differita")); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   return true;   | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| // Riempie i campi valuta a zero in base agli altri
 | // Riempie i campi valuta a zero in base agli altri
 | ||||||
| void TPrimanota_application::gioca_cambi(int force) | void TPrimanota_application::gioca_cambi(int force) | ||||||
| {                | {                | ||||||
|  | |||||||
| @ -103,6 +103,7 @@ class TPrimanota_application : public TRelation_application | |||||||
|   static bool ritsoc_handler(TMask_field& f, KEY key); |   static bool ritsoc_handler(TMask_field& f, KEY key); | ||||||
|   static bool main_codiva_handler(TMask_field& f, KEY key); |   static bool main_codiva_handler(TMask_field& f, KEY key); | ||||||
|   static bool liqdiff_handler(TMask_field& f, KEY key); |   static bool liqdiff_handler(TMask_field& f, KEY key); | ||||||
|  |   static bool ivaxcassa_handler(TMask_field& f, KEY key); | ||||||
|   static bool dataintra_handler(TMask_field& f, KEY key); |   static bool dataintra_handler(TMask_field& f, KEY key); | ||||||
|   static bool corrlire_handler(TMask_field& f, KEY key); |   static bool corrlire_handler(TMask_field& f, KEY key); | ||||||
|   static bool corrvaluta_handler(TMask_field& f, KEY key); |   static bool corrvaluta_handler(TMask_field& f, KEY key); | ||||||
| @ -137,7 +138,6 @@ class TPrimanota_application : public TRelation_application | |||||||
|   static bool recalc_handler(TMask_field& f, KEY key); |   static bool recalc_handler(TMask_field& f, KEY key); | ||||||
|   static bool codcab_handler(TMask_field& f, KEY key); |   static bool codcab_handler(TMask_field& f, KEY key); | ||||||
|   static bool tipopag_handler(TMask_field& f, KEY key); |   static bool tipopag_handler(TMask_field& f, KEY key); | ||||||
|   static bool prorata_handler(TMask_field& f, KEY k); |  | ||||||
|   static bool linkdoc_handler(TMask_field& f, KEY k); |   static bool linkdoc_handler(TMask_field& f, KEY k); | ||||||
|   static bool mastrino_handler(TMask_field& f, KEY k); |   static bool mastrino_handler(TMask_field& f, KEY k); | ||||||
|                 |                 | ||||||
| @ -278,8 +278,11 @@ protected: | |||||||
|   void renumber_partita(TMask& m, const char* oldp, const char* newp); |   void renumber_partita(TMask& m, const char* oldp, const char* newp); | ||||||
|   void recalc_scadenze(const TDate& d); |   void recalc_scadenze(const TDate& d); | ||||||
|    |    | ||||||
|  | #ifdef PRORATA100     | ||||||
|  |   static bool prorata_handler(TMask_field& f, KEY k); | ||||||
|   bool test_prorata(); |   bool test_prorata(); | ||||||
|   bool aggiusta_prorata(); |   bool aggiusta_prorata(); | ||||||
|  | #endif | ||||||
| 
 | 
 | ||||||
|   int cerca_conto_cf(TBill& bill) const; |   int cerca_conto_cf(TBill& bill) const; | ||||||
|    |    | ||||||
|  | |||||||
| @ -73,13 +73,13 @@ public: | |||||||
|   virtual ~TCausale() {} |   virtual ~TCausale() {} | ||||||
| };                                                | };                                                | ||||||
| 
 | 
 | ||||||
|  | // Fatture
 | ||||||
| #define RIGA_IVA_DETRAIBILE      3 | #define RIGA_IVA_DETRAIBILE      3 | ||||||
| #define RIGA_IVA_NON_DETRAIBILE  4 | #define RIGA_IVA_NON_DETRAIBILE  4 | ||||||
| #define RIGA_IVA_DIFFERITA			10 |  | ||||||
| 
 |  | ||||||
| // Fatture
 |  | ||||||
| #define RIGA_RITENUTE_FISCALI    8 | #define RIGA_RITENUTE_FISCALI    8 | ||||||
| #define RIGA_RITENUTE_SOCIALI    9 | #define RIGA_RITENUTE_SOCIALI    9 | ||||||
|  | #define RIGA_IVA_DIFFERITA			10 | ||||||
|  | #define RIGA_IVA_PER_CASSA			11 | ||||||
| 
 | 
 | ||||||
| // Pagamenti
 | // Pagamenti
 | ||||||
| #define RIGA_ABBUONI_PASSIVI     9 | #define RIGA_ABBUONI_PASSIVI     9 | ||||||
|  | |||||||
| @ -254,6 +254,8 @@ bool TPrimanota_application::colors_handler(TMask_field& f, KEY k) | |||||||
|   return true; |   return true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #ifdef PRORATA100     | ||||||
|  | 
 | ||||||
| ///////////////////////////////////////////////////////////
 | ///////////////////////////////////////////////////////////
 | ||||||
| // Gestione cambiamento prorata
 | // Gestione cambiamento prorata
 | ||||||
| ///////////////////////////////////////////////////////////
 | ///////////////////////////////////////////////////////////
 | ||||||
| @ -348,3 +350,4 @@ bool TPrimanota_application::prorata_handler(TMask_field& f, KEY k) | |||||||
|   return TRUE; |   return TRUE; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #endif | ||||||
|  | |||||||
							
								
								
									
										123
									
								
								cg/cg2107.cpp
									
									
									
									
									
								
							
							
						
						
									
										123
									
								
								cg/cg2107.cpp
									
									
									
									
									
								
							| @ -626,11 +626,12 @@ bool TEasySolder_mask::on_field_event(TOperable_field& o, TField_event e, long j | |||||||
| 
 | 
 | ||||||
| static int nrigp_pagamento_locale(const TSolder_tree& st) | static int nrigp_pagamento_locale(const TSolder_tree& st) | ||||||
| { | { | ||||||
|   const long nreg_mov = st.num_reg(); |  | ||||||
|   const int  nrig_mov = st.num_rig(); |  | ||||||
| 
 |  | ||||||
|   const TToken_string& curr = *(TToken_string*)st.curr_node(); |   const TToken_string& curr = *(TToken_string*)st.curr_node(); | ||||||
|   const int level = curr.items(); |   const int level = curr.items(); | ||||||
|  |   if (level >= 3) | ||||||
|  |   { | ||||||
|  |     const long nreg_mov = st.num_reg(); | ||||||
|  |     const int  nrig_mov = st.num_rig(); | ||||||
|     if (level == 3) |     if (level == 3) | ||||||
|     { |     { | ||||||
|       const TRiga_scadenze* scad = st.scadenza(); |       const TRiga_scadenze* scad = st.scadenza(); | ||||||
| @ -648,18 +649,64 @@ static int nrigp_pagamento_locale(const TSolder_tree& st) | |||||||
|     } else |     } else | ||||||
|     if (level == 4) |     if (level == 4) | ||||||
|     { |     { | ||||||
|     const int nrigp = st.pagamento()->get_int(PAGSCA_NRIGP); |       // const int nrigp = st.pagamento()->get_int(PAGSCA_NRIGP);
 | ||||||
|  |       int nrigp = 0; curr.get(3, nrigp); | ||||||
|       const TRiga_partite& riga = st.partita()->riga(nrigp); |       const TRiga_partite& riga = st.partita()->riga(nrigp); | ||||||
|       const long nreg_riga = riga.get_long(PART_NREG); |       const long nreg_riga = riga.get_long(PART_NREG); | ||||||
|       const int nrig_riga = riga.get_int(PART_NUMRIG); |       const int nrig_riga = riga.get_int(PART_NUMRIG); | ||||||
|       if (nreg_riga == nreg_mov && nrig_riga == nrig_mov) |       if (nreg_riga == nreg_mov && nrig_riga == nrig_mov) | ||||||
|         return nrigp; |         return nrigp; | ||||||
|     } |     } | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   return 0; |   return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static bool sheet_rate_filler(TTree& tree, void* jolly, word flags) | // Aggiunge una nota di credito non associata a fattura
 | ||||||
|  | static bool add_lonely_nc(TPartita& game, TSheet_field& sheet, int rigasheet) | ||||||
|  | { | ||||||
|  |   const int nrigp = game.first(); | ||||||
|  |   if (nrigp <= 0) | ||||||
|  |     return false; | ||||||
|  |    | ||||||
|  |   const TRiga_partite& riga = game.riga(nrigp); | ||||||
|  |   if (riga.tipo() != tm_nota_credito) | ||||||
|  |     return false; | ||||||
|  | 
 | ||||||
|  |   TToken_string& row = sheet.row(rigasheet); | ||||||
|  |   row.add(game.codice_valuta(), sheet.cid2index(S_VALUTA)); | ||||||
|  | 
 | ||||||
|  |   const char expected_section = riga.get_char(PART_TIPOCF) == 'C' ? 'D' : 'A'; | ||||||
|  |    | ||||||
|  |   TImporto res = game.calcola_saldo(true); | ||||||
|  |   res.normalize(expected_section); | ||||||
|  |   set_row_currency(sheet, row, S_RESIDUO, res.valore()); | ||||||
|  | 
 | ||||||
|  |   TImporto tot = riga.importo(true); | ||||||
|  |   tot.normalize(expected_section); | ||||||
|  |   set_row_currency(sheet, row, S_TOTALE, tot.valore()); | ||||||
|  |    | ||||||
|  |   set_row_int(sheet, row, S_ANNO, game.anno()); | ||||||
|  |   set_row_str(sheet, row, S_PARTITA, game.numero()); | ||||||
|  |   set_row_int(sheet, row, S_RIGAF, TPartita::UNASSIGNED); | ||||||
|  |   set_row_int(sheet, row, S_RATA, TPartita::UNASSIGNED); | ||||||
|  |   set_row_int(sheet, row, S_RIGAP, 0);  // Lasciare 0 e NON mettere assultamente nrigp o la scambia per pagamento!
 | ||||||
|  |   set_row_str(sheet, row, S_DATASCAD, riga.get(PART_DATAPAG)); | ||||||
|  |   if (game.in_valuta()) | ||||||
|  |   { | ||||||
|  |     TImporto reseur = riga.importo(false); | ||||||
|  |     reseur.normalize(expected_section); | ||||||
|  |     set_row_currency(sheet, row, S_RESIDUO_EUR, reseur.valore()); | ||||||
|  |   } | ||||||
|  |   set_row_str(sheet, row, S_NUMDOC, riga.get(PART_NUMDOC)); | ||||||
|  |   set_row_str(sheet, row, S_DATADOC, riga.get(PART_DATADOC)); | ||||||
|  |   const int nrow = sheet.items()-1; | ||||||
|  |   sheet.disable_cell(nrow, S_SALDO); | ||||||
|  | 
 | ||||||
|  |   return true; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static bool sheet_rate_filler(TTree& tree, void* jolly, word /* flags */) | ||||||
| { | { | ||||||
|   const TSolder_tree& st = (const TSolder_tree&)tree; |   const TSolder_tree& st = (const TSolder_tree&)tree; | ||||||
|   const TToken_string& curr = *(TToken_string*)st.curr_node(); |   const TToken_string& curr = *(TToken_string*)st.curr_node(); | ||||||
| @ -667,30 +714,27 @@ static bool sheet_rate_filler(TTree& tree, void* jolly, word flags) | |||||||
|   if (level < 3) |   if (level < 3) | ||||||
|     return false; |     return false; | ||||||
| 
 | 
 | ||||||
|   const tipo_movimento tm = app().causale().tipomov(); |  | ||||||
| 
 |  | ||||||
|   int nriga; curr.get(1, nriga); |   int nriga; curr.get(1, nriga); | ||||||
|   int nrata; curr.get(2, nrata); |   int nrata; curr.get(2, nrata); | ||||||
|   int nrigp = nrigp_pagamento_locale(st); |   if (level == 3 && nrata >= TPartita::UNASSIGNED) | ||||||
|  |     return false; // Falso nodo dell'albero padre dei non assegnati
 | ||||||
| 
 | 
 | ||||||
|  |   TPartita& game = *st.partita(); | ||||||
|  |   if (!same_values(st.codval(), game.codice_valuta())) | ||||||
|  |     return false; // Scadenza in valuta diversa da quella selezionata
 | ||||||
|  | 
 | ||||||
|  |   int nrigp = nrigp_pagamento_locale(st); | ||||||
|   bool good_rat = level >= 3 && nrata > 0 && nrata < TPartita::UNASSIGNED; |   bool good_rat = level >= 3 && nrata > 0 && nrata < TPartita::UNASSIGNED; | ||||||
|   bool good_pag = level == 4 && nrigp > 0; |   bool good_pag = level == 4 && nrigp > 0; | ||||||
|    |    | ||||||
|   const TRiga_scadenze* scad = good_rat ? st.scadenza() : NULL; |   const TRiga_scadenze* scad = good_rat ? st.scadenza() : NULL; | ||||||
|   if (scad != NULL) |   if (good_rat && scad == NULL) | ||||||
|   { |  | ||||||
|     if (!same_values(st.codval(), scad->codice_valuta())) |  | ||||||
|       return false; // Scadenza in valuta diversa da quella selezionata
 |  | ||||||
|   } |  | ||||||
|   else |  | ||||||
|   { |  | ||||||
|     if (good_rat) |  | ||||||
|   { |   { | ||||||
|     CHECKD(false, "Rata nulla inattesa ", nrata); // Segnalazione 1867
 |     CHECKD(false, "Rata nulla inattesa ", nrata); // Segnalazione 1867
 | ||||||
|     return false; |     return false; | ||||||
|   } |   } | ||||||
|   } |  | ||||||
|   |   | ||||||
|  |   const tipo_movimento tm = app().causale().tipomov(); | ||||||
|   switch (tm) |   switch (tm) | ||||||
|   { |   { | ||||||
|   case tm_nota_credito: |   case tm_nota_credito: | ||||||
| @ -701,13 +745,16 @@ static bool sheet_rate_filler(TTree& tree, void* jolly, word flags) | |||||||
|       if (good_rat) |       if (good_rat) | ||||||
|       { |       { | ||||||
|         good_rat = nrigp <= 0 && !scad->chiusa() && !scad->get_bool(SCAD_BLOCCATA); |         good_rat = nrigp <= 0 && !scad->chiusa() && !scad->get_bool(SCAD_BLOCCATA); | ||||||
|  |         /* Commentato in quanto impedisce di saldare le note di credito
 | ||||||
|         if (good_rat) |         if (good_rat) | ||||||
|         { |         { | ||||||
|  |           const char expected_section = scad->get_char(SCAD_TIPOCF) == 'C' ? 'D' : 'A'; | ||||||
|           TImporto res = scad->residuo(true); |           TImporto res = scad->residuo(true); | ||||||
|           res.normalize(scad->riga().sezione()); |           res.normalize(expected_section);  // res.normalize(scad->riga().sezione());
 | ||||||
|           if (res.valore() <= ZERO) // In realtà ha residuo negativo, per cui è chiusa!
 |           if (res.valore () <= ZERO)                // In realtà è chiusa!
 | ||||||
|             good_rat = false; |             good_rat = false; | ||||||
|         } |         } | ||||||
|  |         */ | ||||||
|       } |       } | ||||||
|     }  |     }  | ||||||
|     else |     else | ||||||
| @ -729,17 +776,24 @@ static bool sheet_rate_filler(TTree& tree, void* jolly, word flags) | |||||||
|     break; |     break; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   TSheet_field& sheet = *(TSheet_field*)jolly; | ||||||
|   if (good_rat || good_pag) // Creo una nuova riga solo se necessario
 |   if (good_rat || good_pag) // Creo una nuova riga solo se necessario
 | ||||||
|   { |   { | ||||||
|     TPartita& game = *st.partita(); |  | ||||||
|     TSheet_field& sheet = *(TSheet_field*)jolly; |  | ||||||
|     TToken_string& row = sheet.row(-1); |     TToken_string& row = sheet.row(-1); | ||||||
| 
 |  | ||||||
|     row.add(game.codice_valuta(), sheet.cid2index(S_VALUTA)); |     row.add(game.codice_valuta(), sheet.cid2index(S_VALUTA)); | ||||||
| 
 |  | ||||||
|     if (good_rat) |     if (good_rat) | ||||||
|     { |     { | ||||||
|       const TImporto res = tm == tm_insoluto ? scad->importo_pagato(true) : scad->residuo(true); |       TImporto res; | ||||||
|  |       if (tm == tm_insoluto) | ||||||
|  |       { | ||||||
|  |         res = scad->importo_pagato(true); | ||||||
|  |       } | ||||||
|  |       else | ||||||
|  |       { | ||||||
|  |         const char expected_section = scad->get_char(SCAD_TIPOCF) == 'C' ? 'D' : 'A'; | ||||||
|  |         res = scad->residuo(true); | ||||||
|  |         res.normalize(expected_section); | ||||||
|  |       } | ||||||
|       set_row_currency(sheet, row, S_RESIDUO, res.valore()); |       set_row_currency(sheet, row, S_RESIDUO, res.valore()); | ||||||
|       const TImporto tot = scad->importo(true); |       const TImporto tot = scad->importo(true); | ||||||
|       set_row_currency(sheet, row, S_TOTALE, tot.valore()); |       set_row_currency(sheet, row, S_TOTALE, tot.valore()); | ||||||
| @ -749,7 +803,7 @@ static bool sheet_rate_filler(TTree& tree, void* jolly, word flags) | |||||||
|       set_row_int(sheet, row, S_RATA, nrata); |       set_row_int(sheet, row, S_RATA, nrata); | ||||||
|       set_row_str(sheet, row, S_DATASCAD, scad->get(SCAD_DATASCAD)); |       set_row_str(sheet, row, S_DATASCAD, scad->get(SCAD_DATASCAD)); | ||||||
|       set_row_str(sheet, row, S_MODOPAG, scad->get(SCAD_TIPOPAG)); // Solo proposta
 |       set_row_str(sheet, row, S_MODOPAG, scad->get(SCAD_TIPOPAG)); // Solo proposta
 | ||||||
|       if (scad->in_valuta()) |       if (game.in_valuta()) | ||||||
|       { |       { | ||||||
|         // Calcola il residuo rata utilizzando il cambio della fattura e non quello del pagamento
 |         // Calcola il residuo rata utilizzando il cambio della fattura e non quello del pagamento
 | ||||||
|         const TImporto reseur = tm == tm_insoluto ? scad->importo_pagato(false) : scad->residuo(false); |         const TImporto reseur = tm == tm_insoluto ? scad->importo_pagato(false) : scad->residuo(false); | ||||||
| @ -777,6 +831,9 @@ static bool sheet_rate_filler(TTree& tree, void* jolly, word flags) | |||||||
|     } |     } | ||||||
|     if (good_pag) |     if (good_pag) | ||||||
|     { |     { | ||||||
|  |       if (!good_rat && nrigp > 1 && game.prima_riga(-1, tm_nota_credito) < nrigp) | ||||||
|  |         add_lonely_nc(game, sheet, sheet.items()-1); | ||||||
|  | 
 | ||||||
|       const TRiga_partite& rigp = game.riga(nrigp); |       const TRiga_partite& rigp = game.riga(nrigp); | ||||||
|       set_row_int(sheet, row, S_RIGAP, nrigp); |       set_row_int(sheet, row, S_RIGAP, nrigp); | ||||||
|       set_row_int(sheet, row, S_NREG, rigp.get_long(PART_NREG)); |       set_row_int(sheet, row, S_NREG, rigp.get_long(PART_NREG)); | ||||||
| @ -787,9 +844,7 @@ static bool sheet_rate_filler(TTree& tree, void* jolly, word flags) | |||||||
|       if (!imp.is_zero()) |       if (!imp.is_zero()) | ||||||
|       { |       { | ||||||
|         set_row_bool(sheet, row, S_SPUNTA, true); |         set_row_bool(sheet, row, S_SPUNTA, true); | ||||||
| 
 |         if (rigp.in_valuta()) | ||||||
|         const TString& codval = rigp.get(PART_CODVAL); |  | ||||||
|         if (is_true_value(codval)) |  | ||||||
|         { |         { | ||||||
|           const real impval = pag.get_real(PAGSCA_IMPORTOVAL); |           const real impval = pag.get_real(PAGSCA_IMPORTOVAL); | ||||||
|           set_row_currency(sheet, row, S_IMPORTO, impval); |           set_row_currency(sheet, row, S_IMPORTO, impval); | ||||||
| @ -798,7 +853,7 @@ static bool sheet_rate_filler(TTree& tree, void* jolly, word flags) | |||||||
|         else |         else | ||||||
|           set_row_currency(sheet, row, S_IMPORTO, imp); |           set_row_currency(sheet, row, S_IMPORTO, imp); | ||||||
|       } |       } | ||||||
|       set_row_str(sheet, row, S_SALDO, pag.get_char(PAGSCA_ACCSAL)=='S'?"X":""); |       set_row_str(sheet, row, S_SALDO, (good_rat && pag.get_char(PAGSCA_ACCSAL)=='S') ? "X" : ""); | ||||||
|       set_row_int(sheet, row, S_MODOPAG, rigp.get_int(PART_TIPOPAG)); |       set_row_int(sheet, row, S_MODOPAG, rigp.get_int(PART_TIPOPAG)); | ||||||
|       set_row_currency(sheet, row, S_RITFIS, pag.get_real(PAGSCA_RITENUTE)); |       set_row_currency(sheet, row, S_RITFIS, pag.get_real(PAGSCA_RITENUTE)); | ||||||
|       set_row_currency(sheet, row, S_RITSOC, pag.get_real(PAGSCA_RITSOC)); |       set_row_currency(sheet, row, S_RITSOC, pag.get_real(PAGSCA_RITSOC)); | ||||||
| @ -820,6 +875,12 @@ static bool sheet_rate_filler(TTree& tree, void* jolly, word flags) | |||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |   else | ||||||
|  |   { | ||||||
|  |     // Nota di credito non assegnata e senza pagamenti successivi
 | ||||||
|  |     if (level == 4 && nriga == TPartita::UNASSIGNED && game.last() == game.first()) | ||||||
|  |       add_lonely_nc(game, sheet, -1); | ||||||
|  |   } | ||||||
|   return false; |   return false; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -1039,9 +1100,9 @@ void TEasySolder_mask::init(const TBill& conto, long numreg, int numrig) | |||||||
|   }  |   }  | ||||||
|   else |   else | ||||||
|     app().causale().bill(2, controbill); |     app().causale().bill(2, controbill); | ||||||
|   if (controbill.ok()) |   if (controbill.gruppo() > 0) // con controbill.ok() non presentava assolutamente i conti parziali
 | ||||||
|   { |   { | ||||||
|     controbill.set(*this, G_GRUPPOC, G_CONTOC, G_SOTTOCONTOC); |     controbill.set(*this, G_GRUPPOC, G_CONTOC, G_SOTTOCONTOC, 0, G_DESCONTOC); | ||||||
|   } |   } | ||||||
|   else |   else | ||||||
|   { |   { | ||||||
|  | |||||||
| @ -87,7 +87,7 @@ _year(4), _nomiditte(100), _menu(m), _firm_bookmark(-1) | |||||||
|   _isplafond = _printonly = _is_visliq = false;  |   _isplafond = _printonly = _is_visliq = false;  | ||||||
|   _isvent = _isagricolo = _isbenzinaro = _isviaggio = _isdiff = false;  |   _isvent = _isagricolo = _isbenzinaro = _isviaggio = _isdiff = false;  | ||||||
|   _row = 1;  _what = all; _comp_acconto = false;  |   _row = 1;  _what = all; _comp_acconto = false;  | ||||||
|   _isriepilogo = FALSE; _calcall = false; |   _isriepilogo = false; _calcall = false; | ||||||
|   _recalc_only = _recalc_regis = _isfinal = _isregis = false;      |   _recalc_only = _recalc_regis = _isfinal = _isregis = false;      | ||||||
|   _stampa_vers = _stampa_acc = false; |   _stampa_vers = _stampa_acc = false; | ||||||
|   _recalc = needed; |   _recalc = needed; | ||||||
| @ -95,23 +95,33 @@ _year(4), _nomiditte(100), _menu(m), _firm_bookmark(-1) | |||||||
| 
 | 
 | ||||||
| bool TLiquidazione_app::user_create() | bool TLiquidazione_app::user_create() | ||||||
| {                  | {                  | ||||||
|   // vediamo se c'e' il messaggio per calcolare in batch
 |   bool is_header = true; | ||||||
|   TMailbox mail; |   int  bodylen = 60; | ||||||
|   TProgind* pnd = NULL; |  | ||||||
|   TMessage* msg = mail.next_s("RCL"); |  | ||||||
|   TToken_string subj(36); |  | ||||||
|   _is_interactive = msg == NULL; |  | ||||||
|   bool is_header = TRUE; |  | ||||||
|   int  bodylen; |  | ||||||
|   TDate   printdate;             |   TDate   printdate;             | ||||||
|   TString filename;          |   TString filename;          | ||||||
|   long    ditta; |   long    ditta = 0; | ||||||
|   bool    nocalc = FALSE;                              |   bool    nocalc = false;                              | ||||||
|    |    | ||||||
|   _prind = NULL; |   _prind = NULL; | ||||||
| 
 | 
 | ||||||
|   if (msg != NULL) subj = msg->body();   |   // vediamo se c'e' il messaggio per calcolare in batch
 | ||||||
|  |   TMailbox mail; | ||||||
|  |   TMessage* msg = mail.next_s("RCL"); | ||||||
|  |   _is_interactive = msg == NULL; | ||||||
| 
 | 
 | ||||||
|  |   TToken_string subj; | ||||||
|  |   if (!_is_interactive)  | ||||||
|  |     subj = msg->body();   | ||||||
|  | #ifdef DBG | ||||||
|  |   else if (argv(2)[1] == 'C') | ||||||
|  |   { | ||||||
|  |     subj = "2012|12|9058|R|12-12-2012|c:/Temp/110|X|60"; | ||||||
|  |     _is_interactive = false; | ||||||
|  |   } | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  |    | ||||||
|  |   TProgind* pnd = NULL; | ||||||
|   if (_is_interactive)  |   if (_is_interactive)  | ||||||
|     pnd = new TProgind (3,TR("Preparazione archivi"), false, true);  |     pnd = new TProgind (3,TR("Preparazione archivi"), false, true);  | ||||||
|   else  |   else  | ||||||
| @ -178,8 +188,7 @@ bool TLiquidazione_app::user_create() | |||||||
|   _rel->add(LF_PCON,"GRUPPO=GRUPPO|CONTO=CONTO|SOTTOCONTO=SOTTOCONTO",1,LF_RMOVIVA,AGR_PCON2); |   _rel->add(LF_PCON,"GRUPPO=GRUPPO|CONTO=CONTO|SOTTOCONTO=SOTTOCONTO",1,LF_RMOVIVA,AGR_PCON2); | ||||||
|   _rel->add(LF_CAUSALI,"CODCAUS=CODCAUS"); |   _rel->add(LF_CAUSALI,"CODCAUS=CODCAUS"); | ||||||
| 
 | 
 | ||||||
| //  _cur = new TCursor(_rel, "", 2);
 |   _cur = new TCursor(_rel, "", 4); // Was  _cur = new TCursor(_rel, "", 2);
 | ||||||
|   _cur = new TCursor(_rel, "", 4); |  | ||||||
| 
 | 
 | ||||||
|   _ver        = new TInteressi_IVA_table(); |   _ver        = new TInteressi_IVA_table(); | ||||||
|   _pim        = new TTable("PIM"); |   _pim        = new TTable("PIM"); | ||||||
| @ -320,7 +329,8 @@ bool TLiquidazione_app::user_create() | |||||||
|     if (_recalc_only)  |     if (_recalc_only)  | ||||||
|       _isprint = FALSE; |       _isprint = FALSE; | ||||||
|     //else printer().set_export_file(filename, is_header, headerlen);
 |     //else printer().set_export_file(filename, is_header, headerlen);
 | ||||||
|     else printer().set_export_file(filename, is_header); |     else  | ||||||
|  |       printer().set_export_file(filename, is_header); | ||||||
|      |      | ||||||
|     // calcola liquidazione 
 |     // calcola liquidazione 
 | ||||||
|     printer().setdate(printdate); |     printer().setdate(printdate); | ||||||
|  | |||||||
| @ -618,12 +618,14 @@ bool TLiquidazione_app::sarebbe_da_pagare(const TRectype& mov, const TDate& fine | |||||||
| 	const TRectype& clifo = cache().get(LF_CLIFO, key); | 	const TRectype& clifo = cache().get(LF_CLIFO, key); | ||||||
|   const int alleg = clifo.get_int(CLI_ALLEG); |   const int alleg = clifo.get_int(CLI_ALLEG); | ||||||
| 
 | 
 | ||||||
|   if (alleg == 5 || alleg == 6 || alleg == 9) // Privati, import ed export non hanno IVA per cassa
 |  | ||||||
|     return true;                |  | ||||||
| 
 |  | ||||||
|   if (alleg == 7 || alleg == 8) // Ente pubblico e amministrazione controllata ...
 |   if (alleg == 7 || alleg == 8) // Ente pubblico e amministrazione controllata ...
 | ||||||
|     return false;               // ... possono aspettare le calende greche  
 |     return false;               // ... possono aspettare le calende greche  
 | ||||||
| 
 | 
 | ||||||
|  |   if (mov.get_bool(MOV_IVAXCASSA)) | ||||||
|  |   { | ||||||
|  |     if (alleg == 5 || alleg == 6 || alleg == 9) // Privati, import ed export non hanno IVA per cassa
 | ||||||
|  |       return true;                | ||||||
|  | 
 | ||||||
|     TString16 paiv = clifo.get(CLI_PAIV); |     TString16 paiv = clifo.get(CLI_PAIV); | ||||||
|     if (paiv.empty() && clifo.get_bool(CLI_OCCAS)) |     if (paiv.empty() && clifo.get_bool(CLI_OCCAS)) | ||||||
|     { |     { | ||||||
| @ -632,6 +634,7 @@ bool TLiquidazione_app::sarebbe_da_pagare(const TRectype& mov, const TDate& fine | |||||||
|     } |     } | ||||||
|     if (paiv.blank()) |     if (paiv.blank()) | ||||||
|       return true;  // In assenza di Partita IVA non c'è IVA per cassa
 |       return true;  // In assenza di Partita IVA non c'è IVA per cassa
 | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   if (ivadiff_chiusa(mov, fine)) |   if (ivadiff_chiusa(mov, fine)) | ||||||
|     return false; |     return false; | ||||||
| @ -944,7 +947,16 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) | |||||||
|     const TString4 tipodoc = _mov->get(MOV_TIPODOC); |     const TString4 tipodoc = _mov->get(MOV_TIPODOC); | ||||||
|     const bool corrisp     = _reg->get_bool("B0");   |     const bool corrisp     = _reg->get_bool("B0");   | ||||||
|     const tiporeg tipomov  = (tiporeg)_reg->get_int("I0"); |     const tiporeg tipomov  = (tiporeg)_reg->get_int("I0"); | ||||||
|     const tipo_movimento tm = (tipo_movimento)_mov->get_int(MOV_TIPOMOV); |      | ||||||
|  |     tipo_movimento tm = (tipo_movimento)_mov->get_int(MOV_TIPOMOV); | ||||||
|  |     if (tm == tm_nessuno) | ||||||
|  |     { | ||||||
|  |       if (tipodoc == "FV" || tipodoc == "FA") | ||||||
|  |         tm = tm_fattura; else | ||||||
|  |       if (tipodoc == "NC") | ||||||
|  |         tm = tm_nota_credito; | ||||||
|  |     } | ||||||
|  |      | ||||||
|     // Controlla se la data del documento si riferisce all'anno precedente (PRORATA 1998)
 |     // Controlla se la data del documento si riferisce all'anno precedente (PRORATA 1998)
 | ||||||
|     const TDate datedoc = _mov->get(MOV_DATADOC); |     const TDate datedoc = _mov->get(MOV_DATADOC); | ||||||
|      |      | ||||||
| @ -960,13 +972,13 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) | |||||||
|     const bool cau_intra    = rcs.get_bool("INTRACOM"); |     const bool cau_intra    = rcs.get_bool("INTRACOM"); | ||||||
|     const bool cau_valintra = rcs.get_bool("VALINTRA"); |     const bool cau_valintra = rcs.get_bool("VALINTRA"); | ||||||
| 
 | 
 | ||||||
|     if (_mov->get_long(MOV_NUMREG) == 20339) |     if (_mov->get_long(MOV_NUMREG) == 31838) | ||||||
|       int cazzone = 1; |       int cazzone = 1; | ||||||
| 
 | 
 | ||||||
|     // Inizio gestione IVA differita
 |     // Inizio gestione IVA differita
 | ||||||
|     const bool iva_diff = _isdiff && _mov->get_bool(MOV_LIQDIFF);  |     const bool iva_diff = _isdiff && _mov->get_bool(MOV_LIQDIFF);  | ||||||
|     const bool iva_cass = !iva_diff && _mov->get_bool(MOV_IVAXCASSA) && tm > 0; |     const bool iva_cass = !iva_diff && _mov->get_bool(MOV_IVAXCASSA) && tm > 0; | ||||||
| 		const bool movdiff = iva_diff || iva_cass; | 		const bool movdiff = (iva_diff || iva_cass) && !_recalc_regis;  // Aggiunto test su ricalcolo da registri 13-12-2012
 | ||||||
| 		bool dok = is_date_ok(date, month, liqmonth, year_int);  | 		bool dok = is_date_ok(date, month, liqmonth, year_int);  | ||||||
| 
 | 
 | ||||||
|     TPartite_array arrpart;  // Partite interessate
 |     TPartite_array arrpart;  // Partite interessate
 | ||||||
| @ -1153,7 +1165,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) | |||||||
|         CHECKD(rmi_tipoatt > 0, "Invalid tipo att ", rmi_tipoatt); |         CHECKD(rmi_tipoatt > 0, "Invalid tipo att ", rmi_tipoatt); | ||||||
|         id.put("TIPOATT", rmi_tipoatt); |         id.put("TIPOATT", rmi_tipoatt); | ||||||
|         id.put("ANNOLIQ", datareg.year()); |         id.put("ANNOLIQ", datareg.year()); | ||||||
|         int mesereg = mesereg = datareg.month(); |         int mesereg = datareg.month(); | ||||||
|         if (_freqviva[0] == 'T') |         if (_freqviva[0] == 'T') | ||||||
|         { |         { | ||||||
|           const int resto = mesereg % 3; |           const int resto = mesereg % 3; | ||||||
| @ -2072,9 +2084,10 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) | |||||||
|           stop  = 3; |           stop  = 3; | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
|  |         { | ||||||
|           if (year_int < 1998) |           if (year_int < 1998) | ||||||
|             stop = 0; // Solo PIM 
 |             stop = 0; // Solo PIM 
 | ||||||
|            |         }  | ||||||
|         for (int i=start; i<=stop; i++) // Ciclo per le tabelle
 |         for (int i=start; i<=stop; i++) // Ciclo per le tabelle
 | ||||||
|         {  |         {  | ||||||
|           if (i == 1 || i == 3) //Is it a valid PIS/PRP (vedi anche sel. cursore & date_ok())?
 |           if (i == 1 || i == 3) //Is it a valid PIS/PRP (vedi anche sel. cursore & date_ok())?
 | ||||||
| @ -2098,31 +2111,32 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) | |||||||
|           } |           } | ||||||
|          |          | ||||||
|           TTable *tab = arr[i]; |           TTable *tab = arr[i]; | ||||||
|  |           TRectype& curr = tab->curr(); | ||||||
|        |        | ||||||
|           if (!ign)  |           if (!ign)  | ||||||
|           { |           { | ||||||
|             tab->put("R0",  tab->get_real("R0")  + imp); |             curr.add("R0",  imp); | ||||||
|             tab->put("R1",  tab->get_real("R1")  + ivp); |             curr.add("R1",  ivp); | ||||||
|             tab->put("R2",  tab->get_real("R2")  + lor);    |             curr.add("R2",  lor);    | ||||||
|             tab->put("R3",  tab->get_real("R3")  + lorcor);   // Corrispettivi, non inclusi quelli da ventilare
 |             curr.add("R3",  lorcor);   // Corrispettivi, non inclusi quelli da ventilare
 | ||||||
|             tab->put("R5",  tab->get_real("R5")  + ifs);    |             curr.add("R5",  ifs);    | ||||||
|             tab->put("R6",  tab->get_real("R6")  + vfs);    |             curr.add("R6",  vfs);    | ||||||
|             tab->put("R7",  tab->get_real("R7")  + adf);    |             curr.add("R7",  adf);    | ||||||
|             tab->put("R8",  tab->get_real("R8")  + adi);   |             curr.add("R8",  adi);   | ||||||
|             tab->put("R9",  tab->get_real("R9")  + bdi);          |             curr.add("R9",  bdi);          | ||||||
|             tab->put("R10", tab->get_real("R10") + bdv);          |             curr.add("R10", bdv);          | ||||||
|             tab->put("R13", tab->get_real("R13") + fci);          |             curr.add("R13", fci);          | ||||||
|             tab->put("R14", tab->get_real("R14") + fcv);        |             curr.add("R14", fcv);        | ||||||
|           }                          |           }                          | ||||||
|                             |  | ||||||
|           // questi servono per i ricalcoli altrui (classify_pim) o 
 |           // questi servono per i ricalcoli altrui (classify_pim) o 
 | ||||||
|           // per trucchetti di ricalcolo successivi
 |           // per trucchetti di ricalcolo successivi
 | ||||||
|           tab->put("R11",tab->get_real("R11")+fsi);          |           curr.add("R11",fsi);          | ||||||
|           tab->put("R12",tab->get_real("R12")+fsv);          |           curr.add("R12",fsv);          | ||||||
|           tab->put("I1", (long)tipomov);   |            | ||||||
|           tab->put("B3", ivarimb ?   "X" : "");   |           curr.put("I1", (long)tipomov);   | ||||||
|           tab->put("B4", (_isricacq && was_riv) ? "X" : "");   |           curr.put("B3", ivarimb ?   "X" : "");   | ||||||
|           tab->put("S5", tipoiva);               |           curr.put("B4", (_isricacq && was_riv) ? "X" : "");   | ||||||
|  |           curr.put("S5", tipoiva);               | ||||||
|        |        | ||||||
|           // art 40 c. 5/6/8 per VA7.
 |           // art 40 c. 5/6/8 per VA7.
 | ||||||
|           real r,v; |           real r,v; | ||||||
|  | |||||||
							
								
								
									
										236
									
								
								cg/cg4400.cpp
									
									
									
									
									
								
							
							
						
						
									
										236
									
								
								cg/cg4400.cpp
									
									
									
									
									
								
							| @ -12,6 +12,7 @@ | |||||||
| #include <defmask.h> | #include <defmask.h> | ||||||
| #include <execp.h> | #include <execp.h> | ||||||
| #include <mailbox.h> | #include <mailbox.h> | ||||||
|  | #include <modaut.h> | ||||||
| #include <progind.h> | #include <progind.h> | ||||||
| #include <recarray.h> | #include <recarray.h> | ||||||
| #include <recset.h> | #include <recset.h> | ||||||
| @ -66,8 +67,6 @@ HIDDEN int compare_rows(const TObject** o1, const TObject** o2) | |||||||
| { | { | ||||||
|   const TRiga& r1 = *(const TRiga*)*o1; |   const TRiga& r1 = *(const TRiga*)*o1; | ||||||
|   const TRiga& r2 = *(const TRiga*)*o2; |   const TRiga& r2 = *(const TRiga*)*o2; | ||||||
|    |  | ||||||
|   //return (strcmp((const char*)r1->_codiva, (const char*)r2->_codiva));
 |  | ||||||
|   return r1._codiva.compare(r2._codiva); |   return r1._codiva.compare(r2._codiva); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -121,7 +120,7 @@ const char* TStampa_registri_app::desc_attivita(const TString& cod) | |||||||
| 
 | 
 | ||||||
| const TRectype& TStampa_registri_app::ricerca_cf(char tipocf, long codcf) | const TRectype& TStampa_registri_app::ricerca_cf(char tipocf, long codcf) | ||||||
| { | { | ||||||
|   TString16 key; |   TString8 key; | ||||||
| 	key.format("%c|%ld", tipocf, codcf); | 	key.format("%c|%ld", tipocf, codcf); | ||||||
|   return cache().get(LF_CLIFO, key); |   return cache().get(LF_CLIFO, key); | ||||||
| } | } | ||||||
| @ -1066,7 +1065,7 @@ int TStampa_registri_app::riga_rmoviva() | |||||||
|     _riga_rmi.add_riga(iva); |     _riga_rmi.add_riga(iva); | ||||||
| 
 | 
 | ||||||
|     if (!mov.get_bool(MOV_LIQDIFF) && !(mov.get_bool(MOV_IVAXCASSA) && mov.get_int(MOV_TIPOMOV)>0)) |     if (!mov.get_bool(MOV_LIQDIFF) && !(mov.get_bool(MOV_IVAXCASSA) && mov.get_int(MOV_TIPOMOV)>0)) | ||||||
|       _riga_prospettoXcassa.add_riga(impo, impos, ZERO, ZERO, codiva, 0, 0, false, 0); |       _riga_prospettoXcassa.add_riga(impo, impos, ZERO, ZERO, ZERO, ZERO, codiva); | ||||||
|      |      | ||||||
|     //stampa di prova, cumula progressivi dai movimenti, anziche' dalle tabelle (solo bollato)
 |     //stampa di prova, cumula progressivi dai movimenti, anziche' dalle tabelle (solo bollato)
 | ||||||
|     if (_tipo_stampa == prova)  |     if (_tipo_stampa == prova)  | ||||||
| @ -1299,6 +1298,7 @@ int TStampa_registri_app::stampa_prospetto(int rr, bool print_prec) | |||||||
|     if (_auto_intraf) |     if (_auto_intraf) | ||||||
|       riga << TR("; 3=intra e AF art.34 comma 3"); |       riga << TR("; 3=intra e AF art.34 comma 3"); | ||||||
|     riga << TR("; 4=liquidazione differita"); |     riga << TR("; 4=liquidazione differita"); | ||||||
|  |     if (has_module(ICAUT)) | ||||||
|       riga << TR("; 5=IVA per cassa"); |       riga << TR("; 5=IVA per cassa"); | ||||||
|     set_row(rr++, riga); |     set_row(rr++, riga); | ||||||
|      |      | ||||||
| @ -1496,6 +1496,7 @@ int TStampa_registri_app::stampa_acquisti(int row) | |||||||
|     } |     } | ||||||
|   }   |   }   | ||||||
|   if (_iva_array.items() > 0) |   if (_iva_array.items() > 0) | ||||||
|  |   { | ||||||
|     if (tdetprec == 1 || tdetprec == 3 || tdetprec == 9) |     if (tdetprec == 1 || tdetprec == 3 || tdetprec == 9) | ||||||
|     { |     { | ||||||
|       set_row(++rw, TR("TOTALE")); |       set_row(++rw, TR("TOTALE")); | ||||||
| @ -1512,6 +1513,7 @@ int TStampa_registri_app::stampa_acquisti(int row) | |||||||
|       } |       } | ||||||
|     }    |     }    | ||||||
|     _iva_array.destroy();  |     _iva_array.destroy();  | ||||||
|  |   } | ||||||
|   rw++; |   rw++; | ||||||
|   return rw; |   return rw; | ||||||
| } | } | ||||||
| @ -1900,25 +1902,11 @@ real TStampa_registri_app::stampa_valori_plafonds(const real& r1, const int mese | |||||||
|   return r; |   return r; | ||||||
| }      | }      | ||||||
| 
 | 
 | ||||||
| bool TStampa_registri_app::some_IVAxCassa() const | bool TStampa_registri_app::some_IVAxCassa(int da_mese, int a_mese) const | ||||||
| { | { | ||||||
|   if (_tipo_reg != vendita && _tipo_reg != acquisto) |   if (_tipo_reg != vendita && _tipo_reg != acquisto) | ||||||
|     return false; |     return false; | ||||||
| 
 | 
 | ||||||
|   int da_mese = _data_da.month(); |  | ||||||
|   int a_mese = _data_a.month(); |  | ||||||
| 
 |  | ||||||
|   if (_frequiva == 'T') |  | ||||||
|   { |  | ||||||
|     const int dr = da_mese % 3; |  | ||||||
|     if (dr != 1) |  | ||||||
|       da_mese -= (dr == 0 ? 2 : 1); |  | ||||||
| 
 |  | ||||||
|     const int ar = a_mese % 3; |  | ||||||
|     if (ar != 0) |  | ||||||
|       a_mese += (ar == 1 ? 2 : 1); |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   TString query; |   TString query; | ||||||
|   query = "USE IVADIFF KEY 2 SELECT (TIPOMOV>2)"; |   query = "USE IVADIFF KEY 2 SELECT (TIPOMOV>2)"; | ||||||
|   query << "\nFROM ANNOLIQ=" << _data_da.year() << " MESELIQ=" << da_mese; |   query << "\nFROM ANNOLIQ=" << _data_da.year() << " MESELIQ=" << da_mese; | ||||||
| @ -1927,7 +1915,7 @@ bool TStampa_registri_app::some_IVAxCassa() const | |||||||
|   return id.items() > 0; |   return id.items() > 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool TStampa_registri_app::print_IVAxCassa(int month) | bool TStampa_registri_app::print_IVAxCassa(int da_month, int a_month) | ||||||
| { | { | ||||||
|   if (_tipo_reg != vendita && _tipo_reg != acquisto) |   if (_tipo_reg != vendita && _tipo_reg != acquisto) | ||||||
|     return false; |     return false; | ||||||
| @ -1936,16 +1924,26 @@ bool TStampa_registri_app::print_IVAxCassa(int month) | |||||||
|   TPrintrow riga; |   TPrintrow riga; | ||||||
|   const TString linea(_stampa_width, '-');    |   const TString linea(_stampa_width, '-');    | ||||||
| 
 | 
 | ||||||
|  |   TDate data_da(1, da_month, _data_da.year()); | ||||||
|  |   if (data_da < _data_da) | ||||||
|  |     data_da = _data_da; | ||||||
|  | 
 | ||||||
|  |   TDate data_a = _data_a; | ||||||
|  |   if (a_month < data_a.month()) | ||||||
|  |   { | ||||||
|  |     data_a = TDate(1, a_month, _data_da.year());  | ||||||
|  |     data_a.set_end_month(); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   TString query; |   TString query; | ||||||
|   query = "USE IVADIFF SELECT (BETWEEN(DATAREGP,#DAL,#AL))&&(MOV.REG=#REG)&&(TIPOMOV>2)&&(STR(IMPONIBILE>0))&&(STR(MESELIQ==#MON))"; |   query = "USE IVADIFF SELECT (BETWEEN(DATAREGP,#DAL,#AL))&&(MOV.REG=#REG)&&(TIPOMOV>2)&&(STR(IMPONIBILE>0))"; | ||||||
|   query << "\nBY DATAREGP DATAREG"; |   query << "\nBY DATAREGP DATAREG"; | ||||||
|   query << "\nJOIN MOV INTO NUMREG==NUMREG"; |   query << "\nJOIN MOV INTO NUMREG==NUMREG"; | ||||||
|   query << "\nJOIN CLIFO TO MOV INTO TIPOCF==TIPO CODCF==CODCF"; |   query << "\nJOIN CLIFO TO MOV INTO TIPOCF==TIPO CODCF==CODCF"; | ||||||
|   TISAM_recordset id(query); |   TISAM_recordset id(query); | ||||||
|   id.set_var("#DAL", _data_da); |   id.set_var("#DAL", data_da); | ||||||
|   id.set_var("#AL", _data_a); |   id.set_var("#AL", data_a); | ||||||
|   id.set_var("#REG", _codreg); |   id.set_var("#REG", _codreg); | ||||||
|   id.set_var("#MON", long(month)); |  | ||||||
| 
 | 
 | ||||||
|   // Sporco trucco per evitare intestazioni inutili
 |   // Sporco trucco per evitare intestazioni inutili
 | ||||||
|   const bool il = _intesta_liq; |   const bool il = _intesta_liq; | ||||||
| @ -1954,7 +1952,11 @@ bool TStampa_registri_app::print_IVAxCassa(int month) | |||||||
|   if (id.items() > 0) |   if (id.items() > 0) | ||||||
|   { |   { | ||||||
|     riga.reset();  |     riga.reset();  | ||||||
|  |     if (pr.rows_left() < id.items()+8) | ||||||
|  |     { | ||||||
|  |       pr.formfeed(); | ||||||
|       riga.put(linea, 0); |       riga.put(linea, 0); | ||||||
|  |     } | ||||||
|     pr.print(riga); |     pr.print(riga); | ||||||
| 
 | 
 | ||||||
|     riga.reset(); |     riga.reset(); | ||||||
| @ -1972,6 +1974,7 @@ bool TStampa_registri_app::print_IVAxCassa(int month) | |||||||
|     riga.put(TR("Documento"), 19); |     riga.put(TR("Documento"), 19); | ||||||
|     riga.put(TR("T Tipo"),    66); |     riga.put(TR("T Tipo"),    66); | ||||||
|     riga.put(TR("Forz"),     123); |     riga.put(TR("Forz"),     123); | ||||||
|  |     if (_tipo_stampa == prova) | ||||||
|       riga.put(TR("Num"),    128); |       riga.put(TR("Num"),    128); | ||||||
|     pr.print(riga); |     pr.print(riga); | ||||||
|      |      | ||||||
| @ -1985,6 +1988,7 @@ bool TStampa_registri_app::print_IVAxCassa(int month) | |||||||
|     riga.put(TR("IVA"),                          102); |     riga.put(TR("IVA"),                          102); | ||||||
|     riga.put(TR("Imposta"),                      115); |     riga.put(TR("Imposta"),                      115); | ||||||
|     riga.put(TR("Scad"),                         123); |     riga.put(TR("Scad"),                         123); | ||||||
|  |     if (_tipo_stampa == prova) | ||||||
|       riga.put(TR("Reg"),                        128); |       riga.put(TR("Reg"),                        128); | ||||||
|     pr.print(riga); |     pr.print(riga); | ||||||
| 
 | 
 | ||||||
| @ -1997,8 +2001,11 @@ bool TStampa_registri_app::print_IVAxCassa(int month) | |||||||
|       const real importo      = rec.get("IMPORTO"); |       const real importo      = rec.get("IMPORTO"); | ||||||
|       const real imponibile   = rec.get("IMPONIBILE"); |       const real imponibile   = rec.get("IMPONIBILE"); | ||||||
|       const real imposta      = rec.get("IMPOSTA"); |       const real imposta      = rec.get("IMPOSTA"); | ||||||
|  |       const int tipodiff      = rec.get_int("TIPODIFF"); | ||||||
| 
 | 
 | ||||||
|       TParagraph_string clifo(id.get("CLIFO.RAGSOC").as_string(), 27); |       TString rs = id.get("CLIFO.RAGSOC").as_string(); | ||||||
|  |       rs.strip_double_spaces(); | ||||||
|  |       TParagraph_string clifo(rs, 27); | ||||||
|    		   |    		   | ||||||
|       riga.reset(); |       riga.reset(); | ||||||
|       riga.put(rec.get_date("DATAREGP").string(brief, '/'),     0); |       riga.put(rec.get_date("DATAREGP").string(brief, '/'),     0); | ||||||
| @ -2007,25 +2014,45 @@ bool TStampa_registri_app::print_IVAxCassa(int month) | |||||||
|       riga.put(id.get("MOV.NUMDOC").as_string(),               24); |       riga.put(id.get("MOV.NUMDOC").as_string(),               24); | ||||||
|       riga.put(format("%6ld", id.get("CLIFO.CODCF").as_int()), 31); |       riga.put(format("%6ld", id.get("CLIFO.CODCF").as_int()), 31); | ||||||
|       riga.put(clifo.get(),                                    38); |       riga.put(clifo.get(),                                    38); | ||||||
|       riga.put(rec.get_int("TIPODIFF") == 2 ? "5" : "4",       66); // 4 = Differita; 5 = x Cassa
 |       riga.put(tipodiff == 2 ? "5" : "4",                      66); // 4 = Differita; 5 = x Cassa
 | ||||||
|       riga.put(id.get("MOV.TIPODOC").as_string(),              68); |       riga.put(id.get("MOV.TIPODOC").as_string(),              68); | ||||||
|       print_real(riga, importo,                                70); |       print_real(riga, importo,                                70); | ||||||
|       print_real(riga, imponibile,                             85); |       print_real(riga, imponibile,                             85); | ||||||
|       riga.put(rec.get("CODIVA"),                             102); |       riga.put(rec.get("CODIVA"),                             102); | ||||||
|       print_real(riga, imposta,                               107); |       print_real(riga, imposta,                               107); | ||||||
|       riga.put(rec.get_int("NUMPRO") >= 999 ? "X" : "",       123); |       riga.put(rec.get_int("NUMPRO") >= 999 ? "X" : "",       123); | ||||||
|  |       if (_tipo_stampa == prova) | ||||||
|         riga.put(format("%6ld", rec.get_long(MOV_NUMREG)),    125); |         riga.put(format("%6ld", rec.get_long(MOV_NUMREG)),    125); | ||||||
|       pr.print(riga); |       pr.print(riga); | ||||||
| 
 | 
 | ||||||
|       _riga_prospettoXcassa.add_riga(ZERO, ZERO, imponibile, imposta, codiva, 0, 0, false, 0);  |       switch (tipodiff) | ||||||
|  |       { | ||||||
|  |       case 1: _riga_prospettoXcassa.add_riga(ZERO, ZERO, imponibile, imposta, ZERO, ZERO, codiva); break; | ||||||
|  |       case 2: _riga_prospettoXcassa.add_riga(ZERO, ZERO, ZERO, ZERO, imponibile, imposta, codiva); break; | ||||||
|  |       default: break; | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  |   } | ||||||
|  |   else | ||||||
|  |   { | ||||||
|  |     _intesta_liq = il; // Ripristina flag intestazioni
 | ||||||
|  |     return false;  // Ho stampato qualcosa?
 | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   if (_riga_prospettoXcassa.items() <= 0) |   int flags = 0x0; | ||||||
|     return id.items() > 0; // Ho stampato qualcosa?
 |   FOR_EACH_ARRAY_ITEM(_riga_prospettoXcassa, r, obj) | ||||||
|  |   { | ||||||
|  |     const TRiga& ri = *(const TRiga*)obj; | ||||||
|  |     if (!ri._implordo.is_zero()) | ||||||
|  |       flags |= 0x1; | ||||||
|  |     if (!ri._impostap.is_zero()) | ||||||
|  |       flags |= 0x2; | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|  |   if (flags != 0x0) | ||||||
|  |   { | ||||||
|     riga.reset();  |     riga.reset();  | ||||||
|   if (pr.rows_left() < _riga_prospettoXcassa.items()+5) |     if (pr.rows_left() < _riga_prospettoXcassa.items()+8) | ||||||
|     { |     { | ||||||
|       pr.formfeed(); |       pr.formfeed(); | ||||||
|       riga.put(linea, 0); |       riga.put(linea, 0); | ||||||
| @ -2033,49 +2060,91 @@ bool TStampa_registri_app::print_IVAxCassa(int month) | |||||||
|     pr.print(riga); |     pr.print(riga); | ||||||
| 
 | 
 | ||||||
|     riga.reset(); |     riga.reset(); | ||||||
|   riga.put(TR("PROSPETTO IMPORTI CON IVA ORDINARIA ED IVA DIFFERITA O PER CASSA"), 40); |     pr.print(riga); | ||||||
|  | 
 | ||||||
|  |     TString str = TR("PROSPETTO IMPORTI CON IVA NORMALE"); | ||||||
|  |     if (flags & 0x1) | ||||||
|  |       str << ((flags == 0x1) ? TR(" ED ") : ", ") << TR("IVA DIFFERITA"); | ||||||
|  |     if (flags & 0x2) | ||||||
|  |       str << " ED " << TR("IVA PER CASSA"); | ||||||
|  | 
 | ||||||
|  |     riga.put(str, (132-str.len())/2); | ||||||
|     pr.print(riga); |     pr.print(riga); | ||||||
| 
 | 
 | ||||||
|     riga.reset(); |     riga.reset(); | ||||||
|     pr.print(riga); |     pr.print(riga); | ||||||
| 
 | 
 | ||||||
|  |     riga.put(TR("NORMALE"),           45); | ||||||
|  |     if (flags & 0x1) | ||||||
|  |       riga.put(TR("DIFFERITA"),       78); | ||||||
|  |     if (flags & 0x2) | ||||||
|  |       riga.put(TR("PER CASSA"),      112); | ||||||
|  |     pr.print(riga); | ||||||
|  | 
 | ||||||
|     riga.reset(); |     riga.reset(); | ||||||
|     riga.put(TR("IVA  Descrizione"),   0); |     riga.put(TR("IVA  Descrizione"),   0); | ||||||
|     riga.put(TR("Imponibile"),        34); |     riga.put(TR("Imponibile"),        34); | ||||||
|     riga.put(TR("Imposta"),           53); |     riga.put(TR("Imposta"),           53); | ||||||
|   riga.put(TR("Imponibile diff."), 84); |     if (flags & 0x1) | ||||||
|   riga.put(TR("Imposta diff."),   109); |     { | ||||||
|  |       riga.put(TR("Imponibile"),        68); | ||||||
|  |       riga.put(TR("Imposta"),           87); | ||||||
|  |     } | ||||||
|  |     if (flags & 0x2) | ||||||
|  |     { | ||||||
|  |       riga.put(TR("Imponibile"),       102); | ||||||
|  |       riga.put(TR("Imposta"),          121); | ||||||
|  |     } | ||||||
|     pr.print(riga); |     pr.print(riga); | ||||||
| 
 | 
 | ||||||
|   real tot_imponib, tot_imposta, tot_imponibp, tot_impostap; |     real tot_imponib0, tot_imposta0, tot_imponib1, tot_imposta1, tot_imponib2, tot_imposta2; | ||||||
|   _riga_prospettoXcassa.sort(compare_righeiva); |     _riga_prospettoXcassa.sort(compare_rows); | ||||||
|     for (int s = 0; s < _riga_prospettoXcassa.items(); s++) |     for (int s = 0; s < _riga_prospettoXcassa.items(); s++) | ||||||
|     { |     { | ||||||
|     const TRigaiva& ri = _riga_prospettoXcassa.riga(s); |       const TRiga& ri = _riga_prospettoXcassa.riga(s); | ||||||
| 
 | 
 | ||||||
|       riga.reset(); |       riga.reset(); | ||||||
|       riga.put(ri._codiva,               0); |       riga.put(ri._codiva,               0); | ||||||
|       riga.put(descr_iva(ri._codiva),    5); |       riga.put(descr_iva(ri._codiva),    5); | ||||||
|       print_real(riga, ri._imponibile,  29); |       print_real(riga, ri._imponibile,  29); | ||||||
|       print_real(riga, ri._imposta,     45); |       print_real(riga, ri._imposta,     45); | ||||||
|     print_real(riga, ri._imponibilep,85); |       if (flags & 0x1) | ||||||
|     print_real(riga, ri._impostap,  107); |       { | ||||||
|  |         print_real(riga, ri._implordo,    63); | ||||||
|  |         print_real(riga, ri._imponibilep, 79); | ||||||
|  |       } | ||||||
|  |       if (flags & 0x2) | ||||||
|  |       { | ||||||
|  |         print_real(riga, ri._impostap,    97); | ||||||
|  |         print_real(riga, ri._implordop,  113); | ||||||
|  |       } | ||||||
|       pr.print(riga); |       pr.print(riga); | ||||||
| 
 | 
 | ||||||
|     tot_imponib += ri._imponibile; |       tot_imponib0 += ri._imponibile; | ||||||
|     tot_imposta += ri._imposta; |       tot_imposta0 += ri._imposta; | ||||||
|     tot_imponibp+= ri._imponibilep; |       tot_imponib1 += ri._implordo; | ||||||
|     tot_impostap+= ri._impostap; |       tot_imposta1 += ri._imponibilep; | ||||||
|  |       tot_imponib2 += ri._impostap; | ||||||
|  |       tot_imposta2 += ri._implordop; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     riga.reset(); |     riga.reset(); | ||||||
|     pr.print(riga); |     pr.print(riga); | ||||||
|   riga.put(TR("TOTALE"), 0); |     riga.put(TR("TOTALI"), 0); | ||||||
|   print_real(riga, tot_imponib,  29); |     print_real(riga, tot_imponib0,  29); | ||||||
|   print_real(riga, tot_imposta,  45); |     print_real(riga, tot_imposta0,  45); | ||||||
|   print_real(riga, tot_imponibp, 85); |     if (flags & 0x1) | ||||||
|   print_real(riga, tot_impostap,107); |     { | ||||||
|  |       print_real(riga, tot_imponib1,  63); | ||||||
|  |       print_real(riga, tot_imposta1,  79); | ||||||
|  |     } | ||||||
|  |     if (flags & 0x2) | ||||||
|  |     { | ||||||
|  |       print_real(riga, tot_imponib2,  97); | ||||||
|  |       print_real(riga, tot_imposta2, 113); | ||||||
|  |     } | ||||||
|     pr.print(riga); |     pr.print(riga); | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   _riga_prospettoXcassa.destroy(); |   _riga_prospettoXcassa.destroy(); | ||||||
|    |    | ||||||
| @ -2228,7 +2297,7 @@ bool TStampa_registri_app::preprocess_page(int file, int counter) | |||||||
|       if (ocfpi.empty()) |       if (ocfpi.empty()) | ||||||
|       { |       { | ||||||
|         TRectype dep = ricerca_cf(tipocf, codcf); |         TRectype dep = ricerca_cf(tipocf, codcf); | ||||||
|         ragsoc = dep.get (CLI_RAGSOC); |         ragsoc = dep.get (CLI_RAGSOC); ragsoc.strip_double_spaces(); | ||||||
|         viacf  = dep.get (CLI_INDCF); |         viacf  = dep.get (CLI_INDCF); | ||||||
|         civcf  = dep.get (CLI_CIVCF); |         civcf  = dep.get (CLI_CIVCF); | ||||||
|         capcf  = dep.get (CLI_CAPCF); |         capcf  = dep.get (CLI_CAPCF); | ||||||
| @ -2248,7 +2317,7 @@ bool TStampa_registri_app::preprocess_page(int file, int counter) | |||||||
|           nome    = ragsoc.mid(30,20); |           nome    = ragsoc.mid(30,20); | ||||||
|           cognome.trim(); nome.trim(); |           cognome.trim(); nome.trim(); | ||||||
|           ragsoc = cognome; |           ragsoc = cognome; | ||||||
|           ragsoc << " " << nome; |           ragsoc << ' ' << nome; | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|       else |       else | ||||||
| @ -2522,19 +2591,36 @@ print_action TStampa_registri_app::postprocess_page (int file, int counter) | |||||||
|         _datareg = save_date; |         _datareg = save_date; | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       if (last_mov)  |       const int a_mese = _datareg.month(); | ||||||
|  |       int da_mese = 0; | ||||||
|  |       if (_frequiva == 'T') | ||||||
|  |       { | ||||||
|  |         if (a_mese % 3 == 0) | ||||||
|  |           da_mese = a_mese-2; | ||||||
|  |       } | ||||||
|  |       else | ||||||
|  |         da_mese = a_mese; | ||||||
|  |       if (da_mese > 0) | ||||||
|  |       { | ||||||
|  |         if (some_IVAxCassa(da_mese, a_mese)) | ||||||
|         { |         { | ||||||
|           printer().formfeed(); |           printer().formfeed(); | ||||||
|         print_IVAxCassa(_datareg.month()); |           print_IVAxCassa(da_mese, a_mese); | ||||||
|  |           da_mese = 0; // vieta ristampa!
 | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |           _riga_prospettoXcassa.destroy(); // Elimina comunque tracking movimenti 
 | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       if (_liquidazione)  |       if (_liquidazione)  | ||||||
|       { |       { | ||||||
|         if (!_st_liq[_datareg.month()] && stampo_liquidazione(_datareg.month())) |         if (!_st_liq[a_mese] && stampo_liquidazione(a_mese)) | ||||||
|         { |         { | ||||||
|           _st_liq[_datareg.month()] = true; |           _st_liq[a_mese] = true; | ||||||
|           if (_scelta == B0_settato) |           if (_scelta == B0_settato) | ||||||
|             liq_b0_settato(); |             liq_b0_settato(); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|           if (_scelta == prosegui_stampa || _scelta == prosegui_cal_stampa) |           if (_scelta == prosegui_stampa || _scelta == prosegui_cal_stampa) | ||||||
|           {   |           {   | ||||||
|             if (_t.exist()) |             if (_t.exist()) | ||||||
| @ -2907,7 +2993,8 @@ void TStampa_registri_app::liq_b0_settato() | |||||||
|   f.temp("rg"); |   f.temp("rg"); | ||||||
|   if (_tipo_stampa == prova) |   if (_tipo_stampa == prova) | ||||||
|     send_message('S', f, _datareg.month());  |     send_message('S', f, _datareg.month());  | ||||||
|   else send_message('s',f, _datareg.month());  |   else  | ||||||
|  |     send_message('s', f, _datareg.month());  | ||||||
| 
 | 
 | ||||||
|   if (f.exist()) |   if (f.exist()) | ||||||
|   { |   { | ||||||
| @ -2955,8 +3042,7 @@ void TStampa_registri_app::liq_other_case() | |||||||
|      // sarebbe necessario un ricalcolo progressivi per sicurezza.
 |      // sarebbe necessario un ricalcolo progressivi per sicurezza.
 | ||||||
|     if (ricalcola(_fino_a_mese) || calc_reg)  |     if (ricalcola(_fino_a_mese) || calc_reg)  | ||||||
|     { |     { | ||||||
|      TFilename app; |       TFilename app; app.temp();                  | ||||||
|      app.temp();                  |  | ||||||
|       int mese = _fino_a_mese;             |       int mese = _fino_a_mese;             | ||||||
|       //se la frequenza e' trimestrale
 |       //se la frequenza e' trimestrale
 | ||||||
|       //aggiusta il mese al trimestre a cui appartiene
 |       //aggiusta il mese al trimestre a cui appartiene
 | ||||||
| @ -3248,7 +3334,7 @@ void TStampa_registri_app::no_movimenti() | |||||||
| { | { | ||||||
|   TRecnotype rec = _tabreg->recno(); |   TRecnotype rec = _tabreg->recno(); | ||||||
|   _mov_empty = true;    |   _mov_empty = true;    | ||||||
|   int da, a; |   int da = 1, a = _fino_a_mese; | ||||||
|   if (_tipo_stampa == bollato || _tipo_stampa == rif_giornale) |   if (_tipo_stampa == bollato || _tipo_stampa == rif_giornale) | ||||||
|     da = 1; |     da = 1; | ||||||
|   if (_tipo_stampa == libro_unico) |   if (_tipo_stampa == libro_unico) | ||||||
| @ -3257,7 +3343,8 @@ void TStampa_registri_app::no_movimenti() | |||||||
|     da = _data_da.month(); |     da = _data_da.month(); | ||||||
|   if (_tipo_stampa == prova) |   if (_tipo_stampa == prova) | ||||||
|     a = _data_a.month(); |     a = _data_a.month(); | ||||||
|   else a = _fino_a_mese;    |   else  | ||||||
|  |     a = _fino_a_mese;    | ||||||
|      |      | ||||||
|   //RICALCOLO PROGRESSIVI per registro riepilogativo
 |   //RICALCOLO PROGRESSIVI per registro riepilogativo
 | ||||||
|   //il ricalcolo dei progressivi mensili viene sempre
 |   //il ricalcolo dei progressivi mensili viene sempre
 | ||||||
| @ -3288,15 +3375,11 @@ void TStampa_registri_app::no_movimenti() | |||||||
|     send_message(calc ? 'R' : 'C', app, calc ? a : mese); |     send_message(calc ? 'R' : 'C', app, calc ? a : mese); | ||||||
|   } |   } | ||||||
|      |      | ||||||
|   if (some_IVAxCassa()) |   if (some_IVAxCassa(da, a)) | ||||||
|   { |   { | ||||||
|     if (! printer().isopen()) |     if (! printer().isopen()) | ||||||
|       printer().open(); |       printer().open(); | ||||||
| 
 |     print_IVAxCassa(da, a); | ||||||
|     int mese = a;        |  | ||||||
|     if (_frequiva == 'T') |  | ||||||
|       mese += 2 - ((mese-1) % 3); |  | ||||||
|     print_IVAxCassa(mese); |  | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   if (_tipo_reg == riepilogativo || _liquidazione || _stampa_plafonds) |   if (_tipo_reg == riepilogativo || _liquidazione || _stampa_plafonds) | ||||||
| @ -3433,13 +3516,14 @@ void TStampa_registri_app::stampa_liq_mesi_succ() | |||||||
| 
 | 
 | ||||||
| void TStampa_registri_app::send_message(char tipo, const TFilename& nome, int mese) | void TStampa_registri_app::send_message(char tipo, const TFilename& nome, int mese) | ||||||
| { | { | ||||||
|   const char* app;  |   const char* app = "cg4 -2";  | ||||||
| 
 | 
 | ||||||
|   if (tipo == 'S' || tipo == 's') |   if (tipo == 'S' || tipo == 's') | ||||||
|     app = "cg4 -2 -S"; |     app = "cg4 -2 -S"; | ||||||
|   else if (tipo == 'C' || tipo == 'R') |   else if (tipo == 'C' || tipo == 'R') | ||||||
|     app = "cg4 -2 -C"; |     app = "cg4 -2 -C"; | ||||||
|   else app = "cg4 -2"; |   else  | ||||||
|  |     app = "cg4 -2"; | ||||||
| 
 | 
 | ||||||
|   TToken_string ss(36); |   TToken_string ss(36); | ||||||
|   ss.add(_annoes); |   ss.add(_annoes); | ||||||
| @ -3451,10 +3535,7 @@ void TStampa_registri_app::send_message(char tipo, const TFilename& nome, int me | |||||||
|   ss.add(tipo); |   ss.add(tipo); | ||||||
|   ss.add(_data_stampa.string());  |   ss.add(_data_stampa.string());  | ||||||
|   ss.add(nome);     |   ss.add(nome);     | ||||||
|   if (_riep_liq)   |   ss.add(_riep_liq ? 'X' : ' '); | ||||||
|     ss.add('X'); |  | ||||||
|   else ss.add(' '); |  | ||||||
| 
 |  | ||||||
|   ss.add(printer().formlen() - _size_header - RIGHE_FOOTER); |   ss.add(printer().formlen() - _size_header - RIGHE_FOOTER); | ||||||
|    |    | ||||||
|   TMessage liq (app, "RCL", ss); |   TMessage liq (app, "RCL", ss); | ||||||
| @ -3666,6 +3747,10 @@ bool TStampa_registri_app::stampa_registri_IVA(const TMask& m) | |||||||
|       }   |       }   | ||||||
|       else //stampa tutti i registri 
 |       else //stampa tutti i registri 
 | ||||||
|       {   |       {   | ||||||
|  |         _scelta = controlla_liquidazione(); | ||||||
|  |         if (_scelta == non_proseguire)  | ||||||
|  |           return false; | ||||||
|  | 
 | ||||||
|         TDate sca_vid; |         TDate sca_vid; | ||||||
|         bool one_printed = false; // Flag per vedere se ha stampato almeno un registro (solo per rif. al libro giornale)
 |         bool one_printed = false; // Flag per vedere se ha stampato almeno un registro (solo per rif. al libro giornale)
 | ||||||
|         for (_tabreg->first(); !_tabreg->eof(); _tabreg->next()) |         for (_tabreg->first(); !_tabreg->eof(); _tabreg->next()) | ||||||
| @ -3711,7 +3796,7 @@ bool TStampa_registri_app::stampa_registri_IVA(const TMask& m) | |||||||
|                   one_printed = true; |                   one_printed = true; | ||||||
|                 else  |                 else  | ||||||
|                   continue;  |                   continue;  | ||||||
|               } |               } else | ||||||
|               if (_tipo_stampa == libro_unico) //stampa su libro unico
 |               if (_tipo_stampa == libro_unico) //stampa su libro unico
 | ||||||
|               { |               { | ||||||
|                 if (cod_lib_un != _codlib) |                 if (cod_lib_un != _codlib) | ||||||
| @ -3747,7 +3832,8 @@ bool TStampa_registri_app::stampa_registri_IVA(const TMask& m) | |||||||
|               if (_liquidazione) |               if (_liquidazione) | ||||||
|               { |               { | ||||||
|                 _size_header = 3; |                 _size_header = 3; | ||||||
|                 if ((_tipo_stampa == bollato || _tipo_stampa == rif_giornale) && !_stampa_ind_ditta) _size_header++; |                 if ((_tipo_stampa == bollato || _tipo_stampa == rif_giornale) && !_stampa_ind_ditta)  | ||||||
|  |                   _size_header++; | ||||||
|                 clear_stliq(); |                 clear_stliq(); | ||||||
|                 //N.B. E' fondamentale che _scelta venga ri-inizializzata ad ogni
 |                 //N.B. E' fondamentale che _scelta venga ri-inizializzata ad ogni
 | ||||||
|                 //registro(cioe' dopo la stampa di ciascuno). Infatti il B0 di un
 |                 //registro(cioe' dopo la stampa di ciascuno). Infatti il B0 di un
 | ||||||
| @ -3806,9 +3892,11 @@ bool TStampa_registri_app::stampa_riepilogo(int m) | |||||||
|   TRiga_array vect, vect_prec;   |   TRiga_array vect, vect_prec;   | ||||||
|   TRigaiva_array vect_det; |   TRigaiva_array vect_det; | ||||||
|   bool stampato = false; |   bool stampato = false; | ||||||
|   if (!printer().isopen()) printer().open(); |   if (!printer().isopen())  | ||||||
|  |     printer().open(); | ||||||
| 
 | 
 | ||||||
|   for (_tabreg->first(); !_tabreg->eof(); _tabreg->next()) // Scorre i registri
 |   _tabreg->put("CODTAB", _annoes); | ||||||
|  |   for (int err = _tabreg->read(_isgteq); err == NOERR; err = _tabreg->next()) // Scorre i registri
 | ||||||
|   { |   { | ||||||
|     const TString8 codtab = _tabreg->get("CODTAB"); |     const TString8 codtab = _tabreg->get("CODTAB"); | ||||||
|     const int a = atoi(codtab.mid(0,4)); |     const int a = atoi(codtab.mid(0,4)); | ||||||
|  | |||||||
| @ -35,10 +35,9 @@ class TStampa_registri_app : public TPrintapp | |||||||
| { | { | ||||||
|   TSorted_cursor * _cur; |   TSorted_cursor * _cur; | ||||||
|   TRelation      *_rel, *_nditte; |   TRelation      *_rel, *_nditte; | ||||||
| //  TLocalisamfile *_clifo, *_occas, *_com, *_anag, *_unloc, *_attiv, *_indlib;
 |  | ||||||
| // TTable         *_tablia, *_tabpim, *_tabprm, *_tabprp, *_table; 
 |  | ||||||
|   TTable         *_tabreg; |   TTable         *_tabreg; | ||||||
|   TRigaiva_array _iva_array, _riga_rmi, _riga_prospettoXcassa; |   TRigaiva_array _iva_array, _riga_rmi; | ||||||
|  |   TRiga_array    _riga_prospettoXcassa; | ||||||
|   TTipodoc_array _doc_array;      |   TTipodoc_array _doc_array;      | ||||||
|   TRiga_array    _tot_iva_array, _tot_prec_iva_array; |   TRiga_array    _tot_iva_array, _tot_prec_iva_array; | ||||||
|   TBit_array     _selected; |   TBit_array     _selected; | ||||||
| @ -147,8 +146,8 @@ public: | |||||||
|   int           stampa_acquisti(int); |   int           stampa_acquisti(int); | ||||||
|   real          stampa_valori_plafonds(const real&, const int, TTable&, const char*); |   real          stampa_valori_plafonds(const real&, const int, TTable&, const char*); | ||||||
| 
 | 
 | ||||||
|   bool          some_IVAxCassa() const;  // C'e' IVA per cassa o differita da stampare?
 |   bool          some_IVAxCassa(int da_month, int a_month) const;  // C'e' IVA per cassa o differita da stampare?
 | ||||||
|   bool          print_IVAxCassa(int month); |   bool          print_IVAxCassa(int da_month, int a_month); | ||||||
| 
 | 
 | ||||||
|   void          build_nomiditte(TProgind* pnd = NULL); |   void          build_nomiditte(TProgind* pnd = NULL); | ||||||
|   void          set_year(int y) { _annoes = y; } |   void          set_year(int y) { _annoes = y; } | ||||||
|  | |||||||
| @ -116,8 +116,9 @@ public: | |||||||
|    |    | ||||||
|   void set_prorata(int annodoc, const real& pro); |   void set_prorata(int annodoc, const real& pro); | ||||||
|   real prorata(int annodoc); |   real prorata(int annodoc); | ||||||
|   bool prorata100(int annodoc) { return prorata(annodoc) >= 100.0; } | #ifdef PRORATA100 | ||||||
|    |   bool prorata100(int annodoc) { return prorata(annodoc) >= CENTO; } | ||||||
|  | #endif   | ||||||
|   bool update(long uprotiva, const TDate& lastreg); |   bool update(long uprotiva, const TDate& lastreg); | ||||||
| 
 | 
 | ||||||
|   TRegistro(const char* code = "", int year = 0);   |   TRegistro(const char* code = "", int year = 0);   | ||||||
|  | |||||||
| @ -42,12 +42,14 @@ real indetraibile_al(const TString& codind, const TCausale& caus, int annodoc, i | |||||||
|   case iva_acquisti: |   case iva_acquisti: | ||||||
|   case nessuna_iva: |   case nessuna_iva: | ||||||
|   case iva_errata:  |   case iva_errata:  | ||||||
|  | #ifdef PRORATA100 | ||||||
| 	  if (!is_liq && caus.reg().prorata100(annodoc)) // Se prorata = 100% e' indetraibile
 | 	  if (!is_liq && caus.reg().prorata100(annodoc)) // Se prorata = 100% e' indetraibile
 | ||||||
| 	  { | 	  { | ||||||
| 		  perc = CENTO; | 		  perc = CENTO; | ||||||
| 		  tipodet = 9; | 		  tipodet = 9; | ||||||
| 	  } | 	  } | ||||||
| 	  else | 	  else | ||||||
|  | #endif | ||||||
| 		tipodet = codind2tipodet(codind, perc); | 		tipodet = codind2tipodet(codind, perc); | ||||||
|     break; |     break; | ||||||
|   default:  |   default:  | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user