Patch level : 10.0 138
Files correlati : ve*.exe mg *.exe Ricompilazione Demo : [ ] Commento : gestione giacenze per cliente/ fornitore git-svn-id: svn://10.65.10.50/trunk@17356 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
81c02d2a98
commit
1c326244ca
@ -48,7 +48,6 @@ TEsercizi_contabili::TEsercizi_contabili()
|
||||
void TEsercizi_contabili::update()
|
||||
{
|
||||
_firm = prefix().get_codditta();
|
||||
|
||||
_esercizi.destroy();
|
||||
TTable tab_esc("ESC");
|
||||
for (int err = tab_esc.first(); err == NOERR; err = tab_esc.next())
|
||||
@ -223,6 +222,14 @@ bool TEsercizi_contabili::code2range(int codice, TDate& dal, TDate& al) const
|
||||
return ok;
|
||||
}
|
||||
|
||||
TEsercizi_contabili & esercizi()
|
||||
{
|
||||
HIDDEN TEsercizi_contabili __esercizi;
|
||||
|
||||
return __esercizi;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// Simpatici metodi jolly
|
||||
/////////////////////////////////////////////////////////
|
||||
|
@ -64,6 +64,8 @@ public:
|
||||
virtual ~TEsercizi_contabili() {}
|
||||
};
|
||||
|
||||
TEsercizi_contabili & esercizi();
|
||||
|
||||
enum TipoIVA
|
||||
{
|
||||
iva_errata = -1,
|
||||
|
@ -51,6 +51,7 @@
|
||||
#define ANAMAG_PAESE "PAESE"
|
||||
#define ANAMAG_COLLTYPE "COLLTYPE"
|
||||
#define ANAMAG_CODMAG "CODMAG"
|
||||
#define ANAMAG_SOSPESO "SOSPESO"
|
||||
#define ANAMAG_USER1 "USER1"
|
||||
#define ANAMAG_USER2 "USER2"
|
||||
#define ANAMAG_USER3 "USER3"
|
||||
|
@ -4,7 +4,7 @@ CODMAG|1|5|0|Codice magazzino e deposito
|
||||
CODART|1|20|0|Codice articolo
|
||||
LIVELLO|1|15|0|Livello di magazzino
|
||||
NRIGA|2|3|0|-numero riga per sheet anagrafica-
|
||||
ANNOES|1|4|0|Codice esercizio
|
||||
ANNOES|9|4|0|Codice esercizio
|
||||
DATARIF|5|8|0|Data di riferimento
|
||||
UBICAZ|1|12|0|Codice ubicazione
|
||||
RIM|4|15|5|Rimanenze iniziali
|
||||
|
@ -1,7 +1,7 @@
|
||||
110
|
||||
19
|
||||
NUMREG|3|7|0|Numero di registrazione
|
||||
ANNOES|1|4|0|Codice esercizio
|
||||
ANNOES|9|4|0|Codice esercizio
|
||||
DATAREG|5|8|0|Data registrazione
|
||||
DATACOMP|5|8|0|Data competenza
|
||||
DOCPROVV|1|1|0|Doc. interno: Flag numeraz. provvisoria
|
||||
|
@ -3,7 +3,7 @@
|
||||
ANNOESRIF|1|4|0|Anno esercizio di riferimento
|
||||
CODART|1|20|0|Codice Articolo
|
||||
CODMAG|1|3|0|Codice magazzino
|
||||
ANNOES|1|4|0|Anno di esercizio
|
||||
ANNOES|9|4|0|Anno di esercizio
|
||||
UM|1|2|0|Unita' di misura
|
||||
QUANT|4|15|5|Quantita'
|
||||
VALORE|4|18|5|Valore
|
||||
|
@ -22,8 +22,7 @@ class TClifo_giac_mask : public TMask
|
||||
|
||||
TString4 _um_principale;
|
||||
TMagazzini *_magazzini;
|
||||
TEsercizi_contabili *_esercizi_contabili;
|
||||
|
||||
|
||||
static bool notify_sheet_giac(TSheet_field & s, int r, KEY k); // notify delle giacenze
|
||||
static bool handle_sheet_giac_valgiac(TMask_field &, KEY); // handler
|
||||
static bool handle_autoinsert_livgiac(TMask_field &, KEY); // handler del campo
|
||||
@ -37,7 +36,6 @@ public:
|
||||
|
||||
TCodart_livelli* get_livelli_art() const { return livelli_art; }
|
||||
TMagazzini& magazzini() { return *_magazzini; }
|
||||
TEsercizi_contabili &esercizi_contabili() { return *_esercizi_contabili; }
|
||||
|
||||
TClifo_giac_mask(TRelation * rel);
|
||||
virtual ~TClifo_giac_mask() {}
|
||||
@ -183,12 +181,9 @@ void TClifo_giac_mask::set_parametered_fields()
|
||||
delete livelli_giac;
|
||||
if (livelli_art)
|
||||
delete livelli_art;
|
||||
if (_esercizi_contabili)
|
||||
delete _esercizi_contabili;
|
||||
if (_magazzini)
|
||||
delete _magazzini;
|
||||
|
||||
_esercizi_contabili = new TEsercizi_contabili;
|
||||
_magazzini = new TMagazzini;
|
||||
|
||||
// imposta il puntatore al gestore livelli giacenze
|
||||
@ -242,7 +237,6 @@ TClifo_giac_mask::TClifo_giac_mask(TRelation * rel) : TMask("mg0400a")
|
||||
|
||||
livelli_giac = NULL;
|
||||
livelli_art = NULL;
|
||||
_esercizi_contabili = NULL;
|
||||
_magazzini = NULL;
|
||||
|
||||
set_parametered_fields();
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <relapp.h>
|
||||
#include <msksheet.h>
|
||||
|
||||
#include "anamag.h"
|
||||
#include "mg1100.h"
|
||||
#include <cfven.h>
|
||||
|
||||
@ -14,9 +15,6 @@
|
||||
//
|
||||
class TMask_movmag : public TMask
|
||||
{
|
||||
static TArticolo_giacenza* _curr_art;
|
||||
|
||||
TEsercizi_contabili _esercizi;
|
||||
TMov_mag * _mov_mag;
|
||||
TCodice_articolo _price_codart;
|
||||
real price_quant;
|
||||
@ -46,7 +44,6 @@ class TMask_movmag : public TMask
|
||||
static void sheetrighe_put(TSheet_field &fld_righe, int item);
|
||||
static void sheetrighe_get(TSheet_field &fld_righe, int item);
|
||||
public:
|
||||
TArticolo_giacenza& curr_art();
|
||||
void update_tot();
|
||||
const TMagazzini& magazzini() const { return _magazzini; }
|
||||
int autorows() const { return _autorows;}
|
||||
@ -55,7 +52,6 @@ public:
|
||||
virtual ~TMask_movmag();
|
||||
};
|
||||
|
||||
TArticolo_giacenza* TMask_movmag::_curr_art = NULL;
|
||||
|
||||
// HANDLER DEL CODICE LIVELLO anagrafica
|
||||
bool TMask_movmag::codgrp_handler(TMask_field& f, KEY k)
|
||||
@ -357,13 +353,6 @@ bool TMask_movmag::handle_righeprezzo2(TMask_field &f, KEY k)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
TArticolo_giacenza& TMask_movmag::curr_art()
|
||||
{
|
||||
if (_curr_art == NULL)
|
||||
_curr_art = new TArticolo_giacenza;
|
||||
return *_curr_art;
|
||||
}
|
||||
|
||||
bool TMask_movmag::handle_checksosp(TMask_field &f, KEY k)
|
||||
{
|
||||
if (k==K_TAB && f.focusdirty())
|
||||
@ -371,15 +360,20 @@ bool TMask_movmag::handle_checksosp(TMask_field &f, KEY k)
|
||||
TMask_movmag& mov_mask = (TMask_movmag &)f.mask().get_sheet()->mask();
|
||||
TMask & row_mask = f.mask();
|
||||
|
||||
mov_mask.curr_art().read(row_mask.get(F_CODART));
|
||||
|
||||
TString8 caus(row_mask.get(F_CAUSRIG));
|
||||
if (caus.empty())
|
||||
caus = mov_mask.get(F_CODCAUS);
|
||||
const TCausale_magazzino c(caus);
|
||||
if (!c.movimenta_sospesi() && mov_mask.curr_art().get_bool("SOSPESO"))
|
||||
return error_box(FR("Articolo %s sospeso, quindi non movimentabile"), (const char *)f.get());
|
||||
|
||||
const TCausale_magazzino & c = cached_causale_magazzino(caus);
|
||||
|
||||
if (!c.movimenta_sospesi())
|
||||
{
|
||||
const bool sospeso = cached_article(row_mask.get(F_CODART)).get_bool(ANAMAG_SOSPESO);
|
||||
|
||||
if (sospeso)
|
||||
return error_box(FR("Articolo %s sospeso, quindi non movimentabile"), (const char *)f.get());
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -419,7 +413,6 @@ bool TMask_movmag::handle_codarticolo(TMask_field &f, KEY k)
|
||||
|
||||
if (ok)
|
||||
{
|
||||
mov_mask.curr_art().read(codart);
|
||||
ok = handle_checksosp(f, k);
|
||||
if (ok)
|
||||
handle_righeprezzo1(f, k);
|
||||
@ -463,9 +456,10 @@ bool TMask_movmag::handle_giacattuale(TMask_field &f, KEY k)
|
||||
const TString& um = maskrighe.get(F_UM);
|
||||
if (um.not_empty())
|
||||
{
|
||||
TArticolo_giacenza & art = maskmov.curr_art();
|
||||
TArticolo_giacenza & art = cached_article_balances(maskrighe.get(F_CODART));
|
||||
real disp = art.disponibilita(maskmov.get(F_ANNOES),codmag,codliv,TRUE);
|
||||
disp = art.convert_to_um(disp, um, NULL, false);
|
||||
|
||||
disp = art.convert_to_um(disp, um, NULL, false);
|
||||
f.set(disp.string());
|
||||
}
|
||||
}
|
||||
@ -759,7 +753,7 @@ bool TMask_movmag::handle_datacomp(TMask_field &fld, KEY k)
|
||||
if (k == K_TAB) // && fld.focusdirty())
|
||||
{
|
||||
TMask_movmag& m = (TMask_movmag&) fld.mask();
|
||||
const int codes = m._esercizi.date2esc(TDate(fld.get()));
|
||||
const int codes = esercizi().date2esc(TDate(fld.get()));
|
||||
if (codes > 0)
|
||||
{
|
||||
m.set(F_ANNOES, codes);
|
||||
@ -798,9 +792,6 @@ inline TApp_movmag& app() { return (TApp_movmag&) main_app(); }
|
||||
|
||||
int TApp_movmag::read(TMask& m)
|
||||
{
|
||||
TArticolo_giacenza & art = _msk->curr_art();
|
||||
|
||||
art.read("");
|
||||
const int err = TRelation_application::read(m);
|
||||
if (err == NOERR)
|
||||
((TMask_movmag &)m).update_tot();
|
||||
|
@ -144,11 +144,11 @@ BEGIN
|
||||
FLAGS "G"
|
||||
FIELD TIPOCF
|
||||
ITEM " |Nessuno"
|
||||
MESSAGE HIDE,F_CODCF|HIDE,F_RAGSOC|HIDE,F_INDSPED|HIDE,F_INDIR|RESET,F_CODCF|RESET,F_RAGSOC|RESET,F_INDSPED|RESET,F_INDIR
|
||||
MESSAGE CLEAR,F_CODCF|CLEAR,F_RAGSOC|CLEAR,F_INDSPED|CLEAR,F_INDIR
|
||||
ITEM "C|Cliente"
|
||||
MESSAGE SHOW,F_CODCF|SHOW,F_RAGSOC|SHOW,F_INDSPED|SHOW,F_INDIR
|
||||
MESSAGE ENABLE,F_CODCF|ENABLE,F_RAGSOC|ENABLE,F_INDSPED|ENABLE,F_INDIR
|
||||
ITEM "F|Fornitore"
|
||||
MESSAGE SHOW,F_CODCF|SHOW,F_RAGSOC|SHOW,F_INDSPED|SHOW,F_INDIR
|
||||
MESSAGE ENABLE,F_CODCF|ENABLE,F_RAGSOC|ENABLE,F_INDSPED|ENABLE,F_INDIR
|
||||
GROUP G_DEFMOV
|
||||
END
|
||||
|
||||
@ -157,7 +157,7 @@ END
|
||||
NUMBER F_CODCF 6
|
||||
BEGIN
|
||||
PROMPT 15 11 "Codice "
|
||||
FLAGS "GR"
|
||||
FLAGS "R"
|
||||
FIELD CODCF
|
||||
USE LF_CLIFO
|
||||
INPUT TIPOCF F_TIPOCF SELECT
|
||||
@ -179,7 +179,7 @@ BEGIN
|
||||
INPUT RAGSOC F_RAGSOC
|
||||
DISPLAY "Ragione sociale@50" RAGSOC
|
||||
DISPLAY "Codice " CODCF
|
||||
OUTPUT F_CODCF CODCF
|
||||
COPY OUTPUT F_CODCF
|
||||
CHECKTYPE NORMAL
|
||||
GROUP G_DEFMOV
|
||||
ADD RUN CG0 -1
|
||||
|
@ -22,7 +22,7 @@ TMask_buildmov::TMask_buildmov()
|
||||
|
||||
bool TMask_buildmov::handle_annoes(TMask_field &fld, KEY k)
|
||||
{
|
||||
TMask_buildmov &mask=(TMask_buildmov &)fld.mask();
|
||||
TMask_buildmov &mask = (TMask_buildmov &)fld.mask();
|
||||
if (fld.empty())
|
||||
{
|
||||
// DEFAULT
|
||||
@ -50,7 +50,7 @@ class TApp_rebuildbalances : public TSkeleton_application
|
||||
{
|
||||
TRelation* _rel; // relazione
|
||||
TCursor* _cur; // cursore
|
||||
TString4 _annoes;
|
||||
int _annoes;
|
||||
bool _reset_giac;
|
||||
|
||||
protected:
|
||||
@ -64,7 +64,8 @@ public:
|
||||
|
||||
bool TApp_rebuildbalances::create()
|
||||
{
|
||||
open_files(LF_ANAMAG,LF_UMART,LF_MAG,LF_MOVMAG,LF_RMOVMAG,LF_TABCOM,LF_STOMAG, LF_DESLIN, LF_CODCORR, 0);
|
||||
open_files(LF_UMART, LF_MAG, LF_RMOVMAG, LF_TABCOM, LF_STOMAG,
|
||||
LF_DESLIN, LF_CODCORR, 0);
|
||||
return TSkeleton_application::create();
|
||||
}
|
||||
|
||||
@ -74,7 +75,7 @@ void TApp_rebuildbalances::main_loop()
|
||||
TMask_buildmov m;
|
||||
while (m.run()==K_ENTER)
|
||||
{
|
||||
if (!rebuild_balances(m.get(F_ANNOES)))
|
||||
if (!rebuild_balances(m.get_int(F_ANNOES)))
|
||||
warning_box(TR("A causa degli errori riscontrati i saldi di magazzino \npotrebbero non essere stati del tutto aggiornati. \nProcedere ad una nuova operazione di ''Ricostruzione saldi''"));
|
||||
|
||||
}
|
||||
|
@ -174,10 +174,9 @@ bool TMask_openclose::handle_val(TMask_field &fld, KEY k)
|
||||
class TApp_openclose : public TSkeleton_application
|
||||
{
|
||||
TMask_openclose *_msk;
|
||||
TArray _movimenti; // Array di movimenti di TMov_mag
|
||||
TString_array _causali; // Array delle causali per i movimenti d'apertura (7)
|
||||
TString _es_to_close;
|
||||
TString _es_to_open;
|
||||
int _es_to_close;
|
||||
int _es_to_open;
|
||||
TString _catven;
|
||||
TString _codlis;
|
||||
TDate _date_to_close;
|
||||
@ -204,7 +203,7 @@ public:
|
||||
bool TApp_openclose::create()
|
||||
{
|
||||
TConfig c(CONFIG_DITTA);
|
||||
open_files(LF_ANAMAG, LF_UMART, LF_MAG, LF_MOVMAG, LF_RMOVMAG, LF_STOMAG, 0);
|
||||
open_files(LF_ANAMAG, LF_UMART, LF_MAG, LF_RMOVMAG, LF_STOMAG, 0);
|
||||
_msk = new TMask_openclose(!c.get_bool("RIPORD"));
|
||||
return TSkeleton_application::create();
|
||||
}
|
||||
@ -355,15 +354,18 @@ void TApp_openclose::chiudi_esercizio()
|
||||
{
|
||||
TRelation rel(LF_ANAMAG);
|
||||
TCursor cur(&rel);
|
||||
TArray movimenti; // Array di movimenti di TMov_mag
|
||||
|
||||
rel.lfile().set_curr(new TArticolo_giacenza()); // setta il Multirec come current della relazione
|
||||
|
||||
TString descr1, descr2, codmag;
|
||||
int err = NOERR;
|
||||
|
||||
TTable esc("ESC");
|
||||
TTable magazzini("MAG");
|
||||
|
||||
// rebuild_balances(_es_to_close); // Cosi' ci assicuriamo che i saldi dell'esercizio vecchio siano a posto
|
||||
descr1.format(_what == definitiva ? FR("Apertura esercizio %s") : FR("Aggiornamento saldi esercizio %s"), (const char*) _es_to_open);
|
||||
descr1.format(_what == definitiva ? FR("Apertura esercizio %04d") : FR("Aggiornamento saldi esercizio %04d"), _es_to_open);
|
||||
descr2 << descr1 << TR(" in corso...");
|
||||
|
||||
// cose specifiche per chiusura definitiva...
|
||||
@ -378,8 +380,8 @@ void TApp_openclose::chiudi_esercizio()
|
||||
{
|
||||
for (int j = 0; j < 9; j++)
|
||||
{
|
||||
_movimenti.add(new TMov_mag);
|
||||
TRectype& h = ((TMov_mag&) _movimenti[j]).head();
|
||||
movimenti.add(new TMov_mag);
|
||||
TRectype& h = ((TMov_mag&) movimenti[j]).head();
|
||||
h.put(MOVMAG_NUMREG, numreg++);
|
||||
h.put(MOVMAG_DESCR, descr1);
|
||||
indici[j] = j;
|
||||
@ -413,17 +415,17 @@ void TApp_openclose::chiudi_esercizio()
|
||||
continue; // Salta eventuali causali vuote
|
||||
// se il numero di righe di questo movimento eccede le 500 ne crea uno nuovo e
|
||||
// setta il nuovo indice
|
||||
const int rows = ((TMov_mag&) _movimenti[indici[i]]).rows() ;
|
||||
const int rows = ((TMov_mag&) movimenti[indici[i]]).rows() ;
|
||||
if (rows > MAX_ROWS)
|
||||
{
|
||||
_movimenti.add(new TMov_mag);
|
||||
movimenti.add(new TMov_mag);
|
||||
last++;
|
||||
indici[i] = last;
|
||||
TRectype& h = ((TMov_mag&) _movimenti[last]).head();
|
||||
TRectype& h = ((TMov_mag&) movimenti[last]).head();
|
||||
h.put(MOVMAG_NUMREG, numreg++); // Aggiorna il nr. reg per il prossimo movimento
|
||||
h.put(MOVMAG_DESCR, descr1);
|
||||
}
|
||||
TMov_mag& currmov = (TMov_mag&) _movimenti[indici[i]];
|
||||
TMov_mag& currmov = (TMov_mag&) movimenti[indici[i]];
|
||||
compila_movimento(currmov, art, rec, i);
|
||||
}
|
||||
}
|
||||
@ -489,12 +491,12 @@ void TApp_openclose::chiudi_esercizio()
|
||||
delete prog;
|
||||
// **************
|
||||
// Effettua la scrittura dei movimenti di apertura generati
|
||||
const int max_mov = _movimenti.items();
|
||||
const int max_mov = movimenti.items();
|
||||
prog = new TProgind(max_mov, TR("Scrittura movimenti di apertura in corso..."),FALSE,TRUE);
|
||||
for (int i=0; err == NOERR && i<max_mov;i++)
|
||||
{
|
||||
prog->addstatus(1L);
|
||||
TMov_mag& mov = (TMov_mag&) _movimenti[i];
|
||||
TMov_mag& mov = (TMov_mag&) movimenti[i];
|
||||
if (mov.rows() == 0)
|
||||
continue; // Salta eventuali movimenti senza righe (OrdC e OrdF)
|
||||
// Effettua la rinumerazione del movimento se esso esiste gia'?
|
||||
@ -521,14 +523,9 @@ void TApp_openclose::chiudi_esercizio()
|
||||
}
|
||||
else
|
||||
error_box(FR("Errore %d durante la scrittura dei movimenti."),err);
|
||||
_movimenti.destroy();
|
||||
movimenti.destroy();
|
||||
}
|
||||
|
||||
// A questo punto l'esercizio vecchio e' marcato come chiuso in base al tipo di chiusura
|
||||
// (definitiva o provvisoria); La ricostruzione dei saldi e' comune in entrambi i casi:
|
||||
// la rebuild_balances() deve sapere da sola se azzerare o meno le giacenze
|
||||
// a seconda che l'esercizio precedente sia chiuso (AZZERA) o no (NON AZZERARE).
|
||||
rebuild_balances(_es_to_open, _calctype, _catven, _codlis);
|
||||
esercizi().update();
|
||||
}
|
||||
|
||||
|
||||
@ -550,14 +547,14 @@ void TApp_openclose::main_loop()
|
||||
_msk->set(F_ESTOCLOSE,es_close);
|
||||
}
|
||||
|
||||
while (_msk->run() == K_ENTER)
|
||||
while (_msk->run() == K_ENTER)
|
||||
{
|
||||
// Here is
|
||||
_causali.destroy();
|
||||
_date_to_close = _msk->get_date(F_DATECLOSE);
|
||||
_date_to_open = _msk->get_date(F_DATEOPEN);
|
||||
_es_to_close = _msk->get(F_ESTOCLOSE);
|
||||
_es_to_open = _msk->get(F_ESTOOPEN);
|
||||
_es_to_close = _msk->get_int(F_ESTOCLOSE);
|
||||
_es_to_open = _msk->get_int(F_ESTOOPEN);
|
||||
_calctype = (TTipo_valorizz) _msk->get_int(F_VALORIZZAZIONE);
|
||||
_what = (action) _msk->get_int(F_WHAT); //Provvisoria o definitiva?
|
||||
_valorizza_comp= _msk->get(F_VALCOMP)=="C"; //Valorizza i componenti o i finiti
|
||||
@ -566,6 +563,11 @@ void TApp_openclose::main_loop()
|
||||
for (short xx = F_CAURIM; xx <= F_CAUVAL; xx++) // legge le causali impostate
|
||||
_causali.add(_msk->get(xx));
|
||||
chiudi_esercizio(); // Chiusura esercizio
|
||||
// A questo punto l'esercizio vecchio e' marcato come chiuso in base al tipo di chiusura
|
||||
// (definitiva o provvisoria); La ricostruzione dei saldi e' comune in entrambi i casi:
|
||||
// la rebuild_balances() deve sapere da sola se azzerare o meno le giacenze
|
||||
// a seconda che l'esercizio precedente sia chiuso (AZZERA) o no (NON AZZERARE).
|
||||
rebuild_balances(_es_to_open, _calctype, _catven, _codlis);
|
||||
}
|
||||
}
|
||||
|
||||
|
430
mg/mglib02.cpp
430
mg/mglib02.cpp
@ -6,6 +6,7 @@
|
||||
#include <diction.h>
|
||||
#include <fraction.h>
|
||||
#include <progind.h>
|
||||
#include <utility.h>
|
||||
|
||||
#include "mglib.h"
|
||||
#include "../cg/cglib01.h"
|
||||
@ -273,41 +274,43 @@ bool TArticolo::unlock()
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool TArticolo::lock_and_prompt(const char * cod)
|
||||
bool TArticolo::lock_and_prompt(word lockop)
|
||||
{
|
||||
int err = _iskeyerr;
|
||||
if (cod && *cod)
|
||||
err = read(cod,_isequal,_testandlock);
|
||||
if (lockop != _nolock)
|
||||
{
|
||||
int err = read(_codice, _isequal, _testandlock);
|
||||
|
||||
if (err != NOERR)
|
||||
{
|
||||
TString mess;
|
||||
if (err == _islocked)
|
||||
{
|
||||
mess << TR("Il record di anagrafica\ndell'articolo '") << cod << TR("' e' gia' usato da un altro programma.");
|
||||
TTimed_skipbox bbox((const char *)mess,10);
|
||||
while (err == _islocked)
|
||||
{
|
||||
bbox.run();
|
||||
err = read(cod,_isequal,_testandlock);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (err == _iskeyerr)
|
||||
mess << TR("Il codice articolo '") << cod << TR("' non e' valido");
|
||||
else
|
||||
if (err == _iskeynotfound)
|
||||
mess << TR("Il record di anagrafica\ndell'articolo '")<< cod << TR("' non esiste.");
|
||||
else
|
||||
mess << TR("Non riesco ad accedere al\nrecord di anagrafica dell'articolo '")<< cod << TR("' - errore ") << err << ".";
|
||||
TTimed_skipbox bbox((const char *)mess,10);
|
||||
|
||||
bbox.run();
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
if (err != NOERR)
|
||||
{
|
||||
TString mess;
|
||||
|
||||
if (err == _islocked)
|
||||
{
|
||||
mess << TR("Il record di anagrafica\ndell'articolo '") << _codice << TR("' e' gia' usato da un altro programma.");
|
||||
TTimed_skipbox bbox((const char *)mess,10);
|
||||
while (err == _islocked)
|
||||
{
|
||||
bbox.run();
|
||||
err = read(_codice,_isequal,_testandlock);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (err == _iskeyerr)
|
||||
mess << TR("Il codice articolo '") << _codice << TR("' non e' valido");
|
||||
else
|
||||
if (err == _iskeynotfound)
|
||||
mess << TR("Il record di anagrafica\ndell'articolo '")<< _codice << TR("' non esiste.");
|
||||
else
|
||||
mess << TR("Non riesco ad accedere al\nrecord di anagrafica dell'articolo '")<< _codice << TR("' - errore ") << err << ".";
|
||||
TTimed_skipbox bbox((const char *)mess,10);
|
||||
|
||||
bbox.run();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int TArticolo::find_um(const char* um, int from) const
|
||||
@ -411,25 +414,35 @@ TArticolo::TArticolo(const TRectype& rec)
|
||||
read(rec.get(ANAMAG_CODART));
|
||||
}
|
||||
|
||||
TArticolo::~TArticolo()
|
||||
{
|
||||
}
|
||||
|
||||
class TArticoli_cache : public TCache
|
||||
///////////////////////////////////////////////////////////
|
||||
// TCache_articoli
|
||||
///////////////////////////////////////////////////////////
|
||||
class TCache_articoli : public TRecord_cache
|
||||
{
|
||||
protected:
|
||||
virtual TObject * key2obj(const char * articolo) { return new TArticolo(articolo); }
|
||||
virtual TObject* rec2obj(const TRectype& rec) const{ return new TArticolo(rec); }
|
||||
|
||||
|
||||
public:
|
||||
const TArticolo & get(const char * articolo) { return *(const TArticolo *) objptr(articolo);}
|
||||
TArticolo& art(const char* key){ return (TArticolo_giacenza&)query(key); }
|
||||
|
||||
TCache_articoli();
|
||||
virtual ~TCache_articoli() { }
|
||||
};
|
||||
|
||||
const TArticolo & cached_articolo(const char * articolo)
|
||||
{
|
||||
static TArticoli_cache * art_cache = NULL;
|
||||
|
||||
if (art_cache == NULL)
|
||||
art_cache = new TArticoli_cache();
|
||||
return art_cache->get(articolo);
|
||||
TCache_articoli::TCache_articoli()
|
||||
: TRecord_cache(LF_ANAMAG, 1)
|
||||
{
|
||||
test_file_changes(); // Tieni d'occhio le modifiche sul file
|
||||
set_items_limit(256); // Standard
|
||||
}
|
||||
|
||||
TArticolo & cached_article(const char * codart)
|
||||
{
|
||||
HIDDEN TCache_articoli __cache_articoli;
|
||||
|
||||
return __cache_articoli.art(codart);
|
||||
}
|
||||
|
||||
// *****************
|
||||
@ -505,14 +518,14 @@ void TArticolo_giacenza::set_body_key(TRectype & rowrec)
|
||||
}
|
||||
}
|
||||
|
||||
void TArticolo_giacenza::set_anno_mag (const char * anno)
|
||||
void TArticolo_giacenza::set_anno_mag (int anno)
|
||||
{
|
||||
if (_anno_mag != anno)
|
||||
remove_body(LF_MAG);
|
||||
_anno_mag = anno;
|
||||
}
|
||||
|
||||
void TArticolo_giacenza::set_anno_sto (const char * anno)
|
||||
void TArticolo_giacenza::set_anno_sto (int anno)
|
||||
{
|
||||
if (_anno_sto != anno)
|
||||
remove_body(LF_STOMAG);
|
||||
@ -550,7 +563,7 @@ int TArticolo_giacenza::find_mag(TRecord_array& rmag, const char * codmag, const
|
||||
return -1;
|
||||
}
|
||||
|
||||
int TArticolo_giacenza::find_mag(const char * annoes, const char * codmag, const char * livello, int from) const
|
||||
int TArticolo_giacenza::find_mag(int annoes, const char * codmag, const char * livello, int from) const
|
||||
{
|
||||
TRecord_array & rmag = mag(annoes);
|
||||
return find_mag(rmag, codmag, livello, from);
|
||||
@ -560,7 +573,7 @@ int TArticolo_giacenza::find_storico(TRecord_array& rsto, const char * codmag, i
|
||||
{
|
||||
const int last = rsto.last_row();
|
||||
|
||||
if (last > 0 && from < last)
|
||||
if (last > 0 && from < last)
|
||||
{
|
||||
const int codmag_len = codmag ? strlen(codmag) : 0;
|
||||
|
||||
@ -578,63 +591,29 @@ int TArticolo_giacenza::find_storico(TRecord_array& rsto, const char * codmag, i
|
||||
return -1;
|
||||
}
|
||||
|
||||
int TArticolo_giacenza::find_storico(const char * annoesrif, const char * codmag, int from) const
|
||||
int TArticolo_giacenza::find_storico(int annoesrif, const char * codmag, int from) const
|
||||
{
|
||||
TRecord_array & rsto = storico(annoesrif);
|
||||
return find_storico(rsto, codmag, from);
|
||||
}
|
||||
|
||||
TRecord_array & TArticolo_giacenza::mag(const char* annoes) const
|
||||
TRecord_array & TArticolo_giacenza::mag(int annoes) const
|
||||
{
|
||||
TString4 anno = annoes;
|
||||
if (anno.blank())
|
||||
{
|
||||
TEsercizi_contabili ese;
|
||||
anno.format("%04d", ese.last_mag());
|
||||
}
|
||||
((TArticolo_giacenza*)this)->set_anno_mag(anno);
|
||||
((TArticolo_giacenza*)this)->set_anno_mag(annoes > 0 ? annoes : esercizi().last_mag());
|
||||
return body(LF_MAG);
|
||||
}
|
||||
|
||||
TRecord_array & TArticolo_giacenza::storico(const char * annoesrif) const
|
||||
TRecord_array & TArticolo_giacenza::storico(int annoesrif) const
|
||||
{
|
||||
TString16 anno = annoesrif;
|
||||
if (anno.blank())
|
||||
{
|
||||
TEsercizi_contabili ese;
|
||||
anno.format("%04d", ese.last_mag());
|
||||
}
|
||||
((TArticolo_giacenza *) this)->set_anno_sto(anno);
|
||||
((TArticolo_giacenza *) this)->set_anno_sto(annoesrif > 0 ? annoesrif : esercizi().last_mag());
|
||||
return body(LF_STOMAG);
|
||||
}
|
||||
|
||||
bool TArticolo_giacenza::is_last_esercizio(const char* annoes) const
|
||||
bool TArticolo_giacenza::is_last_esercizio(int annoes) const
|
||||
{
|
||||
bool yes = TRUE;
|
||||
if (annoes && *annoes)
|
||||
{
|
||||
const int anno = atoi(annoes);
|
||||
if (anno > 0)
|
||||
{
|
||||
TEsercizi_contabili e;
|
||||
yes = !e.esercizio(anno).chiusura_mag().ok() ;
|
||||
}
|
||||
}
|
||||
return yes;
|
||||
return annoes > 0 ? !esercizi().esercizio(annoes).chiusura_mag().ok() : false;
|
||||
}
|
||||
|
||||
|
||||
const char* const zero_fields[] =
|
||||
{
|
||||
MAG_GIAC, MAG_PRODFIN, MAG_INCL, MAG_ACL, MAG_NLABEL,
|
||||
MAG_RIM, MAG_VALRIM, MAG_ACQ, MAG_VALACQ, MAG_ENT, MAG_VALENT,
|
||||
MAG_VEN, MAG_VALVEN, MAG_USC, MAG_VALUSC, MAG_ORDF, MAG_VALORDF,
|
||||
MAG_ORDC, MAG_VALORDC, MAG_SCARTI, MAG_VALSCARTI, MAG_PRODCOMP,
|
||||
"USER1", "USERVAL1", "USER2", "USERVAL2", "USER3", "USERVAL3",
|
||||
"USER4", "USERVAL4", "USER5", "USERVAL5", "USER6", "USERVAL6",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char* const protected_fields[] =
|
||||
{
|
||||
MAG_UBICAZ, MAG_LIVRIOR, MAG_SCORTAMIN, MAG_LOTTORIOR, MAG_LOTTOIRIOR, MAG_GIORNIRIOR, NULL
|
||||
@ -658,9 +637,9 @@ bool TArticolo_giacenza::is_deletable(const TRectype& mag) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TArticolo_giacenza::azzera_saldi(const char* cod_es, bool save_to_disk)
|
||||
bool TArticolo_giacenza::azzera_saldi(int codes, bool save_to_disk)
|
||||
{
|
||||
TRecord_array& rec_arr = TArticolo_giacenza::mag(cod_es);
|
||||
TRecord_array& rec_arr = mag(codes);
|
||||
|
||||
const int last = rec_arr.last_row();
|
||||
for (int r = last; r > 0; r = rec_arr.pred_row(r)) // Scorre le righe
|
||||
@ -671,26 +650,26 @@ bool TArticolo_giacenza::azzera_saldi(const char* cod_es, bool save_to_disk)
|
||||
if (is_deletable(mag))
|
||||
rec_arr.destroy_row(r, TRUE);
|
||||
}
|
||||
bool ok = TRUE;
|
||||
bool ok = true;
|
||||
if (save_to_disk)
|
||||
ok = rec_arr.write(TRUE) == NOERR;
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TArticolo_giacenza::riporta_saldi(const char * oldes, const char* newes, const TTipo_valorizz tipo,
|
||||
|
||||
bool TArticolo_giacenza::riporta_saldi(int oldes, int newes, const TTipo_valorizz tipo,
|
||||
const char* catven, const char* codlis, bool save_to_disk)
|
||||
{
|
||||
TString codes(newes), mag, liv;
|
||||
TRecord_array& rec_arr = TArticolo_giacenza::mag(oldes);
|
||||
TString8 codmag;
|
||||
TString16 liv;
|
||||
TRecord_array& rec_arr = mag(oldes);
|
||||
const int last = rec_arr.last_row();
|
||||
real rim, val, giac, inpf, proc, icl, acl;
|
||||
TCurrency currency(ZERO);
|
||||
|
||||
rec_arr.renum_key(MAG_ANNOES, codes); // Rinumera
|
||||
for (int r = last;r > 0 ; r = rec_arr.pred_row(r)) // Scorre le righe
|
||||
rec_arr.renum_key(MAG_ANNOES, newes); // Rinumera
|
||||
for (int r = last; r > 0 ; r = rec_arr.pred_row(r)) // Scorre le righe
|
||||
{
|
||||
TRectype& rec = rec_arr[r];
|
||||
mag = rec.get(MAG_CODMAG); mag.cut(3);
|
||||
codmag = rec.get(MAG_CODMAG); codmag.cut(3);
|
||||
liv = rec.get(MAG_LIVELLO);
|
||||
giac = rec.get_real(MAG_GIAC);
|
||||
inpf = rec.get_real(MAG_PRODFIN);
|
||||
@ -701,10 +680,10 @@ bool TArticolo_giacenza::riporta_saldi(const char * oldes, const char* newes, co
|
||||
switch (tipo)
|
||||
{
|
||||
case valorizz_costmedio:
|
||||
val = costo_medio(oldes, mag, liv);
|
||||
val = costo_medio(oldes, codmag, liv);
|
||||
break;
|
||||
case valorizz_costmediopond:
|
||||
val = costo_mediopond(oldes, mag, liv);
|
||||
val = costo_mediopond(oldes, codmag, liv);
|
||||
break;
|
||||
case valorizz_ultcos:
|
||||
val = ultimo_costo(oldes);
|
||||
@ -719,22 +698,22 @@ bool TArticolo_giacenza::riporta_saldi(const char * oldes, const char* newes, co
|
||||
val = costo_standard(oldes);
|
||||
break;
|
||||
case valorizz_FIFOa:
|
||||
val = FIFO_annuale(oldes, mag, liv);
|
||||
val = FIFO_annuale(oldes, codmag, liv);
|
||||
break;
|
||||
case valorizz_LIFOa:
|
||||
val = LIFO_annuale(oldes, mag, liv);
|
||||
val = LIFO_annuale(oldes, codmag, liv);
|
||||
break;
|
||||
case valorizz_FIFO:
|
||||
val = FIFO(oldes, mag, liv);
|
||||
val = FIFO(oldes, codmag, liv);
|
||||
break;
|
||||
case valorizz_LIFO:
|
||||
val = LIFO(oldes, mag, liv);
|
||||
val = LIFO(oldes, codmag, liv);
|
||||
break;
|
||||
case valorizz_FIFOr:
|
||||
val = FIFO_ragionieristico(oldes, mag, liv);
|
||||
val = FIFO_ragionieristico(oldes, codmag, liv);
|
||||
break;
|
||||
case valorizz_LIFOr:
|
||||
val = LIFO_ragionieristico(oldes, mag, liv);
|
||||
val = LIFO_ragionieristico(oldes, codmag, liv);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -742,16 +721,17 @@ bool TArticolo_giacenza::riporta_saldi(const char * oldes, const char* newes, co
|
||||
// Setta il prezzo al nr di decimali fissati per i prezzi della valuta corrente
|
||||
if (tipo < valorizz_FIFOa)
|
||||
{
|
||||
currency.set_price(TRUE);
|
||||
currency.set_num(val);
|
||||
val = currency.get_num();
|
||||
TPrice p;
|
||||
p.set_num(val);
|
||||
val = p.get_num();
|
||||
}
|
||||
val *= rim;
|
||||
|
||||
// Setta l'importo al nr di decimali fissati per gli importi della valuta corrente
|
||||
currency.set_price(FALSE);
|
||||
currency.set_num(val);
|
||||
val = currency.get_num();
|
||||
TCurrency c;
|
||||
|
||||
c.set_num(val);
|
||||
val = c.get_num();
|
||||
rec.put(MAG_RIM, rim); rec.put(MAG_VALRIM, val);
|
||||
rec.zero(MAG_ACQ); rec.zero(MAG_VALACQ);
|
||||
rec.zero(MAG_ENT); rec.zero(MAG_VALENT);
|
||||
@ -776,15 +756,15 @@ bool TArticolo_giacenza::riporta_saldi(const char * oldes, const char* newes, co
|
||||
const TRecord_array copia(rec_arr);
|
||||
if (copia.rows() > 0)
|
||||
{
|
||||
TRecord_array& nuovo = TArticolo_giacenza::mag(codes);
|
||||
TRecord_array& nuovo = mag(newes);
|
||||
nuovo = copia;
|
||||
}
|
||||
else
|
||||
azzera_saldi(codes, FALSE);
|
||||
azzera_saldi(newes, false);
|
||||
}
|
||||
|
||||
// Scrive il pastrocchio (eventualmente sovrascrive)
|
||||
return save_to_disk ? (rec_arr.write(TRUE) == NOERR) : TRUE;
|
||||
return save_to_disk ? (rec_arr.write(true) == NOERR) : true;
|
||||
}
|
||||
|
||||
real TArticolo_giacenza::disponibilita(const char * annoes, const char * codmag, const char * livello, bool solo_giac) const
|
||||
@ -806,8 +786,7 @@ real TArticolo_giacenza::disponibilita(const char * annoes, const char * codmag,
|
||||
}
|
||||
if (!solo_giac && !riporta_ordinato()) // Se l-ordinato viene riportato
|
||||
{
|
||||
TEsercizi_contabili ese;
|
||||
const int prev = ese.pred(atoi(annoes)); // Controllo anche l'anno precedente
|
||||
const int prev = esercizi().pred(atoi(annoes)); // Controllo anche l'anno precedente
|
||||
if (prev > 0)
|
||||
{
|
||||
TString8 oldannoes; oldannoes.format("%04d", prev);
|
||||
@ -824,7 +803,7 @@ real TArticolo_giacenza::disponibilita(const char * annoes, const char * codmag,
|
||||
return giac;
|
||||
}
|
||||
|
||||
real TArticolo_giacenza::ultimo_costo(const char * annoes) const
|
||||
real TArticolo_giacenza::ultimo_costo(int annoes) const
|
||||
{
|
||||
if (is_last_esercizio(annoes))
|
||||
{
|
||||
@ -833,14 +812,18 @@ real TArticolo_giacenza::ultimo_costo(const char * annoes) const
|
||||
}
|
||||
else
|
||||
{
|
||||
const int index = find_storico(annoes);
|
||||
if (index < 0 ) return ZERO;
|
||||
const real costo = storico(annoes).row(index).get_real(STOMAG_ULTCOS1);
|
||||
return costo.is_zero() ? costo_standard(annoes) : costo;
|
||||
const int index = find_storico(annoes);
|
||||
|
||||
if (index >= 0 )
|
||||
{
|
||||
const real costo = storico(annoes).row(index).get_real(STOMAG_ULTCOS1);
|
||||
return costo.is_zero() ? costo_standard(annoes) : costo;
|
||||
}
|
||||
}
|
||||
return ZERO;
|
||||
}
|
||||
|
||||
real TArticolo_giacenza::media_costi(const char * annoes) const
|
||||
real TArticolo_giacenza::media_costi(int annoes) const
|
||||
{
|
||||
if (is_last_esercizio(annoes))
|
||||
{
|
||||
@ -851,16 +834,20 @@ real TArticolo_giacenza::media_costi(const char * annoes) const
|
||||
else
|
||||
{
|
||||
const int index = find_storico(annoes);
|
||||
if (index < 0 ) return ZERO;
|
||||
const TRectype & rec = storico(annoes).row(index);
|
||||
real costo = rec.get_real(STOMAG_ULTCOS1);
|
||||
|
||||
costo = (costo + rec.get_real(STOMAG_ULTCOS2)) / 2.0;
|
||||
return costo.is_zero() ? costo_standard(annoes) : costo;
|
||||
|
||||
if (index >= 0 )
|
||||
{
|
||||
const TRectype & rec = storico(annoes).row(index);
|
||||
real costo = rec.get_real(STOMAG_ULTCOS1);
|
||||
|
||||
costo = (costo + rec.get_real(STOMAG_ULTCOS2)) / 2.0;
|
||||
return costo.is_zero() ? costo_standard(annoes) : costo;
|
||||
}
|
||||
}
|
||||
return ZERO;
|
||||
}
|
||||
|
||||
real TArticolo_giacenza::prezzo_listino(const char * annoes, const char * catven, const char * codlist) const
|
||||
real TArticolo_giacenza::prezzo_listino(int annoes, const char * catven, const char * codlist) const
|
||||
{
|
||||
if (is_last_esercizio(annoes))
|
||||
{
|
||||
@ -881,25 +868,29 @@ real TArticolo_giacenza::prezzo_listino(const char * annoes, const char * catven
|
||||
else
|
||||
{
|
||||
const int index = find_storico(annoes);
|
||||
if (index < 0 ) return ZERO;
|
||||
return storico(annoes).row(index).get_real(STOMAG_PRZLIST);
|
||||
|
||||
if (index >= 0 )
|
||||
return storico(annoes).row(index).get_real(STOMAG_PRZLIST);
|
||||
}
|
||||
return ZERO;
|
||||
}
|
||||
|
||||
real TArticolo_giacenza::costo_standard(const char * annoes) const
|
||||
real TArticolo_giacenza::costo_standard(int annoes) const
|
||||
{
|
||||
if (is_last_esercizio(annoes))
|
||||
return get_real(ANAMAG_COSTSTD);
|
||||
else
|
||||
{
|
||||
const int index = find_storico(annoes);
|
||||
if (index < 0 ) return ZERO;
|
||||
return storico(annoes).row(index).get_real(STOMAG_COSTSTD);
|
||||
|
||||
if (index >= 0 )
|
||||
return storico(annoes).row(index).get_real(STOMAG_COSTSTD);
|
||||
}
|
||||
return ZERO;
|
||||
}
|
||||
|
||||
|
||||
real TArticolo_giacenza::costo_medio(const char * annoes, const char * codmag, const char * livello) const
|
||||
real TArticolo_giacenza::costo_medio(int annoes, const char * codmag, const char * livello) const
|
||||
{
|
||||
real acq;
|
||||
real valacq;
|
||||
@ -922,7 +913,7 @@ real TArticolo_giacenza::costo_medio(const char * annoes, const char * codmag, c
|
||||
}
|
||||
|
||||
// costo medio ponderato per periodi pari alla durata dell'esercizio
|
||||
real TArticolo_giacenza::costo_mediopond(const char * annoes, const char * codmag, const char * livello) const
|
||||
real TArticolo_giacenza::costo_mediopond(int annoes, const char * codmag, const char * livello) const
|
||||
{
|
||||
real acq;
|
||||
real valacq;
|
||||
@ -945,10 +936,10 @@ real TArticolo_giacenza::costo_mediopond(const char * annoes, const char * codma
|
||||
return acq.is_zero() ? costo_standard(annoes) : valacq / acq;
|
||||
}
|
||||
|
||||
real TArticolo_giacenza::LIFO_annuale(const char * annoes, const char * codmag, const char * livello,
|
||||
real TArticolo_giacenza::LIFO_annuale(int annoes, const char * codmag, const char * livello,
|
||||
bool giac_eff, bool valorizza_componenti) const
|
||||
{
|
||||
CHECK(strlen(codmag)<=3,"Non è più possibile avere valorizzazione a livello di deposito");
|
||||
CHECK(strlen(codmag) <= 3,"Non è più possibile avere valorizzazione a livello di deposito");
|
||||
real rim,valrim;
|
||||
real acq,valacq;
|
||||
real giacenza;
|
||||
@ -971,10 +962,10 @@ real TArticolo_giacenza::LIFO_annuale(const char * annoes, const char * codmag,
|
||||
}
|
||||
|
||||
|
||||
real TArticolo_giacenza::FIFO_annuale(const char * annoes, const char * codmag, const char * livello,
|
||||
real TArticolo_giacenza::FIFO_annuale(int annoes, const char * codmag, const char * livello,
|
||||
bool giac_eff, bool valorizza_componenti) const
|
||||
{
|
||||
CHECK(strlen(codmag)<=3,"Non è più possibile avere valorizzazione a livello di deposito");
|
||||
CHECK(strlen(codmag) <= 3,"Non è più possibile avere valorizzazione a livello di deposito");
|
||||
real rim,valrim;
|
||||
real acq,valacq;
|
||||
real giacenza;
|
||||
@ -999,10 +990,10 @@ real TArticolo_giacenza::FIFO_annuale(const char * annoes, const char * codmag,
|
||||
}
|
||||
|
||||
|
||||
real TArticolo_giacenza::LIFO(const char * annoes, const char * codmag, const char * livello,
|
||||
real TArticolo_giacenza::LIFO(int annoes, const char * codmag, const char * livello,
|
||||
bool giac_eff, bool valorizza_componenti) const
|
||||
{
|
||||
CHECK(strlen(codmag)<=3,"Non è più possibile avere valorizzazione a livello di deposito");
|
||||
CHECK(strlen(codmag) <= 3,"Non è più possibile avere valorizzazione a livello di deposito");
|
||||
real rim,valrim;
|
||||
real acq,valacq;
|
||||
real giacenza;
|
||||
@ -1049,7 +1040,7 @@ real TArticolo_giacenza::LIFO(const char * annoes, const char * codmag, const ch
|
||||
return rim == ZERO ? ZERO :valrim / rim;
|
||||
}
|
||||
|
||||
real TArticolo_giacenza::FIFO(const char * annoes, const char * codmag, const char * livello,
|
||||
real TArticolo_giacenza::FIFO(int annoes, const char * codmag, const char * livello,
|
||||
bool giac_eff, bool valorizza_componenti) const
|
||||
{
|
||||
CHECK(strlen(codmag)<=3,"Non è più possibile avere valorizzazione a livello di deposito");
|
||||
@ -1110,23 +1101,23 @@ real TArticolo_giacenza::FIFO(const char * annoes, const char * codmag, const ch
|
||||
return ((giacenza - acq) * (valrim / rim) + valacq) / giacenza;
|
||||
}
|
||||
|
||||
real TArticolo_giacenza::FIFO_ragionieristico(const char * annoes, const char * codmag, const char * livello,
|
||||
real TArticolo_giacenza::FIFO_ragionieristico(int annoes, const char * codmag, const char * livello,
|
||||
bool giac_eff, bool valorizza_componenti) const
|
||||
{
|
||||
CHECK(strlen(codmag)<=3, "Non è più possibile avere valorizzazione a livello di deposito");
|
||||
return ZERO; // da implementare
|
||||
}
|
||||
|
||||
real TArticolo_giacenza::LIFO_ragionieristico(const char * annoes, const char * codmag, const char * livello,
|
||||
real TArticolo_giacenza::LIFO_ragionieristico(int annoes, const char * codmag, const char * livello,
|
||||
bool giac_eff, bool valorizza_componenti) const
|
||||
{
|
||||
CHECK(strlen(codmag)<=3, "Non è più possibile avere valorizzazione a livello di deposito");
|
||||
return ZERO; // da implementare
|
||||
}
|
||||
|
||||
void TArticolo_giacenza::copia_storico(TRecord_array& nrstorico,const char * annoes,const char * codmag, const char * annoprec, real rim, real valrim)
|
||||
void TArticolo_giacenza::copia_storico(TRecord_array& nrstorico, int annoes, const char * codmag, int annoprec, real rim, real valrim)
|
||||
{
|
||||
CHECK(annoes && *annoes,"Copia_storico: Indicare l'anno esercizio dello storico");
|
||||
CHECK(annoes > 0,"Copia_storico: Indicare l'anno esercizio dello storico");
|
||||
|
||||
TString nuovoanno(nrstorico.key().get(STOMAG_ANNOESRIF));
|
||||
//nrstorico.destroy_rows();
|
||||
@ -1154,7 +1145,7 @@ void TArticolo_giacenza::copia_storico(TRecord_array& nrstorico,const char * ann
|
||||
valrim -= rst.get_real(STOMAG_VALORE) * q;
|
||||
}
|
||||
}
|
||||
if (*annoprec != '\0' && (rim != ZERO || valrim != ZERO))
|
||||
if (annoprec > 0 && (rim != ZERO || valrim != ZERO))
|
||||
{
|
||||
if (annoes_index <= 0)
|
||||
{
|
||||
@ -1200,10 +1191,8 @@ HIDDEN int sort_storico_rev(const TObject ** a, const TObject ** b)
|
||||
return -sort_storico(a, b);
|
||||
}
|
||||
|
||||
void TArticolo_giacenza::add_storico(TRecord_array& nrstorico,const char * annoes,const char * codmag, const real & qta, const real & prz)
|
||||
void TArticolo_giacenza::add_storico(TRecord_array& nrstorico,int annoes,const char * codmag, const real & qta, const real & prz)
|
||||
{
|
||||
//CHECK(annorif && *annorif,"Add_storico: Indicare l'anno esercizio dello storico");
|
||||
//TRecord_array & rstorico = storico(annorif);
|
||||
TString8 annorif(nrstorico.key().get(STOMAG_ANNOESRIF));
|
||||
int i;
|
||||
|
||||
@ -1228,7 +1217,7 @@ void TArticolo_giacenza::add_storico(TRecord_array& nrstorico,const char * annoe
|
||||
}
|
||||
|
||||
// annoes indica l'anno dell'esercizio da chiudere
|
||||
void TArticolo_giacenza::agg_storicoLIFO(const char * annoes, const char * codmag,
|
||||
void TArticolo_giacenza::agg_storicoLIFO(int annoes, const char * codmag,
|
||||
bool giac_eff, bool valorizza_componenti)
|
||||
{
|
||||
CHECK(strlen(codmag)<=3,"Non è più possibile avere valorizzazione a livello di deposito");
|
||||
@ -1248,13 +1237,11 @@ void TArticolo_giacenza::agg_storicoLIFO(const char * annoes, const char * codma
|
||||
giacenza += giacenza_corretta(rec,giac_eff,valorizza_componenti);
|
||||
}
|
||||
|
||||
TString nuovoanno, annoprec;
|
||||
real prz;
|
||||
real qta;
|
||||
|
||||
TEsercizi_contabili ese;
|
||||
nuovoanno.format("%d", ese.next(atoi(annoes)));
|
||||
annoprec.format("%d", ese.pred(atoi(annoes)));
|
||||
const int nuovoanno = esercizi().next(annoes);
|
||||
const int annoprec = esercizi().pred(annoes);
|
||||
|
||||
TRecord_array nuovo_storico(storico(nuovoanno));
|
||||
copia_storico(nuovo_storico, annoes, codmag, annoprec, rim , valrim);
|
||||
@ -1298,7 +1285,7 @@ void TArticolo_giacenza::agg_storicoLIFO(const char * annoes, const char * codma
|
||||
}
|
||||
|
||||
|
||||
void TArticolo_giacenza::agg_storicoFIFO(const char * annoes, const char * codmag,
|
||||
void TArticolo_giacenza::agg_storicoFIFO(int annoes, const char * codmag,
|
||||
bool giac_eff, bool valorizza_componenti)
|
||||
{
|
||||
CHECK(strlen(codmag)<=3,"Non è più possibile avere valorizzazione a livello di deposito");
|
||||
@ -1321,10 +1308,8 @@ void TArticolo_giacenza::agg_storicoFIFO(const char * annoes, const char * codma
|
||||
if (giacenza <= ZERO)
|
||||
return ;
|
||||
|
||||
TString nuovoanno, annoprec;
|
||||
TEsercizi_contabili ese;
|
||||
nuovoanno.format("%d", ese.next(atoi(annoes)));
|
||||
annoprec.format("%d", ese.pred(atoi(annoes)));
|
||||
const int nuovoanno = esercizi().next(annoes);
|
||||
const int annoprec = esercizi().pred(annoes);
|
||||
|
||||
TRecord_array nuovo_storico(storico(nuovoanno));
|
||||
copia_storico(nuovo_storico, annoes, codmag, annoprec, rim, valrim);
|
||||
@ -1367,7 +1352,7 @@ void TArticolo_giacenza::agg_storicoFIFO(const char * annoes, const char * codma
|
||||
nuovo_storico.write();
|
||||
}
|
||||
|
||||
void TArticolo_giacenza::agg_storico(const char * annoes, const char * codmag,
|
||||
void TArticolo_giacenza::agg_storico(int annoes, const char * codmag,
|
||||
bool giac_eff, bool valorizza_componenti, const real& val)
|
||||
{
|
||||
CHECK(strlen(codmag)<=3,"Non è più possibile avere valorizzazione a livello di deposito");
|
||||
@ -1382,10 +1367,7 @@ void TArticolo_giacenza::agg_storico(const char * annoes, const char * codmag,
|
||||
qta += giacenza_corretta(rec, giac_eff, valorizza_componenti);
|
||||
}
|
||||
|
||||
TString nuovoanno;
|
||||
TEsercizi_contabili ese;
|
||||
nuovoanno.format("%d", ese.next(atoi(annoes)));
|
||||
|
||||
const int nuovoanno = esercizi().next(annoes);
|
||||
TRecord_array& nuovo_storico = storico(nuovoanno);
|
||||
|
||||
//nuovo_storico.destroy_rows();
|
||||
@ -1516,14 +1498,15 @@ long TArticolo_giacenza::lead_time(const char* codmag, const char* livello, int
|
||||
}
|
||||
|
||||
TArticolo_giacenza::TArticolo_giacenza(const char* codice)
|
||||
: TArticolo(codice)
|
||||
: TArticolo(codice), _anno_mag(0), _anno_sto(0)
|
||||
|
||||
{
|
||||
add_file(LF_MAG,"NRIGA");
|
||||
add_file(LF_STOMAG,"NRIGA");
|
||||
}
|
||||
|
||||
TArticolo_giacenza::TArticolo_giacenza(const TRectype& rec)
|
||||
: TArticolo(rec)
|
||||
: TArticolo(rec), _anno_mag(0), _anno_sto(0)
|
||||
{
|
||||
add_file(LF_MAG,"NRIGA");
|
||||
add_file(LF_STOMAG,"NRIGA");
|
||||
@ -1546,27 +1529,24 @@ int TArticolo_giacenza_data::remove(TBaseisamfile& f) const
|
||||
void TArticolo_giacenza_data::al(const TDate& data, const char* codmag, const char* livello,
|
||||
TTipo_valorizz tipo, const char* catven, const char* codlis)
|
||||
{
|
||||
const TEsercizi_contabili esc;
|
||||
const int anno = esc.date2esc(data);
|
||||
const TDate inizio = esc[anno].inizio();
|
||||
TString16 annoes; annoes.format("%04d", anno);
|
||||
TString16 predes;
|
||||
const int anno = esercizi().date2esc(data);
|
||||
const TDate inizio = esercizi()[anno].inizio();
|
||||
|
||||
bool reset_giac = TRUE;
|
||||
const int anno_pred = esc.pred(anno);
|
||||
bool reset_giac = true;
|
||||
const int anno_pred = esercizi().pred(anno);
|
||||
if (anno_pred != 0)
|
||||
{
|
||||
predes.format("%04d", anno_pred);
|
||||
const TDate dc = esc[anno_pred].chiusura_mag();
|
||||
reset_giac = dc.ok();
|
||||
const TDate dc = esercizi()[anno_pred].chiusura_mag();
|
||||
|
||||
reset_giac = dc.ok();
|
||||
}
|
||||
|
||||
remove_body(LF_MAG); // Azzero la cache dei magazzini
|
||||
|
||||
if (reset_giac)
|
||||
azzera_saldi(annoes, FALSE);
|
||||
azzera_saldi(anno, false);
|
||||
else
|
||||
riporta_saldi(predes, annoes, tipo, catven, codlis, FALSE);
|
||||
riporta_saldi(anno_pred, anno, tipo, catven, codlis, false);
|
||||
|
||||
TRelation rel(LF_RMOVMAG); rel.add(LF_MOVMAG, "NUMREG==NUMREG");
|
||||
|
||||
@ -1585,14 +1565,14 @@ void TArticolo_giacenza_data::al(const TDate& data, const char* codmag, const ch
|
||||
if (items >= 10)
|
||||
{
|
||||
TString80 str; str << TR("Calcolo giacenza articolo ") << codice();
|
||||
pi = new TProgind(items, str, FALSE, TRUE);
|
||||
pi = new TProgind(items, str, false, true);
|
||||
}
|
||||
|
||||
TMov_mag* p_movmag = new TMov_mag;
|
||||
rel.lfile(LF_MOVMAG).set_curr(p_movmag);
|
||||
TMov_mag& movmag = *p_movmag;
|
||||
const TRectype& rmovmag = rel.curr();
|
||||
TRecord_array& rmag = mag(annoes);
|
||||
TRecord_array& rmag = mag(anno);
|
||||
|
||||
for (cur = 0; cur.pos() < items; ++cur)
|
||||
{
|
||||
@ -1603,19 +1583,19 @@ void TArticolo_giacenza_data::al(const TDate& data, const char* codmag, const ch
|
||||
const TString16 codmag = rmovmag.get(RMOVMAG_CODMAG);
|
||||
const TString16 livello = rmovmag.get(RMOVMAG_LIVGIAC);
|
||||
const int nrig = rmovmag.get_int(RMOVMAG_NRIG);
|
||||
const int i = find_mag(annoes, codmag, livello);
|
||||
const int i = find_mag(anno, codmag, livello);
|
||||
if (i >= 0) // Se il record di giacenza esiste lo aggiorno ...
|
||||
{
|
||||
TRectype& rec = (TRectype&)rmag.row(i);
|
||||
movmag.update_balances(rec, nrig, +1);
|
||||
movmag.update_balances(rec, nrig);
|
||||
}
|
||||
else // ... altrimenti lo creo e poi lo aggiorno
|
||||
{
|
||||
TRectype& rec = rmag.row(-1, TRUE);
|
||||
rec.put(MAG_ANNOES, annoes); // Setto i campi fondamentali!
|
||||
rec.put(MAG_ANNOES, anno); // Setto i campi fondamentali!
|
||||
rec.put(MAG_CODMAG, codmag);
|
||||
rec.put(MAG_LIVELLO, livello);
|
||||
movmag.update_balances(rec, nrig, +1);
|
||||
movmag.update_balances(rec, nrig);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1665,6 +1645,35 @@ void TArticolo_giacenza_loadable::load(TIsamtempfile& f)
|
||||
f.readat(pos);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TArticolo_giacenza_cache
|
||||
///////////////////////////////////////////////////////////
|
||||
class TCache_articoli_giacenza : public TRecord_cache
|
||||
{
|
||||
protected:
|
||||
virtual TObject* rec2obj(const TRectype& rec) const { return new TArticolo_giacenza(rec);}
|
||||
|
||||
public:
|
||||
TArticolo_giacenza& art(const char* key) { return (TArticolo_giacenza&)query(key); }
|
||||
|
||||
TCache_articoli_giacenza();
|
||||
virtual ~TCache_articoli_giacenza() { }
|
||||
};
|
||||
|
||||
TCache_articoli_giacenza::TCache_articoli_giacenza()
|
||||
: TRecord_cache(LF_ANAMAG, 1)
|
||||
{
|
||||
test_file_changes(); // Tieni d'occhio le modifiche sul file
|
||||
set_items_limit(256); // Standard
|
||||
}
|
||||
|
||||
TArticolo_giacenza & cached_article_balances(const char * codart)
|
||||
{
|
||||
HIDDEN TCache_articoli_giacenza __cache_articoli_giacenza;
|
||||
|
||||
return __cache_articoli_giacenza.art(codart);
|
||||
}
|
||||
|
||||
// causali
|
||||
|
||||
int TCausale_magazzino::sgn(TTipo_saldomag tiposaldo) const
|
||||
@ -1731,6 +1740,45 @@ TCausale_magazzino::TCausale_magazzino(const TRectype &r):
|
||||
CHECK(r.num() == LF_TABCOM, "Tipo record errato sulla causale di magazzino");
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TCache_causali_magazzino
|
||||
///////////////////////////////////////////////////////////
|
||||
class TCache_causali_magazzino : public TRecord_cache
|
||||
{
|
||||
protected:
|
||||
virtual TObject* rec2obj(const TRectype& rec) const{ return new TCausale_magazzino(rec); }
|
||||
|
||||
|
||||
public:
|
||||
TCausale_magazzino & caus(const char* key);
|
||||
|
||||
TCache_causali_magazzino();
|
||||
virtual ~TCache_causali_magazzino() { }
|
||||
};
|
||||
|
||||
|
||||
TCache_causali_magazzino::TCache_causali_magazzino()
|
||||
: TRecord_cache("%CAU", 1)
|
||||
{
|
||||
test_file_changes(); // Tieni d'occhio le modifiche sul file
|
||||
set_items_limit(256); // Standard
|
||||
}
|
||||
|
||||
TCausale_magazzino & TCache_causali_magazzino::caus(const char* key)
|
||||
{
|
||||
TString16 k;
|
||||
|
||||
k << "CAU|" << key;
|
||||
return (TCausale_magazzino &)query(k);
|
||||
}
|
||||
|
||||
TCausale_magazzino & cached_causale_magazzino(const char * codcaus)
|
||||
{
|
||||
HIDDEN TCache_causali_magazzino __cache_causali_magazzino;
|
||||
|
||||
return __cache_causali_magazzino.caus(codcaus);
|
||||
}
|
||||
|
||||
bool TCondizione_vendita::ricerca(const char * codice, const real & qta, bool ignore_umart)
|
||||
{
|
||||
int tiporic;
|
||||
|
1016
mg/mglib02a.cpp
1016
mg/mglib02a.cpp
File diff suppressed because it is too large
Load Diff
@ -539,9 +539,8 @@ public:
|
||||
|
||||
bool TScoperto_app::trova_bolle_fatturate_dal(TString_array& bolle, TString_array& fatture, char stato_fatt, const TDate& datarif)
|
||||
{
|
||||
TEsercizi_contabili esc;
|
||||
const int codes = esc.date2esc(datarif);
|
||||
const TDate inies = esc[codes].inizio();
|
||||
const int codes = esercizi().date2esc(datarif);
|
||||
const TDate inies = esercizi()[codes].inizio();
|
||||
|
||||
TRelation rel(LF_DOC);
|
||||
TRectype& curr = rel.curr();
|
||||
@ -605,9 +604,8 @@ bool TScoperto_app::trova_bolle_fatturate_dal(TString_array& bolle, TString_arra
|
||||
|
||||
void TScoperto_app::print_bolle(TString_array& bolle, char stato_bolle, char stato_fatture, const TDate& datarif, bool work_on_res)
|
||||
{
|
||||
TEsercizi_contabili esc;
|
||||
const int codes = esc.date2esc(datarif);
|
||||
const TDate inies = esc[codes].inizio();
|
||||
const int codes = esercizi().date2esc(datarif);
|
||||
const TDate inies = esercizi()[codes].inizio();
|
||||
|
||||
TRelation rel(LF_DOC);
|
||||
TRectype& curr = rel.curr();
|
||||
|
@ -28,7 +28,6 @@ class TMask_anamag: public TMask
|
||||
|
||||
TString4 _um_principale;
|
||||
TMagazzini *_magazzini;
|
||||
TEsercizi_contabili *_esercizi_contabili;
|
||||
|
||||
static bool handle_codice(TMask_field &, KEY); // handler del campo codice articolo
|
||||
static bool handle_anno(TMask_field &, KEY); // handler del campo anno delle giacenze
|
||||
@ -76,8 +75,6 @@ public:
|
||||
TString& um_principale() { return _um_principale; }
|
||||
TMagazzini& magazzini() { return *_magazzini; }
|
||||
|
||||
TEsercizi_contabili &esercizi_contabili() {return *_esercizi_contabili;}
|
||||
|
||||
TMask_anamag(TRelation * rel);
|
||||
virtual ~TMask_anamag();
|
||||
};
|
||||
@ -289,12 +286,9 @@ void TMask_anamag::set_parametered_fields()
|
||||
delete livelli_giac;
|
||||
if (livelli_art)
|
||||
delete livelli_art;
|
||||
if (_esercizi_contabili)
|
||||
delete _esercizi_contabili;
|
||||
if (_magazzini)
|
||||
delete _magazzini;
|
||||
|
||||
_esercizi_contabili = new TEsercizi_contabili;
|
||||
_magazzini = new TMagazzini;
|
||||
|
||||
// imposta il puntatore al gestore livelli giacenze
|
||||
@ -470,7 +464,6 @@ TMask_anamag::TMask_anamag(TRelation * rel) : TMask("ve2400")
|
||||
|
||||
livelli_giac = NULL;
|
||||
livelli_art = NULL;
|
||||
_esercizi_contabili = NULL;
|
||||
_magazzini = NULL;
|
||||
|
||||
set_parametered_fields();
|
||||
@ -556,8 +549,6 @@ TMask_anamag::~TMask_anamag()
|
||||
delete livelli_art;
|
||||
if (livelli_giac)
|
||||
delete livelli_giac;
|
||||
if (_esercizi_contabili)
|
||||
delete _esercizi_contabili;
|
||||
if (_magazzini)
|
||||
delete _magazzini;
|
||||
}
|
||||
@ -791,7 +782,7 @@ bool TMask_anamag::handle_anno(TMask_field &fld, KEY k)
|
||||
|
||||
if (mask.get(F_ANNO).empty() )
|
||||
{
|
||||
mask.set(F_ANNORIF, mask.esercizi_contabili().last()) ;
|
||||
mask.set(F_ANNORIF, esercizi().last()) ;
|
||||
mask.set(F_ANNO, mask.get(F_ANNORIF));
|
||||
}
|
||||
if (mask.last_annogiac>0 && mask.last_annogiac!=fld.mask().get_int(F_ANNO))
|
||||
@ -822,8 +813,8 @@ void TMask_anamag::update_ordc_ordf()
|
||||
{
|
||||
real ordc,ordf;
|
||||
const TDate oggi(TODAY);
|
||||
int es_corr = esercizi_contabili().date2esc(oggi); // setta l'esercizio corrente (data come intero)
|
||||
int es_pred = esercizi_contabili().pred(es_corr); // " " precedente "
|
||||
int es_corr = esercizi().date2esc(oggi); // setta l'esercizio corrente (data come intero)
|
||||
int es_pred = esercizi().pred(es_corr); // " " precedente "
|
||||
|
||||
TRecord_array arr(LF_MAG, MAG_NRIGA);
|
||||
TRectype rec(LF_MAG); // crea un record vuoto di LF_MAG
|
||||
@ -891,7 +882,7 @@ bool TMask_anamag::handle_stoanno(TMask_field &fld, KEY k)
|
||||
fld_stomag.force_update();
|
||||
mask.last_annosto=mask.get_int(F_STOANNORIF);
|
||||
if (fld.focusdirty())
|
||||
TEsercizi_contabili::update();
|
||||
esercizi().update();
|
||||
in_handler = FALSE;
|
||||
}
|
||||
|
||||
@ -901,7 +892,7 @@ bool TMask_anamag::handle_stoanno(TMask_field &fld, KEY k)
|
||||
bool TMask_anamag::handle_stoanno_row(TMask_field &fld, KEY k)
|
||||
{
|
||||
if (k == K_TAB && fld.focusdirty())
|
||||
TEsercizi_contabili::update();
|
||||
esercizi().update();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -1426,7 +1417,7 @@ bool TMask_anamag::notify_sheet_sto(TSheet_field &s, int r, KEY k)
|
||||
newanno=(s.cell(r,s.cid2index(F_STOANNOES)));
|
||||
newcodmag=(s.cell(r,s.cid2index(F_STOCODMAG)));
|
||||
|
||||
if (m.esercizi_contabili()[atoi(newanno)].inizio() >= m.esercizi_contabili()[m.get_int(F_STOANNO)].inizio())
|
||||
if (esercizi()[atoi(newanno)].inizio() >= esercizi()[m.get_int(F_STOANNO)].inizio())
|
||||
{
|
||||
s.row(r).add(oldanno,s.cid2index(F_STOANNOES));
|
||||
s.error_box("La rimanenza iniziale di un esercizio deve essere composta da parti provenienti da esercizi precedenti");
|
||||
@ -1711,7 +1702,8 @@ void TMask_anamag::ricalcola_giacenze()
|
||||
if (fc != 1.0)
|
||||
{
|
||||
TLocalisamfile mag(LF_MAG),stomag(LF_STOMAG);
|
||||
int annoes=esercizi_contabili().first();
|
||||
int annoes = esercizi().first();
|
||||
|
||||
// ciclo sugli esercizi
|
||||
do {
|
||||
mag.zero();
|
||||
@ -1754,7 +1746,7 @@ void TMask_anamag::ricalcola_giacenze()
|
||||
stomag.next();
|
||||
}
|
||||
}
|
||||
while ((annoes=esercizi_contabili().next(annoes)) > 0); // qui verificare
|
||||
while ((annoes = esercizi().next(annoes)) > 0); // qui verificare
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -510,9 +510,8 @@ void TPenna_app::load_doc() //definizione della me
|
||||
|
||||
TDate datadoc(ini.get(DOC_DATADOC, para)); //dal paragrafo testata documento prende il valore della data del
|
||||
//documento
|
||||
TEsercizi_contabili esc; //crea un oggetto esc di tipo TEsercizi_contabili
|
||||
TString16 annoes;
|
||||
annoes.format("%04d", esc.date2esc(datadoc)); //crea un intero lungo 4 riempito di 0 all'inizio
|
||||
annoes.format("%04d", esercizi().date2esc(datadoc)); //crea un intero lungo 4 riempito di 0 all'inizio
|
||||
TString8 codmag = m.get(F_MAG); // setta codmag in base al valore della maschera
|
||||
codmag.left_just(3) << m.get(F_DEP); // attacca a codmag il F_DEP, codice deposito dalla maschera
|
||||
|
||||
@ -544,7 +543,7 @@ void TPenna_app::load_doc() //definizione della me
|
||||
if (name == RDOC_QTA && tipo==1)
|
||||
{
|
||||
|
||||
TArticolo_giacenza art(codice);
|
||||
TArticolo_giacenza & art = cached_article_balances(codice);
|
||||
real quantita(val);
|
||||
|
||||
const real giacenza=art.disponibilita(annoes,codmag,"",TRUE);
|
||||
|
23
ve/velib.h
23
ve/velib.h
@ -330,16 +330,7 @@ public:
|
||||
|
||||
};
|
||||
|
||||
class TTipi_documento_cache : public TRecord_cache
|
||||
{
|
||||
protected:
|
||||
virtual TObject* rec2obj(const TRectype& rec) const;
|
||||
|
||||
public:
|
||||
TTipo_documento& tipo(const char* key);
|
||||
TTipi_documento_cache();
|
||||
virtual ~TTipi_documento_cache() { }
|
||||
};
|
||||
TTipo_documento & cached_tipodoc(const char * tipodoc);
|
||||
|
||||
class TCodice_numerazione : public TRectype
|
||||
{
|
||||
@ -375,6 +366,8 @@ public:
|
||||
|
||||
};
|
||||
|
||||
TCodice_numerazione & cached_numerazione(const char * codnum);
|
||||
|
||||
class TTipo_riga_documento : public TRectype // velib02
|
||||
{
|
||||
static TAssoc_array _formule_riga;
|
||||
@ -463,7 +456,6 @@ class TRiga_documento : public TAuto_variable_rectype // velib02
|
||||
static TAssoc_array _tipi;
|
||||
static TAssoc_array _spese;
|
||||
static TAssoc_array _ive;
|
||||
static TCache_articoli * _articoli;
|
||||
static int _iva_calc_mode;
|
||||
static bool _rit_calc;
|
||||
|
||||
@ -511,7 +503,7 @@ public:
|
||||
// sheet -> row
|
||||
void autosave(TSheet_field& f);
|
||||
|
||||
const TTipo_riga_documento & tipo() const;
|
||||
const TTipo_riga_documento & tipo() const ;
|
||||
const TSpesa_prest & spesa() const;
|
||||
static const TCodiceIVA & iva(const char * codice);
|
||||
const TCodiceIVA & iva() const {const TString4 cod(get(RDOC_CODIVA)); return iva(cod);}
|
||||
@ -559,7 +551,8 @@ public:
|
||||
const TString & codice_costo() const;
|
||||
const TString & codice_commessa() const;
|
||||
const TString & fase_commessa() const;
|
||||
TArticolo_giacenza * articolo() const;
|
||||
TArticolo & articolo() const;
|
||||
TArticolo_giacenza & articolo_giacenza() const;
|
||||
|
||||
TRiga_documento(TDocumento* doc, const char* tipo = NULL);
|
||||
TRiga_documento(const TRiga_documento & row);
|
||||
@ -634,8 +627,6 @@ class TDocumento : public TMultiple_rectype // velib03
|
||||
|
||||
bool _dirty_deny;
|
||||
|
||||
static TAssoc_array _tipi;
|
||||
static TAssoc_array _numerazioni;
|
||||
static long _firm;
|
||||
static TString4 _codiva_spese;
|
||||
static TString4 _codiva_bolli;
|
||||
@ -729,10 +720,8 @@ public:
|
||||
const TString& valuta() const { return get("CODVAL"); }
|
||||
real cambio() const { return get_real("CAMBIO"); }
|
||||
bool tipo_valido() const { return get("TIPODOC").not_empty(); }
|
||||
static const TTipo_documento& tipo(const char * tipodoc);
|
||||
const TTipo_documento& tipo() const;
|
||||
int tipo_riclassificato() const;
|
||||
static const TCodice_numerazione& codice_numerazione(const char * numerazione);
|
||||
const TCodice_numerazione& codice_numerazione() const;
|
||||
void set_tipo(const char * tipo) { head().put("TIPODOC", tipo);}
|
||||
bool provvisorio() const { return get_char("PROVV") == 'P'; }
|
||||
|
104
ve/velib02.cpp
104
ve/velib02.cpp
@ -9,58 +9,6 @@
|
||||
|
||||
#include "rdoc.h"
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TTipi_documento_cache
|
||||
///////////////////////////////////////////////////////////
|
||||
TTipi_documento_cache::TTipi_documento_cache()
|
||||
: TRecord_cache("%TIP", 1)
|
||||
{
|
||||
test_file_changes(); // Tieni d'occhio le modifiche sul file
|
||||
set_items_limit(64); // Standard
|
||||
}
|
||||
|
||||
TObject* TTipi_documento_cache::rec2obj(const TRectype& curr) const
|
||||
{
|
||||
return new TTipo_documento(curr);
|
||||
}
|
||||
|
||||
TTipo_documento & TTipi_documento_cache::tipo(const char* key)
|
||||
{
|
||||
TTipo_documento & tipo = (TTipo_documento &) query(key);
|
||||
return tipo;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TArticolo_cache
|
||||
///////////////////////////////////////////////////////////
|
||||
class TCache_articoli : public TRecord_cache
|
||||
{
|
||||
protected:
|
||||
virtual TObject* rec2obj(const TRectype& rec) const;
|
||||
|
||||
public:
|
||||
TArticolo_giacenza& art(const char* key);
|
||||
TCache_articoli();
|
||||
virtual ~TCache_articoli() { }
|
||||
};
|
||||
|
||||
TCache_articoli::TCache_articoli()
|
||||
: TRecord_cache(LF_ANAMAG, 1)
|
||||
{
|
||||
test_file_changes(); // Tieni d'occhio le modifiche sul file
|
||||
set_items_limit(256); // Standard
|
||||
}
|
||||
|
||||
TObject* TCache_articoli::rec2obj(const TRectype& curr) const
|
||||
{
|
||||
return new TArticolo_giacenza(curr);
|
||||
}
|
||||
|
||||
TArticolo_giacenza & TCache_articoli::art(const char* key)
|
||||
{
|
||||
TArticolo_giacenza& art = (TArticolo_giacenza&)query(key);
|
||||
return art;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Tipo riga di un documento
|
||||
@ -197,7 +145,6 @@ long TRiga_documento::_firm = -1;
|
||||
TAssoc_array TRiga_documento::_tipi;
|
||||
TAssoc_array TRiga_documento::_spese;
|
||||
TAssoc_array TRiga_documento::_ive;
|
||||
TCache_articoli * TRiga_documento::_articoli = NULL;
|
||||
|
||||
// 0=ignora IVA; 1=consedera iva solo se c'e' addebito; 2=considera sempre IVA
|
||||
int TRiga_documento::_iva_calc_mode = 0;
|
||||
@ -330,12 +277,7 @@ void TRiga_documento::set_variables(TExpression * e) const
|
||||
switch (field.file())
|
||||
{
|
||||
case LF_ANAMAG :
|
||||
{
|
||||
const TArticolo_giacenza * art = articolo();
|
||||
|
||||
if (art != NULL)
|
||||
e->setvar(i, art->get(field.name()));
|
||||
}
|
||||
e->setvar(i, articolo().get(field.name()));
|
||||
break;
|
||||
case LF_DOC :
|
||||
e->setvar(i, doc().get(field.name()));
|
||||
@ -779,33 +721,23 @@ real TRiga_documento::qtaresidua() const
|
||||
real TRiga_documento::calc_conai_qta(int type) const
|
||||
{
|
||||
const char* const __conai_art_names[] = {"CONACC", "CONALL", "CONCAR", "CONPLA", "CONLEG", "CONVET"};
|
||||
real row_qta;
|
||||
real qta = get_real(RDOC_QTA);
|
||||
|
||||
if (is_merce())
|
||||
{
|
||||
const bool has_formula = ((TTipo_riga_documento &)tipo()).has_formula(__conai_art_names[type]);
|
||||
TArticolo_giacenza* art = articolo();
|
||||
if (art != NULL)
|
||||
{
|
||||
const TString4 um = get(RDOC_UMQTA);
|
||||
row_qta = art->convert_to_um(get_real(RDOC_QTA), NULL, um);
|
||||
TArticolo & art = articolo();
|
||||
const TString4 um = get(RDOC_UMQTA);
|
||||
|
||||
if (has_formula)
|
||||
row_qta *= get_real(__conai_art_names[type]);
|
||||
else
|
||||
row_qta *= art->get_real(__conai_art_names[type]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (has_formula)
|
||||
{
|
||||
row_qta = get_real(RDOC_QTA);
|
||||
row_qta *= get_real(__conai_art_names[type]);
|
||||
}
|
||||
}
|
||||
qta = art.convert_to_um(qta, NULL, um);
|
||||
|
||||
if (has_formula)
|
||||
qta *= get_real(__conai_art_names[type]);
|
||||
else
|
||||
qta *= art.get_real(__conai_art_names[type]);
|
||||
}
|
||||
|
||||
return row_qta;
|
||||
return qta;
|
||||
}
|
||||
|
||||
bool TRiga_documento::is_evasa() const
|
||||
@ -1198,16 +1130,14 @@ void TRiga_documento::autoload(TSheet_field & f)
|
||||
}
|
||||
}
|
||||
|
||||
TArticolo_giacenza* TRiga_documento::articolo() const
|
||||
TArticolo & TRiga_documento::articolo() const
|
||||
{
|
||||
if (_articoli == NULL)
|
||||
_articoli = new TCache_articoli();
|
||||
return cached_article(get(RDOC_CODARTMAG));
|
||||
}
|
||||
|
||||
const TString& codart = get(RDOC_CODARTMAG);
|
||||
if (codart.blank())
|
||||
|
||||
return NULL;
|
||||
return &(_articoli->art(codart));
|
||||
TArticolo_giacenza & TRiga_documento::articolo_giacenza() const
|
||||
{
|
||||
return cached_article_balances(get(RDOC_CODARTMAG));
|
||||
}
|
||||
|
||||
void TRiga_documento::set_original_rdoc_key(const TRectype& orig, int depth)
|
||||
|
127
ve/velib03.cpp
127
ve/velib03.cpp
@ -18,6 +18,90 @@
|
||||
#include <clifo.h>
|
||||
#include <cfven.h>
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TTipo_documento_cache
|
||||
///////////////////////////////////////////////////////////
|
||||
class TTipo_documento_cache : public TRecord_cache
|
||||
{
|
||||
protected:
|
||||
virtual TObject* rec2obj(const TRectype& rec) const;
|
||||
|
||||
public:
|
||||
TTipo_documento& tipo(const char* key);
|
||||
TTipo_documento_cache();
|
||||
virtual ~TTipo_documento_cache() { }
|
||||
};
|
||||
|
||||
TTipo_documento_cache::TTipo_documento_cache()
|
||||
: TRecord_cache("%TIP", 1)
|
||||
{
|
||||
test_file_changes(); // Tieni d'occhio le modifiche sul file
|
||||
set_items_limit(64); // Standard
|
||||
}
|
||||
|
||||
TObject* TTipo_documento_cache::rec2obj(const TRectype& curr) const
|
||||
{
|
||||
return new TTipo_documento(curr);
|
||||
}
|
||||
|
||||
TTipo_documento & TTipo_documento_cache::tipo(const char* key)
|
||||
{
|
||||
TString8 k;
|
||||
|
||||
k << "TIP|" << key;
|
||||
TTipo_documento & tipo = (TTipo_documento &) query(k);
|
||||
return tipo;
|
||||
}
|
||||
|
||||
TTipo_documento & cached_tipodoc(const char * tipodoc)
|
||||
{
|
||||
HIDDEN TTipo_documento_cache __cache_tipi_documento;
|
||||
|
||||
return __cache_tipi_documento.tipo(tipodoc);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TTipo_numerazione_cache
|
||||
///////////////////////////////////////////////////////////
|
||||
class TNumerazione_cache : public TRecord_cache
|
||||
{
|
||||
protected:
|
||||
virtual TObject* rec2obj(const TRectype& rec) const;
|
||||
|
||||
public:
|
||||
TCodice_numerazione & num(const char* key);
|
||||
TNumerazione_cache();
|
||||
virtual ~TNumerazione_cache() { }
|
||||
};
|
||||
|
||||
TNumerazione_cache::TNumerazione_cache()
|
||||
: TRecord_cache("%NUM", 1)
|
||||
{
|
||||
test_file_changes(); // Tieni d'occhio le modifiche sul file
|
||||
set_items_limit(64); // Standard
|
||||
}
|
||||
|
||||
TObject* TNumerazione_cache::rec2obj(const TRectype& curr) const
|
||||
{
|
||||
return new TCodice_numerazione(curr);
|
||||
}
|
||||
|
||||
TCodice_numerazione & TNumerazione_cache::num(const char* key)
|
||||
{
|
||||
TString8 k;
|
||||
|
||||
k << "NUM|" << key;
|
||||
TCodice_numerazione & num = (TCodice_numerazione &) query(k);
|
||||
return num;
|
||||
}
|
||||
|
||||
TCodice_numerazione & cached_numerazione(const char * codnum)
|
||||
{
|
||||
HIDDEN TNumerazione_cache __cache_numerazioni;
|
||||
|
||||
return __cache_numerazioni.num(codnum);
|
||||
}
|
||||
|
||||
// calcola il prezzo per le spese
|
||||
void sppr_calc(const TRectype & rec, const TString & valuta_doc, const real & cambio, real & prezzo, exchange_type controeuro)
|
||||
{
|
||||
@ -134,8 +218,6 @@ HIDDEN TAgenti_cache * _agenti = NULL;
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
long TDocumento::_firm = -1;
|
||||
TAssoc_array TDocumento::_tipi;
|
||||
TAssoc_array TDocumento::_numerazioni;
|
||||
TString4 TDocumento::_codiva_spese;
|
||||
TString4 TDocumento::_codiva_bolli;
|
||||
short TDocumento::_has_mag = 3;
|
||||
@ -989,7 +1071,7 @@ int TDocumento::write_rewrite(TBaseisamfile & f, bool re) const
|
||||
if (cambio == ZERO)
|
||||
cambio = 1.0;
|
||||
const TString8 cod_caus(mov.get(MOVMAG_CODCAUS));
|
||||
TCausale_magazzino caus(cod_caus);
|
||||
TCausale_magazzino & caus = cached_causale_magazzino(cod_caus);
|
||||
const bool esplodente = caus.esplodente();
|
||||
const bool scarica_alt = caus.scarica_alternativi();
|
||||
TString8 cod_caus_riga;
|
||||
@ -1008,7 +1090,7 @@ int TDocumento::write_rewrite(TBaseisamfile & f, bool re) const
|
||||
else
|
||||
{
|
||||
codart = r.get(RDOC_CODART);
|
||||
if (codart.full() && (cod_caus_riga.full() ? TCausale_magazzino(cod_caus_riga).esplodente() : esplodente))
|
||||
if (codart.full() && (cod_caus_riga.full() ? cached_causale_magazzino(cod_caus_riga).esplodente() : esplodente))
|
||||
valid_row = dist.set_root(codart);
|
||||
}
|
||||
if (valid_row)
|
||||
@ -1031,7 +1113,7 @@ int TDocumento::write_rewrite(TBaseisamfile & f, bool re) const
|
||||
rm.put(RMOVMAG_IMPIANTO, r.get(RDOC_IMPIANTO));
|
||||
rm.put(RMOVMAG_LINEA, r.get(RDOC_LINEA));
|
||||
rm.put(RMOVMAG_CODMAG, r.get(RDOC_CODMAG));
|
||||
if (articolo && (cod_caus_riga.full() ? TCausale_magazzino(cod_caus_riga).scarica_alternativi() : scarica_alt))
|
||||
if (articolo && (cod_caus_riga.full() ? cached_causale_magazzino(cod_caus_riga).scarica_alternativi() : scarica_alt))
|
||||
{
|
||||
const TRectype art = cache().get(LF_ANAMAG, codart);
|
||||
const TString & alt = art.get(ANAMAG_CODARTALT);
|
||||
@ -1526,21 +1608,6 @@ long TDocumento::get_next_key(char provv, int anno, const char* codnum) const
|
||||
return n;
|
||||
}
|
||||
|
||||
const TTipo_documento& TDocumento::tipo(const char* tipodoc)
|
||||
{
|
||||
TTipo_documento* o = (TTipo_documento*)_tipi.objptr(tipodoc);
|
||||
if (o == NULL)
|
||||
{
|
||||
#ifdef DBG
|
||||
if (tipodoc == NULL || *tipodoc == '\0')
|
||||
NFCHECK("Tipo documento nullo");
|
||||
#endif
|
||||
o = new TTipo_documento(tipodoc);
|
||||
_tipi.add(tipodoc, o);
|
||||
}
|
||||
return *o;
|
||||
}
|
||||
|
||||
const TTipo_documento& TDocumento::tipo() const
|
||||
{
|
||||
TString4 tipodoc(get(DOC_TIPODOC));
|
||||
@ -1554,23 +1621,12 @@ const TTipo_documento& TDocumento::tipo() const
|
||||
((TDocumento*)this)->set_tipo(tipodoc);
|
||||
}
|
||||
#endif
|
||||
return tipo(tipodoc);
|
||||
}
|
||||
|
||||
const TCodice_numerazione& TDocumento::codice_numerazione(const char* numerazione)
|
||||
{
|
||||
TCodice_numerazione* o = (TCodice_numerazione*)_numerazioni.objptr(numerazione);
|
||||
if (o == NULL)
|
||||
{
|
||||
o = new TCodice_numerazione(numerazione);
|
||||
_numerazioni.add(numerazione, o);
|
||||
}
|
||||
return *o;
|
||||
return cached_tipodoc(tipodoc);
|
||||
}
|
||||
|
||||
const TCodice_numerazione& TDocumento::codice_numerazione() const
|
||||
{
|
||||
return codice_numerazione(numerazione());
|
||||
return cached_numerazione(numerazione());
|
||||
}
|
||||
|
||||
bool TDocumento::raggruppabile(const TDocumento& doc, TToken_string& campi) const
|
||||
@ -2344,7 +2400,6 @@ void TDocumento::update_raee()
|
||||
cod_iva_cli = cfven.get("ASSFIS");
|
||||
int nrows = physical_rows();
|
||||
int i;
|
||||
TArticolo art;
|
||||
|
||||
for (i = nrows; i > 0; i--)
|
||||
{
|
||||
@ -2360,9 +2415,7 @@ void TDocumento::update_raee()
|
||||
|
||||
if (r.is_articolo())
|
||||
{
|
||||
const TString & codart = r.get(RDOC_CODARTMAG);
|
||||
|
||||
art.read(codart);
|
||||
TArticolo & art = r.articolo();
|
||||
real tax = art.get_real(r_fld);
|
||||
|
||||
if (tax != ZERO)
|
||||
|
@ -525,7 +525,6 @@ static TString16 _ivasto; // Codice IVA per storno articoli Omaggio
|
||||
static bool _contsclor; // Contabilizza sconti al netto o al lordo (sconti suddiviso per ogni contropartita)
|
||||
//static bool _loaded = false;// Flag per evitare di caricare i parametri più di una volta
|
||||
|
||||
static TEsercizi_contabili _esc; // Per sapere a quale esercizio appartiene il documento
|
||||
static TCausale *_caus = NULL; // causale del documento corrente
|
||||
static TMovimentoPN_VE *_movimento = NULL; // Movimento di prima nota documento vendita
|
||||
static TMovimentoPN *_anticipo = NULL; // Movimento di prima nota relativamente all'anticipo indicato sul documento
|
||||
@ -592,7 +591,7 @@ error_type TIVA_array::add(const TRiga_documento& r, const TBill& conto, const i
|
||||
{
|
||||
TString80 key(rdoc->get(RDOC_CODNUM));
|
||||
|
||||
const TCodice_numerazione& num = TDocumento::codice_numerazione(key);
|
||||
const TCodice_numerazione& num = cached_numerazione(key);
|
||||
if (num.fattura_emettere_ricevere())
|
||||
{
|
||||
key.format("%3d%3d%6ld", c.gruppo(), c.conto(), c.sottoconto());
|
||||
@ -615,8 +614,8 @@ error_type TIVA_array::add(const TRiga_documento& r, const TBill& conto, const i
|
||||
key << '|' << rdoc->get(RDOC_NDOC);
|
||||
|
||||
const TRectype & doc = cache().get(LF_DOC, key);
|
||||
const TTipo_documento & td = TDocumento::tipo(doc.get(DOC_TIPODOC));
|
||||
const TString& codcau = td.causale();
|
||||
const TTipo_documento& td = cached_tipodoc(doc.get(DOC_TIPODOC));
|
||||
const TString& codcau = td.causale();
|
||||
const TCausale caus(codcau);
|
||||
|
||||
caus.bill(1, c);
|
||||
@ -1034,7 +1033,7 @@ error_type TContabilizzazione::compile_head_mov(TDocumento& doc)
|
||||
const TDate data_reg(_auto_data ? datadoc : _data_reg);
|
||||
|
||||
// reperisce il codice anno esercizio,
|
||||
const int cod_es = _esc.date2esc(data_reg);
|
||||
const int cod_es = esercizi().date2esc(data_reg);
|
||||
if (cod_es <= 0)
|
||||
{
|
||||
_error = nr_es_error;
|
||||
@ -1414,7 +1413,7 @@ error_type TContabilizzazione::compile_head_mov_re(TDocumento& doc)
|
||||
const TDate data_reg(_auto_data ? datadoc : _data_reg);
|
||||
|
||||
// reperisce il codice anno esercizio,
|
||||
const int cod_es = _esc.date2esc(data_reg);
|
||||
const int cod_es = esercizi().date2esc(data_reg);
|
||||
if (cod_es <= 0)
|
||||
{
|
||||
_error = nr_es_error;
|
||||
@ -3831,7 +3830,7 @@ bool TContabilizzazione::elabora(TLista_documenti& doc_in, TLista_documenti& doc
|
||||
_nump_iva = 1;
|
||||
}
|
||||
|
||||
_esc.update();
|
||||
esercizi().update();
|
||||
_cpg->setkey(1); // Setta per sicurezza la chiave 1 nel caso l'elaborazione sia invocata da VE0
|
||||
|
||||
if (!load_parameters()) // Carica i parametri dalla configurazione
|
||||
|
@ -298,7 +298,7 @@ bool TConsegna_ordini::calcola_ncolli_tara_pnetto(const TString& codart, const r
|
||||
bool TConsegna_ordini::aggiorna_ncolli_tara_pnetto(TRiga_documento& r) const
|
||||
{
|
||||
const TString& codart = r.get(RDOC_CODARTMAG);
|
||||
TArticolo articolo(codart);
|
||||
TArticolo & articolo = cached_article(codart);
|
||||
const real qta = articolo.convert_to_um(r.quantita(), NULL, r.get(RDOC_UMQTA));
|
||||
real ncolli, tara, pnetto;
|
||||
|
||||
@ -337,12 +337,8 @@ bool TConsegna_ordini::elabora(TLista_documenti& doc_in, TLista_documenti& doc_o
|
||||
const TString& articolo = params().get("ARTICOLO");
|
||||
|
||||
m.doc2mask(indoc, articolo);
|
||||
TArticolo art;
|
||||
if (articolo.full())
|
||||
{
|
||||
art.read(articolo);
|
||||
params().set("QUANTITA", ZERO);
|
||||
}
|
||||
ok = m.run() == K_ENTER;
|
||||
if (ok)
|
||||
{
|
||||
@ -447,8 +443,8 @@ bool TConsegna_ordini::elabora(TLista_documenti& doc_in, TLista_documenti& doc_o
|
||||
{
|
||||
rif << " n. " << nrifin;
|
||||
rif << " del " << d.get(DOC_DATADOCRIF);
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
rif << " n. " << d.numero();
|
||||
rif << " del " << d.data().string();
|
||||
@ -516,7 +512,7 @@ bool TConsegna_ordini::elabora(TLista_documenti& doc_in, TLista_documenti& doc_o
|
||||
}
|
||||
else
|
||||
{
|
||||
scarto = art.convert_to_um(scarto, inrec.get(RDOC_UMQTA), ska->get(0));
|
||||
scarto = inrec.articolo().convert_to_um(scarto, inrec.get(RDOC_UMQTA), ska->get(0));
|
||||
real s = ska->get(1); s += scarto;
|
||||
ska->add(s.string(), 1);
|
||||
}
|
||||
@ -527,7 +523,8 @@ bool TConsegna_ordini::elabora(TLista_documenti& doc_in, TLista_documenti& doc_o
|
||||
if (articolo.not_empty())
|
||||
{
|
||||
const TString4 um(inrec.get(RDOC_UMQTA));
|
||||
const real qta = art.convert_to_um(daeva, params().get("UM"), um);
|
||||
const real qta = inrec.articolo().convert_to_um(daeva, params().get("UM"), um);
|
||||
|
||||
params().set("QUANTITA", qta + params().get_real("QUANTITA"));
|
||||
}
|
||||
|
||||
|
@ -297,7 +297,7 @@ bool TContabilizzazione_analitica::search_costo_ricavo(const TRiga_documento& r,
|
||||
{
|
||||
TString80 key(rdoc->get(RDOC_CODNUM));
|
||||
|
||||
const TCodice_numerazione& num = TDocumento::codice_numerazione(key);
|
||||
const TCodice_numerazione& num = cached_numerazione(key);
|
||||
if (num.fattura_emettere_ricevere())
|
||||
{
|
||||
key.format("%3d%3d%6ld", conto.gruppo(), conto.conto(), conto.sottoconto());
|
||||
@ -507,10 +507,9 @@ bool TContabilizzazione_analitica::elabora(TDocumento& doc, long numreg_cg, TVis
|
||||
}
|
||||
else
|
||||
{
|
||||
TEsercizi_contabili esc;
|
||||
datadoc = doc.get(DOC_DATADOC);
|
||||
datareg = datacomp = datadoc;
|
||||
annoes = esc.date2esc(datareg);
|
||||
annoes = esercizi().date2esc(datareg);
|
||||
doc.riferimento(descr);
|
||||
if (descr.empty())
|
||||
descr = doc.tipo().descrizione();
|
||||
|
111
ve/velib06.cpp
111
ve/velib06.cpp
@ -1216,69 +1216,78 @@ void TDocumento_mask::update_giacenza()
|
||||
if (id2pos(F_CURGIAC)<0 || !is_running())
|
||||
return;
|
||||
|
||||
TSheet_field& sf = sfield(F_SHEET);
|
||||
TSheet_field& sf = sfield(F_SHEET);
|
||||
TToken_string& row = sf.row(sf.selected());
|
||||
TString codart = row.get(sf.cid2index(FR_CODARTMAG));
|
||||
TString16 causmag = row.get(sf.cid2index(FR_CAUS));
|
||||
|
||||
if (codart.blank())
|
||||
{
|
||||
reset(F_CURGIAC);
|
||||
reset(F_CURDISP);
|
||||
return;
|
||||
}
|
||||
|
||||
TString16 causmag = row.get(sf.cid2index(FR_CAUS));
|
||||
|
||||
if (causmag.blank())
|
||||
causmag = get(F_CAUSMAG);
|
||||
|
||||
const TCausale_magazzino c(causmag);
|
||||
|
||||
if (causmag.full() && c.scarica_alternativi())
|
||||
if (causmag.full())
|
||||
{
|
||||
const TString& alt = cache().get(LF_ANAMAG, codart, ANAMAG_CODARTALT);
|
||||
if (alt.full())
|
||||
codart = alt;
|
||||
TCausale_magazzino & c = cached_causale_magazzino(causmag);
|
||||
|
||||
if (c.scarica_alternativi())
|
||||
{
|
||||
const TString& alt = cached_article(codart).get(ANAMAG_CODARTALT);
|
||||
if (alt.full())
|
||||
codart = alt;
|
||||
}
|
||||
}
|
||||
|
||||
real giac, disp;
|
||||
if (codart.full())
|
||||
{
|
||||
TString8 codmag = row.get(sf.cid2index(FR_CODMAG));
|
||||
if (codmag.full())
|
||||
TString8 codmag = row.get(sf.cid2index(FR_CODMAG));
|
||||
if (codmag.full())
|
||||
{
|
||||
const TString4 coddep = row.get(sf.cid2index(FR_CODDEP));
|
||||
if (coddep.full())
|
||||
codmag << coddep;
|
||||
}
|
||||
else
|
||||
{ // Cerca di determinare il magazzino di default, se manca sulla riga
|
||||
if (causmag.full())
|
||||
{
|
||||
const TString4 coddep = row.get(sf.cid2index(FR_CODDEP));
|
||||
if (coddep.full())
|
||||
codmag << coddep;
|
||||
}
|
||||
else
|
||||
{ // Cerca di determinare il magazzino di default, se manca sulla riga
|
||||
if (causmag.full())
|
||||
{
|
||||
const TCausale_magazzino c(causmag);
|
||||
TCausale_magazzino & c = cached_causale_magazzino(causmag);
|
||||
|
||||
if (c.has_default_mag())
|
||||
{
|
||||
codmag = c.default_mag();
|
||||
if (c.has_default_dep())
|
||||
codmag << c.default_dep();
|
||||
}
|
||||
if (c.has_default_mag())
|
||||
{
|
||||
codmag = c.default_mag();
|
||||
if (c.has_default_dep())
|
||||
codmag << c.default_dep();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TString16 livello;
|
||||
TString16 livello;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
const char* liv = row.get(sf.cid2index(FR_LIV1+i));
|
||||
if (*liv > ' ')
|
||||
livello << liv;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
const char* liv = row.get(sf.cid2index(FR_LIV1+i));
|
||||
if (*liv > ' ')
|
||||
livello << liv;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
const TString8 annoes = get(F_ANNO);
|
||||
TArticolo_giacenza art(codart);
|
||||
giac = art.disponibilita(annoes, codmag, livello, TRUE);
|
||||
disp = art.disponibilita(annoes, codmag, livello, FALSE);
|
||||
|
||||
const TString4 um = row.get(sf.cid2index(FR_UMQTA));
|
||||
art.convert_to_um(giac, um);
|
||||
art.convert_to_um(disp, um);
|
||||
}
|
||||
|
||||
const TString8 annoes = get(F_ANNO);
|
||||
TArticolo_giacenza & art = cached_article_balances(codart);
|
||||
|
||||
giac = art.disponibilita(annoes, codmag, livello, TRUE);
|
||||
disp = art.disponibilita(annoes, codmag, livello, FALSE);
|
||||
|
||||
const TString4 um = row.get(sf.cid2index(FR_UMQTA));
|
||||
|
||||
art.convert_to_um(giac, um);
|
||||
art.convert_to_um(disp, um);
|
||||
set(F_CURGIAC, giac.string());
|
||||
set(F_CURDISP, disp.string());
|
||||
}
|
||||
@ -2065,7 +2074,7 @@ bool TDocument_tree::get_description(TString& str) const
|
||||
str.left_just(63);
|
||||
|
||||
const TString& tipodoc = rec.get(DOC_TIPODOC);
|
||||
const TTipo_documento& tipo = TDocumento::tipo(tipodoc);
|
||||
const TTipo_documento& tipo = cached_tipodoc(tipodoc);
|
||||
append_custom_fields(tipo, rec, str);
|
||||
}
|
||||
else
|
||||
@ -2080,7 +2089,7 @@ bool TDocument_tree::get_description(TString& str) const
|
||||
str.left_just(52);
|
||||
|
||||
const TString& tipodoc = testata.get(DOC_TIPODOC);
|
||||
const TTipo_documento& tipo = TDocumento::tipo(tipodoc);
|
||||
const TTipo_documento& tipo = cached_tipodoc(tipodoc);
|
||||
if (codart.not_empty())
|
||||
{
|
||||
const real qta = rec.get_real(tipo.field_qta());
|
||||
@ -2685,7 +2694,7 @@ void TElabora_mask::update_ndoc_filter(bool is_tipo_elaborazione)
|
||||
field(F_STATODOC_ELAB).check();
|
||||
|
||||
// Azzero anno di elaaborazione quando ho a che fare con degli ordini
|
||||
const TTipo_documento& tipodocin = _main->doc().tipo(tipo_in);
|
||||
const TTipo_documento& tipodocin = cached_tipodoc(tipo_in);
|
||||
if (tipodocin.is_ordine())
|
||||
reset(F_ANNO_ELAB);
|
||||
}
|
||||
@ -3301,7 +3310,7 @@ void TDocumento_mask::update_father_rows(bool add)
|
||||
|
||||
if (r.is_articolo())
|
||||
{
|
||||
TArticolo art(r.get(RDOC_CODARTMAG));
|
||||
TArticolo & art = cached_article(r.get(RDOC_CODARTMAG));
|
||||
|
||||
value = art.convert_to_um(value, original_row->get(RDOC_UMQTA), r.get(RDOC_UMQTA));
|
||||
}
|
||||
|
@ -303,10 +303,7 @@ bool data_hndl( TMask_field& field, KEY key )
|
||||
const TCodice_numerazione codnum(m.get(F_CODNUM));
|
||||
if (codnum.test_eser())
|
||||
{
|
||||
|
||||
TEsercizi_contabili esc;
|
||||
|
||||
if (esc.date2esc(datadoc) <= 0)
|
||||
if (esercizi().date2esc(datadoc) <= 0)
|
||||
return field.error_box("La data documento non appartiene ad un esercizio valido.");
|
||||
if (main_app().has_module(CGAUT))
|
||||
{
|
||||
@ -638,15 +635,15 @@ bool codmag_coll_handler( TMask_field& f, KEY key )
|
||||
|
||||
|
||||
|
||||
void upd_colli_peso_tara(TMask& m, const TRectype& a)
|
||||
void upd_colli_peso_tara(TMask& m, const TString & codart)
|
||||
{
|
||||
// const real qta = m.get_real(FR_QTA) * curr_fc; // curr_fc puo' non essere inizializzata e vale -1
|
||||
// Usando il metodo apposito di TArticolo non si sbaglia micca mai.
|
||||
// Sarebbe bene sparare (come dice Luca) a curr_fc ovunque copaia
|
||||
TArticolo articolo(a);
|
||||
TArticolo & articolo = cached_article(codart);
|
||||
const real qta = articolo.convert_to_um(m.get_real(FR_QTA), NULL, m.get(FR_UMQTA));
|
||||
|
||||
const real ppcollo = a.get_real(ANAMAG_PPCOLLO);
|
||||
const real ppcollo = articolo.get_real(ANAMAG_PPCOLLO);
|
||||
|
||||
real ncolli = ppcollo.is_zero() ? UNO : qta / ppcollo;
|
||||
ncolli.ceil(0);
|
||||
@ -661,13 +658,13 @@ void upd_colli_peso_tara(TMask& m, const TRectype& a)
|
||||
pos = m.id2pos(FR_TARA);
|
||||
if (pos >= 0)
|
||||
{
|
||||
const real tara = ncolli * a.get_real(ANAMAG_TARA);
|
||||
const real tara = ncolli * articolo.get_real(ANAMAG_TARA);
|
||||
m.fld(pos).set(tara.string());
|
||||
}
|
||||
pos = m.id2pos(FR_PNETTO);
|
||||
if (pos >= 0)
|
||||
{
|
||||
const real peso = qta * a.get_real(ANAMAG_PESO);
|
||||
const real peso = qta * articolo.get_real(ANAMAG_PESO);
|
||||
m.fld(pos).set(peso.string());
|
||||
}
|
||||
|
||||
@ -1449,7 +1446,7 @@ bool codart_handler(TMask_field& f, KEY key )
|
||||
curr_fc = 1.0;
|
||||
}
|
||||
row_mask.set(FR_UMQTA, curr_um);
|
||||
upd_colli_peso_tara(row_mask, anamag);
|
||||
upd_colli_peso_tara(row_mask, codart);
|
||||
}
|
||||
|
||||
condv.ricerca();
|
||||
@ -1473,7 +1470,7 @@ bool codart_handler(TMask_field& f, KEY key )
|
||||
|
||||
if (caus.not_empty())
|
||||
{
|
||||
const TCausale_magazzino c(caus);
|
||||
const TCausale_magazzino & c = cached_causale_magazzino(caus);
|
||||
|
||||
|
||||
if (!c.movimenta_sospesi())
|
||||
@ -1642,8 +1639,7 @@ bool liv_handler( TMask_field& f, KEY key )
|
||||
TLocalisamfile fl(LF_MAG);
|
||||
fl.setkey(2);
|
||||
TRectype & r = fl.curr();
|
||||
TEsercizi_contabili esc;
|
||||
const int annoes = esc.date2esc(mask.get_date(F_DATADOC));
|
||||
const int annoes = esercizi().date2esc(mask.get_date(F_DATADOC));
|
||||
|
||||
r.put(MAG_ANNOES, annoes);
|
||||
TString16 codmag(row_mask.get(FR_CODMAG));
|
||||
@ -1867,11 +1863,7 @@ bool qtaart_handler( TMask_field& f, KEY key )
|
||||
const TString& codart = row_mask.get(FR_CODARTMAG);
|
||||
|
||||
if (codart.not_empty())
|
||||
{
|
||||
const TRectype& anamag = cache().get(LF_ANAMAG, codart);
|
||||
if (!anamag.empty())
|
||||
upd_colli_peso_tara(row_mask, anamag);
|
||||
}
|
||||
upd_colli_peso_tara(row_mask, codart);
|
||||
|
||||
} //if(key==K_TAB
|
||||
else
|
||||
@ -1906,12 +1898,14 @@ bool qtaart_handler( TMask_field& f, KEY key )
|
||||
|
||||
real qta(row.get(sf.cid2index(FR_QTA)));
|
||||
const TString16 caus(mask.get(F_CAUSMAG));
|
||||
TCausale_magazzino c(caus);
|
||||
TCausale_magazzino & c = cached_causale_magazzino(caus);
|
||||
const long nmovmag = doc.get_long(DOC_MOVMAG);
|
||||
|
||||
if (nmovmag != 0)
|
||||
{
|
||||
TLocalisamfile rmovmag(LF_RMOVMAG); rmovmag.setkey(2);
|
||||
TLocalisamfile rmovmag(LF_RMOVMAG);
|
||||
|
||||
rmovmag.setkey(2);
|
||||
rmovmag.put(RMOVMAG_CODART, codart);
|
||||
rmovmag.put(RMOVMAG_LIVGIAC, livello);
|
||||
rmovmag.put(RMOVMAG_CODMAG, codmag);
|
||||
@ -1991,13 +1985,14 @@ bool causmag_handler( TMask_field& f, KEY key )
|
||||
TMask& row_mask = f.mask( );
|
||||
TDocumento_mask& mask = (TDocumento_mask &) row_mask.get_sheet()->mask();
|
||||
TString8 causmag(f.get());
|
||||
if (causmag.blank())
|
||||
|
||||
if (causmag.blank())
|
||||
causmag = mask.get(F_CAUSMAG);
|
||||
if (causmag.full())
|
||||
{
|
||||
TCausale_magazzino c(causmag);
|
||||
if (c.has_default_mag() && row_mask.get(FR_CODMAG).empty())
|
||||
TCausale_magazzino & c = cached_causale_magazzino(causmag);
|
||||
|
||||
if (c.has_default_mag() && row_mask.get(FR_CODMAG).empty())
|
||||
{
|
||||
row_mask.set(FR_CODMAG, c.default_mag(), true);
|
||||
row_mask.set(FR_CODDEP, "", true);
|
||||
@ -2050,18 +2045,7 @@ bool sppr_handler( TMask_field& f, KEY key )
|
||||
if (key == K_TAB && (f.focusdirty() || row_mask.get(FR_DESCR).empty()))
|
||||
{
|
||||
const TRectype& curr = ((TEdit_field&)f).browse()->cursor()->curr();
|
||||
/*
|
||||
const TString& cod = curr.get("COD");
|
||||
char tiposp = RIGA_SPESEDOC;
|
||||
if (cod == "PRS")
|
||||
tiposp = RIGA_PRESTAZIONI; else
|
||||
if (cod == "RSS")
|
||||
tiposp = RIGA_RISORSE; else
|
||||
if (cod == "ATR")
|
||||
tiposp = RIGA_ATTREZZATURE;
|
||||
const TSpesa_prest sp(row_mask.get(FR_CODART), tiposp);
|
||||
*/
|
||||
const TSpesa_prest sp(curr);
|
||||
const TSpesa_prest sp(curr);
|
||||
|
||||
const int pos = row_mask.id2pos(FR_PREZZO);
|
||||
if (pos >= 0 && !sp.empty())
|
||||
|
Loading…
x
Reference in New Issue
Block a user