Patch level :

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Modifiche fatturazione


git-svn-id: svn://10.65.10.50/branches/R_10_00@21895 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
luca83 2011-04-05 15:05:27 +00:00
parent 6270b14f76
commit 97f6fe0fe9
7 changed files with 362 additions and 25 deletions

View File

@ -94,6 +94,9 @@
#define F_CODARTCOFIX 273
#define F_DESARTCOFIX 274
#define F_AGGHEAD 275
#define F_DESTHEAD 276
#define F_BACKUP 300
#define S_CODNUM_RIT 101

View File

@ -848,14 +848,26 @@ END
LISTBOX F_TIPOPR 1 19
BEGIN
PROMPT 1 20 "Tipo prezzo"
ITEM "0|Prezzo da contratto"
ITEM "1|Prezzo da bolla"
ITEM "0|Prezzo da contratto" MESSAGE "X",F_AGGHEAD|DISABLE,F_AGGHEAD
ITEM "1|Prezzo da bolla" MESSAGE ENABLE,F_AGGHEAD
FIELD Tipopr
END
BOOLEAN F_AGGHEAD
BEGIN
PROMPT 40 20 "Aggiorna la testata delle bolle"
FIELD AggHead
END
BOOLEAN F_DESTHEAD
BEGIN
PROMPT 1 21 "Destinazione nella testata"
FIELD DestHead
END
STRING F_UMPESO 3
BEGIN
PROMPT 40 20 "U.M. "
PROMPT 40 21 "U.M. "
USE %UMS
INPUT CODTAB F_UMPESO
DISPLAY "Codice@6" CODTAB

View File

