From 93e06dc260f310837dbf52565ba80c7d7e1807e4 Mon Sep 17 00:00:00 2001
From: nik <nik@c028cbd2-c16b-5b4b-a496-9718f37d4682>
Date: Fri, 27 Jan 1995 17:05:35 +0000
Subject: [PATCH] Correzioni ai libri IVA

git-svn-id: svn://10.65.10.50/trunk@928 c028cbd2-c16b-5b4b-a496-9718f37d4682
---
 cg/cg4400.cpp  | 114 ++++++++++++++++++++++++-------------------------
 cg/cg4400.h    |   8 +++-
 cg/cg4400b.h   |  10 +++--
 cg/cg4400b.uml |  33 ++++++++++----
 4 files changed, 94 insertions(+), 71 deletions(-)

diff --git a/cg/cg4400.cpp b/cg/cg4400.cpp
index 0f550e371..1da00338d 100755
--- a/cg/cg4400.cpp
+++ b/cg/cg4400.cpp
@@ -479,7 +479,7 @@ void CG4400_application::build_ditte_sheet()
   _ditte->destroy();
   for (int i = 0; i < _nomiditte.items(); i++)
   {
-    TToken_string* d = new TToken_string(74);
+    TToken_string* d = new TToken_string(64);
     *d = (TToken_string&)_nomiditte[i];
     const char vers = d->get_char(2);
     bool selectable = vers == '?';
@@ -622,17 +622,12 @@ void CG4400_application::build_nomiditte()
       if (!look_lia()) good = FALSE; 
     }
     _n_ditte++;
-    TToken_string* d = new TToken_string(74);
-    // add record 
+    TToken_string* d = new TToken_string(64);
     d->add(dt.get("CODDITTA"));
     d->add(dt.get("RAGSOC"));
-    if (good) 
-    {
-      d->add(_tablia->get("S7"));
-      real c = _tablia->get_real("R0");
-      d->add(c.string("###.###.###.###"));
-    }
-    else d->add("??"); 
+    if (good) d->add(_tablia->get("S7"));
+    else d->add("??");
+    
     _nomiditte.add(d);  
   }
   TApplication::set_firm(__firm);
@@ -668,7 +663,7 @@ bool CG4400_application::user_create()
   _cur = new TCursor(_rel, "", 2);
   
   _ditte = new TArray_sheet(-1, -1, 0, 0, "Selezione Ditte",
-                            "@1|Cod.@5|Ragione Sociale@50|Vers.|Credito inizio anno");
+                            "@1|Cod.@5|Ragione Sociale@50|Vers.");
   _n_ditte = 0l;
   __firm = TApplication::get_firm();
   
@@ -1100,13 +1095,13 @@ int CG4400_application::stampa_prospetto()
     rr = r;
   
   if (_stampa && _tipo_reg == 2)
