Patch level : 2.2

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :

Gestione data di attivazione del saldaconto


git-svn-id: svn://10.65.10.50/trunk@13418 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2005-10-13 13:15:38 +00:00
parent e18a8a03b5
commit ae2555b539
8 changed files with 51 additions and 263 deletions

View File

@ -803,7 +803,7 @@ bool TReport_doc_app::print_loop(const TString& query)
doc.move_to(i);
const TString& tipodoc = doc.get(DOC_TIPODOC).as_string();
const TTipo_documento & tipo = _tipi_cache.tipo(tipodoc);
const TTipo_documento& tipo = _tipi_cache.tipo(tipodoc);
TString16 codprof(tipo.main_print_profile());
codprof.trim();
@ -821,6 +821,7 @@ bool TReport_doc_app::print_loop(const TString& query)
{
TString msg; msg << TR("Report inesistente") << " : " << codprof;
statbar_set_title(TASK_WIN, msg);
beep(2);
continue;
}
}

View File

@ -1,246 +1,29 @@
#include <applicat.h>
#include <automask.h>
#include <defmask.h>
#include <execp.h>
#include <reprint.h>
#include <utility.h>
#include "velib.h"
#include "vereplib.h"
#include "../ba/ba8400.h"
#include "../ba/ba8500.h"
///////////////////////////////////////////////////////////
// Utility
// TPeterParker_app
///////////////////////////////////////////////////////////
static bool cod2app(const char* tok, TString& app)
{
if (isalpha(tok[0]) && isalpha(tok[1]) && atoi(tok+2) > 1000)
{
app.strncpy(tok, 3);
app << " -" << char(tok[3]-1);
return true;
}
return false;
}
static bool get_xml_attr(const TString& line, const char* attr, TString& value)
{
TString str; str << ' ' << attr << "=\"";
const int pos = line.find(str);
if (pos >= 0)
{
const int apicia = line.find('"', pos)+1;
const int apicic = line.find('"', apicia);
if (apicic > apicia)
{
value = line.sub(apicia, apicic);
return true;
}
}
return false;
}
static bool get_xml_child(const TString& line, const char* tag, TString& value)
{
TString str; str << '<' << tag << '>';
const int pos = line.find(str);
if (pos >= 0)
{
const int apicia = line.find('>', pos)+1;
const int apicic = line.find('<', apicia);
if (apicic > apicia)
{
value = line.sub(apicia, apicic);
return true;
}
}
return false;
}
bool rep2app(const char* name, TString& app, TString& desc)
{
app = desc = "";
TFilename report_name(name);
report_name.ext("rep");
if (!report_name.custom_path())
return false;
TToken_string libraries(50, ',');
TString stringona;
TScanner scan(report_name);
for (int i = 0; i < 3 && scan.good(); i++) // Leggo solo le prime righe
stringona << scan.line();
get_xml_attr(stringona, "libraries", libraries);
get_xml_child(stringona, "description", desc);
FOR_EACH_TOKEN(libraries, tok) if (strlen(tok) == 6)
{
if (cod2app(tok, app))
return true;
}
cod2app(report_name.name(), app);
return true;
}
///////////////////////////////////////////////////////////
// TKlarkKent_mask
///////////////////////////////////////////////////////////
class TKlarkKent_mask : public TAutomask
class TPeterParker_app : public TKlarkKent_app
{
protected:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
public:
TKlarkKent_mask() : TAutomask("ba8500a") { }
virtual TReport* create_report(const char* name) const;
};
bool TKlarkKent_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
TReport* TPeterParker_app::create_report(const char* name) const
{
switch (o.dlg())
{
case F_REPORT:
if (e == fe_button)
{
TArray_sheet a(-1, -1, 75, 20, "Report", "Nome@16|Progr.|Descrizione@50");
TString_array& arr = a.rows_array();
list_files("*.rep", arr);
TFilename dir = firm2dir(-1); dir.add("custom"); dir.add("*.rep");
list_files(dir, arr);
TString app, desc;
FOR_EACH_ARRAY_ROW(arr, i, row)
{
rep2app(*row, app, desc);
TFilename n = *row; n = n.name(); n.ext("");
*row = n;
row->add(app);
row->add(desc);
}
if (a.run() == K_ENTER)
{
o.set(a.row(-1).get(0));
e = fe_modify;
}
}
if (e == fe_init || e == fe_modify)
{
TFilename name = o.get();
TString app, desc;
const bool ok = rep2app(name, app, desc);
set(F_FORM, desc);
set(F_DOC, app);
enable(DLG_PRINT, ok);
}
break;
case DLG_EDIT:
if (e == fe_button && !field(F_REPORT).empty())
{
TString str;
str << "ba8 -2 " << get(F_REPORT);
TExternal_app app(str);
app.run(true);
}
break;
default:
break;
}
return true;
}
///////////////////////////////////////////////////////////
// TKlarkKent_app
///////////////////////////////////////////////////////////
class TKlarkKent_app : public TSkeleton_application
{
protected:
virtual void main_loop();
};
void TKlarkKent_app::main_loop()
{
TString_array arr;
for (int i = 2; i < argc(); i++)
{
TString name = argv(i);
if (name[0] == '%')
name.ltrim(1);
if (name.len() == 3) //il file in questione e' la stampa di una tabella?
{
TFilename filename(name);
filename.insert("vest");
filename.ext("rep");
if (filename.custom_path())
name = filename.name();
}
name.lower();
arr.add(name);
}
if (arr.items() == 0)
arr.add(EMPTY_STRING);
bool can_repeat = false;
do
{
TReport_book book;
FOR_EACH_ARRAY_ROW(arr, r, row)
{
TFilename report_name = *row;
report_name.ext("rep");
if (row->blank() || !report_name.custom_path())
{
TKlarkKent_mask m;
m.set(F_REPORT, report_name);
if (m.run() == K_ENTER)
{
report_name = m.get(F_REPORT);
report_name.ext("rep");
report_name.custom_path();
*row = report_name;
}
}
TString appname, desc;
rep2app(report_name, appname, desc);
if (appname.not_empty())
{
appname << ' ' << report_name;
TExternal_app app(appname);
app.run(true);
}
else
{
TDocument_report rep;
if (rep.load(report_name))
{
const bool ok = book.add(rep);
if (ok && arr.items() == 1) // Controlla se e' pensabile ripetere la stampa
{
TFilename msk = report_name;
msk.ext("msk");
can_repeat = msk.exist(); // Posso ripetere se ho una maschera collegata
}
else
can_repeat = false;
}
}
}
if (book.pages() > 0)
book.print_or_preview();
} while (can_repeat);
TDocument_report* rep = new TDocument_report;
rep->load(name);
return rep;
}
int ve1400(int argc, char* argv[])
{
TKlarkKent_app app;
TPeterParker_app app;
app.run(argc, argv, TR("Stampa Report Vendite"));
return 0;
}