@ -2,6 +2,7 @@
#include <config.h>
#include <dongle.h>
#include <modaut.h>
#include <reputils.h>
#include <utility.h>
#include "lvlib.h"
@ -10,6 +11,8 @@
#include "../pr/agenti.h"
#include "../pr/percprov.h"
#include "clifo.h"
#include "../cg/cfban.h"
#include "comuni.h"
#include "cfven.h"
#include "lvcondv.h"
#include "lvrcondv.h"
@ -21,6 +24,8 @@
#include "../ve/ve6200.h"
#include "../ve/ve6200a.h"
#define DOC_DEST "DEST" //c campo virtuale per la destinazone
class TFatturazione_lavanderie;
////////////////////////////////////////
//// classe TFatturazione_msk ////
@ -42,11 +47,13 @@ public:
class TFatturazione_lav_app: public TSkeleton_application
{
TFatturazione_msk* _msk;
TLog_report * _log;
bool _solototali;
protected:
virtual void main_loop();
void genera_bolle_nolo(TAssoc_array& cliela, TFatturazione_lavanderie& elab, int& numdocgen);
void genera_bolle_nolo(TAssoc_array& cliela, TFatturazione_lavanderie& elab, int& numdocgen, real & totimp, real &imposta, real & totdoc, real & spese);
bool controlli_preliminari();
bool copy_file(const TFilename& src, const TFilename& dst) const;
bool copy_tree(const char* src_study, const char* dst_study) const;
@ -106,6 +113,9 @@ class TFatturazione_lavanderie:public TFatturazione_bolle
TAssoc_array _output_rows_02;
TAssoc_array _doc_grouped;
bool _prova;
long _last_cli_damn;
int _art_damn;
int _cli_damn;
protected:
virtual void add_rows(TRiga_documento & rout, TRiga_documento & rin);
@ -130,6 +140,9 @@ public:
void set_perc_provv(TRiga_documento & row, bool prima = true);
virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
const TDate& data_elab, bool interattivo = false);
long & last_cli_damn() {return _last_cli_damn;}
int & cli_damn() {return _cli_damn;}
int & art_damn() {return _art_damn;}
TFatturazione_lavanderie(const char* cod, bool prova = false);
~TFatturazione_lavanderie() {}
@ -1314,12 +1327,28 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
doc.put(DOC_CODINDSP, new_reccliven.get(CFV_CODINDDOC));
TString descr;
TRiga_documento & r = doc.insert_row(1, "05");
r.put(RDOC_DESCR, "Consegne effettuate presso\n");
descr << act_cli << " " << reccli.get(CLI_RAGSOC);
r.put(RDOC_DESCLUNGA, "X");
r.put(RDOC_DESCEST, descr);
if (ini_get_bool(CONFIG_DITTA, "lv", "DestHead"))
{
descr << reccli.get(CLI_RAGSOC) << '\n';
descr << reccli.get(CLI_INDCF) << ',' << reccli.get(CLI_CIVCF) << '\n';
descr << reccli.get(CLI_LOCCF) << '\n';
TToken_string keyc = reccli.get(CLI_STATOCF);
keyc.add(reccli.get(CLI_COMCF));
const TRectype & com = cache().get(LF_COMUNI, keyc);
descr << reccli.get(CLI_CAPCF) << ',' << com.get(COM_DENCOM) << '\n';
doc.put(DOC_DEST, descr);
}
else
{
TRiga_documento & r = doc.insert_row(1, "05");
r.put(RDOC_DESCR, "Consegne effettuate presso\n");
descr << act_cli << " " << reccli.get(CLI_RAGSOC);
r.put(RDOC_DESCLUNGA, "X");
r.put(RDOC_DESCEST, descr);
}
if (contr.get_bool(LVCONDV_RAGGCGRUP))
{
add_doc_to_list(key, doc);
@ -1328,6 +1357,23 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
}
}
if (fatt_02())
{
for (int id = doc_in.items() - 1; id >= 0 ; id--)
{
TDocumento & doc = doc_in[id];
const long clifo = doc.get_long(DOC_CODCF);
const int indsped = doc.get_int(DOC_CODINDSP);
TLaundry_contract contr(clifo,indsped,_data_elab);
const real redditivita = contr.get_real(LVCONDV_REDDI);
if (redditivita >= CENTO)
{
doc_in[id].remove();
doc_in.destroy(id);
}
}
}
}
@ -1492,6 +1538,16 @@ void TFatturazione_lavanderie::create_row(TDocumento& doc_out, const TRiga_docum
rd.put(RDOC_DESCEST, "\nper addebito biancheria");
rd.add(RDOC_QTA, qta1);
rd.put(RDOC_PREZZO, rcont.get_real(LVRCONDV_PREZDAN));
if (cau.get_int("I2") > 0)
{
rd.put(RDOC_QTAGG1, cau.get("I0"));
rd.put(RDOC_QTAGG2, cau.get("I1"));
rd.put(RDOC_QTAGG3, cau.get("I2"));
}
if (clifo != _last_cli_damn)
_cli_damn++;
_last_cli_damn = clifo;
_art_damn++;
}
//se è una causale di ritirato e se sto ritirando una quantità di merce diversa da zero, allora:
@ -1612,7 +1668,7 @@ TFatturazione_msk::TFatturazione_msk():TAutomask("lv2500a")
/////////////////////////////////////
//GENERA_BOLLE_NOLO: metodo che genera le fatture di solo nolo per quei clienti a cui non è stato consegnato niente
void TFatturazione_lav_app::genera_bolle_nolo(TAssoc_array& cliela, TFatturazione_lavanderie& elab, int& numdocgen)
void TFatturazione_lav_app::genera_bolle_nolo(TAssoc_array& cliela, TFatturazione_lavanderie& elab, int& numdocgen, real & totimp, real &imposta, real & totdoc, real & spese)
{
TString4 codnum = ini_get_string(CONFIG_DITTA, "lv", "NUM_GEN");
TString4 tipodoc = ini_get_string(CONFIG_DITTA, "lv", "TIPODOC_GEN");
@ -1816,8 +1872,17 @@ void TFatturazione_lav_app::genera_bolle_nolo(TAssoc_array& cliela, TFatturazion
if (doc.physical_rows() > 0)
{
elab.elabora(doc_in, doc_out, _msk->get_date(F_DATAFAT));
int err = doc_out.write();
if (!_solototali)
int err = doc_out.write();
numdocgen += doc_out.items();
if (doc_out.items() > 0)
{
totimp += doc_out[0].imponibile();
imposta += doc_out[0].imposta();
totdoc += doc_out[0].totale_doc();
spese += doc_out[0].spese();
}
}
doc_out.destroy(-1);
@ -1957,6 +2022,11 @@ bool TFatturazione_lav_app::copy_tree(const char* src_study, const char* dst_stu
void TFatturazione_lav_app::main_loop()
{
bool prova = false;
const bool use_indsp = ini_get_bool(CONFIG_DITTA, "mg", "MOV_INDSPED");
const bool prezzo_da_contratto = ini_get_int(CONFIG_DITTA, "lv", "Tipopr") == 0;
const bool agghead = prezzo_da_contratto || ini_get_bool(CONFIG_DITTA, "lv", "AggHead");
const TString4 num_buoni = ini_get_string(CONFIG_DITTA, "lv", "NUM_GEN");
const TString4 tipo_buoni = ini_get_string(CONFIG_DITTA, "lv", "TIPODOC_GEN");
if (main_app().argc() > 2)
{
@ -1976,6 +2046,10 @@ void TFatturazione_lav_app::main_loop()
while (_msk->run()!= K_QUIT)
{
_solototali = _msk->get_bool(F_SOLOTOTALI);
const int annoes = _msk->get_date(F_DATAFAT).year();
if (!controlli_preliminari())
{
TString str;
@ -1984,6 +2058,7 @@ void TFatturazione_lav_app::main_loop()
warning_box(str);
return;
}
_log = new TLog_report("Fatturazione");
if (_msk->get_bool(F_SAVEDATA))
{
@ -2008,6 +2083,7 @@ void TFatturazione_lav_app::main_loop()
if (!dal.ok())
{
dal.set_day(1);
dal.set_month(1);
dal.set_year(year);
}
@ -2021,6 +2097,18 @@ void TFatturazione_lav_app::main_loop()
const int period = _msk->get_int(F_PERFAT);
const TDate datafat = _msk->get_date(F_DATAFAT);
long indsped;
TToken_string tipi;
TToken_string stati;
TString stato_min("Z");
elab.last_cli_damn() = -1L;
elab.cli_damn() = 0;
elab.art_damn() = 0;
elab.tipi_stati_iniziali(tipi, stati);
for (const char * s = stati.get(); s > " "; s = stati.get())
if (stato_min > s)
stato_min = s;
//preparo la query
TString query;
@ -2043,6 +2131,10 @@ void TFatturazione_lav_app::main_loop()
TProgind pi(recset.items(), "Fatturazione", true, true);
long last_clifo = 0;
int numdocgen = 0;
real totimp;
real imposta;
real totdoc;
real spese;
//TAssoc_array dei clienti per cui ho generato dei documenti
TAssoc_array cliela;
@ -2074,7 +2166,8 @@ void TFatturazione_lav_app::main_loop()
const int items = docsout.items();
if (items > 0)
{
docsout.write();
if (!_solototali)
docsout.write();
numdocgen += items;
TString tmp;
tmp << lastcli;
@ -2082,7 +2175,8 @@ void TFatturazione_lav_app::main_loop()
}
docsout.destroy(-1);
docsin.rewrite();
if (!_solototali)
docsin.rewrite();
docsin.destroy(-1);
}
lastcli = clifo;
@ -2093,9 +2187,11 @@ void TFatturazione_lav_app::main_loop()
key.add('C');
key.add(clifo);
const TRectype& clienti = cache().get(LF_CFVEN,key);
const TRectype & docrec = recset.cursor()->curr();
const TRectype& clirec = cache().get(LF_CLIFO,key);
//se il documento che sto analizzando è corretto, allora:
bool cliok = elab.is_document_ok(recset.cursor()->curr());
bool cliok = elab.is_document_ok(docrec);
if (cliok)
{
//se il codice di zona è pieno, allora:
@ -2114,6 +2210,13 @@ void TFatturazione_lav_app::main_loop()
cliok = (codcat == mskcat);
}
}
else
if (!_solototali && docrec.get(DOC_STATO) < stato_min)
{
TString msg("Bolla n.ro ");
msg << docrec.get(DOC_NDOC) << " del " << docrec.get(DOC_DATADOC) << "Cliente " << clifo << " " << clirec.get(CLI_RAGSOC) << " in stato " << docrec.get(DOC_STATO);
_log->log(0, msg);
}
//se ho passato tutti e due i test, allora:
if (cliok)
@ -2124,9 +2227,137 @@ void TFatturazione_lav_app::main_loop()
const int contrper = contr.get_int(LVCONDV_PERFAT);
//se il cliente non è sospeso e se si è nel periodo di fatturazione giusto, aggiungo il documento alla
//lista dei documetni da elaborare
//lista dei documenti da elaborare
if (!contr.get_bool(LVCONDV_FATTSOSP) && contrper <= period)
docsin.add(new TDocumento(recset.cursor()->curr()));
{
TDocumento * doc = new TDocumento(recset.cursor()->curr());
if (agghead && !_solototali && doc->get(DOC_CODNUM) == num_buoni && doc->tipo().codice() == tipo_buoni)
{
bool doc_updated = false;
// banche
key.cut(0);
key.add(clirec.get(CLI_TIPOCF));
key.add(clirec.get(CLI_CODCF));
key.add("V");
key.add("1");
const TRectype & cfban = cache().get(LF_CFBAN, key);
TString8 abi;
TString8 cab;
TString iban;
if (cfban.empty())
{
abi = clirec.get(CLI_CODABI);
cab = clirec.get(CLI_CODCAB);
iban = clirec.get(CLI_IBAN);
}
else
{
abi = cfban.get(CFBAN_ABI);
cab = cfban.get(CFBAN_CAB);
iban = cfban.get(CFBAN_IBAN);
}
if (cab.full() && cab != "00000")
{
doc_updated |= (doc->get(DOC_CODABIA) != abi) || (doc->get(DOC_CODCABA) != cab);
doc->put(DOC_CODABIA, abi);
doc->put(DOC_CODCABA, cab);
doc->put(DOC_IBAN, iban);
}
key.cut(0);
key.add(clirec.get(CLI_TIPOCF));
key.add(clirec.get(CLI_CODCF));
key.add("N");
key.add("1");
const TRectype & cfbanpr = cache().get(LF_CFBAN, key);
int progbnp = 0;
if (cfbanpr.empty())
{
abi = clienti.get(CFV_CODABIPR);
cab = clienti.get(CFV_CODCABPR);
}
else
{
abi = cfbanpr.get(CFBAN_ABI);
cab = cfbanpr.get(CFBAN_CAB);
progbnp = cfbanpr.get_int(CFBAN_PROGPR);
}
if (cab.full() && cab != "00000")
{
doc_updated |= (doc->get(DOC_CODABIP) != abi) || (doc->get(DOC_CODCABP) != cab);
doc->put(DOC_CODABIP, abi);
doc->put(DOC_CODCABP, cab);
doc->put(DOC_PROGBNP, progbnp);
}
const TString codpag = clirec.get(CLI_CODPAG);
if (codpag.full())
{
doc_updated |= (doc->get(DOC_CODPAG) != codpag);
doc->put(DOC_CODPAG, codpag);
}
const TString spinc = clienti.get(CFV_PERCSPINC);
if (spinc.full())
{
doc_updated |= (doc->get(DOC_PERCSPINC) != spinc);
doc->put(DOC_PERCSPINC, spinc);
}
const bool addbolli = clienti.get_bool(CFV_ADDBOLLI);
doc_updated |= (doc->get_bool(DOC_ADDBOLLI) != addbolli);
doc->put(DOC_ADDBOLLI, addbolli);
const TString agente1 = clienti.get(CFV_CODAG1);
if (agente1.full())
{
doc_updated |= (doc->get(DOC_CODAGVIS) != agente1);
doc->put(DOC_CODAGVIS, agente1);
}
if (doc_updated)
{
TString msg("Bolla n.ro ");
msg << docrec.get(DOC_NDOC) << " del " << docrec.get(DOC_DATADOC) << " Cliente " << clifo << " " << clirec.get(CLI_RAGSOC) << " aggirnata la testata ";
_log->log(2, msg);
}
}
for (int r = 1; !_solototali && r <= doc->physical_rows(); r++)
{
const TString & codart = (*doc)[r].get(RDOC_CODARTMAG);
if (codart.full())
{
const TRectype & rcont = contr.row(codart);
TArticolo_lavanderie& art = cached_article_laundry(codart, 'C', clifo, use_indsp ? indsped : 0);
//estraggo il record corrispondente su LF_CLIFOGIAC
const TRecmag_lavanderie& rec = art.find_rec(annoes);
if (rec.get_real("DOTOD") < ZERO)
{
TString msg("Bolla n.ro ");
msg << docrec.get(DOC_NDOC) << " del " << docrec.get(DOC_DATADOC) << " Cliente " << clifo << " " << clirec.get(CLI_RAGSOC) << " articolo " << codart << " dotazione odierna negativa";
_log->log(2, msg);
}
if (rec.get_real("DOTIN") < ZERO)
{
TString msg("Bolla n.ro ");
msg << docrec.get(DOC_NDOC) << " del " << docrec.get(DOC_DATADOC) << " Cliente " << clifo << " " << clirec.get(CLI_RAGSOC) << " articolo " << codart << " dotazione iniziale negativa";
_log->log(2, msg);
}
if (prezzo_da_contratto && rcont.get_real(LVRCONDV_PREZZO) == ZERO)
{
TString msg("Bolla n.ro ");
msg << docrec.get(DOC_NDOC) << " del " << docrec.get(DOC_DATADOC) << " Cliente " << clifo << " " << clirec.get(CLI_RAGSOC) << " articolo " << codart << " prezzo da contratto zero";
_log->log(2, msg);
}
}
}
docsin.add(doc);
}
}
}
@ -2140,29 +2371,54 @@ void TFatturazione_lav_app::main_loop()
const int items = docsout.items();
if (items > 0)
{
docsout.write();
if (!_solototali)
docsout.write();
numdocgen += items;
TString tmp;
tmp << lastcli;
cliela.add(tmp, tmp);
for (int i = 0; i < items; i++)
{
const TDocumento & doc = docsout[i];
totimp += doc.imponibile();
imposta += doc.imposta();
totdoc += doc.totale_doc();
spese += doc.spese();
}
}
docsout.destroy(-1);
docsin.rewrite();
if (!_solototali)
docsin.rewrite();
docsin.destroy(-1);
}
genera_bolle_nolo(cliela, elab, numdocgen);
genera_bolle_nolo(cliela, elab, numdocgen, totimp, imposta, totdoc, spese);
numdocgen += elab.write_fatt_ragg();
TString str;
if (numdocgen > 1 || numdocgen == 0)
str << "Sono state generate " << numdocgen << " fatture";
else
str << "E' stata generata " << numdocgen << " fattura";
if (!_solototali)
{
if (numdocgen > 1 || numdocgen == 0)
str << "Sono state generate " << numdocgen << " fatture";
else
str << "E' stata generata " << numdocgen << " fattura";
}
message_box(str);
message_box(TR("Elaborazione terminata"));
str = "Clienti Danneggati Articoli danneggiati";
_log->log(0, str);
str.format(" %5d %5d", elab.cli_damn(), elab.art_damn());
_log->log(0, str);
str = "Numero fatture Imponibile Imposta Totale Spese";
_log->log(0, str);
str.format(" %5d", numdocgen);
str << totimp.stringa(15) << imposta.stringa(14) << totdoc.stringa(15) << spese.stringa(13);
_log->log(0, str);
_log->print_or_preview();
delete _log;
}
}