-    //if (_stampa_cred_pre && _mese_credito==0 && _credito > ZERO)
-    if (_stampa_cred_pre && _mese_credito==0 && _credito.not_empty() )
+  {
+    if (_stampa_cred_pre && _mese_credito==0 && _credito > ZERO)
     {
-      //set_row (++rr, "** CREDITO INIZIO ANNO @39g%r", &_credito);
-      set_row (++rr, "** CREDITO INIZIO ANNO @39g%s", (const char*)_credito);
+      set_row (++rr, "** CREDITO INIZIO ANNO @39g%r", &_credito);
       rr++;
     }
+  }
   
   if (_esiste_riga_iva && _stampa)
   {
@@ -1754,10 +1749,10 @@ bool CG4400_application::preprocess_page(int file, int counter)
           {
             _datareg = format("01/%02d/%4d", m, _annoes); //serve per la preprocess_header (intestazione per la stampa liquidazione)
             TFilename t;
-            t.temp();    
-
-            send_message(_tipo_stampa == 1 ? 'L': 'l', t, m);  
-
+            t.temp("reg");    
+            //if (_tipo_stampa == 1)
+            send_message('L', t, m);  
+            //else send_message('l', t, m);  
             TString80 nomef; nomef = t.path(); nomef << "\\" << t.name();
             if (fexist(nomef))
             {  
@@ -2028,22 +2023,22 @@ void CG4400_application::aggiorna_reg()
   if (Tabreg.read() == NOERR)
   {
     TDate d = Tabreg.get_date("D3");
-    //stampate = ultimast + 1;
     if (!_mov_empty) //cioe' se e' stata stampata almeno una pagina
     {
       TDate ultima_data = format("%02d/%02d/%4d", _datareg.last_day(_datareg.month(), _annoes), _datareg.month(), _annoes);
       if (ultima_data > d) 
         Tabreg.put("D3", ultima_data);
-      //pag = _pagine_stampate + ultimast;
-      //Tabreg.put("I1", pag);
     }  
     else if (_data_a > d) 
       Tabreg.put("D3", _data_a);
 
     Tabreg.put("I1", _pagine_stampate);
+    
+    if (_intesta_liq)
+      Tabreg.put("I4", (long)_datareg.month());
+
     if (_tipo_reg == 2 && _stampa_cred_pre)
-      //if (_mese_credito == 0 && _credito > ZERO)
-      if (_mese_credito == 0 && _credito.not_empty())
+      if (_mese_credito == 0 && _credito > ZERO)
         if (_mov_empty) 
           Tabreg.put("I8", (long)_fino_a_mese);
         else Tabreg.put("I8", (long)_datareg.month());
@@ -2229,9 +2224,9 @@ print_action CG4400_application::postprocess_page (int file, int counter)
           _st_liq[_datareg.month()] = TRUE;
           TFilename t;
           t.temp("rg");
-          if (_tipo_stampa == 1)
-            send_message('L',t, _datareg.month()); //stampa liquidazione
-          else send_message('l',t, _datareg.month()); 
+          //if (_tipo_stampa == 1)
+          send_message('L',t, _datareg.month()); 
+          //else send_message('l',t, _datareg.month()); 
           TString80 nomef; 
           nomef = t.path(); nomef << "\\" << t.name();
           if (fexist(nomef))
@@ -2390,7 +2385,10 @@ bool CG4400_application::look_lia()
   _tablia->zero();
   _tablia->put("CODTAB", y);
   _tablia->read();
-  const bool ok = _tablia->good();
+  const bool ok = _tablia->good(); 
+  if (ok) 
+    _credito = _tablia->get_real("R0");
+  else _credito = ZERO;  
   return ok;
 }
 
@@ -2407,11 +2405,12 @@ bool CG4400_application::stampa_registri_IVA(const TMask& m)
   {
     if (_selected[(long)i])
     {
-      _ditta    = _ditte->row(i).get_long(1);
-      _frequiva = _ditte->row(i).get_char(3);
-      _credito  = _ditte->row(i).get(4); //credito iva anno precedente
       bool msg = TRUE;
-      TApplication::set_firm(_ditta); 
+      _ditta       = _ditte->row(i).get_long(1);
+      _frequiva    = _ditte->row(i).get_char(3);
+      _intesta_liq = FALSE;
+      TApplication::set_firm(_ditta);
+      look_lia(); 
       ok = compila_reg(m);   
       if (!ok) continue;
       if (_tipo_stampa == 2 || _tipo_stampa == 4)
@@ -2436,7 +2435,9 @@ bool CG4400_application::stampa_registri_IVA(const TMask& m)
         {
           if (_tipo_stampa == 2 || _tipo_stampa == 4)
           {
-            TMask mb("cg4400b");
+            TMask mb("cg4400b"); 
+            mb.set(F_CODDITTA, _ditta);
+            mb.set(F_RAGSOC, _ditte->row(i).get(2));
             mb.set(COD_LIB, _codreg);
             const char* m = "";
             m = format("%02d", _stampa_mese);
@@ -2453,7 +2454,6 @@ bool CG4400_application::stampa_registri_IVA(const TMask& m)
             t.temp();
             send_message('C',t, _fino_a_mese);
           } 
-          
           print();
           
           if (_tipo_stampa != 3 && _liquidazione)  
@@ -2476,18 +2476,18 @@ else //non ci sono movimenti da stampare nel periodo richiesto!
     if (_tipo_stampa == 1)
       a = _data_a.month();
     else a = _fino_a_mese;      
-    if (! printer().isopen())
-      printer().open();
     for (int m = da; m <= a; m++)
     {
+      if (! printer().isopen())
+        printer().open();
       if (stampo_liquidazione(m))
       {
         _datareg = format("01/%02d/%4d", m, _annoes); //serve per la preprocess_header
         TFilename t;
         t.temp("rgp");
-        if (_tipo_stampa == 1)
-          send_message('L',t, m);
-        else send_message('l',t, m);
+        //if (_tipo_stampa == 1)
+        send_message('L',t, m);
+        //else send_message('l',t, m);
         TString80 nomef; 
         nomef = t.path(); nomef << "\\" << t.name();
         if (fexist(nomef))
@@ -2497,9 +2497,9 @@ else //non ci sono movimenti da stampare nel periodo richiesto!
           merge_export_file(t,FALSE,TRUE);
           _intesta_liq = FALSE; 
         }  
-      } 
+      }
+      printer().close(); 
     }
-    printer().close();
   }        
 }
 if (_tipo_stampa == 3 && _rif_vid)
@@ -2589,6 +2589,8 @@ else //stampa tutti i registri
           if (_tipo_stampa == 2 || _tipo_stampa == 4)
           {
             TMask mb("cg4400b");
+            mb.set(F_CODDITTA, _ditta);
+            mb.set(F_RAGSOC, _ditte->row(i).get(2));
             mb.set(COD_LIB, _codreg); 
             const char* m = "";
             m = format("%02d", _stampa_mese);
@@ -2633,12 +2635,10 @@ else //stampa tutti i registri
             if (_tipo_stampa == 1)
               a = _data_a.month();
             else a = _fino_a_mese;
-            
-            if (!printer().isopen())
-              printer().open();
-            
             for (int m = da; m <= a; m++)
             {
+              if (!printer().isopen())
+                printer().open();
               if (stampo_liquidazione(m))
               {
                 //ok = controlla_liquidazione();
@@ -2647,9 +2647,9 @@ else //stampa tutti i registri
                 TFilename t;
                 t.temp("rgi");
                 TString80 nomef; nomef = t.path(); nomef << "\\" << t.name();
-                if (_tipo_stampa == 1)
-                  send_message('L',t, m);
-                else send_message('l',t, m);
+                //if (_tipo_stampa == 1)
+                send_message('L',t, m);
+                //else send_message('l',t, m);
                 if (fexist(nomef))
                 {  
                   _intesta_liq = TRUE;
@@ -2658,8 +2658,8 @@ else //stampa tutti i registri
                   _intesta_liq = FALSE; 
                 } 
               } 
+              printer().close();
             }
-            printer().close();  
           }
         } 
         if (_tipo_stampa == 3 && _rif_vid)
@@ -2682,19 +2682,19 @@ return TRUE;
 void CG4400_application::stampa_liq_mesi_succ()
 {
   int da = _datareg.month() + 1;
-  if (!printer().isopen())
-    printer().open();
-  int a = _data_a.month();   
+  int a  = _data_a.month();   
   for (int m = da; m <= a; m++)
   {
+    if (!printer().isopen())
+      printer().open();
     if (stampo_liquidazione(m))
     {
       _datareg = format("01/%02d/%4d", m, _annoes); //serve per la preprocess_header (intestazione per la stampa liquidazione)
       TFilename t;
       t.temp("iva");    
-      if (_tipo_stampa == 1)
-        send_message('L',t, m);  
-      else send_message('l',t,m);
+      //if (_tipo_stampa == 1)
+      send_message('L',t, m);  
+      //else send_message('l',t,m);
       TString80 nomef; nomef = t.path(); nomef << "\\" << t.name();
       if (fexist(nomef))
       {  
@@ -2703,9 +2703,9 @@ void CG4400_application::stampa_liq_mesi_succ()
         merge_export_file(t,FALSE,TRUE);
         _intesta_liq = FALSE;  
       } 
-    }  
+    }
+    printer().close();  
   }
-  printer().close();                                  
 }  
 
 void CG4400_application::send_message(char tipo, const TFilename& nome, int mese)
