Potenziamento stampa solleciti via mail
git-svn-id: svn://10.65.10.50/branches/R_10_00@22911 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									586708fb09
								
							
						
					
					
						commit
						201a3466f2
					
				
							
								
								
									
										158
									
								
								sc/sc2400.cpp
									
									
									
									
									
								
							
							
						
						
									
										158
									
								
								sc/sc2400.cpp
									
									
									
									
									
								
							| @ -17,9 +17,9 @@ | ||||
| class TStampaSol_application: public TSkeleton_application  | ||||
| {                    | ||||
|   TString _lingua_ditta; | ||||
|   TSol_mask *_msk; | ||||
|   TSol_mask* _msk; | ||||
|   bool _gesval; | ||||
|   TSol_form *_form; | ||||
|   TSol_form* _form; | ||||
|                                              | ||||
| protected: | ||||
|   virtual bool create(); | ||||
| @ -33,13 +33,14 @@ protected: | ||||
| 								             TString& subj, TString& text, TToken_string& attach, short& ui) const; | ||||
| 
 | ||||
|   const TString& game_key(const TRectype& part) const;  // Costruisce chiave univoca per TAssoc_array partite
 | ||||
|   bool ci_sono_scadenze_aperte(const TPartita& game, const TDate& dal, const TDate& al) const; | ||||
|   bool ci_sono_scadenze_aperte(const TPartita& game, const TDate& dal, const TDate& al, const TDate& data_rischio) const; | ||||
|   bool puoi_scartare(const TPartita& game, const TDate& datalim) const; | ||||
|   int print_sol(); // stampa l'elemento corrente
 | ||||
| 
 | ||||
| public: | ||||
|   TSol_mask &mask() const { return *_msk; } | ||||
|   TSol_form &form() const { return *_form; } | ||||
|   TCursor_sheet &sheet() { return _msk->cur_sheet(); } | ||||
|   TSol_mask& mask() const { return *_msk; } | ||||
|   TSol_form& form() const { return *_form; } | ||||
|   TCursor_sheet& sheet()  { return _msk->cur_sheet(); } | ||||
|    | ||||
|   bool print_selected(); // cicla la stampa sugli elementi selezionati
 | ||||
|   bool mail_selected();  // manda email agli elementi selezionati
 | ||||
| @ -96,26 +97,32 @@ bool TStampaSol_application::print_selected() | ||||
|   return true;   | ||||
| } | ||||
| 
 | ||||
