Corretta gestione IVA detraibile e non

git-svn-id: svn://10.65.10.50/trunk@308 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-10-04 15:37:32 +00:00
parent a0b81b88f3
commit f3d76f55e8
14 changed files with 90 additions and 92 deletions

View File

@ -53,6 +53,7 @@ STRING F_TIPO_DOC 2
BEGIN BEGIN
PROMPT 2 4 "Tipo doc. " PROMPT 2 4 "Tipo doc. "
FIELD LF_CAUSALI->TIPODOC FIELD LF_CAUSALI->TIPODOC
FLAGS "U"
USE %TPD USE %TPD
INPUT CODTAB F_TIPO_DOC INPUT CODTAB F_TIPO_DOC
DISPLAY "Tipo " CODTAB DISPLAY "Tipo " CODTAB
@ -62,7 +63,6 @@ BEGIN
CHECKTYPE NORMAL CHECKTYPE NORMAL
// MESSAGE SHOW, 2@ // MESSAGE SHOW, 2@
// MESSAGE EMPTY HIDE, 2@ // MESSAGE EMPTY HIDE, 2@
FLAGS "U"
END END
STRING F_COD_REG 3 STRING F_COD_REG 3
@ -142,10 +142,10 @@ BEGIN
PROMPT 0 7 "" PROMPT 0 7 ""
ITEM "Tipo conto@21" ITEM "Tipo conto@21"
ITEM "C/F" ITEM "C/F"
ITEM "Gr." ITEM "Gr.@3"
ITEM "Co." ITEM "Co.@3"
ITEM "Sottoc." ITEM "Sottoc.@6"
ITEM "D/A" ITEM "D/A@1"
ITEM "Descrizione@50" ITEM "Descrizione@50"
ITEM "Descr. agg." ITEM "Descr. agg."
ITEM "Iva" ITEM "Iva"

View File

