2000-10-03 13:45:12 +00:00
|
|
|
|
#include <applicat.h>
|
1998-05-04 09:54:49 +00:00
|
|
|
|
#include <defmask.h>
|
2000-10-03 13:45:12 +00:00
|
|
|
|
#include <modaut.h>
|
1998-11-04 18:04:26 +00:00
|
|
|
|
#include <progind.h>
|
1999-10-22 10:00:18 +00:00
|
|
|
|
#include <sheet.h>
|
1997-10-23 10:53:49 +00:00
|
|
|
|
#include <tabutil.h>
|
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
#include "velib.h"
|
|
|
|
|
#include "vepriv.h"
|
|
|
|
|
|
1997-10-23 10:53:49 +00:00
|
|
|
|
#ifndef __VERIG_H
|
|
|
|
|
#include "verig.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef __VEUML1_H
|
|
|
|
|
#include "veuml1.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef __VEINI_H
|
|
|
|
|
#include "veini.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef __SCONTI_H
|
|
|
|
|
#include "sconti.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2000-10-03 13:45:12 +00:00
|
|
|
|
#include "../cg/cg2103.h"
|
|
|
|
|
|
1998-11-04 18:04:26 +00:00
|
|
|
|
#ifndef __MGLIB_H
|
|
|
|
|
#include "../mg/mglib.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef __DBLIB_H
|
|
|
|
|
#include "../db/dblib.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
1997-10-23 10:53:49 +00:00
|
|
|
|
#include "../mg/anamag.h"
|
|
|
|
|
#include "../mg/codcorr.h"
|
|
|
|
|
#include "../mg/deslin.h"
|
|
|
|
|
#include "../mg/umart.h"
|
1999-10-22 10:00:18 +00:00
|
|
|
|
#include "velib.h"
|
2000-10-03 13:45:12 +00:00
|
|
|
|
|
1999-06-18 15:35:05 +00:00
|
|
|
|
#define MAX_VIS_RATE 5
|
1997-10-23 10:53:49 +00:00
|
|
|
|
|
2001-05-02 13:40:49 +00:00
|
|
|
|
bool numdocrif_hndl( TMask_field& field, KEY key )
|
|
|
|
|
{
|
|
|
|
|
if (key == K_ENTER)
|
|
|
|
|
{
|
2002-10-23 14:14:55 +00:00
|
|
|
|
TDocumento_mask& m = (TDocumento_mask&)field.mask();
|
|
|
|
|
TString16 campo = DOC_NUMDOCRIF;
|
|
|
|
|
if (field.field() != NULL)
|
|
|
|
|
campo = field.field()->name();
|
2001-05-02 13:40:49 +00:00
|
|
|
|
|
|
|
|
|
TRectype filtrec(LF_DOC);
|
|
|
|
|
filtrec.put(DOC_TIPOCF, m.get(F_TIPOCF));
|
|
|
|
|
filtrec.put(DOC_CODCF, m.get(F_CODCF));
|
|
|
|
|
filtrec.put(DOC_PROVV, m.get(F_PROVV));
|
|
|
|
|
filtrec.put(DOC_ANNO, m.get(F_ANNO));
|
|
|
|
|
|
|
|
|
|
TRelation rel(LF_DOC);
|
2002-10-23 14:14:55 +00:00
|
|
|
|
TString sortkey = "TIPOCF|CODCF|PROVV|ANNO|CODNUM|"; sortkey << campo;
|
|
|
|
|
TSorted_cursor cur(&rel, sortkey, "", 2, &filtrec, &filtrec);
|
|
|
|
|
TString80 f; f.format("CODNUM==\"%s\"", (const char*)m.get(F_CODNUM));
|
2001-05-02 13:40:49 +00:00
|
|
|
|
|
|
|
|
|
cur.setfilter(f);
|
|
|
|
|
|
|
|
|
|
filtrec.put(DOC_CODNUM, m.get(F_CODNUM));
|
2002-10-23 14:14:55 +00:00
|
|
|
|
filtrec.put(campo, field.get());
|
2001-05-02 13:40:49 +00:00
|
|
|
|
cur.curr() = filtrec;
|
|
|
|
|
cur.read(_isequal);
|
|
|
|
|
|
|
|
|
|
if (cur.file().status() == NOERR)
|
|
|
|
|
{
|
|
|
|
|
const long numdoc = m.get_long(F_NDOC);
|
|
|
|
|
if (numdoc != cur.curr().get_long(DOC_NDOC))
|
2002-10-23 14:14:55 +00:00
|
|
|
|
return yesno_box("Il numero di riferimento %s <20> gi<67> stato utilizzato\nsi desidera registrare ugualmente?",
|
|
|
|
|
(const char *)field.get());
|
2001-05-02 13:40:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1999-10-22 10:00:18 +00:00
|
|
|
|
bool totdoc_hndl( TMask_field& field, KEY key )
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
if (key == K_ENTER)
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask & m = (TDocumento_mask &) field.mask();
|
|
|
|
|
const real totdoc = m.doc().totale_doc();
|
|
|
|
|
const real totdoc_check(field.get());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (totdoc != totdoc_check)
|
|
|
|
|
{
|
|
|
|
|
const TString16 tchk(totdoc_check.string());
|
|
|
|
|
|
|
|
|
|
return yesno_box("Il totale documento digitato (%s) non corrisponde\nal totale documento (%s) calcolato,\n devo registrare ugualmente",
|
|
|
|
|
(const char *) tchk, totdoc.string());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2001-05-02 13:40:49 +00:00
|
|
|
|
|
1997-10-23 10:53:49 +00:00
|
|
|
|
bool ora_hndl( TMask_field& field, KEY key )
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
if (field.to_check(key))
|
|
|
|
|
{
|
|
|
|
|
TFixed_string ora( field.get( ), 6 );
|
|
|
|
|
|
|
|
|
|
ora.trim( );
|
|
|
|
|
if (ora.not_empty() || field.required() )
|
|
|
|
|
{
|
|
|
|
|
if ( isdigit( ora[ 0 ] ) )
|
|
|
|
|
{
|
|
|
|
|
if ( ora[ 2 ] != ':')
|
|
|
|
|
{
|
|
|
|
|
if ( ora.len( ) > 4 )
|
|
|
|
|
ora.overwrite( ":", 2 );
|
|
|
|
|
else
|
|
|
|
|
ora.insert( ":", 2 );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const bool ok = ((isdigit(ora[0]))&&(isdigit(ora[1]))&&(isdigit(ora[3]))&&(isdigit(ora[4]))) &&
|
|
|
|
|
((atoi(&(ora[0]))<24)&&(atoi(&(ora[3]))<60));
|
|
|
|
|
if (ok )
|
|
|
|
|
field.set((ora));
|
|
|
|
|
else
|
|
|
|
|
return error_box("Ora errata o formato non valido");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool dummy_hndl(TMask_field& field, KEY key)
|
|
|
|
|
{
|
|
|
|
|
warning_box( "Al campo %d <20> arrivato un KEY %d", field.dlg( ), key );
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handler per il calcolo delle date di pagamento
|
|
|
|
|
bool condpag_hndl( TMask_field& field, KEY key )
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask& m = (TDocumento_mask &) field.mask( );
|
|
|
|
|
|
|
|
|
|
if ( field.to_check(key) || (key == K_TAB && !m.is_running()))
|
|
|
|
|
{
|
1999-04-06 15:34:39 +00:00
|
|
|
|
const TString& condpag = m.get(F_CODPAG);
|
|
|
|
|
if (condpag.not_empty())
|
1997-10-23 10:53:49 +00:00
|
|
|
|
{
|
1999-04-06 15:34:39 +00:00
|
|
|
|
TDocumento& doc = m.doc();
|
|
|
|
|
// Aggiorna dati necessari per determinare il pagamento
|
|
|
|
|
doc.put(DOC_CODPAG, condpag);
|
|
|
|
|
doc.put(DOC_DATADOC, m.get(F_DATADOC));
|
|
|
|
|
doc.put(DOC_DATAINSC, m.get(F_DATAINSC));
|
|
|
|
|
doc.put(DOC_TIPOCF, m.get(F_TIPOCF));
|
|
|
|
|
doc.put(DOC_CODCF, m.get(F_CODCF));
|
|
|
|
|
TPagamento& pag = doc.pagamento();
|
1999-10-22 10:00:18 +00:00
|
|
|
|
pag.set_total(real(100), real(10), real(10));
|
1999-04-06 15:34:39 +00:00
|
|
|
|
pag.set_rate_auto();
|
1997-10-23 10:53:49 +00:00
|
|
|
|
|
|
|
|
|
int numrate = pag.n_rate( );
|
1999-06-18 15:35:05 +00:00
|
|
|
|
for(int i = 0; i < MAX_VIS_RATE; i++)
|
1997-10-23 10:53:49 +00:00
|
|
|
|
{
|
1999-06-18 15:35:05 +00:00
|
|
|
|
if (i < numrate)
|
|
|
|
|
{
|
|
|
|
|
m.show(F_DATASCAD1+i);
|
|
|
|
|
m.set(F_DATASCAD1+i, pag.data_rata(i));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
m.hide(F_DATASCAD1+i);
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2000-05-05 15:25:49 +00:00
|
|
|
|
}
|
1997-10-23 10:53:49 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool note_hndl( TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask & m = (TDocumento_mask &) f.mask();
|
|
|
|
|
|
|
|
|
|
if (key == K_TAB && (f.focusdirty() || !m.is_running()))
|
2004-06-04 11:20:51 +00:00
|
|
|
|
{
|
1997-10-23 10:53:49 +00:00
|
|
|
|
TTable & note = (TTable &) ((TEdit_field &) f).browse()->cursor()->file();
|
2004-06-04 11:20:51 +00:00
|
|
|
|
// gestione del campo con descrizione estesa
|
|
|
|
|
TString stringone;
|
|
|
|
|
TRectype& rec = note.curr();
|
|
|
|
|
TString4 fieldname;
|
|
|
|
|
for (int i = 0; i < 6; i++)
|
|
|
|
|
{
|
|
|
|
|
fieldname.format("S%d", i);
|
|
|
|
|
stringone << rec.get(fieldname);
|
|
|
|
|
}
|
|
|
|
|
stringone.replace((char)0xB6, '\n');
|
|
|
|
|
m.set(F_NOTECLI, stringone);
|
|
|
|
|
|
1997-10-23 10:53:49 +00:00
|
|
|
|
note.setkey(1);
|
|
|
|
|
const TString16 cod(f.get());
|
|
|
|
|
|
|
|
|
|
if (cod != note.get("CODTAB"))
|
|
|
|
|
{
|
|
|
|
|
note.zero();
|
|
|
|
|
note.put("CODTAB", cod);
|
|
|
|
|
if (note.read() != NOERR)
|
|
|
|
|
note.zero();
|
1998-08-25 18:07:30 +00:00
|
|
|
|
}
|
1999-06-18 15:35:05 +00:00
|
|
|
|
if (m.doc().modificabile() && m.field(DLG_SAVEREC).enabled())
|
1998-08-25 18:07:30 +00:00
|
|
|
|
{
|
1998-11-04 18:04:26 +00:00
|
|
|
|
const bool reg_disabled = note.get_bool("B0");
|
|
|
|
|
|
|
|
|
|
if (reg_disabled)
|
1999-10-22 10:00:18 +00:00
|
|
|
|
message_box("Registrazione disabilitata : %s", (const char *) note.get("S0"));
|
1998-11-04 18:04:26 +00:00
|
|
|
|
m.enable(DLG_SAVEREC, !reg_disabled);
|
|
|
|
|
}
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handler per il calcolo delle date di pagamento
|
|
|
|
|
bool data_hndl( TMask_field& field, KEY key )
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask& m = (TDocumento_mask &) field.mask( );
|
|
|
|
|
if (field.to_check(key))
|
1998-08-25 18:07:30 +00:00
|
|
|
|
{
|
|
|
|
|
if (m.id2pos(F_DATAINSC) >= 0)
|
|
|
|
|
{
|
|
|
|
|
TEdit_field & e = m.efield(F_DATAINSC);
|
|
|
|
|
e.set_dirty();
|
|
|
|
|
e.on_hit();
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-27 15:01:34 +00:00
|
|
|
|
if (m.id2pos(F_DATACAMBIO1) >= 0 && !m.get(F_CODVAL).empty())
|
1998-08-25 18:07:30 +00:00
|
|
|
|
m.set(F_DATACAMBIO1, field.get(), TRUE);
|
|
|
|
|
}
|
1999-10-22 10:00:18 +00:00
|
|
|
|
if (key == K_ENTER || field.to_check(key))
|
1998-11-04 18:04:26 +00:00
|
|
|
|
{
|
2000-10-03 13:45:12 +00:00
|
|
|
|
const TDate datadoc(m.get(F_DATADOC));
|
1999-10-22 10:00:18 +00:00
|
|
|
|
if (!datadoc.ok())
|
|
|
|
|
return field.error_box("La data documento deve essere comunque indicata.");
|
2000-10-03 13:45:12 +00:00
|
|
|
|
|
|
|
|
|
TEsercizi_contabili esc;
|
|
|
|
|
if (esc.date2esc(datadoc) <= 0)
|
|
|
|
|
return field.error_box("La data documento non appartiene ad un esercizio valido.");
|
|
|
|
|
if (main_app().has_module(CGAUT))
|
|
|
|
|
{
|
|
|
|
|
const TTipo_documento& td = m.doc().tipo();
|
|
|
|
|
TString16 codcaus = td.causale();
|
|
|
|
|
if (codcaus.empty())
|
|
|
|
|
{
|
|
|
|
|
const TRectype& clifo = m.doc().clifor().vendite();
|
|
|
|
|
codcaus = clifo.get("CODCAUS");
|
|
|
|
|
}
|
|
|
|
|
if (codcaus.not_empty())
|
|
|
|
|
{
|
|
|
|
|
const int year = datadoc.year();
|
|
|
|
|
TCausale caus;
|
|
|
|
|
if (!caus.read(codcaus, year))
|
|
|
|
|
return FALSE; // L'errore viene segnalato nella read
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1998-11-04 18:04:26 +00:00
|
|
|
|
const TCodice_numerazione codnum(m.get(F_CODNUM));
|
|
|
|
|
if (codnum.dont_test_datadoc())
|
1999-10-22 10:00:18 +00:00
|
|
|
|
return TRUE; // Non devo fare altri test
|
1998-11-04 18:04:26 +00:00
|
|
|
|
|
1997-10-23 10:53:49 +00:00
|
|
|
|
TLocalisamfile doc(LF_DOC);
|
|
|
|
|
|
|
|
|
|
doc.curr() = m.doc().head();
|
1998-11-04 18:04:26 +00:00
|
|
|
|
bool same_key = FALSE;
|
1998-08-25 18:07:30 +00:00
|
|
|
|
|
1999-10-22 10:00:18 +00:00
|
|
|
|
doc.read(_isgteq);
|
1998-11-04 18:04:26 +00:00
|
|
|
|
if (doc.eof() || doc.prev() == NOERR)
|
1998-08-25 18:07:30 +00:00
|
|
|
|
{
|
1998-11-04 18:04:26 +00:00
|
|
|
|
TDate dataprev = doc.get_date(DOC_DATADOC);
|
2000-05-05 15:25:49 +00:00
|
|
|
|
|
1998-11-04 18:04:26 +00:00
|
|
|
|
same_key = doc.curr().same_key(m.doc().head(), 1, 1);
|
|
|
|
|
if (same_key && datadoc < dataprev)
|
1998-08-25 18:07:30 +00:00
|
|
|
|
return field.error_box("Data documento inferiore alla data del documento precedente");
|
|
|
|
|
}
|
1997-10-23 10:53:49 +00:00
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
doc.curr() = m.doc().head();
|
1998-11-04 18:04:26 +00:00
|
|
|
|
doc.read(_isgreat);
|
|
|
|
|
same_key = doc.curr().same_key(m.doc().head(), 1, 1);
|
|
|
|
|
if (doc.good() && same_key && datadoc > doc.get_date(DOC_DATADOC))
|
|
|
|
|
return field.error_box("Data documento superiore alla data del documento successivo");
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// handler delle righe
|
|
|
|
|
|
|
|
|
|
void row_set_handler( TMask& m, const int field, const int index )
|
|
|
|
|
{
|
|
|
|
|
switch ( index )
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
2001-06-25 10:41:20 +00:00
|
|
|
|
m.set_handler( field, pricerange_handler);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
1997-10-23 10:53:49 +00:00
|
|
|
|
m.set_handler( field, dummy_hndl );
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
yesnofatal_box( FALSE, "Funzione di handler sulla riga non definita( %d ).", index );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HIDDEN TString16 curr_um;
|
|
|
|
|
HIDDEN real curr_fc(1.0);
|
|
|
|
|
|
|
|
|
|
bool iva_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
1998-11-04 18:04:26 +00:00
|
|
|
|
TDocumento_mask & mask = (TDocumento_mask &) f.mask().get_sheet()->mask();
|
|
|
|
|
|
1997-10-23 10:53:49 +00:00
|
|
|
|
if (key == 0 || (key == K_ENTER && f.get().empty()))
|
|
|
|
|
{
|
|
|
|
|
const TString16 codiva = mask.condv().clifo().vendite().get(CFV_ASSFIS);
|
|
|
|
|
if (codiva.not_empty())
|
|
|
|
|
f.set(codiva);
|
|
|
|
|
f.check();
|
|
|
|
|
}
|
1998-11-04 18:04:26 +00:00
|
|
|
|
|
2000-10-03 13:45:12 +00:00
|
|
|
|
if (key == K_ENTER && /*f.focusdirty() &&*/ f.get().empty())
|
1998-11-04 18:04:26 +00:00
|
|
|
|
{
|
|
|
|
|
TMask & row_mask = f.mask();
|
|
|
|
|
const int r = f.mask().get_sheet()->selected() + 1;
|
|
|
|
|
TRiga_documento& riga = mask.doc()[r];
|
|
|
|
|
|
|
|
|
|
const int pos_ai = row_mask.id2pos(FR_ADDIVA);
|
|
|
|
|
bool addiva = FALSE;
|
|
|
|
|
|
|
|
|
|
if (pos_ai >= 0)
|
|
|
|
|
addiva = row_mask.fld(pos_ai).get() == "X"; // Controlla le righe Omaggio solo se e' settato l'addebito IVA
|
|
|
|
|
|
|
|
|
|
const bool check = riga.is_merce() || riga.is_spese() || riga.is_prestazione() ||
|
|
|
|
|
(riga.is_omaggio() && addiva);
|
|
|
|
|
|
|
|
|
|
if (check)
|
|
|
|
|
{
|
|
|
|
|
const int pos_p = row_mask.id2pos(FR_PREZZO);
|
|
|
|
|
const int pos_q = row_mask.id2pos(FR_QTA);
|
1999-04-06 15:34:39 +00:00
|
|
|
|
const bool pe = pos_p >= 0 && row_mask.fld(pos_p).enabled();
|
|
|
|
|
const bool qe = pos_q >= 0 && row_mask.fld(pos_q).enabled();
|
|
|
|
|
const bool pf = pe && row_mask.fld(pos_p).get().not_empty();
|
|
|
|
|
const bool qf = qe && row_mask.fld(pos_q).get().not_empty();
|
2000-05-05 15:25:49 +00:00
|
|
|
|
const bool required = pf && !(qe && !qf);
|
1998-11-04 18:04:26 +00:00
|
|
|
|
if (required)
|
1999-04-06 15:34:39 +00:00
|
|
|
|
return f.error_box("Il codice IVA e' obbligatorio.");
|
1998-11-04 18:04:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1997-10-23 10:53:49 +00:00
|
|
|
|
return TRUE;
|
2001-05-02 13:40:49 +00:00
|
|
|
|
}
|
1997-10-23 10:53:49 +00:00
|
|
|
|
|
1998-04-30 14:04:19 +00:00
|
|
|
|
bool codmag_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
2000-05-05 15:25:49 +00:00
|
|
|
|
// if (f.to_check(key, TRUE))
|
|
|
|
|
if (key == K_TAB && f.focusdirty())
|
1998-04-30 14:04:19 +00:00
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask();
|
1999-05-24 13:34:11 +00:00
|
|
|
|
TSheet_field& sf = *row_mask.get_sheet();
|
|
|
|
|
TDocumento_mask& docmask = (TDocumento_mask&)sf.mask();
|
1998-04-30 14:04:19 +00:00
|
|
|
|
|
1999-06-18 15:35:05 +00:00
|
|
|
|
if (sf.column_enabled(sf.cid2index(FR_CODDEP)))
|
1998-04-30 14:04:19 +00:00
|
|
|
|
{
|
|
|
|
|
const int pos = row_mask.id2pos(FR_CODDEP);
|
|
|
|
|
const TString & val = f.get();
|
|
|
|
|
|
|
|
|
|
if (pos >= 0 && val.not_empty())
|
|
|
|
|
{
|
1999-07-16 14:59:11 +00:00
|
|
|
|
const TRectype& mag = cache().get("MAG", val);
|
1998-04-30 14:04:19 +00:00
|
|
|
|
const bool active = mag.get_bool("B0");
|
|
|
|
|
row_mask.fld(pos).enable(active);
|
|
|
|
|
if (!active)
|
|
|
|
|
row_mask.fld(pos).reset();
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-07-16 14:59:11 +00:00
|
|
|
|
|
|
|
|
|
if (f.get().empty() && docmask.doc().tipo().mov_mag())
|
|
|
|
|
return f.error_box("Indicare il magazzino.");
|
|
|
|
|
|
1999-05-24 13:34:11 +00:00
|
|
|
|
docmask.update_giacenza();
|
1998-04-30 14:04:19 +00:00
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool codmag_coll_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
2000-05-05 15:25:49 +00:00
|
|
|
|
if (key == K_TAB && f.focusdirty())
|
1998-04-30 14:04:19 +00:00
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask();
|
1999-07-16 14:59:11 +00:00
|
|
|
|
TSheet_field& sf = *row_mask.get_sheet();
|
1998-04-30 14:04:19 +00:00
|
|
|
|
|
1999-07-16 14:59:11 +00:00
|
|
|
|
if (sf.column_enabled( ((TSheet_field &)f).cid2index(FR_CODDEPC)))
|
1998-04-30 14:04:19 +00:00
|
|
|
|
{
|
|
|
|
|
const int pos = row_mask.id2pos(FR_CODDEPC);
|
|
|
|
|
const TString & val = f.get();
|
|
|
|
|
|
|
|
|
|
if (pos >= 0 && val.not_empty())
|
|
|
|
|
{
|
1999-07-16 14:59:11 +00:00
|
|
|
|
const TRectype& mag = cache().get("MAG", val);
|
1998-04-30 14:04:19 +00:00
|
|
|
|
const bool active = mag.get_bool("B0");
|
|
|
|
|
row_mask.fld(pos).enable(active);
|
|
|
|
|
if (!active)
|
|
|
|
|
row_mask.fld(pos).reset();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-24 13:34:11 +00:00
|
|
|
|
void upd_colli_peso_tara(TMask & m, TRectype & a)
|
|
|
|
|
{
|
1999-10-22 10:00:18 +00:00
|
|
|
|
const real qta = m.get_real(FR_QTA) * curr_fc;
|
|
|
|
|
const real ppcollo = a.get_real(ANAMAG_PPCOLLO);
|
|
|
|
|
|
|
|
|
|
real ncolli = ppcollo != ZERO ? qta / ppcollo : (real)1.0;
|
|
|
|
|
ncolli.ceil(0);
|
1999-05-24 13:34:11 +00:00
|
|
|
|
|
|
|
|
|
int pos = m.id2pos(FR_NCOLLI);
|
1999-10-22 10:00:18 +00:00
|
|
|
|
if (pos >= 0)
|
1999-05-24 13:34:11 +00:00
|
|
|
|
if (ppcollo != ZERO)
|
1999-06-18 15:35:05 +00:00
|
|
|
|
m.fld(pos).set(ncolli.string());
|
1999-10-22 10:00:18 +00:00
|
|
|
|
else
|
|
|
|
|
m.fld(pos).reset();
|
|
|
|
|
|
1999-05-24 13:34:11 +00:00
|
|
|
|
pos = m.id2pos(FR_TARA);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
{
|
1999-10-22 10:00:18 +00:00
|
|
|
|
const real tara = ncolli * a.get_real(ANAMAG_TARA);
|
1999-05-24 13:34:11 +00:00
|
|
|
|
m.fld(pos).set(tara.string());
|
|
|
|
|
}
|
|
|
|
|
pos = m.id2pos(FR_PNETTO);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
{
|
1999-10-22 10:00:18 +00:00
|
|
|
|
const real peso = qta * a.get_real(ANAMAG_PESO);
|
1999-05-24 13:34:11 +00:00
|
|
|
|
m.fld(pos).set(peso.string());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-10-22 10:00:18 +00:00
|
|
|
|
|
2001-06-25 10:41:20 +00:00
|
|
|
|
bool pricerange_handler(TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
if (key == K_TAB && f.focusdirty())
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask();
|
|
|
|
|
TDocumento_mask& mask = (TDocumento_mask &) row_mask.get_sheet()->mask();
|
|
|
|
|
|
|
|
|
|
if (mask.doc().tipo().controllo_prezzi())
|
|
|
|
|
{
|
|
|
|
|
TSheet_field& sh = (TSheet_field &)mask.field(F_SHEET);
|
|
|
|
|
const int current_doc_row = sh.selected() + 1;
|
|
|
|
|
TRiga_documento & riga = mask.doc()[current_doc_row];
|
|
|
|
|
const real old_price = riga.get_real(RDOC_PREZZO);
|
2004-04-28 22:23:16 +00:00
|
|
|
|
const real new_price = row_mask.get_real(FR_PREZZO);
|
2001-06-25 10:41:20 +00:00
|
|
|
|
|
|
|
|
|
if (old_price != ZERO)
|
|
|
|
|
{
|
|
|
|
|
const TTipo_riga_documento& tipo_riga = riga.tipo();
|
|
|
|
|
const int incr = tipo_riga.incr_perc_prezzo();
|
|
|
|
|
const int decr = tipo_riga.decr_perc_prezzo();
|
|
|
|
|
|
|
|
|
|
if (incr == 0 && decr == 0)
|
|
|
|
|
{
|
|
|
|
|
if (old_price != new_price && !yesno_box("Il prezzo <20> variato, confermare"))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
real inf = old_price * (1.00 - (decr/100.0));
|
|
|
|
|
if (inf > new_price && !yesno_box("Il prezzo <20> diminuito di pi<70> del %d%%, confermare", decr))
|
|
|
|
|
return FALSE;
|
|
|
|
|
real sup = old_price * (1.00 + (incr/100.0));
|
|
|
|
|
if (sup < new_price && !yesno_box("Il prezzo <20> aumentato di pi<70> del %d%%, confermare", incr))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
riga.put(RDOC_PREZZO, new_price);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
bool codart_handler(TMask_field& f, KEY key )
|
1997-10-23 10:53:49 +00:00
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask();
|
1999-04-06 15:34:39 +00:00
|
|
|
|
TDocumento_mask& mask = (TDocumento_mask &) row_mask.get_sheet()->mask();
|
|
|
|
|
TSheet_field& sh = (TSheet_field &)mask.field(F_SHEET);
|
1998-11-04 18:04:26 +00:00
|
|
|
|
const int current_doc_row = sh.selected() + 1;
|
1997-10-23 10:53:49 +00:00
|
|
|
|
|
|
|
|
|
if (f.to_check(key, TRUE))
|
|
|
|
|
{
|
2003-05-22 15:20:01 +00:00
|
|
|
|
if (!f.empty())
|
|
|
|
|
row_mask.enable(FR_LIV1);
|
1997-10-23 10:53:49 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
row_mask.reset(FR_LIV1);
|
|
|
|
|
row_mask.disable(FR_LIV1);
|
|
|
|
|
}
|
|
|
|
|
row_mask.field(FR_LIV1).on_hit();
|
|
|
|
|
}
|
1998-11-04 18:04:26 +00:00
|
|
|
|
|
1997-10-23 10:53:49 +00:00
|
|
|
|
if (key == K_TAB && (f.focusdirty() || row_mask.get(FR_CHECKED).empty()))
|
|
|
|
|
{
|
|
|
|
|
TCond_vendita & condv = mask.condv();
|
|
|
|
|
|
|
|
|
|
condv.set_testa(&mask);
|
|
|
|
|
condv.set_riga(&row_mask);
|
|
|
|
|
|
2003-05-22 15:20:01 +00:00
|
|
|
|
TString80 codart = f.get();
|
|
|
|
|
TRectype anamag = cache().get(LF_ANAMAG, codart); // anamag puo' cambiare
|
|
|
|
|
bool found = !anamag.empty();
|
1997-10-23 10:53:49 +00:00
|
|
|
|
|
|
|
|
|
if (found)
|
|
|
|
|
row_mask.set(FR_CODARTMAG, codart, TRUE);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile codalt(LF_CODCORR);
|
|
|
|
|
|
|
|
|
|
codalt.setkey(2);
|
|
|
|
|
codalt.put(CODCORR_CODARTALT, codart);
|
|
|
|
|
if (codalt.read() == NOERR)
|
2003-05-22 15:20:01 +00:00
|
|
|
|
{
|
1997-10-23 10:53:49 +00:00
|
|
|
|
codart = codalt.get(CODCORR_CODART);
|
2003-05-22 15:20:01 +00:00
|
|
|
|
anamag = cache().get(LF_ANAMAG, codart);
|
|
|
|
|
found = !anamag.empty();
|
1997-10-23 10:53:49 +00:00
|
|
|
|
if (found)
|
|
|
|
|
row_mask.set(FR_CODARTMAG, codart, TRUE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
row_mask.set(FR_CHECKED, "X");
|
|
|
|
|
if (!found)
|
2003-05-22 15:20:01 +00:00
|
|
|
|
row_mask.set(FR_CODARTMAG, "", TRUE);
|
1997-10-23 10:53:49 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2003-10-23 10:33:56 +00:00
|
|
|
|
const TString8 lingua = mask.get(F_CODLIN);
|
|
|
|
|
const TCodice_articolo codart(row_mask.get(FR_CODARTMAG));
|
1997-10-23 10:53:49 +00:00
|
|
|
|
TString desc(anamag.get("DESCR"));
|
|
|
|
|
|
1998-11-04 18:04:26 +00:00
|
|
|
|
if (mask.doc()[current_doc_row].is_omaggio())
|
1999-05-24 13:34:11 +00:00
|
|
|
|
{
|
2003-10-23 10:33:56 +00:00
|
|
|
|
static TString* dicitura_omaggio = NULL;
|
|
|
|
|
if (dicitura_omaggio == NULL)
|
1999-05-24 13:34:11 +00:00
|
|
|
|
{
|
2003-10-23 10:33:56 +00:00
|
|
|
|
TConfig c(CONFIG_STUDIO, "ve");
|
|
|
|
|
dicitura_omaggio = new TString(c.get("DESOMAGGI"));
|
|
|
|
|
if (dicitura_omaggio->blank())
|
|
|
|
|
*dicitura_omaggio = TR("(OMAGGIO)");
|
1999-05-24 13:34:11 +00:00
|
|
|
|
}
|
2003-10-23 10:33:56 +00:00
|
|
|
|
desc << ' ' << *dicitura_omaggio;
|
1999-05-24 13:34:11 +00:00
|
|
|
|
}
|
1997-10-23 10:53:49 +00:00
|
|
|
|
if (lingua.not_empty())
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile deslin(LF_DESLIN);
|
|
|
|
|
|
|
|
|
|
deslin.setkey(2);
|
|
|
|
|
deslin.put(DESLIN_CODART, codart);
|
|
|
|
|
deslin.put(DESLIN_CODLIN, lingua);
|
|
|
|
|
if (deslin.read() == NOERR)
|
2001-06-25 10:41:20 +00:00
|
|
|
|
{
|
2002-12-18 11:58:58 +00:00
|
|
|
|
static int __lingua_only = 3;
|
2001-06-25 10:41:20 +00:00
|
|
|
|
|
|
|
|
|
if (__lingua_only > 2)
|
|
|
|
|
{
|
2003-10-23 10:33:56 +00:00
|
|
|
|
TConfig c(CONFIG_DITTA, "ve");
|
2001-06-25 10:41:20 +00:00
|
|
|
|
__lingua_only = c.get_bool("LINGUA_ONLY");
|
|
|
|
|
}
|
|
|
|
|
if (__lingua_only)
|
|
|
|
|
desc = deslin.get(DESLIN_DESCR);
|
|
|
|
|
else
|
|
|
|
|
desc << '\n' << deslin.get(DESLIN_DESCR);
|
|
|
|
|
}
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
1998-11-04 18:04:26 +00:00
|
|
|
|
|
|
|
|
|
TString descest(anamag.get("DESCRAGG"));
|
|
|
|
|
if (descest.not_empty())
|
|
|
|
|
desc << "\n" << descest;
|
|
|
|
|
|
1997-10-23 10:53:49 +00:00
|
|
|
|
row_mask.set(FR_DESCR, desc);
|
2003-05-22 15:20:01 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
TLocalisamfile umart(LF_UMART);
|
1997-10-23 10:53:49 +00:00
|
|
|
|
umart.setkey(1);
|
|
|
|
|
umart.zero();
|
|
|
|
|
umart.put(UMART_CODART, codart);
|
|
|
|
|
if (umart.read(_isgteq) == NOERR && codart == umart.get(UMART_CODART))
|
2003-05-22 15:20:01 +00:00
|
|
|
|
*/
|
2003-10-23 10:33:56 +00:00
|
|
|
|
TString80 key; key << codart << "|1";
|
2003-05-22 15:20:01 +00:00
|
|
|
|
const TRectype& umart = cache().get(LF_UMART, key);
|
|
|
|
|
if (!umart.empty())
|
1997-10-23 10:53:49 +00:00
|
|
|
|
{
|
|
|
|
|
curr_um = umart.get(UMART_UM);
|
|
|
|
|
curr_fc = umart.get_real(UMART_FC);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
curr_um.cut(0);
|
|
|
|
|
curr_fc = 1.0;
|
|
|
|
|
}
|
|
|
|
|
row_mask.set(FR_UMQTA, curr_um);
|
2003-05-22 15:20:01 +00:00
|
|
|
|
upd_colli_peso_tara(row_mask, anamag);
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
condv.ricerca();
|
2001-06-25 10:41:20 +00:00
|
|
|
|
mask.doc()[current_doc_row].put(RDOC_PREZZO, row_mask.get(FR_PREZZO));
|
|
|
|
|
|
1997-10-23 10:53:49 +00:00
|
|
|
|
const int pos = row_mask.id2pos(FR_CODIVA);
|
|
|
|
|
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
iva_handler(row_mask.fld(pos), 0);
|
2003-01-28 13:33:45 +00:00
|
|
|
|
|
|
|
|
|
if (found)
|
|
|
|
|
{
|
|
|
|
|
TString16 caus(row_mask.get(FR_CAUS));
|
|
|
|
|
|
|
|
|
|
if (caus.empty())
|
|
|
|
|
caus = mask.get(F_CAUSMAG);
|
|
|
|
|
|
|
|
|
|
if (caus.not_empty())
|
|
|
|
|
{
|
|
|
|
|
const TCausale_magazzino c(caus);
|
|
|
|
|
|
|
|
|
|
if (!c.movimenta_sospesi())
|
|
|
|
|
{
|
|
|
|
|
const TRectype & rec = cache().get(LF_ANAMAG, row_mask.get(FR_CODARTMAG));
|
|
|
|
|
|
|
|
|
|
if (rec.get_bool("SOSPESO"))
|
2003-10-23 10:33:56 +00:00
|
|
|
|
return error_box(TR("Articolo %s sospeso, quindi non movimentabile"), (const char *)codart);
|
2003-01-28 13:33:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
1999-05-24 13:34:11 +00:00
|
|
|
|
else
|
1999-06-18 15:35:05 +00:00
|
|
|
|
if (key == K_F8 && !sh.sheet_mask().is_running())
|
1999-05-24 13:34:11 +00:00
|
|
|
|
{
|
2002-12-18 11:58:58 +00:00
|
|
|
|
static int explode_db = 3;
|
1999-05-24 13:34:11 +00:00
|
|
|
|
static bool valcomp = FALSE;
|
|
|
|
|
static bool matbase = TRUE;
|
1999-06-18 15:35:05 +00:00
|
|
|
|
static TExplosion_grouping raggart = RAGGR_EXP_NONE;
|
1999-05-24 13:34:11 +00:00
|
|
|
|
static bool elrorig = FALSE;
|
|
|
|
|
static int livello = 1;
|
|
|
|
|
static int ordin = 0;
|
1998-11-04 18:04:26 +00:00
|
|
|
|
|
1999-05-24 13:34:11 +00:00
|
|
|
|
if (explode_db > 2)
|
|
|
|
|
{
|
2000-05-05 15:25:49 +00:00
|
|
|
|
TConfig d(CONFIG_DITTA, "ve");
|
|
|
|
|
|
1999-05-24 13:34:11 +00:00
|
|
|
|
explode_db = d.get_bool("EXPLODEDB", "ve");
|
|
|
|
|
valcomp = d.get_bool("VALCOMP", "ve");
|
|
|
|
|
matbase = d.get_bool("TIPOESPL", "ve");
|
1999-06-18 15:35:05 +00:00
|
|
|
|
raggart = (TExplosion_grouping) d.get_int("RAGGART", "ve");
|
1999-05-24 13:34:11 +00:00
|
|
|
|
livello = d.get_int("LIVESPL", "ve");
|
|
|
|
|
elrorig = d.get_bool("ELRORIG", "ve");
|
|
|
|
|
ordin = d.get_int("ORDDB", "ve");
|
|
|
|
|
}
|
|
|
|
|
if (explode_db && !sh.sheet_mask().is_running())
|
|
|
|
|
{
|
1999-07-16 14:59:11 +00:00
|
|
|
|
TDocumento & doc = mask.doc();
|
|
|
|
|
TRiga_documento & curr_row = doc[current_doc_row];
|
|
|
|
|
|
|
|
|
|
sh.update_row(current_doc_row - 1);
|
|
|
|
|
curr_row.autosave(sh);
|
|
|
|
|
|
1999-05-24 13:34:11 +00:00
|
|
|
|
TDistinta_tree db;
|
|
|
|
|
TArray components;
|
|
|
|
|
|
1999-07-16 14:59:11 +00:00
|
|
|
|
db.set_root(curr_row);
|
|
|
|
|
|
1999-05-24 13:34:11 +00:00
|
|
|
|
const int items = db.explode(components, matbase, raggart, livello, "A", ordin);
|
|
|
|
|
if (items > 0)
|
|
|
|
|
{
|
|
|
|
|
TProgind pi(items, "Esplosione in corso...",FALSE, TRUE);
|
|
|
|
|
int row = current_doc_row;
|
1999-10-22 10:00:18 +00:00
|
|
|
|
const TString16 tiporiga(curr_row.tipo().codice());
|
1998-11-04 18:04:26 +00:00
|
|
|
|
|
1999-05-24 13:34:11 +00:00
|
|
|
|
TString_array& str_arr = sh.rows_array();
|
|
|
|
|
|
|
|
|
|
for (int i = components.first(); i < items; i = components.succ(i))
|
1998-11-04 18:04:26 +00:00
|
|
|
|
{
|
1999-05-24 13:34:11 +00:00
|
|
|
|
pi.addstatus(1L);
|
|
|
|
|
TRiga_esplosione & r = (TRiga_esplosione &) components[i];
|
|
|
|
|
TRiga_documento & new_row = doc.insert_row(row + 1, tiporiga);
|
|
|
|
|
//sh.insert(row, FALSE);
|
|
|
|
|
str_arr.insert(new TToken_string, row);
|
|
|
|
|
|
|
|
|
|
TDocumento::copy_data(new_row, curr_row);
|
|
|
|
|
new_row.put(RDOC_CODART, r.articolo());
|
|
|
|
|
new_row.put(RDOC_CODARTMAG, r.articolo());
|
1999-07-16 14:59:11 +00:00
|
|
|
|
new_row.put(RDOC_LIVELLO, r.giacenza());
|
1999-05-24 13:34:11 +00:00
|
|
|
|
new_row.zero(RDOC_DESCR);
|
2003-12-15 14:25:45 +00:00
|
|
|
|
new_row.zero(RDOC_DESCLUNGA);
|
1999-05-24 13:34:11 +00:00
|
|
|
|
new_row.zero(RDOC_DESCEST);
|
|
|
|
|
new_row.put(RDOC_CHECKED, "");
|
|
|
|
|
new_row.put(RDOC_UMQTA, r.um());
|
1999-07-16 14:59:11 +00:00
|
|
|
|
new_row.put(RDOC_QTA, r.val() /* * qta_fin */);
|
1998-11-04 18:04:26 +00:00
|
|
|
|
new_row.autoload(sh);
|
1999-05-24 13:34:11 +00:00
|
|
|
|
sh.check_row(row++);
|
|
|
|
|
new_row.autosave(sh);
|
|
|
|
|
if (!valcomp)
|
|
|
|
|
{
|
|
|
|
|
new_row.zero(RDOC_PREZZO);
|
|
|
|
|
new_row.autoload(sh);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (elrorig)
|
1998-11-04 18:04:26 +00:00
|
|
|
|
{
|
1999-05-24 13:34:11 +00:00
|
|
|
|
doc.destroy_row(current_doc_row, TRUE);
|
|
|
|
|
sh.destroy(current_doc_row - 1, FALSE);
|
|
|
|
|
row--;
|
1998-11-04 18:04:26 +00:00
|
|
|
|
}
|
1999-05-24 13:34:11 +00:00
|
|
|
|
else
|
|
|
|
|
if (valcomp)
|
|
|
|
|
{
|
|
|
|
|
curr_row.zero(RDOC_PREZZO);
|
|
|
|
|
curr_row.autoload(sh);
|
|
|
|
|
}
|
|
|
|
|
sh.force_update();
|
|
|
|
|
sh.select(row-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
1998-11-04 18:04:26 +00:00
|
|
|
|
}
|
2003-01-28 13:33:45 +00:00
|
|
|
|
|
|
|
|
|
|
1997-10-23 10:53:49 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool codartmag_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
bool to_check = key == K_TAB && f.focusdirty();
|
|
|
|
|
TMask & m = f.mask();
|
2003-01-28 13:33:45 +00:00
|
|
|
|
const TString codart = f.get();
|
|
|
|
|
const bool artmag = codart.not_empty();
|
|
|
|
|
TDocumento_mask& mask= (TDocumento_mask&) m.get_sheet()->mask();
|
1997-10-23 10:53:49 +00:00
|
|
|
|
|
|
|
|
|
if (!to_check)
|
|
|
|
|
{
|
|
|
|
|
TSheet_field * s = m.get_sheet();
|
|
|
|
|
if (s)
|
|
|
|
|
to_check = !s->mask().is_running();
|
|
|
|
|
}
|
|
|
|
|
if (to_check)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
m.show(FR_UMQTA, artmag);
|
|
|
|
|
m.show(FR_UMQTA2, !artmag);
|
1999-05-24 13:34:11 +00:00
|
|
|
|
|
|
|
|
|
mask.update_giacenza();
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool liv_handler( TMask_field& f, KEY key )
|
2000-05-05 15:25:49 +00:00
|
|
|
|
{
|
2000-10-03 13:45:12 +00:00
|
|
|
|
bool ok = TRUE;
|
2000-05-05 15:25:49 +00:00
|
|
|
|
TDocumento_mask & mask=(TDocumento_mask &) f.mask().get_sheet()->mask();
|
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
if (key == K_TAB && f.focusdirty() && !f.get().empty())
|
1998-11-04 18:04:26 +00:00
|
|
|
|
{
|
|
|
|
|
const int levnum=f.dlg()-FR_LIV1+1;
|
|
|
|
|
// Se e' abilitato l'autoinserimento del livello di giacenza...
|
|
|
|
|
if (mask.livelli().autoinsert(levnum))
|
|
|
|
|
mask.livelli().autoinsert(levnum, f);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 15:25:49 +00:00
|
|
|
|
if (key == K_ENTER && !f.get().empty())
|
|
|
|
|
{
|
2002-12-18 11:58:58 +00:00
|
|
|
|
static int checkgiac = 3;
|
2000-05-05 15:25:49 +00:00
|
|
|
|
if (checkgiac > 2)
|
|
|
|
|
{
|
2000-10-03 13:45:12 +00:00
|
|
|
|
TConfig c(CONFIG_DITTA);
|
|
|
|
|
checkgiac = c.get_bool("LIVPERART", "ve");
|
2000-05-05 15:25:49 +00:00
|
|
|
|
}
|
|
|
|
|
if (mask.is_running() && checkgiac)
|
|
|
|
|
{
|
2000-10-03 13:45:12 +00:00
|
|
|
|
TLocalisamfile fl(LF_MAG);
|
|
|
|
|
fl.setkey(2);
|
|
|
|
|
TRectype & r = fl.curr();
|
|
|
|
|
TMask& row_mask = f.mask();
|
2000-05-05 15:25:49 +00:00
|
|
|
|
TEsercizi_contabili esc;
|
|
|
|
|
const int annoes = esc.date2esc(mask.get_date(F_DATADOC));
|
|
|
|
|
|
2000-10-03 13:45:12 +00:00
|
|
|
|
r.put(MAG_ANNOES, annoes);
|
|
|
|
|
TString16 codmag(row_mask.get(FR_CODMAG));
|
|
|
|
|
|
|
|
|
|
codmag.left_just(3);
|
|
|
|
|
codmag << row_mask.get(FR_CODDEP);
|
|
|
|
|
r.put(MAG_CODMAG, codmag);
|
|
|
|
|
const TString80 codart(row_mask.get(FR_CODART));
|
|
|
|
|
|
|
|
|
|
r.put(MAG_CODART, codart);
|
|
|
|
|
TString liv;
|
|
|
|
|
|
|
|
|
|
for (int l = 0 ; l <= f.dlg() - FR_LIV1; l++)
|
|
|
|
|
mask.doc().livelli().pack_grpcode(liv,row_mask.get(FR_LIV1+l),l+1);
|
2000-05-05 15:25:49 +00:00
|
|
|
|
|
2000-10-03 13:45:12 +00:00
|
|
|
|
r.put(MAG_LIVELLO, liv);
|
|
|
|
|
|
|
|
|
|
TRectype new_rec(r);
|
|
|
|
|
if (fl.read() != NOERR)
|
|
|
|
|
{
|
|
|
|
|
ok = yesno_box("Il codice di giacenza %s non e' legato all' articolo. Devo legarlo", (const char *)f.get());
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
fl.setkey(1);
|
|
|
|
|
r = new_rec;
|
|
|
|
|
r.put("NRIGA", 999);
|
|
|
|
|
int nriga = 1;
|
|
|
|
|
if (fl.read(_isgteq) == NOERR)
|
|
|
|
|
fl.prev();
|
|
|
|
|
if (codart == fl.get("CODART"))
|
|
|
|
|
nriga = fl.get_int("NRIGA")+1;
|
2000-05-05 15:25:49 +00:00
|
|
|
|
new_rec.put("NRIGA", nriga);
|
2000-10-03 13:45:12 +00:00
|
|
|
|
const int err = new_rec.write(fl);
|
|
|
|
|
if (err != NOERR)
|
|
|
|
|
ok = error_box("Non sono riuscito a legare il codice di giacenza. Errore %d", err);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-05-05 15:25:49 +00:00
|
|
|
|
}
|
2000-10-03 13:45:12 +00:00
|
|
|
|
|
1999-05-24 13:34:11 +00:00
|
|
|
|
if (f.to_check(key, TRUE))
|
1997-10-23 10:53:49 +00:00
|
|
|
|
{
|
1999-06-18 15:35:05 +00:00
|
|
|
|
if (f.dlg() < FR_LIV4)
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask();
|
|
|
|
|
TMask_field & next = row_mask.field(f.dlg() + 1);
|
|
|
|
|
if (f.get().not_empty())
|
|
|
|
|
next.enable();
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
next.reset();
|
|
|
|
|
next.disable();
|
|
|
|
|
}
|
|
|
|
|
next.on_hit();
|
1999-05-24 13:34:11 +00:00
|
|
|
|
}
|
|
|
|
|
TDocumento_mask& mask=(TDocumento_mask&)f.mask().get_sheet()->mask();
|
|
|
|
|
mask.update_giacenza();
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
2000-05-05 15:25:49 +00:00
|
|
|
|
return ok;
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-17 10:20:13 +00:00
|
|
|
|
void set_curr_um(const TString & um)
|
1997-10-23 10:53:49 +00:00
|
|
|
|
{
|
2003-11-17 10:20:13 +00:00
|
|
|
|
curr_um = um;
|
1997-10-23 10:53:49 +00:00
|
|
|
|
curr_fc = -1.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool umart_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
2003-06-05 13:17:23 +00:00
|
|
|
|
TMask& row_mask = f.mask( );
|
|
|
|
|
TDocumento_mask & mask = (TDocumento_mask &) row_mask.get_sheet()->mask();
|
1997-10-23 10:53:49 +00:00
|
|
|
|
// Se qualcuno cerca di modificare la maschera
|
2003-06-05 13:17:23 +00:00
|
|
|
|
if ( key == K_TAB && f.focusdirty() && mask.is_running())
|
1997-10-23 10:53:49 +00:00
|
|
|
|
{
|
2001-06-25 10:41:20 +00:00
|
|
|
|
TSheet_field& sh = (TSheet_field &)mask.field(F_SHEET);
|
|
|
|
|
const int current_doc_row = sh.selected() + 1;
|
2003-06-05 13:17:23 +00:00
|
|
|
|
|
1997-10-23 10:53:49 +00:00
|
|
|
|
TCond_vendita & condv = mask.condv();
|
1998-08-26 10:54:46 +00:00
|
|
|
|
condv.set_riga(&row_mask);
|
1997-10-23 10:53:49 +00:00
|
|
|
|
|
2003-06-05 13:17:23 +00:00
|
|
|
|
const TString& um = f.get();
|
1997-10-23 10:53:49 +00:00
|
|
|
|
real fc(1.0);
|
|
|
|
|
|
|
|
|
|
if (um.not_empty() && curr_um.not_empty() && um != curr_um)
|
|
|
|
|
{
|
2003-06-05 13:17:23 +00:00
|
|
|
|
TLocalisamfile umart(LF_UMART);
|
1997-10-23 10:53:49 +00:00
|
|
|
|
umart.setkey(2);
|
|
|
|
|
umart.put(UMART_CODART, row_mask.get(FR_CODARTMAG));
|
|
|
|
|
umart.put(UMART_UM, um);
|
|
|
|
|
if (umart.read() == NOERR)
|
|
|
|
|
{
|
|
|
|
|
real qta(row_mask.get_real(FR_QTA));
|
|
|
|
|
fc = umart.get_real(UMART_FC);
|
|
|
|
|
if (curr_fc < ZERO)
|
|
|
|
|
{
|
|
|
|
|
umart.put(UMART_CODART, row_mask.get(FR_CODARTMAG));
|
|
|
|
|
umart.put(UMART_UM, curr_um);
|
|
|
|
|
if (umart.read() == NOERR)
|
|
|
|
|
curr_fc = umart.get_real(UMART_FC);
|
|
|
|
|
else
|
|
|
|
|
curr_fc = 1.0;
|
|
|
|
|
}
|
|
|
|
|
qta *= curr_fc;
|
|
|
|
|
qta /= fc;
|
|
|
|
|
qta.round(5);
|
|
|
|
|
row_mask.set(FR_QTA, qta);
|
1999-04-06 15:34:39 +00:00
|
|
|
|
qta = row_mask.get_real(FR_QTAEVASA);
|
|
|
|
|
qta *= curr_fc;
|
|
|
|
|
qta /= fc;
|
|
|
|
|
qta.round(5);
|
|
|
|
|
row_mask.set(FR_QTAEVASA, qta);
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
curr_um = um;
|
|
|
|
|
curr_fc = fc;
|
|
|
|
|
condv.ricerca(TRUE);
|
2001-06-25 10:41:20 +00:00
|
|
|
|
mask.doc()[current_doc_row].put(RDOC_PREZZO, row_mask.get(FR_PREZZO));
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
bool um_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
// Se qualcuno cerca di modificare la maschera
|
|
|
|
|
if ( key == K_TAB && f.focusdirty())
|
|
|
|
|
{
|
2004-04-28 22:23:16 +00:00
|
|
|
|
TMask& row_mask = f.mask( );
|
|
|
|
|
// TDocumento_mask & mask = (TDocumento_mask &) row_mask.get_sheet()->mask();
|
1999-04-06 15:34:39 +00:00
|
|
|
|
TTable & ums = (TTable &) ((TEdit_field &) f).browse()->cursor()->file();
|
|
|
|
|
|
|
|
|
|
const TString16 um(f.get());
|
|
|
|
|
real fc(1.0);
|
|
|
|
|
|
|
|
|
|
if (um.not_empty() && curr_um.not_empty() && um != curr_um)
|
|
|
|
|
{
|
|
|
|
|
ums.put("CODTAB", curr_um);
|
|
|
|
|
if (ums.read() == NOERR)
|
|
|
|
|
{
|
|
|
|
|
real qta(row_mask.get_real(FR_QTA));
|
|
|
|
|
const TString16 umsrif0(ums.get("S7"));
|
|
|
|
|
const real fc0 = ums.get_real("R10");
|
|
|
|
|
if (um == umsrif0)
|
|
|
|
|
fc = fc0;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ums.put("CODTAB", um);
|
|
|
|
|
if (ums.read() == NOERR)
|
|
|
|
|
{
|
|
|
|
|
const real fc1 = ums.get_real("R10");
|
|
|
|
|
const TString16 umsrif1(ums.get("S7"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (fc1 > ZERO)
|
|
|
|
|
{
|
|
|
|
|
if (curr_um == umsrif1)
|
|
|
|
|
fc = 1 / fc1;
|
|
|
|
|
else
|
|
|
|
|
if (umsrif0 == ums.get("S7"))
|
|
|
|
|
fc = fc0 / ums.get_real("R10");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
qta *= fc;
|
|
|
|
|
qta.round(5);
|
|
|
|
|
row_mask.set(FR_QTA, qta);
|
|
|
|
|
qta = row_mask.get_real(FR_QTAEVASA);
|
|
|
|
|
qta *= fc;
|
|
|
|
|
qta.round(5);
|
|
|
|
|
row_mask.set(FR_QTAEVASA, qta);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
curr_um = um;
|
|
|
|
|
curr_fc = fc;
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1997-10-23 10:53:49 +00:00
|
|
|
|
bool descr_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
if (key == K_TAB && f.focusdirty())
|
|
|
|
|
{
|
|
|
|
|
const TString s(f.get());
|
|
|
|
|
if (s.find('\n') < 0)
|
|
|
|
|
{
|
1999-06-18 15:35:05 +00:00
|
|
|
|
TLocalisamfile anamag(LF_ANAMAG);
|
1997-10-23 10:53:49 +00:00
|
|
|
|
|
|
|
|
|
anamag.zero();
|
|
|
|
|
anamag.setkey(2);
|
|
|
|
|
anamag.put(ANAMAG_DESCR, ((TZoom_field &) f).get_first_line());
|
|
|
|
|
if (anamag.read() == NOERR)
|
|
|
|
|
{
|
|
|
|
|
f.mask().set(FR_CODART, anamag.get(ANAMAG_CODART));
|
|
|
|
|
f.mask().field(FR_CODART).set_dirty();
|
|
|
|
|
f.mask().check_field(FR_CODART);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
bool qtaart_handler( TMask_field& f, KEY key )
|
1997-10-23 10:53:49 +00:00
|
|
|
|
{
|
|
|
|
|
// Se qualcuno cerca di modificare la maschera
|
|
|
|
|
if ( key == K_TAB && f.focusdirty())
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask( );
|
|
|
|
|
TDocumento_mask & mask = (TDocumento_mask &) row_mask.get_sheet()->mask();
|
2001-06-25 10:41:20 +00:00
|
|
|
|
TSheet_field& sh = (TSheet_field &)mask.field(F_SHEET);
|
|
|
|
|
const int current_doc_row = sh.selected() + 1;
|
2002-12-20 16:15:03 +00:00
|
|
|
|
|
1997-10-23 10:53:49 +00:00
|
|
|
|
TCond_vendita & condv = mask.condv();
|
|
|
|
|
|
1998-08-26 10:54:46 +00:00
|
|
|
|
condv.set_riga(&row_mask);
|
1997-10-23 10:53:49 +00:00
|
|
|
|
condv.ricerca(FALSE, TRUE);
|
2001-06-25 10:41:20 +00:00
|
|
|
|
mask.doc()[current_doc_row].put(RDOC_PREZZO, row_mask.get(FR_PREZZO));
|
1999-05-24 13:34:11 +00:00
|
|
|
|
const TString & codart = row_mask.get(FR_CODARTMAG);
|
|
|
|
|
|
|
|
|
|
if (codart.not_empty())
|
|
|
|
|
{
|
1999-06-18 15:35:05 +00:00
|
|
|
|
TLocalisamfile anamag(LF_ANAMAG);
|
|
|
|
|
|
|
|
|
|
anamag.put(ANAMAG_CODART, codart);
|
|
|
|
|
if (anamag.read() == NOERR)
|
|
|
|
|
upd_colli_peso_tara(row_mask, anamag.curr());
|
|
|
|
|
}
|
1999-05-24 13:34:11 +00:00
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
}
|
2002-12-20 16:15:03 +00:00
|
|
|
|
else
|
|
|
|
|
if (key == K_ENTER && f.dirty())
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask& mask=(TDocumento_mask&)f.mask().get_sheet()->mask();
|
|
|
|
|
TDocumento & doc = mask.doc();
|
|
|
|
|
|
|
|
|
|
if ((doc.tipo().check_giac() || doc.tipo().check_disp()) &&
|
|
|
|
|
main_app().has_module(MGAUT, CHK_DONGLE) && doc.tipo().mov_mag())
|
|
|
|
|
{
|
|
|
|
|
TSheet_field& sf = mask.sfield(F_SHEET);
|
|
|
|
|
TToken_string& row = sf.row(sf.selected());
|
|
|
|
|
const TString codart = row.get(sf.cid2index(FR_CODARTMAG));
|
|
|
|
|
|
|
|
|
|
if (codart.not_empty())
|
|
|
|
|
{
|
|
|
|
|
TString16 codmag = row.get(sf.cid2index(FR_CODMAG));
|
|
|
|
|
const TString16 coddep = row.get(sf.cid2index(FR_CODDEP));
|
|
|
|
|
if (!coddep.blank())
|
|
|
|
|
codmag << coddep;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
real qta(row.get(sf.cid2index(FR_QTA)));
|
|
|
|
|
const TString16 caus(mask.get(F_CAUSMAG));
|
|
|
|
|
TCausale_magazzino c(caus);
|
|
|
|
|
const long nmovmag = doc.get_long(DOC_MOVMAG);
|
|
|
|
|
|
|
|
|
|
if (nmovmag != 0)
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile rmovmag(LF_RMOVMAG); rmovmag.setkey(2);
|
|
|
|
|
rmovmag.put(RMOVMAG_CODART, codart);
|
|
|
|
|
rmovmag.put(RMOVMAG_LIVGIAC, livello);
|
|
|
|
|
rmovmag.put(RMOVMAG_CODMAG, codmag);
|
|
|
|
|
rmovmag.put(RMOVMAG_NUMREG, nmovmag);
|
|
|
|
|
if (rmovmag.read() == NOERR)
|
|
|
|
|
qta -= rmovmag.get_real(RMOVMAG_QUANT);
|
|
|
|
|
}
|
|
|
|
|
if (doc.tipo().check_giac())
|
|
|
|
|
{
|
|
|
|
|
real giac(mask.get(F_CURGIAC));
|
|
|
|
|
if (giac < -(c.sgn(s_giac) * qta))
|
|
|
|
|
warning_box("Attenzione giacenza negativa");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (doc.tipo().check_disp())
|
|
|
|
|
{
|
|
|
|
|
real disp(mask.get(F_CURDISP));
|
|
|
|
|
if (disp < -(c.sgn(s_giac) * qta))
|
|
|
|
|
warning_box("Attenzione disponibilita' negativa");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return qta_handler(f, key);
|
|
|
|
|
}
|
1998-08-25 18:07:30 +00:00
|
|
|
|
|
|
|
|
|
bool qta_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
// Se qualcuno cerca di modificare la maschera
|
|
|
|
|
if ( key == K_TAB && f.focusdirty())
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask( );
|
|
|
|
|
const real qta_evasa = row_mask.get_real(FR_QTAEVASA);
|
|
|
|
|
const real qta(f.get());
|
|
|
|
|
|
|
|
|
|
if (qta_evasa > 0 && qta_evasa >= qta)
|
|
|
|
|
{
|
|
|
|
|
row_mask.set(FR_RIGAEVASA, "X");
|
|
|
|
|
row_mask.disable(FR_RIGAEVASA);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
row_mask.enable(FR_RIGAEVASA);
|
|
|
|
|
}
|
2002-12-20 16:15:03 +00:00
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool qta_evasa_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
if (f.to_check(key))
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask( );
|
|
|
|
|
const real qta_evasa(f.get());
|
|
|
|
|
const real qta = row_mask.get_real(FR_QTA);
|
|
|
|
|
|
|
|
|
|
if (qta_evasa > 0 && qta_evasa >= qta)
|
|
|
|
|
{
|
|
|
|
|
row_mask.set(FR_RIGAEVASA, "X");
|
|
|
|
|
row_mask.disable(FR_RIGAEVASA);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
row_mask.enable(FR_RIGAEVASA);
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
1998-11-04 18:04:26 +00:00
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
bool causmag_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
if (f.to_check(key))
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask( );
|
|
|
|
|
TDocumento_mask & mask = (TDocumento_mask &) row_mask.get_sheet()->mask();
|
|
|
|
|
TString16 causmag(f.get());
|
|
|
|
|
if (causmag.empty())
|
|
|
|
|
causmag = mask.get(F_CAUSMAG);
|
|
|
|
|
|
1999-06-18 15:35:05 +00:00
|
|
|
|
TCausale_magazzino c(cache().get("%CAU", causmag));
|
|
|
|
|
if (c.empty())
|
1999-04-06 15:34:39 +00:00
|
|
|
|
{
|
1999-06-18 15:35:05 +00:00
|
|
|
|
cache().discard("%CAU", causmag);
|
2002-05-08 16:25:49 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
1999-06-18 15:35:05 +00:00
|
|
|
|
if (c.has_default_mag() && row_mask.get(FR_CODMAG).empty())
|
|
|
|
|
{
|
|
|
|
|
row_mask.set(FR_CODMAG, c.default_mag(), TRUE);
|
|
|
|
|
row_mask.set(FR_CODDEPC, "", TRUE);
|
|
|
|
|
}
|
|
|
|
|
if (c.has_default_dep() && row_mask.get(FR_CODDEP).empty())
|
2002-05-08 16:25:49 +00:00
|
|
|
|
row_mask.set(FR_CODDEP, c.default_dep(), TRUE);
|
|
|
|
|
|
1999-06-18 15:35:05 +00:00
|
|
|
|
if (!c.caus_collegata().empty())
|
|
|
|
|
{
|
|
|
|
|
c = cache().get("%CAU", c.caus_collegata());
|
|
|
|
|
if (c.has_default_mag() && row_mask.get(FR_CODMAGC).empty())
|
|
|
|
|
{
|
|
|
|
|
row_mask.set(FR_CODMAGC, c.default_mag(), TRUE);
|
|
|
|
|
row_mask.set(FR_CODDEPC, "", TRUE);
|
|
|
|
|
}
|
|
|
|
|
if (c.has_default_dep() && row_mask.get(FR_CODDEPC).empty())
|
2002-05-08 16:25:49 +00:00
|
|
|
|
row_mask.set(FR_CODDEPC, c.default_dep(), TRUE);
|
|
|
|
|
|
|
|
|
|
static int copy_defmagc = -883;
|
|
|
|
|
if (copy_defmagc < 0)
|
|
|
|
|
{
|
2003-10-01 14:31:28 +00:00
|
|
|
|
TFilename fname; mask.doc().tipo().profile_name(fname);
|
2002-05-08 16:25:49 +00:00
|
|
|
|
TConfig c_tipo_documento(fname,"MAIN");
|
|
|
|
|
copy_defmagc = c_tipo_documento.get_bool("DEFMAGXCOLL");
|
|
|
|
|
}
|
|
|
|
|
if (copy_defmagc!=0)
|
|
|
|
|
{
|
|
|
|
|
if (row_mask.get(FR_CODMAGC).empty())
|
|
|
|
|
row_mask.set(FR_CODMAGC, mask.stdmag(), TRUE);
|
|
|
|
|
if (row_mask.get(FR_CODDEPC).empty())
|
|
|
|
|
row_mask.set(FR_CODDEPC, mask.stddep(), TRUE);
|
|
|
|
|
}
|
1999-06-18 15:35:05 +00:00
|
|
|
|
}
|
2003-01-28 13:33:45 +00:00
|
|
|
|
if (!c.movimenta_sospesi())
|
|
|
|
|
{
|
|
|
|
|
const TRectype & rec = cache().get(LF_ANAMAG, row_mask.get(FR_CODARTMAG));
|
|
|
|
|
|
|
|
|
|
if (rec.get_bool("SOSPESO"))
|
|
|
|
|
return error_box("Articolo %s sospeso, quindi non movmentabile", (const char *)rec.get(ANAMAG_CODART));
|
|
|
|
|
}
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1997-10-23 10:53:49 +00:00
|
|
|
|
bool sppr_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask();
|
|
|
|
|
|
|
|
|
|
if (key == K_TAB && (f.focusdirty() || row_mask.get(FR_DESCR).empty()))
|
|
|
|
|
{
|
|
|
|
|
const int pos = row_mask.id2pos(FR_PREZZO);
|
|
|
|
|
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
{
|
|
|
|
|
TMask & mask = row_mask.get_sheet()->mask();
|
2001-05-02 13:40:49 +00:00
|
|
|
|
TEdit_field & e = (TEdit_field &) f;
|
|
|
|
|
TRelation * r = e.browse()->cursor()->relation();
|
2003-01-28 13:33:45 +00:00
|
|
|
|
const TString16 cod = r->curr().get("COD");
|
2001-05-02 13:40:49 +00:00
|
|
|
|
TSpesa_prest sp(NULL, cod == "SPP" ? 'S' : 'P');
|
2000-05-05 15:25:49 +00:00
|
|
|
|
if (sp.read(row_mask.get(FR_CODART)) == NOERR)
|
|
|
|
|
{
|
|
|
|
|
const char tipo = sp.tipo();
|
1997-10-23 10:53:49 +00:00
|
|
|
|
const bool qta_val_fl = tipo == 'Q';
|
|
|
|
|
const bool perc_fl = tipo == 'P';
|
|
|
|
|
|
|
|
|
|
short pos = row_mask.id2pos(FR_UMQTASP);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
row_mask.fld(pos).enable(!perc_fl);
|
|
|
|
|
pos = row_mask.id2pos(FR_PREZZO);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
row_mask.fld(pos).enable(!perc_fl);
|
|
|
|
|
pos = row_mask.id2pos(FR_SCONTO);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
row_mask.fld(pos).enable(!perc_fl);
|
|
|
|
|
pos = row_mask.id2pos(FR_QTA);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
{
|
|
|
|
|
row_mask.fld(pos).show(!perc_fl);
|
|
|
|
|
row_mask.fld(pos).enable(qta_val_fl);
|
|
|
|
|
}
|
|
|
|
|
pos = row_mask.id2pos(FR_PERCSP);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
{
|
|
|
|
|
row_mask.fld(pos).show(perc_fl);
|
|
|
|
|
row_mask.fld(pos).enable(perc_fl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!perc_fl)
|
|
|
|
|
{
|
2004-04-28 22:23:16 +00:00
|
|
|
|
const real cambio = mask.get_real(F_CAMBIO);
|
2000-05-05 15:25:49 +00:00
|
|
|
|
real prezzo = sp.prezzo();
|
2003-01-28 13:33:45 +00:00
|
|
|
|
const TString& doc_valuta = mask.get(F_CODVAL);
|
2000-05-05 15:25:49 +00:00
|
|
|
|
const bool controeuro = mask.get_bool(F_CONTROEURO);
|
|
|
|
|
|
|
|
|
|
sppr_calc(sp, doc_valuta, cambio, prezzo, controeuro ? _exchange_contro : _exchange_base);
|
1997-10-23 10:53:49 +00:00
|
|
|
|
row_mask.set(FR_PREZZO, prezzo);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
const int posiva = row_mask.id2pos(FR_CODIVA);
|
|
|
|
|
if (posiva >= 0)
|
|
|
|
|
iva_handler(row_mask.fld(posiva), 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1999-10-22 10:00:18 +00:00
|
|
|
|
bool TDocumento_mask::numdocrif_search_handler(TMask_field& f, KEY key)
|
|
|
|
|
{
|
|
|
|
|
if (key == K_F9)
|
|
|
|
|
{
|
|
|
|
|
TMask& m = f.mask();
|
|
|
|
|
|
|
|
|
|
TRectype filtrec(LF_DOC);
|
|
|
|
|
filtrec.put(DOC_TIPOCF, m.get(F_TIPOCF));
|
|
|
|
|
filtrec.put(DOC_CODCF, m.get(F_CODCF));
|
|
|
|
|
filtrec.put(DOC_PROVV, m.get(F_PROVV));
|
|
|
|
|
filtrec.put(DOC_ANNO, m.get(F_ANNO));
|
|
|
|
|
|
|
|
|
|
TRelation rel(LF_DOC);
|
|
|
|
|
rel.add(LF_CLIFO, "TIPOCF==TIPOCF|CODCF==CODCF");
|
|
|
|
|
TSorted_cursor cur(&rel, "TIPOCF|CODCF|PROVV|ANNO|CODNUM|NUMDOCRIF", "", 2, &filtrec, &filtrec);
|
2000-05-05 15:25:49 +00:00
|
|
|
|
TString80 f; f.format("CODNUM==\"%s\"", (const char *)m.get(F_CODNUM));
|
|
|
|
|
|
|
|
|
|
cur.setfilter(f);
|
|
|
|
|
TCursor_sheet sheet(&cur, "TIPOCF|CODCF|ANNO|CODNUM|NUMDOCRIF|DATADOCRIF|DOC1|DOC2|DOC3|NDOC|20->RAGSOC",
|
1999-10-22 10:00:18 +00:00
|
|
|
|
"Documento di riferimento",
|
2000-05-05 15:25:49 +00:00
|
|
|
|
"Tipo|Codice|Anno|Numeraz|Docum.Rif.|Data@10|Docum.Rif. 1|Docum.Rif. 2|Docum.Rif. 3|Documento|Ragione Sociale@50",
|
1999-10-22 10:00:18 +00:00
|
|
|
|
0, 1);
|
|
|
|
|
if (sheet.run() == K_ENTER)
|
|
|
|
|
{
|
2000-05-05 15:25:49 +00:00
|
|
|
|
const TString16 ndoc = sheet.row(-1).get(9);
|
1999-10-22 10:00:18 +00:00
|
|
|
|
m.set(F_NDOC, ndoc);
|
|
|
|
|
m.stop_run(K_AUTO_ENTER);
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-10-03 13:45:12 +00:00
|
|
|
|
|
1999-10-22 10:00:18 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2000-10-03 13:45:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TDocumento_mask::datadocrif_handler(TMask_field& f, KEY key)
|
|
|
|
|
{
|
|
|
|
|
if (key == K_ENTER && f.empty())
|
|
|
|
|
{
|
|
|
|
|
const TDocumento_mask& m = (const TDocumento_mask&)f.mask();
|
|
|
|
|
if (m.get_bool(F_RAGGREFF))
|
|
|
|
|
{
|
|
|
|
|
const TDocumento& doc = m.doc();
|
|
|
|
|
if (doc.is_nota_credito())
|
|
|
|
|
return f.error_box("E' necessario specificare data e numero documento di riferimento\n"
|
|
|
|
|
"quando si desidera generare effetti raggruppati");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
2002-05-31 10:35:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool link_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
if (key == K_SPACE)
|
|
|
|
|
{
|
|
|
|
|
const TSheet_field & sf = *f.mask().get_sheet();
|
|
|
|
|
const TDocumento_mask & m = (const TDocumento_mask & )sf.mask();
|
|
|
|
|
const TDocumento & d = m.doc();
|
|
|
|
|
const int nrow = sf.selected() + 1;
|
|
|
|
|
const TRiga_documento & r = d[nrow];
|
|
|
|
|
r.edit(LF_DOC, "DAPROVV|DAANNO|DACODNUM|DANDOC");
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|