diff --git a/build/mg.sln b/build/mg.sln
index af28e828d..aaf0786da 100644
--- a/build/mg.sln
+++ b/build/mg.sln
@@ -19,6 +19,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vedoc", "vedoc.vcxproj", "{
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lilib", "lilib.vcxproj", "{B61F0AD4-0CCE-4371-8E92-85A26CAF1A7C}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cglib", "cglib.vcxproj", "{7B80F974-CE2E-4BD9-855A-44FF139FF288}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -57,6 +59,10 @@ Global
{B61F0AD4-0CCE-4371-8E92-85A26CAF1A7C}.Debug|Win32.Build.0 = Debug|Win32
{B61F0AD4-0CCE-4371-8E92-85A26CAF1A7C}.Release|Win32.ActiveCfg = Release|Win32
{B61F0AD4-0CCE-4371-8E92-85A26CAF1A7C}.Release|Win32.Build.0 = Release|Win32
+ {7B80F974-CE2E-4BD9-855A-44FF139FF288}.Debug|Win32.ActiveCfg = Debug|Win32
+ {7B80F974-CE2E-4BD9-855A-44FF139FF288}.Debug|Win32.Build.0 = Debug|Win32
+ {7B80F974-CE2E-4BD9-855A-44FF139FF288}.Release|Win32.ActiveCfg = Release|Win32
+ {7B80F974-CE2E-4BD9-855A-44FF139FF288}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/build/mg0.vcxproj b/build/mg0.vcxproj
index 9306989d3..cfda390fc 100644
--- a/build/mg0.vcxproj
+++ b/build/mg0.vcxproj
@@ -158,24 +158,11 @@
$(IntDir)
- "C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x64\signtool.exe" sign /a /s MY /n "Sirio Informatica e Sistemi SPA" /t http://timestamp.verisign.com/scripts/timstamp.dll /v "$(TargetPath)"
+
+
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
-
%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
@@ -289,6 +276,9 @@
{2d38a763-3d74-4338-9362-b891784ec90e}
+
+ {7b80f974-ce2e-4bd9-855a-44ff139ff288}
+
diff --git a/build/mg0.vcxproj.filters b/build/mg0.vcxproj.filters
index 2ea4adc76..e466ce8ec 100644
--- a/build/mg0.vcxproj.filters
+++ b/build/mg0.vcxproj.filters
@@ -29,12 +29,6 @@
Sources
-
- Sources
-
-
- Sources
-
Sources
@@ -62,12 +56,6 @@
Sources
-
- Sources
-
-
- Sources
-
diff --git a/build/mg1.vcxproj b/build/mg1.vcxproj
index 54b9f2972..2a9825884 100644
--- a/build/mg1.vcxproj
+++ b/build/mg1.vcxproj
@@ -101,7 +101,8 @@
Shout Out To My Ex
- "C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x64\signtool.exe" sign /a /s MY /n "Sirio Informatica e Sistemi SPA" /t http://timestamp.verisign.com/scripts/timstamp.dll /v "$(TargetPath)"
+
+
@@ -159,25 +160,6 @@
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
@@ -259,12 +241,16 @@
+
{2d38a763-3d74-4338-9362-b891784ec90e}
+
+ {7b80f974-ce2e-4bd9-855a-44ff139ff288}
+
{a1ce9743-a597-4f92-b55a-345a366c9e55}
diff --git a/build/mg1.vcxproj.filters b/build/mg1.vcxproj.filters
index 8d0127159..7426ed3d6 100644
--- a/build/mg1.vcxproj.filters
+++ b/build/mg1.vcxproj.filters
@@ -15,15 +15,6 @@
-
- Sources
-
-
- Sources
-
-
- Sources
-
Sources
@@ -54,9 +45,6 @@
Sources
-
- Sources
-
@@ -82,5 +70,8 @@
Headers
+
+ Headers
+
\ No newline at end of file
diff --git a/build/mg3.vcxproj b/build/mg3.vcxproj
index 1a379350d..438a327a7 100644
--- a/build/mg3.vcxproj
+++ b/build/mg3.vcxproj
@@ -100,7 +100,8 @@
.\..\release/mg3.bsc
- "C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x64\signtool.exe" sign /a /s MY /n "Sirio Informatica e Sistemi SPA" /t http://timestamp.verisign.com/scripts/timstamp.dll /v "$(TargetPath)"
+
+
@@ -162,20 +163,6 @@
%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
-
%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
@@ -306,6 +293,9 @@
{2d38a763-3d74-4338-9362-b891784ec90e}
+
+ {7b80f974-ce2e-4bd9-855a-44ff139ff288}
+
diff --git a/build/mg3.vcxproj.filters b/build/mg3.vcxproj.filters
index 7e267548c..a9403ebc8 100644
--- a/build/mg3.vcxproj.filters
+++ b/build/mg3.vcxproj.filters
@@ -26,12 +26,6 @@
Sources
-
- Sources
-
-
- Sources
-
Sources
@@ -68,12 +62,6 @@
Sources
-
- Sources
-
-
- Sources
-
diff --git a/build/mg4.vcxproj b/build/mg4.vcxproj
index f266a2465..641c8febb 100644
--- a/build/mg4.vcxproj
+++ b/build/mg4.vcxproj
@@ -105,7 +105,8 @@
$(IntDir)
- "C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x64\signtool.exe" sign /a /s MY /n "Sirio Informatica e Sistemi SPA" /t http://timestamp.verisign.com/scripts/timstamp.dll /v "$(TargetPath)"
+
+
diff --git a/cd/test/cg1070.txt b/cd/test/cg1070.txt
new file mode 100644
index 000000000..a6e38e416
--- /dev/null
+++ b/cd/test/cg1070.txt
@@ -0,0 +1,2 @@
+
+Il bilancio di verifica sui clienti pe data limite non riportava i saldi iniziali.
diff --git a/cd/test/cg1070a.ini b/cd/test/cg1070a.ini
new file mode 100644
index 000000000..02b125afd
--- /dev/null
+++ b/cd/test/cg1070a.ini
@@ -0,0 +1,98 @@
+[Main]
+Demo=0
+
+[cg1]
+File(9) = cg1.exe|X
+Patch = 1070
+Versione = 21511200
+
+[cg99]
+Kill(0) = bastndo.rep|x
+Kill(1) = bastscc.msk|x
+Kill(2) = batbreg.msk|x
+Kill(3) = batblia.msk|x
+Kill(4) = bastzon.msk|x
+Kill(5) = bastdpn.rep|x
+Kill(6) = bastcco.rep|x
+Kill(7) = bastreg.msk|x
+Kill(8) = bastmsp.msk|x
+Kill(9) = batbarb.msk|x
+Kill(10) = bastcam.msk|x
+Kill(11) = batbdpn.msk|x
+Kill(12) = batbvet.msk|x
+Kill(13) = bastcco.msk|x
+Kill(14) = bastivd.msk|x
+Kill(15) = batbpdb.msk|x
+Kill(16) = batbleg.msk|x
+Kill(17) = batblbu.msk|x
+Kill(18) = batbntb.msk|x
+Kill(19) = batbins.msk|x
+Kill(20) = batbind.msk|x
+Kill(21) = batbpor.msk|x
+Kill(22) = bastcfi.msk|x
+Kill(23) = bastdpn.msk|x
+Kill(24) = bastleg.msk|x
+Kill(25) = bastpor.rep|x
+Kill(26) = bastpor.msk|x
+Kill(27) = bastnot.msk|x
+Kill(28) = cgtbcon.msk|x
+Kill(29) = bastarb.rep|x
+Kill(30) = batbdel.msk|x
+Kill(31) = batbcfi.msk|x
+Kill(32) = bastcve.msk|x
+Kill(33) = bastvet.rep|x
+Kill(34) = bastcve.rep|x
+Kill(35) = bastcfi.rep|x
+Kill(36) = batbcam.msk|x
+Kill(37) = batbzon.msk|x
+Kill(38) = bastmsp.rep|x
+Kill(39) = bastver.rep|x
+Kill(40) = batbver.msk|x
+Kill(41) = bastntb.msk|x
+Kill(42) = bastesc.msk|x
+Kill(43) = batbcve.msk|x
+Kill(44) = bastvet.msk|x
+Kill(45) = bastcam.rep|x
+Kill(46) = batblia.msk|x
+Kill(47) = bastpdb.msk|x
+Kill(48) = bastscc.rep|x
+Kill(49) = bastndo.msk|x
+Kill(50) = batbesc.msk|x
+Kill(51) = batbmsp.msk|x
+Kill(52) = bastpdb.rep|x
+Kill(53) = bastleg.rep|x
+Kill(54) = batbnot.msk|x
+Kill(55) = bastreg.rep|x
+Kill(56) = bastnot.rep|x
+Kill(57) = bastntb.rep|x
+Kill(58) = cg2fppro.msk|x
+Kill(59) = bastarb.msk|x
+Kill(60) = batbscc.msk|x
+Kill(61) = batbndo.msk|x
+Kill(62) = batbtra.msk|x
+Kill(63) = batbivd.msk|x
+Kill(64) = bastver.msk|x
+Kill(65) = bastesc.rep|x
+Kill(66) = bastzon.rep|x
+Kill(67) = batbcco.msk|x
+Kill(68) = bastivd.rep|x
+Kill(69) = batbinl.msk|x
+Kill(70) = batbtit.msk|x
+
+[cg]
+Data = 21-07-2021
+Descrizione = Contabilita' Generale
+Dischi = 1
+Edit_19 = cg0 -0
+Edit_20 = cg0 -1
+Edit_26 = cg0 -4
+Edit_5 = cg0 -5
+Moduli = ba
+OEM =
+Patch = 1070
+PostProcess = bainst -0 CG
+PreProcess =
+Prezzo(1) =
+Prezzo(2) =
+Versione = 21511200
+
diff --git a/cd/test/cg1070a1.zip b/cd/test/cg1070a1.zip
new file mode 100644
index 000000000..aefadc23b
Binary files /dev/null and b/cd/test/cg1070a1.zip differ
diff --git a/cd/test/mg1070.txt b/cd/test/mg1070.txt
new file mode 100644
index 000000000..d0d5cdad6
--- /dev/null
+++ b/cd/test/mg1070.txt
@@ -0,0 +1,4 @@
+mg1.exe
+mg1200.msk
+
+Ricostruzione saldi per aticolo
\ No newline at end of file
diff --git a/cd/test/mg1070a.ini b/cd/test/mg1070a.ini
new file mode 100644
index 000000000..268dcdf6d
--- /dev/null
+++ b/cd/test/mg1070a.ini
@@ -0,0 +1,31 @@
+[Main]
+Demo=0
+
+[mg1]
+Edit_110 = mg1 -0
+File(36) = mg1.exe|X
+File(39) = mg1200.msk|X
+Patch = 1070
+Versione = 21511200
+
+[mg99]
+Kill(0) = batbfcg.msk|x
+Kill(1) = batbubi.msk|x
+Kill(2) = efstbnp.rep|x
+Kill(3) = efstbnp.msk|x
+Kill(4) = eftbbnp.msk|x
+Kill(5) = bastfcg.msk|x
+
+[mg]
+Data = 27-07-2021
+Descrizione = Magazzino
+Dischi = 1
+Moduli = ba,cg9,ve9,pr9,ef9
+OEM =
+Patch = 1070
+PostProcess = bainst -0 MG
+PreProcess =
+Prezzo(1) =
+Prezzo(2) =
+Versione = 21511200
+
diff --git a/cd/test/mg1070a1.zip b/cd/test/mg1070a1.zip
new file mode 100644
index 000000000..05c055435
Binary files /dev/null and b/cd/test/mg1070a1.zip differ
diff --git a/cd/test/sy1069.txt b/cd/test/sy1069.txt
new file mode 100644
index 000000000..5623514c3
--- /dev/null
+++ b/cd/test/sy1069.txt
@@ -0,0 +1,6 @@
+bamenu.men
+setup\teamviewerqs.exe
+
+Aggiornamento versione TeamViewer v 13.2
+
+
diff --git a/cd/test/sy1069a.ini b/cd/test/sy1069a.ini
new file mode 100644
index 000000000..0ad9bcbf3
--- /dev/null
+++ b/cd/test/sy1069a.ini
@@ -0,0 +1,25 @@
+[Main]
+Demo=0
+
+[sy1]
+File(35) = bamenu.men|X
+File(42) = setup\teamviewerqs.exe|X
+Patch = 1069
+Versione = 21511200
+
+[sy99]
+Kill(0) = setup\teamviewerqs_it.exe|x
+
+[sy]
+Data = 27-07-2021
+Descrizione = Sistema
+Dischi = 1
+Moduli =
+OEM =
+Patch = 1069
+PostProcess =
+PreProcess =
+Prezzo(1) =
+Prezzo(2) =
+Versione = 21511200
+
diff --git a/cd/test/sy1069a1.zip b/cd/test/sy1069a1.zip
new file mode 100644
index 000000000..712372fa1
Binary files /dev/null and b/cd/test/sy1069a1.zip differ
diff --git a/src/ba/bamenu.men b/src/ba/bamenu.men
index b2f2b53e8..8b37720f3 100755
--- a/src/ba/bamenu.men
+++ b/src/ba/bamenu.men
@@ -123,7 +123,7 @@ Item_09 = "Gestione dizionario", "ba2 -6", ""
Item_10 = "Query e Report", [MENU_014], "", 10217
Item_11 = "Firma digitale", "ba8 -6", ""
Item_12 = "Postino", "ba7 -0", ""
-Item_13 = "Teleassistenza", "setup/TeamviewerQS_it.exe", "F", 10236
+Item_13 = "Teleassistenza", "setup/TeamviewerQS.exe", "F", 10236
[MENU_016]
Caption = "Procedure speciali"
diff --git a/src/cg/cg1500.cpp b/src/cg/cg1500.cpp
index 3b40740fb..20b6771e4 100755
--- a/src/cg/cg1500.cpp
+++ b/src/cg/cg1500.cpp
@@ -1927,11 +1927,11 @@ void TStampa_bilanci::leggi_clifo(const TArray& gccf)
tipocfp = ' ';
_saldo_ini_conto_dare = ZERO;
_saldo_ini_conto_avere = ZERO;
- saldo_conto = ZERO;
+ /* saldo_conto = ZERO;
mov_conto_dare = ZERO;
mov_conto_avere = ZERO;
prg_conto_dare = ZERO;
- prg_conto_avere = ZERO;
+ prg_conto_avere = ZERO;*/
_u_max = 0l;
const int anno = _tipo_stampa == 1 ? _annoapp : _annoes;
@@ -2037,7 +2037,7 @@ void TStampa_bilanci::leggi_clifo(const TArray& gccf)
saldo_iniziale = _saldo_ini_dare - _saldo_ini_avere;
else
{
- sld.ultima_immissione_verifica(g, c, codcf, _indbil, _stampa_mov_prov);
+ sld.ultima_immissione_verifica(anno, g, c, codcf, _indbil, _stampa_mov_prov);
saldo_iniziale = sld.saldoini();
if (saldo_iniziale > ZERO)
_saldo_ini_dare = saldo_iniziale;
diff --git a/src/include/array.h b/src/include/array.h
index 19ffca91c..8a9deb63c 100755
--- a/src/include/array.h
+++ b/src/include/array.h
@@ -226,12 +226,12 @@ TArray& objptr2array(TObject* obj);
///////////////////////////////////////////////////////////
// TString_array
///////////////////////////////////////////////////////////
-#define STRING_TOKEN(obj) (obj == nullptr ? EMPTY_STRING : *(TString *) obj)
-
#ifndef __STRINGS_H
class TToken_string;
#endif
+#define STRING_TOKEN(obj) (obj == nullptr ? EMPTY_STRING : *(TToken_string *) obj)
+
// @doc EXTERNAL
// @class TString_array | Array di stringhe
diff --git a/src/include/defmask.h b/src/include/defmask.h
index c10ff420c..1fb92ec50 100755
--- a/src/include/defmask.h
+++ b/src/include/defmask.h
@@ -124,5 +124,39 @@
#define STR_CALC VALIDATE STRCALC_FUNC 1
#define THIS_FIELD 0
#define THIS 0
+#define CANCELLETTO #
+
+#define RIF_FIELD(FLD) CANCELLETTO FLD
+#define RIF_THIS_FIELD RIF_FIELD(0)
+#define RIF_THIS RIF_FIELD(0)
+#define FLD_EMPTY(FLD) (RIF_FIELD(FLD)=="")
+#define FLD_FULL(FLD) (RIF_FIELD(FLD)!="")
+#define THIS_EMPTY (RIF_THIS=="")
+#define THIS_FULL (RIF_THIS!="")
+
+#define EQ_IF_SET(FLD) STR_EXPR (THIS_EMPTY||(RIF_THIS==RIF_FIELD(FLD)))
+#define GT_IF_SET(FLD) STR_EXPR (THIS_EMPTY||(RIF_THIS>RIF_FIELD(FLD)))
+#define GE_IF_SET(FLD) STR_EXPR (THIS_EMPTY||(RIF_THIS>=RIF_FIELD(FLD)))
+#define LT_IF_SET(FLD) STR_EXPR (THIS_EMPTY||(RIF_THISRIF_FIELD(FLD))
+#define GE(FLD) STR_EXPR (RIF_THIS>=RIF_FIELD(FLD))
+#define LT(FLD) STR_EXPR (RIF_THISRIF_FIELD(FLD)))
+#define NUM_GE_IF_SET(FLD) NUM_EXPR (THIS_EMPTY||(RIF_THIS>=RIF_FIELD(FLD)))
+#define NUM_LT_IF_SET(FLD) NUM_EXPR (THIS_EMPTY||(RIF_THISRIF_FIELD(FLD))
+#define NUM_GE(FLD) NUM_EXPR (RIF_THIS>=RIF_FIELD(FLD))
+#define NUM_LT(FLD) NUM_EXPR (RIF_THIS= 16)
- {
- TString80 str; str << TR("Calcolo giacenza articolo ") << codice();
- pi = new TProgress_monitor(items, str, false);
- }
- /*
- TMov_mag* p_movmag = new TMov_mag;
- rel.lfile(LF_MOVMAG).set_curr(p_movmag);
- TMov_mag& movmag = *p_movmag;
- */
+
+ TString80 str; str << TR("Calcolo giacenza articolo ") << codice();
+ TProgress_monitor pi(items, str, false);
const TRectype& rmovmag = rel.curr();
TRecord_array& rmag = mag(anno);
- for (cur = 0; cur.pos() < items; ++cur)
+ for (cur = 0; cur.pos() < items && pi.add_status(); ++cur)
{
const TDate datacomp = rel.curr(LF_MOVMAG).get_date(MOVMAG_DATACOMP);
const TString& codart = rmovmag.get(RMOVMAG_CODART);
+
if (codart == codice() && datacomp >= inizio && datacomp <= data)
{
const TString8 codmag = rmovmag.get(RMOVMAG_CODMAG);
@@ -1753,23 +1745,20 @@ void TArticolo_giacenza_data::al(const TDate& data, const char* codmag, const ch
if (i >= 0) // Se il record di giacenza esiste lo aggiorno ...
{
TRectype& rec = (TRectype&)rmag.row(i);
+
movmag.update_balances(rec, nrig);
}
else // ... altrimenti lo creo e poi lo aggiorno
{
- TRectype& rec = rmag.row(-1, TRUE);
+ TRectype& rec = rmag.row(-1, true);
+
rec.put(MAG_ANNOES, anno); // Setto i campi fondamentali!
rec.put(MAG_CODMAG, codmag);
rec.put(MAG_LIVELLO, livello);
movmag.update_balances(rec, nrig);
}
}
-
- if (pi && !pi->add_status())
- break;
}
-
- if (pi) delete pi;
}
TArticolo_giacenza_data::TArticolo_giacenza_data(const char* codice)
diff --git a/src/mg/mglib02a.cpp b/src/mg/mglib02a.cpp
index 450addb62..416ffcc29 100755
--- a/src/mg/mglib02a.cpp
+++ b/src/mg/mglib02a.cpp
@@ -461,6 +461,8 @@ TSaldo_mag_clifo::TSaldo_mag_clifo(const TSaldo_mag_clifo & s)
static bool __cache_saldi = false;
static TAssoc_array __saldi_mag;
static TAssoc_array __saldi_mag_clifo;
+static TString __from_art;
+static TString __to_art;
// ********************************
// TMov_mag
@@ -755,7 +757,18 @@ void TMov_mag::add_saldi(const bool plus)
for (int i = b.last_row(); i > 0; i = b.pred_row(i))
{
- const TRectype & rec = b[i];
+ const TRectype & rec = b[i];
+
+ if (__cache_saldi)
+ {
+ const TString & codart = rec.get(ANAMAG_CODART);
+
+ if (__from_art.full() && codart < __from_art)
+ continue;
+ if (__to_art.full() && codart > __to_art)
+ continue;
+ }
+
TToken_string & key_mag = TSaldo_mag::key(*this, rec);
TSaldo_mag * s_mag = (TSaldo_mag*)(__cache_saldi ? __saldi_mag.objptr(key_mag) : _saldi_mag.objptr(key_mag));
@@ -1212,7 +1225,7 @@ bool rebuild_balances(int codes, const TTipo_valorizz tipo_valorizz,
relmovmag.lfile().set_curr(new TMov_mag());
msg.format(FR("Ricostruzione saldi esercizio %04d ..."), codes);
__cache_saldi = true;
- mov_cur.scan(recalc_mov, (void*)&ok, msg);
+ mov_cur.scan(recalc_mov, (void*)&ok, msg);
if (__cache_saldi && __saldi_mag.items() > 0)
{
@@ -1325,3 +1338,197 @@ bool rebuild_balances(int codes, const TTipo_valorizz tipo_valorizz,
return ok;
}
+
+bool articles_rebuild_balances(int codes, const char* from_art, const char* to_art,
+ const TTipo_valorizz tipo_valorizz)
+{
+ TSystemisamfile a(LF_MOVMAG);
+
+ if (a.open(_excllock) != NOERR)
+ return false;
+
+ const TEsercizi_contabili& esc = esercizi();
+ TBalance_params p;
+
+ p.codes = codes;
+ p.codesprec = esc.pred(codes);
+ p.closed = p.codesprec <= 0 || esc[p.codesprec].chiusura_mag().ok();
+ p.zero_giac = p.closed;
+ p.catv = "";
+ p.codl = "";
+ p.tipov = tipo_valorizz;
+
+ TString msg;
+
+ {
+ // azzera tutte giacenze (ciclo sulle giacenze)
+ TRelation anamag_rel(LF_ANAMAG);
+ TCursor anamag_cur(&anamag_rel);
+ TRectype from(LF_ANAMAG);
+ TRectype to(from);
+
+ if (from_art)
+ from.put(ANAMAG_CODART, from_art);
+ if (to_art)
+ to.put(ANAMAG_CODART, to_art);
+ anamag_cur.setregion(from, to);
+
+ //anamag_cur.relation()->lfile().set_curr(new TArticolo_giacenza());
+ msg.format(FR("Ricostruzione saldi esercizio %04d: azzeramento..."), codes);
+ anamag_cur.scan(reset_giac, (void*)&p, msg);
+ }
+
+ if (p.codesprec > 0)
+ {
+ TRelation clifogiac_rel(LF_CLIFOGIAC);
+ TRectype filter = clifogiac_rel.curr();
+
+ filter.put(CLIFOGIAC_ANNOES, p.codesprec);
+
+ TString select("BETWEEN(CODART,");
+
+ select << '"' << from_art << '"' << ',' << '"' << to_art << '"' << ')';
+ // Scandisce anno precedente
+ TCursor c(&clifogiac_rel, select, 1, &filter, &filter); // ANNO+CODCF+CODART+NRIGA
+ msg.format(FR("Ricostruzione saldi esercizio %04d: azzeramento giacenze clienti..."), codes);
+ c.scan(rel_reset_clifogiac, (void*)&p, msg);
+
+ filter.put(CLIFOGIAC_ANNOES, p.codes); // Scandisce anno corrente
+ c.setregion(filter, filter);
+ msg.format(FR("Ricostruzione saldi esercizio %04d: ricalcolo dotazione iniziale..."), codes);
+ c.scan(rel_reset_newclifogiac, (void*)&p, msg);
+ }
+
+ // ricostruisce i saldi (ciclo sui movimenti)
+ bool ok = true;
+
+ __from_art = from_art;
+ __to_art = to_art;
+ {
+ TRelation relmovmag(LF_MOVMAG);
+ TRectype filter(LF_MOVMAG);
+ filter.put(MOVMAG_ANNOES, codes);
+
+ TCursor mov_cur(&relmovmag, "", 2, &filter, &filter);
+
+ mov_cur = 0L; //non togliere
+ mov_cur.freeze(); // non togliere
+
+ relmovmag.lfile().set_curr(new TMov_mag());
+ msg.format(FR("Ricostruzione saldi esercizio %04d ..."), codes);
+ __cache_saldi = true;
+ mov_cur.scan(recalc_mov, (void*)&ok, msg);
+
+ if (__cache_saldi && __saldi_mag.items() > 0)
+ {
+ TFast_isamfile mag(LF_MAG);
+ TRectype& mag_curr = mag.curr();
+ TString_array keys_mag;
+
+ mag.setkey(2);
+ __saldi_mag.get_keys(keys_mag);
+ keys_mag.sort();
+
+ TString msg = TR("Aggiornamento saldi magazzini");
+ TProgress_monitor pi(keys_mag.items(), msg, false);
+
+ FOR_EACH_ARRAY_ROW(keys_mag, r, curr_key)
+ {
+ const TSaldo_mag& saldo = (const TSaldo_mag&)__saldi_mag[*curr_key];
+ const TCodice_articolo& codart = saldo.codart();
+
+ saldo.putkey(mag_curr);
+
+ int readerr = mag_curr.read(mag, _isequal);
+
+ if (readerr != NOERR)
+ {
+ mag.setkey(1);
+ saldo.putkey(mag_curr);
+ mag_curr.put(MAG_NRIGA, 999);
+ if (mag.read(_isgteq) == NOERR)
+ mag.prev();
+
+ int nriga = 1;
+
+ if (mag_curr.get_int(MAG_ANNOES) == saldo.codes() &&
+ mag_curr.get(MAG_CODART) == saldo.codart())
+ nriga = mag_curr.get_int(MAG_NRIGA) + 1;
+ saldo.putkey(mag_curr);
+ mag_curr.put(MAG_NRIGA, nriga);
+
+ const int err = mag.write();
+
+ CHECKD(err == NOERR, "Mag : Errore di write:", err);
+ mag.setkey(2);
+ }
+ saldo.update_record(mag_curr);
+ if (mag.rewrite() != NOERR)
+ ok = false;
+ pi.add_status();
+ }
+ }
+
+ if (__cache_saldi && __saldi_mag_clifo.items() > 0)
+ {
+ TFast_isamfile clifomag(LF_CLIFOGIAC);
+ TRectype& clifomag_curr = clifomag.curr();
+ TString_array keys_clifo;
+
+ clifomag.setkey(2);
+ __saldi_mag_clifo.get_keys(keys_clifo);
+ keys_clifo.sort();
+
+ TString msg = TR("Aggiornamento saldi magazzini clienti");
+ TProgress_monitor pi(keys_clifo.items(), msg, false);
+
+ for (TToken_string* curr_key = (TToken_string*)keys_clifo.first_item();
+ curr_key != nullptr; curr_key = (TToken_string*)keys_clifo.succ_item())
+ {
+ TSaldo_mag_clifo & saldo = (TSaldo_mag_clifo &)__saldi_mag_clifo[*curr_key];
+ const TCodice_articolo& codart = saldo.codart();
+
+ saldo.putkey(clifomag_curr);
+ if (clifomag.read(_isequal) != NOERR)
+ {
+ // non trovato: aggiungo
+ clifomag.setkey(1);
+ saldo.putkey(clifomag_curr);
+ clifomag_curr.put(CLIFOGIAC_NRIGA, 999);
+ if (clifomag.read(_isgteq) == NOERR)
+ clifomag.prev();
+
+ saldo.putkey(clifomag_curr);
+
+ int nriga = 1;
+
+ if (clifomag_curr.get_int(CLIFOGIAC_ANNOES) == saldo.codes() &&
+ clifomag_curr.get_char(CLIFOGIAC_TIPOCF) == saldo.tipocf() &&
+ clifomag_curr.get(CLIFOGIAC_CODCF) == saldo.codcf() &&
+ clifomag_curr.get(CLIFOGIAC_INDSPED) == saldo.codindsp() &&
+ clifomag_curr.get(CLIFOGIAC_CODART) == saldo.codart())
+ nriga = clifomag_curr.get_int(CLIFOGIAC_NRIGA) + 1;
+ clifomag_curr.put(CLIFOGIAC_NRIGA, nriga);
+
+ const int err = clifomag.write();
+
+ CHECKD(err == NOERR, "Clifomag : Errore di write:", err);
+ clifomag.setkey(2);
+ }
+ saldo.update_record(clifomag_curr);
+ if (clifomag.rewrite() != NOERR)
+ ok = false;
+ pi.add_status();
+ }
+ }
+ __saldi_mag.destroy();
+ __saldi_mag_clifo.destroy();
+ __cache_saldi = false;
+ __from_art = EMPTY_STRING;
+ __to_art = EMPTY_STRING;
+ }
+
+ a.close();
+
+ return ok;
+}