View File

@ -1179,9 +1179,9 @@ ENDPAGE
ENDMASK
#include "ve2400c.uml"
#include "ve2400b.uml"
#include "ve2400a.uml"
#include "ve2400d.uml"
#include "ve2400e.uml"
#include "ve2400c.uml"
#include "ve2400b.uml"
#include "ve2400a.uml"
#include "ve2400d.uml"
#include "ve2400e.uml"

View File

@ -1,7 +1,7 @@
// SHEET 0 (unita' di misura) DI VE2400
PAGE "Pagina 1" 8 5 65 11
PAGE "Pagina 1" -1 -1 65 11
STRING FS_CODUM 2
BEGIN

View File

@ -1,7 +1,7 @@
// SHEET 1 (descrizioni in lingua) DI VE2400
PAGE "Pagina 1" 8 5 65 11
PAGE "Pagina 1" -1 -1 65 11
STRING FS_CODLIN 1
BEGIN

View File

@ -1,7 +1,7 @@
// SHEET 2 (codici alternativi) DI VE2400
PAGE "Pagina 1" 8 5 65 11
PAGE "Pagina 1" -1 -1 65 11
STRING FS_CODARTALT 20
BEGIN

View File

@ -339,9 +339,9 @@ protected:
// restituisce la sezione per sto cliente
char sezione() const;
// Cerca il conto cliente per il movimento d'anticipo
error_type search_clifo_bill(TString &);
error_type search_clifo_bill(const TString& catven);
// Cerca il conto di contropartita per il movimento d'anticipo
error_type search_counter_bill(TDocumento&);
error_type search_counter_bill(TDocumento& doc, const TDate& datareg);
// compila la testata del movimento di anticipo
error_type compile_head_anticipo(TDocumento&);
// compila le righe del movimento di anticipo
@ -361,7 +361,7 @@ protected:
// Verifica se non ci sono stati errori
bool good() const { return _error == no_error;}
// Ritorna true se il saldaconto e' abilitato (verifica anche la causale del documento corrente)
bool sc_enabled() const ;
bool sc_enabled(const TDate& data) const ;
// Ritorna true se il modulo INTRA e' abilitato (verifica anche la causale del documento corrente)
bool in_enabled() const ;
// Controlla se il tipo riga esiste