@ -1,4 +1,3 @@
#include "cg0500.h" #include "cg0500.h"
PAGE "" -1 -1 68 11 PAGE "" -1 -1 68 11
@ -39,7 +38,7 @@ BEGIN
OUTPUT 103 GRUPPO OUTPUT 103 GRUPPO
OUTPUT 107 DESCR OUTPUT 107 DESCR
// OUTPUT 102 TMCF // OUTPUT 102 TMCF
WARNING "Gruppo inesistente o mancante" WARNING "Gruppo assente"
// CHECKTYPE REQUIRED // CHECKTYPE REQUIRED
CHECKTYPE NORMAL CHECKTYPE NORMAL
GROUP 1 GROUP 1
@ -95,7 +94,7 @@ NUMBER 205 6
BEGIN BEGIN
PROMPT 29 3 "Cliente " PROMPT 29 3 "Cliente "
FIELD LF_RCAUSALI->SOTTOCONTO FIELD LF_RCAUSALI->SOTTOCONTO
USE LF_CLIFO KEY 1 SELECT (TIPOCF=="C") USE LF_CLIFO KEY 1
INPUT TIPOCF "C" INPUT TIPOCF "C"
INPUT CODCF 205 INPUT CODCF 205
DISPLAY "Gruppo" GRUPPO DISPLAY "Gruppo" GRUPPO
@ -104,11 +103,8 @@ BEGIN
DISPLAY "Ragione sociale@50" RAGSOC DISPLAY "Ragione sociale@50" RAGSOC
DISPLAY "Tipo C/F" TIPOCF DISPLAY "Tipo C/F" TIPOCF
OUTPUT 205 CODCF OUTPUT 205 CODCF
OUTPUT 107 RAGSOC OUTPUT 207 RAGSOC
CHECKTYPE NORMAL CHECKTYPE NORMAL
FLAGS "H"
MESSAGE CLEAR,105
MESSAGE COPY,105
ADD RUN CG0 -1 ADD RUN CG0 -1
GROUP 1 GROUP 1
END END
@ -118,7 +114,7 @@ NUMBER 305 6
BEGIN BEGIN
PROMPT 29 3 "Fornitore " PROMPT 29 3 "Fornitore "
FIELD LF_RCAUSALI->SOTTOCONTO FIELD LF_RCAUSALI->SOTTOCONTO
USE LF_CLIFO KEY 1 SELECT (TIPOCF=="F") USE LF_CLIFO KEY 1
INPUT TIPOCF "F" INPUT TIPOCF "F"
INPUT CODCF 305 INPUT CODCF 305
DISPLAY "Gruppo" GRUPPO DISPLAY "Gruppo" GRUPPO
@ -127,11 +123,8 @@ BEGIN
DISPLAY "Ragione sociale@50" RAGSOC DISPLAY "Ragione sociale@50" RAGSOC
DISPLAY "Tipo C/F" TIPOCF DISPLAY "Tipo C/F" TIPOCF
OUTPUT 305 CODCF OUTPUT 305 CODCF
OUTPUT 107 RAGSOC OUTPUT 307 RAGSOC
CHECKTYPE NORMAL CHECKTYPE NORMAL
FLAGS "H"
MESSAGE CLEAR,105
MESSAGE COPY,105
ADD RUN CG0 -1 ADD RUN CG0 -1
GROUP 1 GROUP 1
END END
@ -161,8 +154,6 @@ BEGIN
OUTPUT 104 CONTO OUTPUT 104 CONTO
OUTPUT 103 GRUPPO OUTPUT 103 GRUPPO
OUTPUT 107 DESCR OUTPUT 107 DESCR
// MESSAGE COPY, 207
// MESSAGE COPY, 307
ADD RUN CG0 -0 ADD RUN CG0 -0
GROUP 1 GROUP 1
END END
@ -172,7 +163,7 @@ STRING 207 50
BEGIN BEGIN
PROMPT 1 5 "Rag.sociale " PROMPT 1 5 "Rag.sociale "
FIELD LF_RCAUSALI->DESC FIELD LF_RCAUSALI->DESC
USE LF_CLIFO KEY 2 SELECT (TIPOCF=="C") USE LF_CLIFO KEY 2
INPUT TIPOCF "C" INPUT TIPOCF "C"
INPUT CODCF 205 INPUT CODCF 205
DISPLAY "Tipo C/F" TIPOCF DISPLAY "Tipo C/F" TIPOCF
@ -182,8 +173,6 @@ BEGIN
DISPLAY "Sottoconto" CODCF DISPLAY "Sottoconto" CODCF
OUTPUT 205 CODCF OUTPUT 205 CODCF
OUTPUT 207 RAGSOC OUTPUT 207 RAGSOC
MESSAGE CLEAR,107
MESSAGE COPY,107
GROUP 1 GROUP 1
FLAGS "H" FLAGS "H"
END END
@ -193,7 +182,7 @@ STRING 307 50
BEGIN BEGIN
PROMPT 1 5 "Rag.sociale " PROMPT 1 5 "Rag.sociale "
FIELD LF_RCAUSALI->DESC FIELD LF_RCAUSALI->DESC
USE LF_CLIFO KEY 2 SELECT (TIPOCF=="F") USE LF_CLIFO KEY 2
INPUT TIPOCF "F" INPUT TIPOCF "F"
INPUT CODCF 305 INPUT CODCF 305
DISPLAY "Tipo C/F" TIPOCF DISPLAY "Tipo C/F" TIPOCF
@ -203,8 +192,6 @@ BEGIN
DISPLAY "Sottoconto" CODCF DISPLAY "Sottoconto" CODCF
OUTPUT 305 CODCF OUTPUT 305 CODCF
OUTPUT 307 RAGSOC OUTPUT 307 RAGSOC
MESSAGE CLEAR,107
MESSAGE COPY,107
GROUP 1 GROUP 1
FLAGS "H" FLAGS "H"
END END

View File

