Patch level : 10.0 410
Files correlati : cg4.exe Ricompilazione Demo : [ ] Commento IVA per cassa con saldaconto git-svn-id: svn://10.65.10.50/trunk@19227 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									4921dd1b12
								
							
						
					
					
						commit
						1ceb9c0708
					
				
							
								
								
									
										181
									
								
								cg/cg4301.cpp
									
									
									
									
									
								
							
							
						
						
									
										181
									
								
								cg/cg4301.cpp
									
									
									
									
									
								
							@ -5,11 +5,13 @@
 | 
				
			|||||||
// ------------------------------------------------------------
 | 
					// ------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <config.h>
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					#include <modaut.h>
 | 
				
			||||||
#include <recarray.h> 
 | 
					#include <recarray.h> 
 | 
				
			||||||
#include <progind.h>              
 | 
					#include <progind.h>              
 | 
				
			||||||
#include <sheet.h>
 | 
					#include <sheet.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "cg4300.h"
 | 
					#include "cg4300.h"
 | 
				
			||||||
 | 
					#include "cgsaldac.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <nditte.h>
 | 
					#include <nditte.h>
 | 
				
			||||||
#include <attiv.h>
 | 
					#include <attiv.h>
 | 
				
			||||||
@ -564,6 +566,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
 | 
				
			|||||||
  // occhecasino. Se _comp_acconto e' TRUE, i movimenti considerati
 | 
					  // occhecasino. Se _comp_acconto e' TRUE, i movimenti considerati
 | 
				
			||||||
  // saranno solo quelli di dicembre per data <= 20/12; 
 | 
					  // saranno solo quelli di dicembre per data <= 20/12; 
 | 
				
			||||||
{ 
 | 
					{ 
 | 
				
			||||||
 | 
						const bool has_sc = has_module(SCAUT, CHK_DONGLE);
 | 
				
			||||||
  real totintra         = ZERO;
 | 
					  real totintra         = ZERO;
 | 
				
			||||||
  real nond19_imp       = ZERO;
 | 
					  real nond19_imp       = ZERO;
 | 
				
			||||||
  real nond19_iva       = ZERO;
 | 
					  real nond19_iva       = ZERO;
 | 
				
			||||||
@ -743,10 +746,14 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
 | 
				
			|||||||
    t.set_month(month < 12 ? 12 : _freqviva == "M" ? 1 : 3);
 | 
					    t.set_month(month < 12 ? 12 : _freqviva == "M" ? 1 : 3);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  t.set_end_month();
 | 
					  t.set_end_month();
 | 
				
			||||||
 | 
						TDate inizio(f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						--inizio;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	TDate todate(1, month == 13 ? 12 : month, year_int);
 | 
						TDate todate(1, month == 13 ? 12 : month, year_int);
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	todate.set_end_month();
 | 
						todate.set_end_month();
 | 
				
			||||||
 | 
						const TDate fine(todate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  from.put(MOV_REG, fromreg);
 | 
					  from.put(MOV_REG, fromreg);
 | 
				
			||||||
  to.put(MOV_REG, toreg);
 | 
					  to.put(MOV_REG, toreg);
 | 
				
			||||||
@ -811,8 +818,6 @@ 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");
 | 
				
			||||||
		const bool movdiff = _isdiff && _mov->get_bool(MOV_LIQDIFF);
 | 
							const bool movdiff = _isdiff && _mov->get_bool(MOV_LIQDIFF);
 | 
				
			||||||
	//	if (movdiff)
 | 
					 | 
				
			||||||
	//		int i = 1;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		TDate datainc = _mov->get_date(MOV_DATAINC);
 | 
							TDate datainc = _mov->get_date(MOV_DATAINC);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -837,7 +842,46 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
 | 
				
			|||||||
		if (diffpayed)
 | 
							if (diffpayed)
 | 
				
			||||||
      date = datainc;
 | 
					      date = datainc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		const bool dok = is_date_ok(date, month, liqmonth, year_int); 
 | 
					  	real pagatt;
 | 
				
			||||||
 | 
							real totfat;
 | 
				
			||||||
 | 
							TImporto pagprec;
 | 
				
			||||||
 | 
							TImporto pag;
 | 
				
			||||||
 | 
							bool dok = is_date_ok(date, month, liqmonth, year_int); 
 | 
				
			||||||
 | 
							TPartite_array arrpart;
 | 
				
			||||||
 | 
							const long numreg = _mov->get_long(MOV_NUMREG);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (has_sc && movdiff)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								arrpart.add_numreg(numreg);
 | 
				
			||||||
 | 
								if (arrpart.utilizzata(numreg, 1))
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									const int items = arrpart.items();
 | 
				
			||||||
 | 
									const char sez = (tipomov == vendita ? 'A' : 'D');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									for (TPartita * p = arrpart.first(); p != NULL; p = arrpart.next())
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										int row = p->mov2rig(numreg, 1);
 | 
				
			||||||
 | 
										
 | 
				
			||||||
 | 
										if (row >= 0)
 | 
				
			||||||
 | 
										{
 | 
				
			||||||
 | 
											TRiga_partite rp = p->riga(row);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											totfat += rp.get_real(PART_IMPORTO);
 | 
				
			||||||
 | 
											pagprec += rp.calcola_pagato_al(false, inizio, inizio, inizio, 9); pagprec.normalize(sez);
 | 
				
			||||||
 | 
											pag += rp.calcola_pagato_al(false, fine, fine, fine, 9); pag.normalize(sez);
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
									if ((diffpayed && dok) || (pag.valore() > totfat))
 | 
				
			||||||
 | 
										pag.set(sez, totfat);
 | 
				
			||||||
 | 
									pagatt = pag.valore() - pagprec.valore();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if (pagatt > ZERO)
 | 
				
			||||||
 | 
										dok = true;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/*
 | 
							/*
 | 
				
			||||||
     * check register present, rmoviva present and date OK
 | 
					     * check register present, rmoviva present and date OK
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@ -885,7 +929,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    do
 | 
					    do
 | 
				
			||||||
    {     
 | 
					    {     
 | 
				
			||||||
      int tipoatt= _rmoviva->get_int(RMI_TIPOATT);
 | 
					      int tipoatt = _rmoviva->get_int(RMI_TIPOATT);
 | 
				
			||||||
      /*
 | 
					      /*
 | 
				
			||||||
       * puo' capitare per motivi brutalmente prassici
 | 
					       * puo' capitare per motivi brutalmente prassici
 | 
				
			||||||
       * SENSU Sergio 1995, Guido
 | 
					       * SENSU Sergio 1995, Guido
 | 
				
			||||||
@ -949,20 +993,129 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
 | 
				
			|||||||
			real impon_det;								 // Imponibile detraibile
 | 
								real impon_det;								 // Imponibile detraibile
 | 
				
			||||||
			real impos_det;								 // Imposta detraibile
 | 
								real impos_det;								 // Imposta detraibile
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (difftopay)
 | 
								if (pagatt > ZERO)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				diff_imp = imponibile_orig;
 | 
									if (pag.valore() >= totfat)
 | 
				
			||||||
				diff_iva = imposta_orig;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				if (diffpayed)
 | 
					 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					incdiff_imp = imponibile_orig;
 | 
								    TDate from(_mov->get(MOV_DATAREG));
 | 
				
			||||||
					incdiff_iva = imposta_orig;
 | 
										real impprec;
 | 
				
			||||||
 | 
										real ivaprec;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										if (month < 13)
 | 
				
			||||||
 | 
										{
 | 
				
			||||||
 | 
											TDate to(inizio);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											from.set_day(1);
 | 
				
			||||||
 | 
											--from;
 | 
				
			||||||
 | 
											while (from < to)
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												TDate endp(from);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
												if (_freqviva == "M")
 | 
				
			||||||
 | 
													endp.addmonth();
 | 
				
			||||||
 | 
												else
 | 
				
			||||||
 | 
													endp.set_month((endp.month() / 3 + 1) * 3);
 | 
				
			||||||
 | 
												endp.set_end_month();
 | 
				
			||||||
 | 
												if (arrpart.utilizzata(numreg, 1))
 | 
				
			||||||
 | 
												{
 | 
				
			||||||
 | 
													const int items = arrpart.items();
 | 
				
			||||||
 | 
													const char sez = (tipomov == vendita ? 'A' : 'D');
 | 
				
			||||||
 | 
													TImporto pagtmp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
													for (TPartita * p = arrpart.first(); p != NULL; p = arrpart.next())
 | 
				
			||||||
 | 
													{
 | 
				
			||||||
 | 
														int row = p->mov2rig(numreg, 1);
 | 
				
			||||||
 | 
														
 | 
				
			||||||
 | 
														if (row >= 0)
 | 
				
			||||||
 | 
														{
 | 
				
			||||||
 | 
															TRiga_partite rp = p->riga(row);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
															pagtmp += rp.calcola_pagato_al(false, endp, endp, endp, 9);
 | 
				
			||||||
 | 
															pagtmp -= rp.calcola_pagato_al(false, from, from, from, 9);
 | 
				
			||||||
 | 
															pagtmp.normalize(sez);
 | 
				
			||||||
 | 
														}
 | 
				
			||||||
 | 
													}
 | 
				
			||||||
 | 
													if (!pagtmp.is_zero())
 | 
				
			||||||
 | 
													{
 | 
				
			||||||
 | 
														real perc = pagtmp.valore() / totfat;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
														real imp = imponibile_orig * perc;
 | 
				
			||||||
 | 
														real iva = imposta_orig * perc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
														imp.round(TCurrency::get_firm_dec());
 | 
				
			||||||
 | 
														impprec += imp;
 | 
				
			||||||
 | 
					  								iva.round(TCurrency::get_firm_dec());
 | 
				
			||||||
 | 
														ivaprec += iva;
 | 
				
			||||||
 | 
													}
 | 
				
			||||||
 | 
													from = endp;
 | 
				
			||||||
 | 
												}
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										else
 | 
				
			||||||
 | 
										{
 | 
				
			||||||
 | 
											if (from.year() != fromdate.year())
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												if (arrpart.utilizzata(numreg, 1))
 | 
				
			||||||
 | 
												{
 | 
				
			||||||
 | 
													TDate to(31,12, from.year());
 | 
				
			||||||
 | 
													const int items = arrpart.items();
 | 
				
			||||||
 | 
													const char sez = (tipomov == vendita ? 'A' : 'D');
 | 
				
			||||||
 | 
													TImporto pagtmp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
													for (TPartita * p = arrpart.first(); p != NULL; p = arrpart.next())
 | 
				
			||||||
 | 
													{
 | 
				
			||||||
 | 
														int row = p->mov2rig(numreg, 1);
 | 
				
			||||||
 | 
														
 | 
				
			||||||
 | 
														if (row >= 0)
 | 
				
			||||||
 | 
														{
 | 
				
			||||||
 | 
															TRiga_partite rp = p->riga(row);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
															pagtmp += rp.calcola_pagato_al(false, to, to, to, 9);
 | 
				
			||||||
 | 
															pagtmp.normalize(sez);
 | 
				
			||||||
 | 
														}
 | 
				
			||||||
 | 
													}
 | 
				
			||||||
 | 
													if (!pagtmp.is_zero())
 | 
				
			||||||
 | 
													{
 | 
				
			||||||
 | 
														real perc = pagtmp.valore() / totfat;
 | 
				
			||||||
 | 
														real imp = imponibile_orig * perc;
 | 
				
			||||||
 | 
														real iva = imposta_orig * perc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
														imp.round(TCurrency::get_firm_dec());
 | 
				
			||||||
 | 
														impprec = imp;
 | 
				
			||||||
 | 
					  								iva.round(TCurrency::get_firm_dec());
 | 
				
			||||||
 | 
														ivaprec = iva;
 | 
				
			||||||
 | 
													}
 | 
				
			||||||
 | 
												}
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										incdiff_imp = imponibile_orig - impprec;
 | 
				
			||||||
 | 
										incdiff_iva = imposta_orig - ivaprec;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				else
 | 
									else
 | 
				
			||||||
					analizza_IVA(imponibile_orig, imposta_orig, percind, corrisp, false, codiva,
 | 
									{
 | 
				
			||||||
			                 impon_det, impos_det, impon_ind, impos_ind);
 | 
										real perc = pagatt / totfat;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										incdiff_imp = imponibile_orig * perc;
 | 
				
			||||||
 | 
										incdiff_imp.round(TCurrency::get_firm_dec());
 | 
				
			||||||
 | 
										incdiff_iva = imposta_orig * perc;
 | 
				
			||||||
 | 
					  				incdiff_iva.round(TCurrency::get_firm_dec());
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
									if (difftopay)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										diff_imp = imponibile_orig;
 | 
				
			||||||
 | 
										diff_iva = imposta_orig;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									else
 | 
				
			||||||
 | 
										if (diffpayed)
 | 
				
			||||||
 | 
										{
 | 
				
			||||||
 | 
											incdiff_imp = imponibile_orig;
 | 
				
			||||||
 | 
											incdiff_iva = imposta_orig;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										else
 | 
				
			||||||
 | 
											analizza_IVA(imponibile_orig, imposta_orig, percind, corrisp, false, codiva,
 | 
				
			||||||
 | 
																	 impon_det, impos_det, impon_ind, impos_ind);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// qui
 | 
					// qui
 | 
				
			||||||
			for (int is_detraibile = 0; is_detraibile < 2; is_detraibile++)
 | 
								for (int is_detraibile = 0; is_detraibile < 2; is_detraibile++)
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										174
									
								
								cg/cgsaldac.cpp
									
									
									
									
									
								
							
							
						
						
									
										174
									
								
								cg/cgsaldac.cpp
									
									
									
									
									
								
							@ -315,6 +315,60 @@ bool TRiga_scadenze::chiusa(bool update) const
 | 
				
			|||||||
  return chiusa;  
 | 
					  return chiusa;  
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Calcola il totale dei pagamenti alla data (eventualmente in valuta)
 | 
				
			||||||
 | 
					TImporto TRiga_scadenze::importo_pagato_al(bool val, const TDate & al, int mode) const
 | 
				
			||||||
 | 
					{                                
 | 
				
			||||||
 | 
					  CHECKD(mode > 0x0 && mode <= 0xFF, "Bad importo_pagato mode ", mode);
 | 
				
			||||||
 | 
					  const TPartita& game = partita();
 | 
				
			||||||
 | 
					  const bool in_val = in_valuta();   
 | 
				
			||||||
 | 
					  const char* imp_field = (val && in_val) ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  TImporto totale;
 | 
				
			||||||
 | 
					  for (int p = last(); p > 0; p = pred(p))
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    const TRectype& pag = row(p);                         // Riga pagamento
 | 
				
			||||||
 | 
					    const TRiga_partite& sum = game.riga(p);              // Riga partite
 | 
				
			||||||
 | 
							const TDate & datapag = sum.get_date(PART_DATAPAG);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (datapag <= al)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								const char sez = sum.sezione();
 | 
				
			||||||
 | 
						    
 | 
				
			||||||
 | 
								if (mode & 0x1)              
 | 
				
			||||||
 | 
									totale += TImporto(sez, pag.get_real(imp_field));
 | 
				
			||||||
 | 
								if (!in_val && (mode & 0x8))      // Le ritenute non esistono nei pagamenti in valuta
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									totale += TImporto(sez, pag.get_real(PAGSCA_RITENUTE));
 | 
				
			||||||
 | 
									totale += TImporto(sum.sezione_ritsoc(), pag.get_real(PAGSCA_RITSOC));
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
						    
 | 
				
			||||||
 | 
								if (mode & 0x2)                   // Voglio anche gli abbuoni
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									real abb = pag.get_real(PAGSCA_ABBUONI);
 | 
				
			||||||
 | 
									if (!abb.is_zero())
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										if (in_val && !val)             // Gli abbuoni sono sempre in valuta e quindi
 | 
				
			||||||
 | 
										{                               // devono essere convertiti opportunamente
 | 
				
			||||||
 | 
											const TExchange cmb(sum);
 | 
				
			||||||
 | 
											TCurrency cur(abb, cmb);
 | 
				
			||||||
 | 
											cur.change_to_firm_val();
 | 
				
			||||||
 | 
											abb = cur.get_num();
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										totale += TImporto(sez, abb);
 | 
				
			||||||
 | 
									}  
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
						    
 | 
				
			||||||
 | 
								if (in_val && !val && (mode & 0x4))   // Voglio anche le differenze cambio
 | 
				
			||||||
 | 
								{                                     // Esse esistono solo nei pagamenti in valuta
 | 
				
			||||||
 | 
									const TImporto diffcam(sez, pag.get_real(PAGSCA_DIFFCAM));
 | 
				
			||||||
 | 
									totale += diffcam;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					  }  
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  return totale.normalize();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Calcola il totale dei pagamenti (eventualmente in valuta)
 | 
					// Calcola il totale dei pagamenti (eventualmente in valuta)
 | 
				
			||||||
TImporto TRiga_scadenze::importo_pagato(bool val, int mode) const
 | 
					TImporto TRiga_scadenze::importo_pagato(bool val, int mode) const
 | 
				
			||||||
{                                
 | 
					{                                
 | 
				
			||||||
@ -466,6 +520,45 @@ TImporto TRiga_scadenze::residuo(bool val, int mode) const
 | 
				
			|||||||
  return residuo;
 | 
					  return residuo;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TImporto TRiga_scadenze::esposto_al(bool valuta, const TDate & al, const TDate & data_scad, const TDate & data_rischio, bool & sbf) const
 | 
				
			||||||
 | 
					{        
 | 
				
			||||||
 | 
					  TImporto esposto;
 | 
				
			||||||
 | 
					  const bool rischio = data_scad != data_rischio; 
 | 
				
			||||||
 | 
						TDate data(get(SCAD_DATASCAD));
 | 
				
			||||||
 | 
						const int lasts = last();
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					  sbf = false;
 | 
				
			||||||
 | 
						for (int p = first(); p <= lasts; p = succ(p)) 
 | 
				
			||||||
 | 
						{            
 | 
				
			||||||
 | 
							const TRiga_partite & pag = riga().partita().riga(p);
 | 
				
			||||||
 | 
							TDate datapag = pag.get_date(PART_DATAPAG);
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							if (data.ok() && datapag > data)
 | 
				
			||||||
 | 
								datapag = data;
 | 
				
			||||||
 | 
							if (datapag <= al)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								const int tp = pag.get_int(PART_TIPOPAG);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (tp >= 2 && tp <= 7)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									const char sez = pag.sezione();
 | 
				
			||||||
 | 
									const TImporto imp(sez, pag.get_real(valuta ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO));
 | 
				
			||||||
 | 
									
 | 
				
			||||||
 | 
									if (rischio && datapag > data_rischio && datapag <= data_scad)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										esposto += imp; 
 | 
				
			||||||
 | 
										sbf = true;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									else
 | 
				
			||||||
 | 
										if (datapag > data_scad)
 | 
				
			||||||
 | 
											esposto += imp;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						} 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return esposto;    
 | 
				
			||||||
 | 
					} 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TImporto TRiga_scadenze::esposto(bool valuta, const TDate & data_scad, const TDate & data_rischio, bool & sbf) const
 | 
					TImporto TRiga_scadenze::esposto(bool valuta, const TDate & data_scad, const TDate & data_rischio, bool & sbf) const
 | 
				
			||||||
{        
 | 
					{        
 | 
				
			||||||
  TImporto esposto;
 | 
					  TImporto esposto;
 | 
				
			||||||
@ -486,7 +579,7 @@ TImporto TRiga_scadenze::esposto(bool valuta, const TDate & data_scad, const TDa
 | 
				
			|||||||
			TDate datapag(pag.get(PART_DATAPAG));
 | 
								TDate datapag(pag.get(PART_DATAPAG));
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
			if (data.ok() && datapag > data)
 | 
								if (data.ok() && datapag > data)
 | 
				
			||||||
				datapag = datapag;
 | 
									datapag = data; // controllo
 | 
				
			||||||
			if (rischio && datapag > data_rischio && datapag <= data_scad)
 | 
								if (rischio && datapag > data_rischio && datapag <= data_scad)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				esposto += imp; 
 | 
									esposto += imp; 
 | 
				
			||||||
@ -925,7 +1018,7 @@ TImporto TRiga_partite::esposto(bool valuta, const TDate & data_scad, const TDat
 | 
				
			|||||||
    if (rischio && datapag > data_rischio && datapag <= data_scad)
 | 
					    if (rischio && datapag > data_rischio && datapag <= data_scad)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      esposto += imp; 
 | 
					      esposto += imp; 
 | 
				
			||||||
      sbf = TRUE;
 | 
					      sbf = true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
      if (datapag > data_scad)
 | 
					      if (datapag > data_scad)
 | 
				
			||||||
@ -934,6 +1027,33 @@ TImporto TRiga_partite::esposto(bool valuta, const TDate & data_scad, const TDat
 | 
				
			|||||||
  return esposto;    
 | 
					  return esposto;    
 | 
				
			||||||
} 
 | 
					} 
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
 | 
					TImporto TRiga_partite::calcola_pagato_al(bool valuta,const TDate& al, const TDate & data_scaduto, const TDate& data_rischio, int mode) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TImporto pagato;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  if (is_fattura())
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
							const int nrigp = get_int(PART_NRIGA);
 | 
				
			||||||
 | 
							const char sez = sezione();
 | 
				
			||||||
 | 
							const bool rischio = data_scaduto != data_rischio; 
 | 
				
			||||||
 | 
							const int lastr = rate();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							for (int r = lastr; r > 0; r--)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								const TRiga_scadenze& scad = rata(r);
 | 
				
			||||||
 | 
								const TImporto pag = scad.importo_pagato_al(valuta, al, mode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								pagato += pag;
 | 
				
			||||||
 | 
								if (!pag.is_zero() && rischio)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									bool sbf = false;
 | 
				
			||||||
 | 
									pagato -= scad.esposto_al(valuta, al, data_scaduto, data_rischio, sbf);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					  }  
 | 
				
			||||||
 | 
					  return pagato;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
///////////////////////////////////////////////////////////
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
// TPartita
 | 
					// TPartita
 | 
				
			||||||
///////////////////////////////////////////////////////////
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
@ -1562,6 +1682,7 @@ void TPartita::calcola_saldo(TImporto& saldo, TImporto& doc, TImporto& pag, TImp
 | 
				
			|||||||
TImporto TPartita::calcola_saldo(bool valuta) const
 | 
					TImporto TPartita::calcola_saldo(bool valuta) const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  TImporto saldo;
 | 
					  TImporto saldo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (int r = last(); r > 0; r = pred(r))
 | 
					  for (int r = last(); r > 0; r = pred(r))
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    const TRiga_partite& row = riga(r);
 | 
					    const TRiga_partite& row = riga(r);
 | 
				
			||||||
@ -1570,45 +1691,40 @@ TImporto TPartita::calcola_saldo(bool valuta) const
 | 
				
			|||||||
  return saldo;
 | 
					  return saldo;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TImporto TPartita::calcola_saldo_al(bool valuta,const TDate& al, const TDate & data_scaduto, const TDate& data_rischio) const
 | 
					TImporto TPartita::calcola_pagato_al(bool valuta,const TDate& al, const TDate & data_scaduto, const TDate& data_rischio) const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  TImporto saldo;
 | 
					  TImporto pagato;
 | 
				
			||||||
//   const bool calcolo_rischio = data_rischio.ok();
 | 
					 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  for (int r = last(); r > 0; r = pred(r))
 | 
					  for (int r = last(); r > 0; r = pred(r))
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    const TRiga_partite& row = riga(r);
 | 
					    const TRiga_partite& row = riga(r);
 | 
				
			||||||
/* vecchia implementazione
 | 
					    const TDate data(row.get(PART_DATAREG));
 | 
				
			||||||
    if (row.is_fattura())
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      for (int s = row.rate(); s > 0 ;s--)
 | 
					 | 
				
			||||||
      {
 | 
					 | 
				
			||||||
        const TRiga_scadenze & rata = row.rata(s);
 | 
					 | 
				
			||||||
        const TDate data(rata.get(SCAD_DATASCAD));
 | 
					 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        if (data <= al)
 | 
					        if (data <= al)
 | 
				
			||||||
         saldo += rata.importo(valuta);
 | 
					 | 
				
			||||||
      }  
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      const TDate data = row.get(PART_DATAPAG); 
 | 
					      pagato += row.importo(valuta);
 | 
				
			||||||
      if (calcolo_rischio)
 | 
								if (!row.is_fattura())
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        const int tipopag = row.get_int(PART_TIPOPAG);
 | 
					        const int tipopag = row.get_int(PART_TIPOPAG);
 | 
				
			||||||
        if (tipopag < 2 || tipopag > 7)
 | 
					
 | 
				
			||||||
 | 
									if (tipopag >= 2 && tipopag <= 7)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          if (data <= al)
 | 
										bool sbf = false;
 | 
				
			||||||
            saldo += row.importo(valuta);
 | 
										pagato -= row.esposto(valuta, data_scaduto, data_rischio, sbf);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else
 | 
					 | 
				
			||||||
          if (data <= data_rischio)
 | 
					 | 
				
			||||||
            saldo += row.importo(valuta);
 | 
					 | 
				
			||||||
      }    
 | 
					      }    
 | 
				
			||||||
      else
 | 
					    }
 | 
				
			||||||
        if (data <= al)
 | 
					  }  
 | 
				
			||||||
          saldo += row.importo(valuta);
 | 
					  return pagato;
 | 
				
			||||||
*/        
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TImporto TPartita::calcola_saldo_al(bool valuta,const TDate& al, const TDate & data_scaduto, const TDate& data_rischio) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TImporto saldo;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  for (int r = last(); r > 0; r = pred(r))
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    const TRiga_partite& row = riga(r);
 | 
				
			||||||
    const TDate data(row.get(PART_DATAREG));
 | 
					    const TDate data(row.get(PART_DATAREG));
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    if (data <= al)
 | 
					    if (data <= al)
 | 
				
			||||||
@ -2166,4 +2282,4 @@ TRiga_partite* TPartite_array::mov2rig(long numreg, int numrig)
 | 
				
			|||||||
      return &game->riga(r);
 | 
					      return &game->riga(r);
 | 
				
			||||||
  }            
 | 
					  }            
 | 
				
			||||||
  return NULL;
 | 
					  return NULL;
 | 
				
			||||||
}        
 | 
					}        
 | 
				
			||||||
 | 
				
			|||||||
@ -143,9 +143,11 @@ public:
 | 
				
			|||||||
  TPartita& partita() const;
 | 
					  TPartita& partita() const;
 | 
				
			||||||
  TRiga_partite& riga() const { return *_riga; } // Riga partite
 | 
					  TRiga_partite& riga() const { return *_riga; } // Riga partite
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
 | 
						TImporto importo_pagato_al(bool val, const TDate & al, int mode = 0xF) const;
 | 
				
			||||||
  TImporto importo_pagato(bool val, int mode = 0xF) const;
 | 
					  TImporto importo_pagato(bool val, int mode = 0xF) const;
 | 
				
			||||||
  TImporto importo(bool val) const;
 | 
					  TImporto importo(bool val) const;
 | 
				
			||||||
  TImporto residuo(bool val, int mode = 0xF) const;   // Differenza delle due funzioni precedenti
 | 
					  TImporto residuo(bool val, int mode = 0xF) const;   // Differenza delle due funzioni precedenti
 | 
				
			||||||
 | 
						TImporto esposto_al(bool valuta, const TDate & al, const TDate & data_scad, const TDate & data_rischio, bool & sbf) const;
 | 
				
			||||||
	TImporto esposto(bool valuta, const TDate & data_scad, const TDate & data_rischio, bool & sbf) const ;
 | 
						TImporto esposto(bool valuta, const TDate & data_scad, const TDate & data_rischio, bool & sbf) const ;
 | 
				
			||||||
		  
 | 
							  
 | 
				
			||||||
  bool esistono_abbuoni_diffcam() const;
 | 
					  bool esistono_abbuoni_diffcam() const;
 | 
				
			||||||
@ -192,6 +194,8 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  TImporto importo(bool valuta, int mode = 0xF) const;
 | 
					  TImporto importo(bool valuta, int mode = 0xF) const;
 | 
				
			||||||
  TImporto esposto(bool valuta, const TDate & data_scad, const TDate & data_rischio, bool & sbf) const;
 | 
					  TImporto esposto(bool valuta, const TDate & data_scad, const TDate & data_rischio, bool & sbf) const;
 | 
				
			||||||
 | 
						TImporto calcola_pagato_al(bool valuta,const TDate& al, const TDate & data_scaduto, const TDate& data_rischio, int mode = 0xF) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const TString& codice_valuta() const;
 | 
					  const TString& codice_valuta() const;
 | 
				
			||||||
  bool in_valuta() const;
 | 
					  bool in_valuta() const;
 | 
				
			||||||
@ -288,6 +292,7 @@ public:
 | 
				
			|||||||
  void update_reg(long nreg, const TRectype& mov, TPartite_array& pa);
 | 
					  void update_reg(long nreg, const TRectype& mov, TPartite_array& pa);
 | 
				
			||||||
  void calcola_saldo(TImporto& saldo, TImporto& doc, TImporto& pag, TImporto& imp) const;
 | 
					  void calcola_saldo(TImporto& saldo, TImporto& doc, TImporto& pag, TImporto& imp) const;
 | 
				
			||||||
  TImporto calcola_saldo(bool valuta) const;
 | 
					  TImporto calcola_saldo(bool valuta) const;
 | 
				
			||||||
 | 
						TImporto calcola_pagato_al(bool valuta,const TDate& al, const TDate & data_scaduto, const TDate& data_rischio) const;
 | 
				
			||||||
  TImporto calcola_saldo_al(bool valuta, const TDate& al, const TDate& data_scaduto, const TDate& data_rischio) const;
 | 
					  TImporto calcola_saldo_al(bool valuta, const TDate& al, const TDate& data_scaduto, const TDate& data_rischio) const;
 | 
				
			||||||
  real calcola_scaduto_al(bool valuta, const TDate& al = botime) const;
 | 
					  real calcola_scaduto_al(bool valuta, const TDate& al = botime) const;
 | 
				
			||||||
  TImporto importo_pagato_unassigned(bool val, int mode = 0xF) const;
 | 
					  TImporto importo_pagato_unassigned(bool val, int mode = 0xF) const;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user