View File

@ -1135,7 +1135,7 @@ error_type TContabilizzazione::compile_head_mov(TDocumento& doc)
TRegistro& registro = _caus->reg();
const bool iva_mov = registro.ok();
/*
/* Causa errori non desiderati
if (!iva_mov && !_caus->saldaconto())
{
_error = register_error;
@ -1225,9 +1225,9 @@ error_type TContabilizzazione::compile_head_mov(TDocumento& doc)
}
// Codice pagamento
TString4 codpag(doc.get(DOC_CODPAG));
if (sc_enabled() || codpag.not_empty()) // La condizione di pagamento va controllata
{ // se e' abilitato il saldaconto o se e' stata inserita
const TString4 codpag(doc.get(DOC_CODPAG));
if (sc_enabled(data_reg) || codpag.not_empty()) // La condizione di pagamento va controllata
{ // se e' abilitato il saldaconto o se e' stata inserita
_cpg->put("CODTAB",codpag);
if (_cpg->read() != NOERR)
{
@ -2761,7 +2761,7 @@ error_type TContabilizzazione::write_all(TDocumento& doc, TMovimentoPN_VE & movi
// Aggiorno subito i saldi
aggiorna_saldi(saldo, movimento, true);
if (sc_enabled())
if (sc_enabled(head.get_date(MOV_DATAREG)))
write_scadenze(doc);
if (good() && in_enabled())
@ -2840,7 +2840,7 @@ error_type TContabilizzazione::compile_head_anticipo(TDocumento& doc)
{
TString descr;
const TString4 codcaus = doc.tipo().caus_anticipo();
TDate datareg(_movimento->lfile().get_date(MOV_DATAREG));
const TDate datareg = _movimento->curr().get_date(MOV_DATAREG);
if (!_caus->read(codcaus,datareg.year()))
return caus_ant_error;
@ -2873,7 +2873,7 @@ error_type TContabilizzazione::compile_head_anticipo(TDocumento& doc)
// real cambio = head.get_real(MOV_CAMBIOI);
head.zero(MOV_CODVALI);
head.zero(MOV_CAMBIOI);
if (sc_enabled())
if (sc_enabled(datareg))
{
TCurrency_documento p(doc.get_real(DOC_IMPPAGATO), doc);
TCurrency_documento plit(p); p.change_to_firm_val();
@ -2923,10 +2923,10 @@ char TContabilizzazione::sezione() const
return sezione;
}
error_type TContabilizzazione::search_clifo_bill(TString & catven)
error_type TContabilizzazione::search_clifo_bill(const TString& catven)
{
_error = no_error;
TLocalisamfile& clifo = _clifo->lfile();
const TRectype& clifo = _clifo->curr();
const long codcf = clifo.get_long(CLI_CODCF);
const char tipocf = clifo.get_char(CLI_TIPOCF);
_co_cliente.set(0,0,0);
@ -2954,7 +2954,7 @@ error_type TContabilizzazione::search_clifo_bill(TString & catven)
return _error;
}
error_type TContabilizzazione::search_counter_bill(TDocumento& doc)
error_type TContabilizzazione::search_counter_bill(TDocumento& doc, const TDate& datareg)
{
_error = no_error;
// cerca il conto relativo alla riga di causale:
@ -2969,7 +2969,8 @@ error_type TContabilizzazione::search_counter_bill(TDocumento& doc)
// 9 Bonifici riga 2
// Se il saldaconto e' attivo prende il conto relativo al tipo pagamento
// Altrimenti sempre la riga 2
if (sc_enabled())
if (sc_enabled(datareg))
{
int tipopag = doc.pagamento().tipo_rata(0); // Quello della prima rata... prolly is right .. ;P
_caus->bill(tipopag>0 && tipopag<8 ? tipopag+1:2,_co_controp);
@ -2991,14 +2992,14 @@ error_type TContabilizzazione::compile_rows_anticipo(TDocumento& doc)
// per il conto di contropartita se non c'e' il saldaconto lo si prende dalla
// seconda riga. Se il saldaconto esiste si consulta la riga relativa al
// tipo di pagamento.
TString16 codpag(doc.get(DOC_CODPAG));
TString16 catven(doc.get(DOC_CATVEN));
if (search_clifo_bill(catven) == no_error && search_counter_bill(doc) == no_error)
const TString4 codpag(doc.get(DOC_CODPAG));
const TString4 catven(doc.get(DOC_CATVEN));
const TRectype& mov = _anticipo->curr();
const TDate datareg = mov.get_date(MOV_DATAREG);
if (search_clifo_bill(catven) == no_error && search_counter_bill(doc, datareg) == no_error)
{
TCurrency_documento importo(doc.get_real(DOC_IMPPAGATO), doc); importo.change_to_firm_val();
TLocalisamfile& mov = _anticipo->lfile();
TDate datareg = mov.get_date(MOV_DATAREG);
TString16 codes = mov.get(MOV_ANNOES);
const TString4 codes = mov.get(MOV_ANNOES);
const long numreg = mov.get_long(MOV_NUMREG);
TRectype& c_rec = _anticipo->cg(0);
// setta i valori per la riga cliente
@ -3014,7 +3015,7 @@ error_type TContabilizzazione::compile_rows_anticipo(TDocumento& doc)
c_rec.put(RMV_GRUPPOC,_co_controp.gruppo());
c_rec.put(RMV_CONTOC,_co_controp.conto());
c_rec.put(RMV_SOTTOCONTOC,_co_controp.sottoconto());
c_rec.put(RMV_ROWTYPE,sc_enabled() ? "K" : " ");
c_rec.put(RMV_ROWTYPE,sc_enabled(datareg) ? "K" : " ");
c_rec.put(RMV_IMPORTO, importo.get_num());
TRectype& co_rec = _anticipo->cg(1);
@ -3030,7 +3031,7 @@ error_type TContabilizzazione::compile_rows_anticipo(TDocumento& doc)
co_rec.put(RMV_GRUPPOC,_co_cliente.gruppo());
co_rec.put(RMV_CONTOC,_co_cliente.conto());
co_rec.put(RMV_SOTTOCONTOC,_co_cliente.sottoconto());
co_rec.put(RMV_ROWTYPE,sc_enabled() ? "I" : " ");
co_rec.put(RMV_ROWTYPE,sc_enabled(datareg) ? "I" : " ");
}
return _error;
}
@ -3221,7 +3222,7 @@ error_type TContabilizzazione::write_anticipo(TDocumento& doc)
if (_error == no_error)
{
// Scrive il movimento... gestendo la rinumerazione
if (sc_enabled())
if (sc_enabled(_anticipo->curr().get_date(MOV_DATAREG)))
// ... il pagamento vero e proprio, scrivendo la partita e modificando
// il movimento se vi sono abbuoni
write_pagamento_anticipo(doc);
@ -3707,18 +3708,21 @@ void TContabilizzazione::display_error(TDocumento& doc)
_can_write = false; // But from now on u cannot write anymore. U must exit this program and repair errors occurred.
}
bool TContabilizzazione::sc_enabled() const
bool TContabilizzazione::sc_enabled(const TDate& data) const
{
bool rt = _sc_enabled;
if (_caus != NULL) rt &= _caus->saldaconto();
if (_clifo != NULL) rt &= !_clifo->lfile().get_bool(CLI_OCCAS); // Saldaconto solo se C/F non occasionale
if (_caus != NULL)
rt &= _caus->saldaconto(data);
if (_clifo != NULL)
rt &= !_clifo->curr().get_bool(CLI_OCCAS); // Saldaconto solo se C/F non occasionale
return rt;
}
bool TContabilizzazione::in_enabled() const
{
bool rt = _in_enabled;
if (_caus != NULL) rt &= _caus->intra();
if (_caus != NULL)
rt &= _caus->intra();
return rt;
}