diff --git a/cg/cg4400.h b/cg/cg4400.h
index aae3f37cc..0d51f60a4 100755
--- a/cg/cg4400.h
+++ b/cg/cg4400.h
@@ -13,7 +13,11 @@
 #include <sheet.h>
 #include <config.h> 
 #include <prefix.h>
+<<<<<<< cg4400.h
+#include "conto.h"
+=======
 #include "conto.h"   // CI VOGLIONO LE VIRGOLETTE! CAPITELA!
+>>>>>>> 1.25
 #include <nditte.h>
 #include <anagr.h>
 #include <comuni.h>
@@ -53,9 +57,9 @@ class CG4400_application : public TPrintapp
   int            _fino_a_mese, _tipo_reg, _tipo_stampa, _cod_un_loc;
   int            _annoes, _r, _stampa_width, _mese_ultima_liq, _mese_credito; 
   int            _stampa_len, _stampa_mese;
-  real           _totale_doc;
+  real           _totale_doc, _credito;
   TString        _codreg, _desc_lib, _codatt, _attivita, _tipoatt;
-  TString        _tipodoc, _descr_doc, _codlib, _codice_vidi, _credito;
+  TString        _tipodoc, _descr_doc, _codlib, _codice_vidi;
   TString        _cofi,_cap,_paiva,_ragsoc,_comunefis,_provfis,_viafis;
 
 protected:  
