Gestione split payment in fatturazione
git-svn-id: svn://10.65.10.50/branches/R_10_00@23056 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
61fd44bec6
commit
9ca7526e5a
@ -11,9 +11,7 @@
|
||||
#include "../cg/cfban.h"
|
||||
#include "../cg/cglib03.h"
|
||||
|
||||
#include "clifo.h"
|
||||
#include "comuni.h"
|
||||
#include "cfven.h"
|
||||
#include "lvcondv.h"
|
||||
#include "lvrcondv.h"
|
||||
|
||||
@ -129,8 +127,10 @@ protected:
|
||||
virtual bool gestione_riferimenti() const { return true; }
|
||||
virtual bool riferimenti_in_testa() const { return true; }
|
||||
virtual TRiga_documento& find_or_create_row(TDocumento& doc_out, const TRiga_documento & rin,const char lavtype);
|
||||
virtual bool get_num_tip_out(const TDocumento& doc_out, TString& codnum, TString& tipodoc) const;
|
||||
|
||||
void aggiorna_fattura(TDocumento & doc, int codcont);
|
||||
bool fatt_02() const { return !_prova &&lv_is_02_active(); }
|
||||
bool fatt_02() const { return !_prova && lv_is_02_active(); }
|
||||
void add_doc_to_list(const TString & key, const TDocumento & doc);
|
||||
real get_percprovv(const TRiga_documento & row, char tipoprovv, const TString & codpr, bool first, const TRectype & age) const;
|
||||
|
||||
@ -158,7 +158,7 @@ bool TFatturazione_lavanderie::is_document_compatible(const TRectype & doc) cons
|
||||
bool ok = false;
|
||||
const TString4 codnum(doc.get(DOC_CODNUM));
|
||||
const TString4 tipodoc(doc.get(DOC_TIPODOC));
|
||||
const char stato(doc.get_char(DOC_STATO));
|
||||
const char stato = doc.get_char(DOC_STATO);
|
||||
const TString& codnumel = codice_numerazione_iniziale();
|
||||
|
||||
if (codnumel.blank() || codnum == codnumel)
|
||||
@ -290,7 +290,7 @@ void TFatturazione_lavanderie::aggiorna_fattura(TDocumento& doc, int codcont)
|
||||
for (int i = 1; to_add && i <= nrows ; i++)
|
||||
{
|
||||
TRiga_documento& rout = doc[i];
|
||||
const TString80 codart_contr = rout.get(RDOC_CODART);
|
||||
const TCodice_articolo codart_contr = rout.get(RDOC_CODART);
|
||||
|
||||
if (codart == codart_contr)
|
||||
to_add = false;
|
||||
@ -345,7 +345,7 @@ real TFatturazione_lavanderie::get_percprovv(const TRiga_documento & row, char t
|
||||
{
|
||||
real val = ZERO;
|
||||
const TDocumento & doc = row.doc();
|
||||
const TRectype & anamag = cache().get(LF_ANAMAG, row.get(RDOC_CODARTMAG));
|
||||
const TRectype& anamag = cache().get(LF_ANAMAG, row.get(RDOC_CODARTMAG));
|
||||
|
||||
switch (tipoprovv)
|
||||
{
|
||||
@ -408,7 +408,7 @@ real TFatturazione_lavanderie::get_percprovv(const TRiga_documento & row, char t
|
||||
campo.rpad(doc.length(DOC_ZONA));
|
||||
break;
|
||||
case 'M':
|
||||
campo = row.get( RDOC_CODARTMAG );
|
||||
campo = row.get(RDOC_CODARTMAG);
|
||||
campo.rpad(row.length(RDOC_CODARTMAG));
|
||||
break;
|
||||
case 'E':
|
||||
@ -530,8 +530,7 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
|
||||
bool elcons = contr.get_bool(LVCONDV_ELCONS);
|
||||
bool rifbol = contr.get_bool(LVCONDV_RIFBOL);
|
||||
|
||||
const int alleg = doc.clifor().get_int(CLI_ALLEG);
|
||||
const bool splitpay = alleg == 7 && doc.clifor().get_bool(CLI_SPLITPAY);
|
||||
const bool splitpay = doc.clifor().get_bool(CLI_SPLITPAY);
|
||||
real consvconv;
|
||||
real impvconv;
|
||||
TAssoc_array nolo_computed;
|
||||
@ -540,14 +539,14 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
|
||||
doc.zero(DOC_IVAXCASSA);
|
||||
if (!splitpay)
|
||||
{
|
||||
const bool liqdiff = alleg == 7 && doc.clifor().vendite().get_bool(CFV_FATTSOSP);
|
||||
const bool liqdiff = doc.clifor().vendite().get_bool(CFV_FATTSOSP);
|
||||
if (liqdiff)
|
||||
{
|
||||
doc.put(DOC_LIQDIFF, "X");
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((alleg < 5 || alleg == 7) && doc.clifor().get(CLI_PAIV).full() &&
|
||||
if (doc.clifor().get(CLI_PAIV).full() &&
|
||||
gestione_IVAxCassa(doc.get_date(DOC_DATADOC)))
|
||||
{
|
||||
doc.put(DOC_IVAXCASSA, "X");
|
||||
@ -624,7 +623,7 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
|
||||
|
||||
TRiga_documento& riga = doc.new_row("01");
|
||||
|
||||
const TString80 codartcfg = ini_get_string(CONFIG_DITTA, "lv", "Codartcafix");
|
||||
const TCodice_articolo codartcfg = ini_get_string(CONFIG_DITTA, "lv", "Codartcafix");
|
||||
const TString80 descart = cache().get(LF_ANAMAG, codartcfg, ANAMAG_DESCR);
|
||||
const TString descragg = cache().get(LF_ANAMAG, codartcfg, ANAMAG_DESCRAGG);
|
||||
|
||||
@ -670,7 +669,7 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
|
||||
{
|
||||
// estraggo il canone fisso e l'articolo in configurazione
|
||||
const real canfis=contr.get_real(LVCONDV_IMPFIX);
|
||||
const TString80 codartcfg = ini_get_string(CONFIG_DITTA, "lv", "Codartfix");
|
||||
const TCodice_articolo codartcfg = ini_get_string(CONFIG_DITTA, "lv", "Codartfix");
|
||||
const TString80 descart = cached_article(codartcfg).get(ANAMAG_DESCR);
|
||||
const TString descragg = cached_article(codartcfg).get(ANAMAG_DESCRAGG);
|
||||
|
||||
@ -746,7 +745,7 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
|
||||
{
|
||||
TRiga_documento& rout = doc[i];
|
||||
|
||||
const TString80 codart = rout.get(RDOC_CODART);
|
||||
const TCodice_articolo codart = rout.get(RDOC_CODART);
|
||||
//leggo dalla riga del contratto di questo articolo il tipo dotazione e
|
||||
//la scelta per la % sul val.conv su articolo <A> o cliente <C>
|
||||
const TRectype& rcont = contr.row(codart);
|
||||
@ -974,7 +973,7 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
|
||||
//instanzio la riga documento e sommo ai totali gli importi solo se
|
||||
//la percentuale sul valore convenzionale è sul cliente
|
||||
TRiga_documento& riga = doc[j];
|
||||
const TString80 codart = riga.get(RDOC_CODART);
|
||||
const TCodice_articolo codart = riga.get(RDOC_CODART);
|
||||
const TRectype & rcont = contr.row(codart);
|
||||
const char tipvalconvcli = rcont.get_char(LVRCONDV_VCARTCLI);
|
||||
const char lavtype = riga.get_char("LVTYPE");
|
||||
@ -1003,7 +1002,7 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
|
||||
if (consumotot < impconvtot)
|
||||
{
|
||||
const bool cicl2rig=contr.get_bool(LVCONDV_CICLAGGIO);
|
||||
const TString80 codartcon = ini_get_string(CONFIG_DITTA, "lv", "Codartcofix");
|
||||
const TCodice_articolo codartcon = ini_get_string(CONFIG_DITTA, "lv", "Codartcofix");
|
||||
|
||||
//se il ciclaggio è su due linee, allora aggiungo una riga merce, che contiene
|
||||
//il conguaglio al valore convenzionale, che ha come quantità la costante UNO
|
||||
@ -1037,7 +1036,7 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
|
||||
for (int k = doc.physical_rows(); k > i; k--)
|
||||
{
|
||||
TRiga_documento& delrow = doc[k];
|
||||
const TString80 codart = delrow.get(RDOC_CODART);
|
||||
const TCodice_articolo codart = delrow.get(RDOC_CODART);
|
||||
const TRectype& rcont = contr.row(codart);
|
||||
const char tipvalconvcli = rcont.get_char(LVRCONDV_VCARTCLI);
|
||||
char lavtype = delrow.get_char("LVTYPE");
|
||||
@ -1070,12 +1069,11 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
|
||||
}
|
||||
}
|
||||
|
||||
const TString80 codartorig=rout.get(RDOC_CODART);
|
||||
|
||||
const TCodice_articolo codartorig=rout.get(RDOC_CODART);
|
||||
for (int h = doc.physical_rows(); h > i; h--)
|
||||
{
|
||||
TRiga_documento& delrow = doc[h];
|
||||
const TString80 codart=delrow.get(RDOC_CODART);
|
||||
const TCodice_articolo codart=delrow.get(RDOC_CODART);
|
||||
if ( codartorig == codart)
|
||||
doc.destroy_row(h, true);
|
||||
}
|
||||
@ -1092,7 +1090,7 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
|
||||
if (canfis > imponibile)
|
||||
{
|
||||
TRiga_documento& congrow = doc.new_row("01");
|
||||
const TString80 codartcon = ini_get_string(CONFIG_DITTA, "lv", "Codartcofix");
|
||||
const TCodice_articolo codartcon = ini_get_string(CONFIG_DITTA, "lv", "Codartcofix");
|
||||
|
||||
congrow.put(RDOC_CODART, codartcon);
|
||||
congrow.put(RDOC_CHECKED, "X");
|
||||
@ -1122,7 +1120,7 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
|
||||
//e come prezzo la differenza tra l'importo convenzionale e il consumo;
|
||||
//altimenti correggo quantità e prezzo direttamente sulla riga documento che sto analizzando
|
||||
TRiga_documento& congrow = doc.new_row("01");
|
||||
const TString80 codartcon = ini_get_string(CONFIG_DITTA, "lv", "Codartcofix");
|
||||
const TCodice_articolo codartcon = ini_get_string(CONFIG_DITTA, "lv", "Codartcofix");
|
||||
|
||||
congrow.put(RDOC_CODART, codartcon);
|
||||
congrow.put(RDOC_CHECKED, "X");
|
||||
@ -1145,7 +1143,7 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
|
||||
for (int k = rows - 1; k >= 1; k--)
|
||||
{
|
||||
TRiga_documento& delrow = doc[k];
|
||||
const TString80 codart = delrow.get(RDOC_CODART);
|
||||
const TCodice_articolo codart = delrow.get(RDOC_CODART);
|
||||
const TRectype& rcont = contr.row(codart);
|
||||
const int tipoforf = rcont.get_int(LVRCONDV_TIPOFORF);
|
||||
char lavtype = delrow.get_char("LVTYPE");
|
||||
@ -1170,7 +1168,7 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
|
||||
for(int j = doc.physical_rows(); j > 0; j--)
|
||||
{
|
||||
TRiga_documento& rdoc = doc[j];
|
||||
const TString80 codart = rdoc.get(RDOC_CODARTMAG);
|
||||
const TCodice_articolo codart = rdoc.get(RDOC_CODARTMAG);
|
||||
const TRectype& rcont = contr.row(codart);
|
||||
const int tipoforf = rcont.get_int(LVRCONDV_TIPOFORF);
|
||||
long ppconf = cached_article(codart).get_long(ANAMAG_PPCONF);
|
||||
@ -1529,7 +1527,6 @@ TRiga_documento& TFatturazione_lavanderie::find_or_create_row(TDocumento& doc_ou
|
||||
set_perc_provv(row);
|
||||
set_perc_provv(row, false);
|
||||
|
||||
|
||||
const TRectype& anamag = cache().get(LF_ANAMAG, rin.get(RDOC_CODART));
|
||||
row.put(RDOC_CODIVA, anamag.get(ANAMAG_CODIVA));
|
||||
|
||||
@ -1541,7 +1538,7 @@ TRiga_documento& TFatturazione_lavanderie::find_or_create_row(TDocumento& doc_ou
|
||||
r = row.get_int(RDOC_NRIGA);
|
||||
|
||||
TString msg; msg.format(FR("Creazione riga %d in fattura %d/%s/%ld"),
|
||||
r, doc_out.anno(), (const char*)doc_out.numerazione(), doc_out.numero());
|
||||
r, doc_out.anno(), (const char*)row.get(RDOC_CODNUM), row.get_long(RDOC_NDOC));
|
||||
app().log(msg, -1);
|
||||
}
|
||||
if (fatt_02())
|
||||
@ -1555,7 +1552,7 @@ TRiga_documento& TFatturazione_lavanderie::find_or_create_row(TDocumento& doc_ou
|
||||
data = new TCalc_02_data(key);
|
||||
_output_rows_02.add(key, data);
|
||||
}
|
||||
TString bolkey = rin.get_rdoc_key();
|
||||
TString16 bolkey = rin.get_rdoc_key();
|
||||
data->bol_rows().add(bolkey, bolkey);
|
||||
}
|
||||
return doc_out[r];
|
||||
@ -1575,7 +1572,7 @@ void TFatturazione_lavanderie::create_row(TDocumento& doc_out, const TRiga_docum
|
||||
|
||||
//leggo dal documento i valori che vanno riportati sulla fattura e recupero la riga contratto
|
||||
//di quell'articolo
|
||||
const TString80 codart = rin.get(RDOC_CODARTMAG); // non è gestito il caso di un articolo fuori contratto
|
||||
const TCodice_articolo codart = rin.get(RDOC_CODARTMAG); // non è gestito il caso di un articolo fuori contratto
|
||||
const real qta = rin.get_real(RDOC_QTA);
|
||||
const real qta1 = rin.get_real(RDOC_QTAGG1);
|
||||
const TRectype& rcont = contr.row(codart);
|
||||
@ -1685,6 +1682,20 @@ void TFatturazione_lavanderie::create_row(TDocumento& doc_out, const TRiga_docum
|
||||
}
|
||||
}
|
||||
|
||||
bool TFatturazione_lavanderie::get_num_tip_out(const TDocumento& doc_out, TString& codnum, TString& tipodoc) const
|
||||
{
|
||||
// Nel caso di fatturazione di prova NON deve scattare il meccanismo di riattribuzione del tipo documento in base a CFV_TIPODOCFAT.
|
||||
// Deve accontentarsi del tipo documento specificato normalmente sul record dell'elaborazione
|
||||
if (_prova)
|
||||
{
|
||||
codnum = codice_numerazione_finale();
|
||||
tipodoc = get_tipo_out(doc_out);
|
||||
const TCodice_numerazione& cn = cached_numerazione(codnum);
|
||||
return cn.find_tipo_doc(tipodoc) >= 0;
|
||||
}
|
||||
return TFatturazione_bolle::get_num_tip_out(doc_out, codnum, tipodoc);
|
||||
}
|
||||
|
||||
//ELABORA: metodo che esegue alcune operazioni prliminari, quali settare la data elaborazione e trovare i campi
|
||||
//in base ai quali è possibile raggruppare le righe documetno, e poi chiama l'elaborazione standard per la fatturazione
|
||||
bool TFatturazione_lavanderie::elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||
@ -2440,7 +2451,7 @@ void TFatturazione_lav_app::main_loop()
|
||||
for (int r = 1; !_solototali && r <= doc->physical_rows(); r++)
|
||||
{
|
||||
const TRiga_documento& rdoc = (*doc)[r];
|
||||
const TString80 codart = rdoc.get(RDOC_CODARTMAG);
|
||||
const TCodice_articolo codart = rdoc.get(RDOC_CODARTMAG);
|
||||
|
||||
if (codart.full())
|
||||
{
|
||||
|
26
lv/lvlib.cpp
26
lv/lvlib.cpp
@ -1,20 +1,17 @@
|
||||
#include "lvlib.h"
|
||||
|
||||
#include "../cg/cglib01.h"
|
||||
#include "../mg/clifogiac.h"
|
||||
|
||||
#include "lvrcondv.h"
|
||||
#include "lvcondv.h"
|
||||
|
||||
#include "../mg/clifogiac.h"
|
||||
#include "../ve/pacchi.h"
|
||||
|
||||
#include <applicat.h>
|
||||
#include <config.h>
|
||||
#include <modaut.h>
|
||||
#include <dongle.h>
|
||||
#include <recset.h>
|
||||
#include <utility.h>
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Utilities
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -63,7 +60,7 @@ bool lv_is_02_active()
|
||||
HIDDEN short __lv_02_active = 0x3;
|
||||
if (__lv_02_active == 0x3)
|
||||
{
|
||||
__lv_02_active = main_app().has_module(L2AUT);
|
||||
__lv_02_active = dongle().active(L2AUT);
|
||||
|
||||
if (__lv_02_active)
|
||||
{
|
||||
@ -1745,7 +1742,7 @@ bool TLV_report::msg_lv_tot_art(TVariant& var, const char * field) const
|
||||
|
||||
if(recset != NULL && cf != NULL)
|
||||
{
|
||||
const TString80 codart = recset->get("CODART").as_string();
|
||||
const TCodice_articolo codart = recset->get("CODART").as_string();
|
||||
const int es = esercizi().last();
|
||||
TRectype from(LF_CLIFOGIAC);
|
||||
real val;
|
||||
@ -1775,7 +1772,7 @@ bool TLV_report::msg_lv_consmese(TVariant& var) const
|
||||
{
|
||||
TRecordset* row_recset = cf->section().recordset();
|
||||
const long codcf = recset->get("CODCF").as_int();
|
||||
const TString80 codart = row_recset != NULL ? row_recset->get("CODART").as_string() : recset->get("CODART").as_string();
|
||||
const TCodice_articolo codart = row_recset != NULL ? row_recset->get("CODART").as_string() : recset->get("CODART").as_string();
|
||||
|
||||
TArticolo_lavanderie& artrec = cached_article_laundry(codart, 'C', codcf, 0);
|
||||
|
||||
@ -1793,16 +1790,15 @@ bool TLV_report::msg_lv_consmese(TVariant& var) const
|
||||
|
||||
TISAM_recordset fatture(query);
|
||||
|
||||
if(fatture.empty())
|
||||
if (fatture.empty())
|
||||
{
|
||||
query.cut(0);
|
||||
query << "USE DOC KEY 4\n"
|
||||
<< "FROM TIPOCF=C CODCF=" << codcf << " PROVV=D ANNO=" << last_esc - 1 << "CODNUM=\"F01\"\n"
|
||||
<< "TO TIPOCF=C CODCF=" << codcf << " PROVV=D ANNO=" << last_esc - 1 << "CODNUM=\"F01\"\n";
|
||||
|
||||
TISAM_recordset tmp(query);
|
||||
fatture = tmp;
|
||||
<< "FROM TIPOCF=C CODCF=" << codcf << " PROVV=D ANNO=" << (last_esc - 1) << "CODNUM=\"F01\"\n"
|
||||
<< "TO TIPOCF=C CODCF=" << codcf << " PROVV=D ANNO=" << (last_esc - 1) << "CODNUM=\"F01\"\n";
|
||||
fatture.set(query);
|
||||
}
|
||||
fatture.move_last();
|
||||
|
||||
TString note = fatture.get(DOC_NOTE).as_string(); note.strip_spaces();
|
||||
TString16 data = note.right(10);
|
||||
|
Loading…
x
Reference in New Issue
Block a user