| bool TStampaSol_application::ci_sono_scadenze_aperte(const TPartita& game, const TDate& dal, const TDate& al) const | ||||
| bool TStampaSol_application::ci_sono_scadenze_aperte(const TPartita& game, const TDate& dal, const TDate& al, const TDate& data_rischio) const | ||||
| { | ||||
|   bool found = false; | ||||
|   const int ultima = game.last(); | ||||
|   if (ultima > 0 && !game.chiusa(true)) | ||||
|    | ||||
|   for (int r = game.last(); r > 0; r = game.pred(r)) | ||||
|   { | ||||
|     for (int r = ultima; r > 0; r = game.pred(r)) | ||||
|     const TRiga_partite& row = game.riga(r);     | ||||
|     if (row.is_fattura() && row.get_date(PART_DATAREG) <= al) | ||||
|     { | ||||
|       const TRiga_partite& row = game.riga(r);     | ||||
|       if (row.is_fattura() && row.get_date(PART_DATAREG) <= al) | ||||
|       for (int s = row.rate(); s > 0 ;s--) | ||||
|       { | ||||
|         for (int s = row.rate(); s > 0 ;s--) | ||||
|         const TRiga_scadenze& rata = row.rata(s); | ||||
|         const TDate data = rata.get(SCAD_DATASCAD); | ||||
|         if (data >= dal && data <= al) | ||||
|         { | ||||
|           const TRiga_scadenze& rata = row.rata(s); | ||||
|           if (!rata.chiusa(true)) | ||||
|           found = !rata.chiusa(); | ||||
|           if (!found) | ||||
|           { | ||||
|             const TDate data = rata.get(SCAD_DATASCAD); | ||||
|             if (data >= dal && data <= al) | ||||
|               found = true; | ||||
|             TImporto rat = rata.importo(true); | ||||
|             TImporto imp = rata.importo_pagato_al(true, data_rischio);  | ||||
|             imp.normalize(rat.sezione()); | ||||
|             const real saldo = rat.valore() + imp.valore(); | ||||
|             found = saldo > ZERO; | ||||
|           } | ||||
|           if (found) | ||||
|             break; | ||||
|         } | ||||
|       }   | ||||
|     } | ||||
| @ -132,13 +139,34 @@ const TString& TStampaSol_application::game_key(const TRectype& part) const | ||||
|   return tok; | ||||
| } | ||||
| 
 | ||||
| bool TStampaSol_application::puoi_scartare(const TPartita& game, const TDate& datalim) const | ||||
| { | ||||
|   bool yes = game.chiusa(); | ||||
|   if (yes && datalim.ok()) | ||||
|   { | ||||
|     TDate last; | ||||
|     for (int r = game.last(); r > 0; r = game.pred(r)) | ||||
|     { | ||||
|       const TRiga_partite& riga = game.riga(r); | ||||
|       if (riga.tipo() > tm_fattura) | ||||
|       { | ||||
|         const TDate d = riga.get(PART_DATAPAG); | ||||
|         if (d > last) | ||||
|           last = d; | ||||
|       } | ||||
|     } | ||||
|     yes = last < datalim; | ||||
|   } | ||||
|   return yes; | ||||
| } | ||||
| 
 | ||||
| int TStampaSol_application::print_sol() | ||||
| { | ||||
|   TSol_form& f = form(); | ||||
| 
 | ||||
|   // preparazione variabili per controllo lingua
 | ||||
|   const TRectype &clf= f.cursor()->file().curr(); | ||||
|   const TString lincf(clf.get(CLI_CODLIN)); | ||||
|   const TString4 lincf = clf.get(CLI_CODLIN); | ||||
|   bool ok = true; | ||||
| 
 | ||||
|   // controllo lingua ditta corrente
 | ||||
| @ -151,7 +179,9 @@ int TStampaSol_application::print_sol() | ||||
|   partite.zero(); | ||||
|   partite.put(PART_TIPOCF, clf.get(CLI_TIPOCF)); | ||||
|   partite.put(PART_SOTTOCONTO, clf.get(CLI_CODCF)); | ||||
|   const TRectype filter(partite.curr()); | ||||
| 
 | ||||
|   const TRectype& parkur = partite.curr(); | ||||
|   const TRectype filter(parkur); | ||||
|    | ||||
|   bool one_printed = false; // booleano di controllo di riuscita della stampa
 | ||||
|   const bool sel_tot_saldo = f.get_sel_tot_saldo(); // selezione sul saldo totale cliente
 | ||||
| @ -159,6 +189,7 @@ int TStampaSol_application::print_sol() | ||||
|   const TDate data_inizio_soll = _msk->get(F_DATAINISCAD); | ||||
|   const TDate data_limite_soll = f.data_limite_operazione(); | ||||
|   const TDate data_limite_scaduto = f.data_limite_scaduto(); | ||||
|   const TDate data_rischio = f.data_inizio_rischio(); | ||||
| 
 | ||||
|   TAssoc_array games_in_range; | ||||
|    | ||||
| @ -166,17 +197,23 @@ int TStampaSol_application::print_sol() | ||||
|   {                    | ||||
|     real saldo; | ||||
|     for (int err = partite.read(_isgteq);  | ||||
|          err == NOERR && partite.curr() == filter;  | ||||
|          err == NOERR && parkur == filter;  | ||||
|          err = partite.read(_isgreat)) | ||||
|     {                                 | ||||
|       const TPartita game(partite.curr()); | ||||
|       const real sld = game.calcola_scaduto_al(false, data_limite_soll); | ||||
|        | ||||
|       if (sld > ZERO && data_inizio_soll.ok() &&  | ||||
|           ci_sono_scadenze_aperte(game, data_inizio_soll, data_limite_soll)) | ||||
|         games_in_range.add(game_key(partite.curr())); | ||||
| 
 | ||||
|       saldo += sld; | ||||
|       const TPartita game(parkur); | ||||
|       if (!puoi_scartare(game, data_rischio)) | ||||
|       { | ||||
|         if (sel_tot_saldo) | ||||
|         { | ||||
|           const real sld = game.calcola_scaduto_al(false, data_limite_soll); | ||||
|           saldo += sld; | ||||
|         } | ||||
|         if (data_inizio_soll.ok()) | ||||
|         { | ||||
|           if (ci_sono_scadenze_aperte(game, data_inizio_soll, data_limite_soll, data_rischio)) | ||||
|             games_in_range.add(game_key(parkur)); | ||||
|         } | ||||
|       } | ||||
|       partite.put(PART_NRIGA, 9999); | ||||
|     } | ||||
|      | ||||
| @ -187,34 +224,38 @@ int TStampaSol_application::print_sol() | ||||
| 
 | ||||
|     partite.curr() = filter; | ||||
|   } | ||||
|    | ||||
|   for (int err = partite.read(_isgteq);  | ||||
|        err == NOERR && partite.curr() == filter;  | ||||
|        err == NOERR && parkur == filter;  | ||||
|        err = partite.read(_isgreat)) | ||||
|   {                                 | ||||
|     if (data_inizio_soll.ok() && !games_in_range.is_key(game_key(partite.curr()))) | ||||
|     if (data_inizio_soll.ok() && !games_in_range.is_key(game_key(parkur))) | ||||
|       continue; // Scarta parite fuori range di date
 | ||||
| 
 | ||||
|     const TPartita game(partite.curr());  | ||||
|     const real saldo = game.calcola_scaduto_al(false, data_limite_scaduto); | ||||
|      | ||||
|     TImporto unreferenced; //Totale non assegnati per questa partita.
 | ||||
|     const TPartita game(parkur);  | ||||
|     if (!puoi_scartare(game, data_rischio)) | ||||
|     { | ||||
|       // E' giusto calcolare il saldo, comprendente i non assegnati.
 | ||||
|       // se il saldo della partita chiude in avere va sommato ad unreferenced
 | ||||
|       const TRiga_partite& sum = game.riga(game.first()); | ||||
|       unreferenced = game.calcola_saldo_al(game.in_valuta() && f.in_valuta(),data_limite_soll, data_limite_scaduto, data_limite_scaduto); | ||||
|       if (unreferenced.valore() > ZERO && unreferenced.sezione() == 'A') | ||||
|       const real saldo = game.calcola_scaduto_al(false, data_limite_scaduto); | ||||
|      | ||||
|       TImporto unreferenced; //Totale non assegnati per questa partita.
 | ||||
|       { | ||||
|         unreferenced.normalize('A'); //per i non assegnati/anticipi c'e' solo la colonna AVERE
 | ||||
|         const TString8 valuta = sum.get(PART_CODVAL); | ||||
|         form().totali().add(unreferenced,valuta); | ||||
|         // E' giusto calcolare il saldo, comprendente i non assegnati.
 | ||||
|         // se il saldo della partita chiude in avere va sommato ad unreferenced
 | ||||
|         const TRiga_partite& sum = game.riga(game.first()); | ||||
|         unreferenced = game.calcola_saldo_al(game.in_valuta() && f.in_valuta(),data_limite_soll, data_limite_scaduto, data_rischio); | ||||
|         if (unreferenced.valore() > ZERO && unreferenced.sezione() == 'A') | ||||
|         { | ||||
|           unreferenced.normalize('A'); //per i non assegnati/anticipi c'e' solo la colonna AVERE
 | ||||
|           const TString4 valuta = sum.get(PART_CODVAL); | ||||
|           form().totali().add(unreferenced,valuta); | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|      | ||||
|     if (sel_tot_saldo || (saldo > ZERO && saldo >= sel_importo )) | ||||
|     {                          | ||||
|       const bool printed = form().print_game(game); | ||||
|       one_printed |= printed; | ||||
|       if (sel_tot_saldo || (saldo > ZERO && saldo >= sel_importo ) || (saldo.is_zero() && !unreferenced.is_zero() && data_rischio < data_limite_scaduto)) | ||||
|       {                          | ||||
|         const bool printed = form().print_game(game); | ||||
|         one_printed |= printed; | ||||
|       } | ||||
|     } | ||||
|      | ||||
|     partite.put(PART_NRIGA, 9999); | ||||
| @ -465,26 +506,19 @@ void TStampaSol_application::on_firm_change() | ||||
| void TStampaSol_application::main_loop() | ||||
| { | ||||
|   TSol_mask& m = mask(); | ||||
|   for(;;)  | ||||
|   for (;;)  | ||||
|   { | ||||
|     const KEY key = m.run(); | ||||
|     if (key == K_QUIT) | ||||
|       break; | ||||
|              | ||||
|     const TDate dlimsol(m.get(F_DATALIMSOL)); | ||||
|     const TDate dsped(m.get(F_DATASEND));                          | ||||
|     if (dlimsol >= dsped) | ||||
|     { | ||||
|       _form= new TSol_form(m, _gesval, F_DATALIMOP, F_DATALIMSOL); | ||||
|       if (key == 'M') | ||||
|         mail_selected(); | ||||
|       else | ||||
|         print_selected(); | ||||
|       delete _form; | ||||
|       _form= NULL; | ||||
|     } | ||||
|     _form= new TSol_form(m, _gesval, F_DATALIMOP, F_DATALIMSOL, F_GGRISCHIO); | ||||
|     if (key == 'M') | ||||
|       mail_selected(); | ||||
|     else | ||||
|       error_box(TR("La data limite sollecito deve essere specificata e non puo' essere superiore alla data di invio")); | ||||
|       print_selected(); | ||||
|     delete _form; | ||||
|     _form= NULL; | ||||
|   } | ||||
| }                 | ||||
| 
 | ||||
|  | ||||
| @ -10,5 +10,6 @@ | ||||
| #define F_STAMPESP    132 | ||||
| #define F_IMPORMIN    133 | ||||
| #define F_RIFIMPMIN   134 | ||||
| #define F_GGRISCHIO   135 | ||||
| 
 | ||||
| #endif        | ||||
|  | ||||
| @ -97,6 +97,13 @@ BEGIN | ||||
|   PROMPT 2 4 "Data limite operazione  " | ||||
| END | ||||
| 
 | ||||
| NUMBER F_GGRISCHIO 3 | ||||
| BEGIN | ||||
|   PROMPT 41 4 "Giorni calcolo rischio " | ||||
|   HELP "Inserire il numero di giorni per il calcolo del rischio" | ||||
|   FLAGS "DU" | ||||
| END | ||||
| 
 | ||||
| DATE F_DATALIMSOL | ||||
| BEGIN | ||||
|   PROMPT 2 5 "Data limite solleciti   " | ||||
| @ -106,7 +113,7 @@ END | ||||
| 
 | ||||
| DATE F_DATAINISCAD | ||||
| BEGIN | ||||
|   PROMPT 42 5 "Dal     " | ||||
|   PROMPT 41 5 "Dal     " | ||||
|   VALIDATE DATE_CMP_FUNC <= F_DATALIMSOL | ||||
|   WARNING "Inserire una data precedente a quella limite" | ||||
| END | ||||
| @ -126,6 +133,8 @@ END | ||||
| BOOLEAN F_STAMPESP | ||||
| BEGIN | ||||
|   PROMPT 2 7 "Stampa esposizione" | ||||
|   MESSAGE FALSE CLEAR,F_GGRISCHIO | ||||
|   MESSAGE TRUE ENABLE,F_GGRISCHIO | ||||
| END | ||||
| 
 | ||||
| BOOLEAN F_STAMPSALDO | ||||
|  | ||||
| @ -105,7 +105,7 @@ bool TESSL_mask::stampa_saldo() const { | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| 
 | ||||
| TESSL_row::TESSL_row(const TRiga_partite& row, const TDate& data, const TImporto& imp, int rata) | ||||
|           : _num_prot(0), _num_reg(0), _salvo_buon_fine(FALSE) | ||||
|           : _num_prot(0), _num_reg(0), _salvo_buon_fine(false) | ||||
|  {         | ||||
|   _riga        = row.get_int(PART_NRIGA);  | ||||
|   _rata        = rata; | ||||
| @ -129,7 +129,7 @@ TESSL_row::TESSL_row(const TRiga_partite& row, const TDate& data, const TImporto | ||||
| } | ||||
| 
 | ||||
| TESSL_row::TESSL_row(const char* desc, const TImporto& imp, const TValuta& val) | ||||
|           : _riga(9999), _rata(9999), _num_prot(0), _num_reg(0), _salvo_buon_fine(FALSE) | ||||
|           : _riga(9999), _rata(9999), _num_prot(0), _num_reg(0), _salvo_buon_fine(false) | ||||
| { | ||||
|   _descrizione = desc; | ||||
|   _importo = imp; _importo.normalize(); | ||||
| @ -475,7 +475,7 @@ void TESSL_array::add_row(const TRiga_partite& row) | ||||
|         const int gr = form().giorni_rischio();  | ||||
|         const TDate& dir = form().data_inizio_rischio(); | ||||
|             | ||||
|         bool sbf = FALSE; | ||||
|         bool sbf = false; | ||||
|         TImporto esposto(row.esposto(in_valuta, dls, dir, sbf)); | ||||
|         bool esp = !esposto.is_zero(); | ||||
| 
 | ||||
| @ -921,7 +921,7 @@ void TESSL_form::azzera_totali() | ||||
| 
 | ||||
| bool TESSL_form::print_game(const TPartita& game) | ||||
| { | ||||
|   bool ok = FALSE; | ||||
|   bool ok = false; | ||||
|    | ||||
|   TESSL_array righe(game, this); | ||||
|    | ||||
| @ -959,17 +959,25 @@ bool TESSL_form::print_game(const TPartita& game) | ||||
|     ultima_riga = ri;    | ||||
|     ultima_rata = ra;    | ||||
| 
 | ||||
|     real resp = riga.esposto();   | ||||
|     if (resp < ZERO) | ||||
|     { | ||||
|       resp = -resp; | ||||
|       riga.esposto(resp);   | ||||
|     } | ||||
|      | ||||
|     riga.print_on(body); | ||||
|     pr.print(body.row(0)); | ||||
|      | ||||
|     | ||||
|     totali().add(riga.importo(), riga.scaduto(), riga.esposto(),  | ||||
|                  riga.importo_in_euro(), riga.valuta().codice()); | ||||
|      | ||||
|     saldo += riga.importo(); | ||||
|     saldo   += riga.importo(); | ||||
|     scaduto += riga.scaduto(); | ||||
|     esposto += riga.esposto(); | ||||
|     impeuro += riga.importo_in_euro(); | ||||
|     ok = TRUE; | ||||
|     ok = true; | ||||
|   } | ||||
|    | ||||
|   if (ok) | ||||
| @ -978,12 +986,11 @@ bool TESSL_form::print_game(const TPartita& game) | ||||
|     { | ||||
|       saldo.normalize();          | ||||
|        | ||||
|       const TString & dessaldo = describe(PEC_SALDO); | ||||
|       TString desc(80); | ||||
|       const TValuta & val = righe.row(r-1).valuta(); | ||||
|    | ||||
|       desc = dessaldo; | ||||
|       desc << ' ' << val.codice(); | ||||
|       TString desc; | ||||
|       desc = describe(PEC_SALDO); | ||||
|       const TValuta& val = righe.row(r-1).valuta(); | ||||
|       if (val.in_valuta())  | ||||
|         desc << ' ' << val.codice(); | ||||
|    | ||||
|       TESSL_row sld(desc, saldo, val); | ||||
|    | ||||
|  | ||||
| @ -40,8 +40,8 @@ TSol_row::TSol_row(const char* desc, const TImporto& imp, const TValuta& val) | ||||
| // TSol_form: form speciale per solleciti
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| 
 | ||||
| TSol_form::TSol_form(const TSol_mask& m, bool gesval, short id_datalim, short id_datascad) | ||||
|          : TESSL_form(m, gesval, id_datalim, id_datascad) | ||||
| TSol_form::TSol_form(const TSol_mask& m, bool gesval, short id_datalim, short id_datascad, short id_ggrischio) | ||||
|          : TESSL_form(m, gesval, id_datalim, id_datascad, id_ggrischio) | ||||
| {  | ||||
|   _sel_tot_saldo = m.get_sel_tot_saldo(); | ||||
|   _sel_importo = m.get_sel_importo(); | ||||
|  | ||||
| @ -43,8 +43,8 @@ protected: | ||||
|    | ||||
| public: | ||||
|   bool get_sel_tot_saldo() const { return _sel_tot_saldo;} | ||||
|   const real & get_sel_importo() const { return _sel_importo; } | ||||
|   TSol_form(const TSol_mask& m, bool gesval, short id_datalim, short id_datascad); | ||||
|   const real& get_sel_importo() const { return _sel_importo; } | ||||
|   TSol_form(const TSol_mask& m, bool gesval, short id_datalim, short id_datascad, short id_ggrischio); | ||||
| };     | ||||
| 
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user