diff --git a/cg/cg4400b.h b/cg/cg4400b.h
index 0d3f21f70..a3a855307 100755
--- a/cg/cg4400b.h
+++ b/cg/cg4400b.h
@@ -1,4 +1,6 @@
-#define COD_LIB 123
-#define U_MESE 124
-#define U_PAGINA 125
-#define U_DATA 126
+#define F_CODDITTA 123
+#define F_RAGSOC 124
+#define COD_LIB 125
+#define U_MESE 126
+#define U_PAGINA 127
+#define U_DATA 128
diff --git a/cg/cg4400b.uml b/cg/cg4400b.uml
index eb432ee83..8257e35db 100755
--- a/cg/cg4400b.uml
+++ b/cg/cg4400b.uml
@@ -1,39 +1,56 @@
 #include "cg4400b.h"
 
-PAGE "Stampa registri IVA" -1 -1 54 10 
+PAGE "Stampa registri IVA" -1 -1 78 14 
+
+GROUPBOX DLG_NULL 78 3
+BEGIN
+    PROMPT 1 0 ""
+END
+
+NUMBER F_CODDITTA 5
+BEGIN
+    PROMPT 3 1 "Ditta  "
+    FLAGS "D"
+END
+
+STRING F_RAGSOC 50
+BEGIN
+    PROMPT 17 1 "Ragione "
+    FLAGS "D"
+END
 
 STRING COD_LIB 3
 BEGIN
-  PROMPT 2 1 "Codice Libro                        "
+  PROMPT 3 4 "Codice Libro                           "
   FLAGS "D"
 END
 
 LISTBOX U_MESE 10
 BEGIN
-  PROMPT 2 2 "Stampa mese                         "
+  PROMPT 3 5 "Stampa mese                            "
   FLAGS "MD"
 END
 
 NUMBER U_PAGINA 4
 BEGIN
-  PROMPT 2 3 "Ult.num.pagina stampata libro ditta "
+  PROMPT 3 6 "Ult.num.pagina stampata libro ditta    "
   FLAGS "R"
 END
 
 DATE U_DATA
-BEGIN
-  PROMPT 2 4 "Ultima data di stampa               "
+BEGIN                                              
+  PROMPT 3 7 "Ultima data di stampa                  "
   FLAGS "D"
 END
 
 BUTTON DLG_OK 9 2
 BEGIN
- PROMPT -12 7 ""  
+ PROMPT -12 -1 ""  
 END
 
 BUTTON DLG_CANCEL 9 2
 BEGIN
- PROMPT -22 7 ""  
+ PROMPT -22 -1 ""  
 END
 
 ENDPAGE