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

View File

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

View File

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

View File

@ -63,13 +63,6 @@
#define H_DESCRCAUS 204
#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
#define O_CODICE 100
#define O_RAGSOC 101

View File

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

View File

@ -174,35 +174,24 @@ int TMovimentoPN::registra(bool re, bool force)
int TMovimentoPN::write(bool force, TDate&)
{
const TLocalisamfile& r = lfile();
const TRectype& r = lfile().curr();
const int annoiva = r.get_int("ANNOIVA");
const TString16 reg(r.get("REG"));
TRegistro registro(reg, annoiva);
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++)
{
int tipoatt = 1;
if (mista)
{
const int riga = iva(i).get_int("RIGAIMP");
if (riga)
{
const TRectype& r = cg(riga-1);
const char tipo = r.get_char("TIPOC");
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;
}
}
const char tipo = r.get_char("TIPOC");
if (tipo == ' ')
{
TBill c(r.get_int("GRUPPO"), r.get_int("CONTO"), r.get_long("SOTTOCONTO"));
tipoatt = c.tipo_att();
}
}
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
// 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;
if (app().iva() != iva_acquisti)
if (app().iva() == iva_vendite) // Vendite sempre detraibili
return TRUE;
TRegistro& reg = app().causale().reg();
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");
pla.put("CODTAB", chiave);
@ -210,7 +221,7 @@ int TPrimanota_application::det_used(char det) const
TToken_string& row = (TToken_string&)rows[i];
if (!row.empty_items())
{
const bool d = detraibile(row.get_int(4));
const bool d = detraibile(row);
if (detraib == d) users++;
}
}
@ -468,12 +479,16 @@ bool TPrimanota_application::cg_notify(int r, KEY k)
case K_ENTER:
if (r == 0 && app().iva() == nessuna_iva && cg.row(1).empty_items())
{
TImporto i; i = row; i.swap_section();
TBill contro(row, 9, 0x3);
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);
TImporto i; i = row;
if (i.valore() != 0.0)
{
i.swap_section();
TBill contro(row, 9, 0x3);
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();
break;
@ -649,7 +664,7 @@ bool TPrimanota_application::iva_notify(int r, KEY k)
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);
if (oldposiva < 0 && oldiva != ZERO)
{
@ -702,7 +717,7 @@ bool TPrimanota_application::iva_notify(int r, KEY k)
// 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);
const char tipod = detrarre ? 'D' : 'N';
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());
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
m.set(cid-1, c.gruppo());
m.set(cid, c.conto());
@ -1127,13 +1142,7 @@ bool TPrimanota_application::main_codiva_handler(TMask_field& f, KEY key)
}
if (!bill.ok())
app().causale().bill(2, bill);
row.add(bill.tipo_cr(), 4);
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);
bill.add_to(row, 4, 0x7);
app().ivas().force_update(0);
iva_notify(0, K_ENTER);
}

View File

@ -118,7 +118,7 @@ protected:
static int type2pos(char tipo);
static const real& cod2IVA(const TMask& m);
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 bill_used(const TBill& conto) const;

View File

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

View File

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

View File

@ -260,8 +260,8 @@ void CG3400_application::user_create()
_cur = new TCursor (_rel, "", 2); // usa la chiave 2 su MOV
_RecPartoDa = new TRectype(_cur->file(LF_MOV));
_RecArrivoA = new TRectype(_cur->file(LF_MOV));
_RecPartoDa = new TRectype(_cur->file(LF_MOV).curr());
_RecArrivoA = new TRectype(_cur->file(LF_MOV).curr());
add_cursor (_cur);
@ -888,13 +888,13 @@ bool CG3400_application::preprocess_page(int file, int counter)
reset_row(2); reset_row(3);
}
g = _cur->file(LF_RMOV)->get_int(RMV_GRUPPO);
c = _cur->file(LF_RMOV)->get_int(RMV_CONTO);
s = _cur->file(LF_RMOV)->get_long(RMV_SOTTOCONTO);
cf = _cur->file(LF_RMOV)->get_char(RMV_TIPOC);
sezione = _cur->file(LF_RMOV)->get_char (RMV_SEZIONE);
importo = _cur->file(LF_RMOV)->get_real (RMV_IMPORTO);
rmv_descr = _cur->file(LF_RMOV)->get(RMV_DESCR);
g = _cur->file(LF_RMOV).get_int(RMV_GRUPPO);
c = _cur->file(LF_RMOV).get_int(RMV_CONTO);
s = _cur->file(LF_RMOV).get_long(RMV_SOTTOCONTO);
cf = _cur->file(LF_RMOV).get_char(RMV_TIPOC);
sezione = _cur->file(LF_RMOV).get_char (RMV_SEZIONE);
importo = _cur->file(LF_RMOV).get_real (RMV_IMPORTO);
rmv_descr = _cur->file(LF_RMOV).get(RMV_DESCR);
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...
{
TLocalisamfile* occ = _cur->file(LF_OCCAS);
TLocalisamfile& occ = _cur->file(LF_OCCAS);
viacf = occ->get (OCC_INDIR);
civcf = occ->get (OCC_CIV);
capcf = occ->get (OCC_CAP);
comcf = occ->get (OCC_COM);
viacf = occ.get (OCC_INDIR);
civcf = occ.get (OCC_CIV);
capcf = occ.get (OCC_CAP);
comcf = occ.get (OCC_COM);
}
else
{

View File

@ -283,7 +283,7 @@ bool CG4300_App::set_liquidazione()
for (i = 0; i < _nomiditte.items(); i++)
{
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 vers = d.get(2);
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)
{
const int cr = tipo_cr();
ts.add(cr > 0 ? format("%d", cr) : "", from++);
ts.add(cr > 0 ? format("%d", cr) : " ", from++);
}
if (mode & 0x1)
ts.add(_tipo, from++);
@ -162,6 +162,22 @@ bool TBill::read(TRectype &r)
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)
const TString& TBill::descrizione()
{

View File

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