@ -102,8 +102,8 @@ if (n == 1 || n == 2)
cgm.set_handler(306, cg_clifo_handler); cgm.set_handler(306, cg_clifo_handler);
cgm.set_handler(112, suspended_handler); cgm.set_handler(112, suspended_handler);
cgm.set_handler(113, suspended_handler); cgm.set_handler(113, suspended_handler);
cgm.set_handler(213, suspended_handler); cgm.set_handler(213, cg_clifo_handler);
cgm.set_handler(313, suspended_handler); cgm.set_handler(313, cg_clifo_handler);
} }
return _msk[n] = m; return _msk[n] = m;

View File

@ -63,13 +63,6 @@
#define H_DESCRCAUS 204 #define H_DESCRCAUS 204
#define H_ANNOES 205 #define H_ANNOES 205
// Campi ripetuti sulla terza pagina
#define H_DATAREG1 211
#define H_NUMREG1 212
#define H_CODCAUS1 213
#define H_DESCRCAUS1 214
#define H_ANNOES1 215
// Maschera clienti/fornitori occasionali // Maschera clienti/fornitori occasionali
#define O_CODICE 100 #define O_CODICE 100
#define O_RAGSOC 101 #define O_RAGSOC 101

View File

@ -237,8 +237,9 @@ BEGIN
OUTPUT F_OCCASIONALE OCCAS OUTPUT F_OCCASIONALE OCCAS
MESSAGE COPY,F_FORNITORE MESSAGE COPY,F_FORNITORE
CHECKTYPE REQUIRED CHECKTYPE REQUIRED
WARNING "Cliente assente"
ADD RUN cg0 -1 ADD RUN cg0 -1
END END
NUMBER F_FORNITORE 6 NUMBER F_FORNITORE 6
BEGIN BEGIN
@ -265,6 +266,7 @@ BEGIN
OUTPUT F_PIVAFORNITORE PAIV OUTPUT F_PIVAFORNITORE PAIV
MESSAGE COPY,F_CLIENTE MESSAGE COPY,F_CLIENTE
CHECKTYPE REQUIRED CHECKTYPE REQUIRED
WARNING "Fornitore assente"
ADD RUN cg0 -1 ADD RUN cg0 -1
END END

View File