View File

@ -11,6 +11,7 @@
#define F_CODCATC 111
#define F_CODZONA 112
#define F_SAVEDATA 113
#define F_SOLOTOTALI 114

View File

@ -148,9 +148,14 @@ BEGIN
ITEM "0|Giornaliera"
END
BOOLEAN F_SOLOTOTALI
BEGIN
PROMPT 2 12 "Solo Totali"
END
BOOLEAN F_SAVEDATA
BEGIN
PROMPT 2 12 "Salvataggio dati"
PROMPT 2 14 "Salvataggio dati"
END
ENDPAGE

View File

@ -22,6 +22,12 @@
#define F_CAUSALE_RESO 121
#define F_CAUSALE_ROTTO 122
#define F_MOV_CONGUAGLIO 123
#define F_GRUPPO 124
#define F_CONTO 125
#define F_SOTTOC 126
#define F_DESCR 127
#define R_CON 16
//#define F_STAMPA_BOLLA 117
//#define F_CALC_IMPORTO 118
//#define F_CONTR_DOTAZIONE 119

View File

@ -1,4 +1,4 @@
#include "lvtbcau.h"
2#include "lvtbcau.h"
TOOLBAR "" 0 0 0 2
#include "relapbar.h"
@ -280,6 +280,8 @@ BOOLEAN F_CAUSALE_ROTTO
BEGIN
FIELD B3
PROMPT 25 16 "Causale di rotto"
MESSAGE TRUE ENABLE,-R_CON
MESSAGE TRUE CLEAR,-R_CON
END
BOOLEAN F_MOV_CONGUAGLIO
@ -288,6 +290,58 @@ BEGIN
PROMPT 45 16 "Non movimentare conguaglio"
END
NUMBER F_GRUPPO 3
BEGIN
PROMPT 1 18 "Conto per i rotti "
FIELD I0
GROUP R_CON
END
NUMBER F_CONTO 3
BEGIN
PROMPT 22 18 ""
FIELD I1
GROUP R_CON
END
NUMBER F_SOTTOC 6
BEGIN
PROMPT 26 18 ""
FIELD I2
GROUP R_CON
USE LF_PCON
INPUT GRUPPO F_GRUPPO
INPUT CONTO F_CONTO
INPUT SOTTOCONTO F_SOTTOC
DISPLAY "Gruppo" GRUPPO
DISPLAY "Conto" CONTO
DISPLAY "Sottoconto" SOTTOCONTO
DISPLAY "Descrizione@50" DESCR
OUTPUT F_GRUPPO GRUPPO
OUTPUT F_CONTO CONTO
OUTPUT F_SOTTOC SOTTOCONTO
OUTPUT F_DESCR DESCR
CHECKTYPE NORMAL
WARNING "Conto assente"
ADD RUN cg0 -0
END
STRING F_DESCR 50 37
BEGIN
PROMPT 36 18 ""
GROUP R_CON
USE LF_PCON KEY 2
INPUT DESCR F_DESCR
DISPLAY "Descrizione@50" DESCR
DISPLAY "Gruppo" GRUPPO
DISPLAY "Conto" CONTO
DISPLAY "Sottoconto" SOTTOCONTO
COPY OUTPUT F_SOTTOC
WARNING "Conto assente"
ADD RUN cg0 -0
END
ENDPAGE
ENDMASK