@ -174,35 +174,24 @@ int TMovimentoPN::registra(bool re, bool force)
int TMovimentoPN::write(bool force, TDate&) int TMovimentoPN::write(bool force, TDate&)
{ {
const TLocalisamfile& r = lfile(); const TRectype& r = lfile().curr();
const int annoiva = r.get_int("ANNOIVA"); const int annoiva = r.get_int("ANNOIVA");
const TString16 reg(r.get("REG")); const TString16 reg(r.get("REG"));
TRegistro registro(reg, annoiva); TRegistro registro(reg, annoiva);
if (registro.iva() != nessuna_iva) if (registro.iva() != nessuna_iva)
{ {
const bool mista = registro.tipo_attivita() == "M"; const bool mista = registro.attivita_mista();
for (int i = 0; i < iva_items(); i++) for (int i = 0; i < iva_items(); i++)
{ {
int tipoatt = 1; int tipoatt = 1;
if (mista) if (mista)
{ {
const int riga = iva(i).get_int("RIGAIMP"); const char tipo = r.get_char("TIPOC");
if (riga) if (tipo == ' ')
{ {
const TRectype& r = cg(riga-1); TBill c(r.get_int("GRUPPO"), r.get_int("CONTO"), r.get_long("SOTTOCONTO"));
const char tipo = r.get_char("TIPOC"); tipoatt = c.tipo_att();
if (tipo == ' ')
{
TBill c(r.get_int("GRUPPO"), r.get_int("CONTO"), r.get_long("SOTTOCONTO"));
TRectype conto(LF_PCON); c.read(conto);
const TIndbil ib = (TIndbil)conto.get_int("INDBIL");
if (ib == ib_passivita || ib == ib_ricavi)
{
int ricser = conto.get_int("RICSER");
tipoatt = (ricser == 0) ? 2 : 1;
}
}
} }
} }
iva(i).put("TIPOATT", tipoatt); iva(i).put("TIPOATT", tipoatt);

View File

@ -106,15 +106,26 @@ bool TPrimanota_application::suspended_handler(TMask_field& f, KEY k)
// Determina se un codice detrazione e' di tipo detraibile o no // Determina se un codice detrazione e' di tipo detraibile o no
// Certified 70% // Certified 70%
bool TPrimanota_application::detraibile(int tipodet) bool TPrimanota_application::detraibile(TToken_string& row)
{ {
if (tipodet) const int tipo_det = row.get_int(2); // Leggi tipo detraibilita
if (tipo_det != 0)
return FALSE; return FALSE;
if (app().iva() != iva_acquisti)
if (app().iva() == iva_vendite) // Vendite sempre detraibili
return TRUE; return TRUE;
TRegistro& reg = app().causale().reg();
TString16 chiave; TString16 chiave;
chiave << app().mask().get(F_ANNOIVA) << app().causale().reg().attivita(); chiave << app().mask().get(F_ANNOIVA) << reg.attivita();
int tipoatt = 1;
if (reg.attivita_mista()) // Se attivita mista ...
{
TBill bill(row, 5, 0x1);
tipoatt = bill.tipo_att(); // ... determina attivita
}
chiave << tipoatt; // anno|attivita|tipo_attivita
TTable pla("PLA"); TTable pla("PLA");
pla.put("CODTAB", chiave); pla.put("CODTAB", chiave);
@ -210,7 +221,7 @@ int TPrimanota_application::det_used(char det) const
TToken_string& row = (TToken_string&)rows[i]; TToken_string& row = (TToken_string&)rows[i];
if (!row.empty_items()) if (!row.empty_items())
{ {
const bool d = detraibile(row.get_int(4)); const bool d = detraibile(row);
if (detraib == d) users++; if (detraib == d) users++;
} }
} }
@ -468,12 +479,16 @@ bool TPrimanota_application::cg_notify(int r, KEY k)
case K_ENTER: case K_ENTER:
if (r == 0 && app().iva() == nessuna_iva && cg.row(1).empty_items()) if (r == 0 && app().iva() == nessuna_iva && cg.row(1).empty_items())
{ {
TImporto i; i = row; i.swap_section(); TImporto i; i = row;
TBill contro(row, 9, 0x3); if (i.valore() != 0.0)
app().set_cgs_row(1, i, contro, "", ' '); {
TBill conto(row, 2, 0x3); i.swap_section();
conto.add_to(cg.row(1), 9, 0x3); TBill contro(row, 9, 0x3);
app().cgs().force_update(1); app().set_cgs_row(1, i, contro, "", ' ');
TBill conto(row, 2, 0x3);
conto.add_to(cg.row(1), 9, 0x3);
app().cgs().force_update(1);
}
} }
app().calcola_saldo(); app().calcola_saldo();
break; break;
@ -649,7 +664,7 @@ bool TPrimanota_application::iva_notify(int r, KEY k)
oldiva = scorpora(oldimp, percent); oldiva = scorpora(oldimp, percent);
} }
const char tipod = detraibile(row.get_int(2)) ? 'D' : 'N'; // Tipodet 2 const char tipod = detraibile(row) ? 'D' : 'N';
oldposiva = type2pos(tipod); oldposiva = type2pos(tipod);
if (oldposiva < 0 && oldiva != ZERO) if (oldposiva < 0 && oldiva != ZERO)
{ {
@ -702,7 +717,7 @@ bool TPrimanota_application::iva_notify(int r, KEY k)
// Aggiorna conto IVA sulla riga contabile // Aggiorna conto IVA sulla riga contabile
const bool detrarre = detraibile(row.get_int(2)); // Determina se IVA detraibile const bool detrarre = detraibile(row); // Determina se IVA detraibile
app().causale().bill(detrarre ? 3 : 4, conto); app().causale().bill(detrarre ? 3 : 4, conto);
const char tipod = detrarre ? 'D' : 'N'; const char tipod = detrarre ? 'D' : 'N';
const int newposiva = type2pos(tipod); const int newposiva = type2pos(tipod);
@ -766,7 +781,7 @@ bool TPrimanota_application::cg_clifo_handler(TMask_field& f, KEY k)
const long codice = atol(f.get()); const long codice = atol(f.get());
if (codice > 0L) if (codice > 0L)
{ {
TBill c(0, 0, codice, app().clifo()); TBill c(0, 0, codice, m.get(cid-2)[0]);
c.descrizione(); // Carica gruppo e conto c.descrizione(); // Carica gruppo e conto
m.set(cid-1, c.gruppo()); m.set(cid-1, c.gruppo());
m.set(cid, c.conto()); m.set(cid, c.conto());
@ -1127,13 +1142,7 @@ bool TPrimanota_application::main_codiva_handler(TMask_field& f, KEY key)
} }
if (!bill.ok()) if (!bill.ok())
app().causale().bill(2, bill); app().causale().bill(2, bill);
row.add(bill.tipo_cr(), 4); bill.add_to(row, 4, 0x7);
row.add(bill.tipo(), 5);
row.add(bill.gruppo(), 6);
row.add(bill.conto(), 7);
row.add(bill.sottoconto(), 8);
row.add(bill.descrizione(), 9);
app().ivas().force_update(0); app().ivas().force_update(0);
iva_notify(0, K_ENTER); iva_notify(0, K_ENTER);
} }

View File

@ -118,7 +118,7 @@ protected:
static int type2pos(char tipo); static int type2pos(char tipo);
static const real& cod2IVA(const TMask& m); static const real& cod2IVA(const TMask& m);
static real scorpora(real& imponibile, const real& percentuale); static real scorpora(real& imponibile, const real& percentuale);
static bool detraibile(int tipodet); static bool detraibile(TToken_string& row);
int bill2contr(const TBill& c, char sezione) const; int bill2contr(const TBill& c, char sezione) const;
int bill_used(const TBill& conto) const; int bill_used(const TBill& conto) const;

View File

@ -46,6 +46,7 @@ public:
bool agenzia_viaggi(); bool agenzia_viaggi();
const TString& tipo_attivita(); const TString& tipo_attivita();
bool attivita_mista() { return tipo_attivita()[0] == 'M'; }
bool update(long uprotiva, const TDate& lastreg); bool update(long uprotiva, const TDate& lastreg);

View File

@ -111,7 +111,7 @@ BEGIN
DISPLAY "Gruppo" GRUPPO DISPLAY "Gruppo" GRUPPO
DISPLAY "Conto" CONTO DISPLAY "Conto" CONTO
OUTPUT 206 CODCF OUTPUT 206 CODCF
OUTPUT 307 RAGSOC OUTPUT 207 RAGSOC
MESSAGE COPY,106 MESSAGE COPY,106
ADD RUN cg0 -1 ADD RUN cg0 -1
CHECKTYPE NORMAL CHECKTYPE NORMAL

View File

@ -260,8 +260,8 @@ void CG3400_application::user_create()
_cur = new TCursor (_rel, "", 2); // usa la chiave 2 su MOV _cur = new TCursor (_rel, "", 2); // usa la chiave 2 su MOV
_RecPartoDa = new TRectype(_cur->file(LF_MOV)); _RecPartoDa = new TRectype(_cur->file(LF_MOV).curr());
_RecArrivoA = new TRectype(_cur->file(LF_MOV)); _RecArrivoA = new TRectype(_cur->file(LF_MOV).curr());
add_cursor (_cur); add_cursor (_cur);
@ -888,13 +888,13 @@ bool CG3400_application::preprocess_page(int file, int counter)
reset_row(2); reset_row(3); reset_row(2); reset_row(3);
} }
g = _cur->file(LF_RMOV)->get_int(RMV_GRUPPO); g = _cur->file(LF_RMOV).get_int(RMV_GRUPPO);
c = _cur->file(LF_RMOV)->get_int(RMV_CONTO); c = _cur->file(LF_RMOV).get_int(RMV_CONTO);
s = _cur->file(LF_RMOV)->get_long(RMV_SOTTOCONTO); s = _cur->file(LF_RMOV).get_long(RMV_SOTTOCONTO);
cf = _cur->file(LF_RMOV)->get_char(RMV_TIPOC); cf = _cur->file(LF_RMOV).get_char(RMV_TIPOC);
sezione = _cur->file(LF_RMOV)->get_char (RMV_SEZIONE); sezione = _cur->file(LF_RMOV).get_char (RMV_SEZIONE);
importo = _cur->file(LF_RMOV)->get_real (RMV_IMPORTO); importo = _cur->file(LF_RMOV).get_real (RMV_IMPORTO);
rmv_descr = _cur->file(LF_RMOV)->get(RMV_DESCR); rmv_descr = _cur->file(LF_RMOV).get(RMV_DESCR);
tc.set(g,c,s,cf); tc.set(g,c,s,cf);
@ -1087,12 +1087,12 @@ void CG3400_application::setta_righe_indirizzo(char tipocf, long codcf)
if (_occfpi.not_empty()) // => e' un occasionale... if (_occfpi.not_empty()) // => e' un occasionale...
{ {
TLocalisamfile* occ = _cur->file(LF_OCCAS); TLocalisamfile& occ = _cur->file(LF_OCCAS);
viacf = occ->get (OCC_INDIR); viacf = occ.get (OCC_INDIR);
civcf = occ->get (OCC_CIV); civcf = occ.get (OCC_CIV);
capcf = occ->get (OCC_CAP); capcf = occ.get (OCC_CAP);
comcf = occ->get (OCC_COM); comcf = occ.get (OCC_COM);
} }
else else
{ {

View File

@ -283,7 +283,7 @@ bool CG4300_App::set_liquidazione()
for (i = 0; i < _nomiditte.items(); i++) for (i = 0; i < _nomiditte.items(); i++)
{ {
if (_selected[i]) continue; if (_selected[i]) continue;
TToken_string d = (const char*)((TToken_string&)_nomiditte[i]); TToken_string d((const TToken_string&)_nomiditte[i]);
TString cod = d.get(0); TString cod = d.get(0);
TString vers = d.get(2); TString vers = d.get(2);
if ((_what == mnt && vers == "T") || if ((_what == mnt && vers == "T") ||

View File

@ -49,7 +49,7 @@ const TBill& TBill::add_to(TToken_string& ts, int from, int mode)
if (mode & 0x4) if (mode & 0x4)
{ {
const int cr = tipo_cr(); const int cr = tipo_cr();
ts.add(cr > 0 ? format("%d", cr) : "", from++); ts.add(cr > 0 ? format("%d", cr) : " ", from++);
} }
if (mode & 0x1) if (mode & 0x1)
ts.add(_tipo, from++); ts.add(_tipo, from++);
@ -162,6 +162,22 @@ bool TBill::read(TRectype &r)
return err == NOERR; return err == NOERR;
} }
int TBill::tipo_att()
{
int tipo_att = 1;
if (_tipo == ' ')
{
TRectype conto(LF_PCON); read(conto);
const TIndbil ib = (TIndbil)conto.get_int("INDBIL");
if (ib == ib_passivita || ib == ib_ricavi)
{
const int ricser = conto.get_int("RICSER");
tipo_att = (ricser == 0) ? 2 : 1;
}
}
return tipo_att;
}
// Certified 99% (describe uses __tmp_string) // Certified 99% (describe uses __tmp_string)
const TString& TBill::descrizione() const TString& TBill::descrizione()
{ {

View File

@ -41,6 +41,7 @@ public:
const TString& descrizione(); const TString& descrizione();
int tipo_cr(); int tipo_cr();
int tipo_att();
bool read(TRectype& r); bool read(TRectype& r);
const char* string(int mode = 0); const char* string(int mode = 0);