32ac934b35
- L'indirizzo dei percipienti ora viene troncato a 30 caratteri anziche' a 20 - La firma ora viene stampata alla fine di ogni modulo, mentre i totali solo a fine dichiarazione git-svn-id: svn://10.65.10.50/trunk@3784 c028cbd2-c16b-5b4b-a496-9718f37d4682
344 lines
9.2 KiB
C++
Executable File
344 lines
9.2 KiB
C++
Executable File
///////////////////////////////////////////////////////////
|
|
// Quadro 770/C
|
|
///////////////////////////////////////////////////////////
|
|
|
|
#include "77stqc.h"
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
// Quadro C
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
bool TQuadroC::controlla_percentuale(TCursor& cur, const real& perc_p)
|
|
{
|
|
bool stampa = TRUE;
|
|
|
|
long ditta_p = cur.curr().get_long(QUC_CODDITTA);
|
|
char tipo_p = cur.curr().get_char(QUC_TIPOA);
|
|
long codana_p = cur.curr().get_long(QUC_CODANAGR);
|
|
TString codcaus_p = cur.curr().get (QUC_CODCAUS);
|
|
TString ragsoc_p = get_ragsoc_anagr(tipo_p,codana_p);
|
|
|
|
if (perc_p == ZERO)
|
|
{
|
|
++(cur);
|
|
long ditta = cur.curr().get_long(QUC_CODDITTA);
|
|
char tipo = cur.curr().get_char(QUC_TIPOA);
|
|
long codana = cur.curr().get_long(QUC_CODANAGR);
|
|
TString codcaus = cur.curr().get (QUC_CODCAUS);
|
|
TString ragsoc = get_ragsoc_anagr(tipo,codana);
|
|
real perc = cur.curr().get_real(QUC_PERC);
|
|
|
|
if (ditta == ditta_p && tipo == tipo_p && ragsoc == ragsoc_p
|
|
&& codana == codana_p && codcaus == codcaus_p)
|
|
{
|
|
if (perc != ZERO)
|
|
{
|
|
stampa = FALSE;
|
|
_devo_sommare = TRUE;
|
|
}
|
|
else
|
|
stampa = FALSE;
|
|
}
|
|
--(cur);
|
|
}
|
|
else
|
|
if (perc_p != ZERO)
|
|
{
|
|
++(cur);
|
|
long ditta = cur.curr().get_long(QUC_CODDITTA);
|
|
char tipo = cur.curr().get_char(QUC_TIPOA);
|
|
long codana = cur.curr().get_long(QUC_CODANAGR);
|
|
TString codcaus = cur.curr().get (QUC_CODCAUS);
|
|
TString ragsoc = get_ragsoc_anagr(tipo,codana);
|
|
real perc = cur.curr().get_real(QUC_PERC);
|
|
|
|
if (ditta == ditta_p && tipo == tipo_p && ragsoc == ragsoc_p &&
|
|
codana == codana_p && codcaus == codcaus_p && perc_p == perc)
|
|
stampa = FALSE;
|
|
else
|
|
_devo_sommare = TRUE;
|
|
|
|
--(cur);
|
|
}
|
|
|
|
return stampa;
|
|
}
|
|
|
|
void TQuadroC::leggi_importi()
|
|
{
|
|
TCursor* cur = cursor();
|
|
|
|
_totale += cur->curr().get_real(QUC_TOTALE);
|
|
_contssn += cur->curr().get_real(QUC_CONTSSN);
|
|
_somme += cur->curr().get_real(QUC_SOMME);
|
|
_imponibile += cur->curr().get_real(QUC_IMPONIBILE);
|
|
_ritenute += cur->curr().get_real(QUC_RITENUTE);
|
|
_netto += cur->curr().get_real(QUC_NETTO);
|
|
}
|
|
|
|
void TQuadroC::setta_importi(TPrint_section& body)
|
|
{
|
|
TCursor* cur = cursor();
|
|
|
|
real totale = cur->curr().get_real(QUC_TOTALE);
|
|
real contssn = cur->curr().get_real(QUC_CONTSSN);
|
|
real somme = cur->curr().get_real(QUC_SOMME);
|
|
real imponibile = cur->curr().get_real(QUC_IMPONIBILE);
|
|
real ritenute = cur->curr().get_real(QUC_RITENUTE);
|
|
real netto = cur->curr().get_real(QUC_NETTO);
|
|
|
|
if (_devo_sommare)
|
|
{
|
|
totale += _totale;
|
|
contssn += _contssn;
|
|
somme += _somme;
|
|
imponibile += _imponibile;
|
|
ritenute += _ritenute;
|
|
netto += _netto;
|
|
_devo_sommare = FALSE;
|
|
_totale = ZERO;
|
|
_contssn = ZERO;
|
|
_somme = ZERO;
|
|
_imponibile = ZERO;
|
|
_ritenute = ZERO;
|
|
_netto = ZERO;
|
|
}
|
|
|
|
TForm_item& ftotale = body.find_field(C_TOTALE);
|
|
TForm_item& fcontssn = body.find_field(C_CONTSSN);
|
|
TForm_item& fsomme = body.find_field(C_SOMME);
|
|
TForm_item& fimponibile = body.find_field(C_IMPONIBILE);
|
|
TForm_item& fritenute = body.find_field(C_RITENUTE);
|
|
TForm_item& fnetto = body.find_field(C_NETTO);
|
|
|
|
TString stotale (totale.string());
|
|
TString scontssn (contssn.string());
|
|
TString ssomme (somme.string());
|
|
TString simponibile(imponibile.string());
|
|
TString sritenute (ritenute.string());
|
|
TString snetto (netto.string());
|
|
// Setta i campi
|
|
ftotale.set(stotale);
|
|
fcontssn.set(scontssn);
|
|
fsomme.set(ssomme);
|
|
fimponibile.set(simponibile);
|
|
fritenute.set(sritenute);
|
|
fnetto.set(snetto);
|
|
}
|
|
|
|
void TQuadroC::stampa_corpo(TPrinter& pr)
|
|
{
|
|
TPrint_section& body = section('B', odd_page);
|
|
const int body_righe = body.height();
|
|
body.reset();
|
|
// body.update();
|
|
setta_importi(body);
|
|
body.update();
|
|
// const int body_righe = body.height();
|
|
for (int i=0; i < body_righe; i++)
|
|
{
|
|
pr.print(body.row(i));
|
|
_RigaCorr++;
|
|
}
|
|
body.reset();
|
|
if (usa_progind())
|
|
progind()->addstatus(1);
|
|
}
|
|
|
|
int TQuadroC::elementi_pagina(PaginaQuadro p) const
|
|
{
|
|
const int n[4] = { 6, 10, 10, 9 };
|
|
return n[p-PRIMA];
|
|
}
|
|
|
|
int TQuadroC::prima_riga(PaginaQuadro p) const
|
|
{
|
|
// old return p == PRIMA ? 27 : 8;
|
|
// nik1 return p == PRIMA ? 26 : 7;
|
|
return p == PRIMA ? 26 : 8;
|
|
}
|
|
|
|
bool TQuadroC::print(const long codditta, const long NumFis, const long NumNoFis)
|
|
{
|
|
TCursor& cur = *cursor();
|
|
TPrinter& pr = printer();
|
|
bool stampa = TRUE;
|
|
|
|
if (!InitPrint(codditta))
|
|
return FALSE;
|
|
|
|
// pr.formlen(QA_FORMLEN);
|
|
|
|
int elementi = 0; // Numero di elementi stampati in questa pagina
|
|
int ele_bis = 0;
|
|
bool stampato_ultimo = FALSE;
|
|
bool stampati_totali = FALSE;
|
|
|
|
int pos = 0;
|
|
TDipendenti indice;
|
|
if (quadro() == "A" || quadro() == "B")
|
|
{
|
|
const int i = indice.fill(cur);
|
|
if (i > 0)
|
|
{
|
|
if (usa_progind())
|
|
progind()->addstatus(cur.items()-i); // Segna come elaborati tutti gli ignorati
|
|
|
|
cur = indice[0].pos();
|
|
}
|
|
else
|
|
return FALSE;
|
|
}
|
|
else
|
|
cur = 0;
|
|
|
|
while (!stampati_totali)
|
|
{
|
|
bool stampa = TRUE;
|
|
bool stampero_ultimo = stampato_ultimo == FALSE;
|
|
if (stampero_ultimo)
|
|
{
|
|
if (indice.items() > 0) // Usa indice alternativo
|
|
stampero_ultimo &= pos == indice.items()-1;
|
|
else // Usa indice del cursore
|
|
stampero_ultimo &= cur.pos() == cur.items()-1;
|
|
}
|
|
|
|
_EndPrintDitta=stampato_ultimo;
|
|
switch(_PaginaCorrente)
|
|
{
|
|
case PRIMA:
|
|
pr.formlen(dic_form_len());
|
|
|
|
if (_modulaser)
|
|
ClearFlagModulaser();
|
|
|
|
if (ele_bis == 0)
|
|
{
|
|
stampa_testata(pr);
|
|
if (_PaginaPosizionamento)
|
|
jump_to_line(pr, prima_riga(PRIMA));
|
|
else
|
|
jump_to_line(pr, prima_riga(PRIMA)+HEADER_PRIMA_NOPOS);
|
|
}
|
|
|
|
if (!stampato_ultimo)
|
|
{
|
|
real perc_p = cur.curr().get_real(QUC_PERC);
|
|
stampa = controlla_percentuale(cur,perc_p);
|
|
if (stampa)
|
|
stampa_corpo(pr);
|
|
else
|
|
{
|
|
leggi_importi();
|
|
elementi--;
|
|
}
|
|
stampato_ultimo = stampero_ultimo;
|
|
}
|
|
|
|
elementi++;
|
|
ele_bis++;
|
|
if (elementi >= elementi_pagina(PRIMA))
|
|
{
|
|
next_page(pr);
|
|
elementi = 0;
|
|
ele_bis = 0;
|
|
}
|
|
break;
|
|
case SECONDA:
|
|
case TERZA:
|
|
_PaginaPosizionamento=FALSE;
|
|
pr.formlen(dic_form_len());
|
|
if (!stampato_ultimo)
|
|
{
|
|
if (ele_bis == 0)
|
|
jump_to_line(pr, prima_riga(_PaginaCorrente));
|
|
|
|
real perc_p = cur.curr().get_real(QUC_PERC);
|
|
stampa = controlla_percentuale(cur,perc_p);
|
|
if (stampa)
|
|
stampa_corpo(pr);
|
|
else
|
|
{
|
|
leggi_importi();
|
|
elementi--;
|
|
}
|
|
stampato_ultimo = stampero_ultimo;
|
|
}
|
|
elementi++;
|
|
ele_bis++;
|
|
if (elementi >= elementi_pagina(_PaginaCorrente))
|
|
{
|
|
next_page(pr);
|
|
elementi = 0;
|
|
ele_bis = 0;
|
|
}
|
|
break;
|
|
case QUARTA:
|
|
pr.formlen(dic_form_len());
|
|
if (!stampato_ultimo)
|
|
{
|
|
if (ele_bis == 0)
|
|
jump_to_line(pr, prima_riga(QUARTA));
|
|
|
|
real perc_p = cur.curr().get_real(QUC_PERC);
|
|
stampa = controlla_percentuale(cur,perc_p);
|
|
if (stampa)
|
|
stampa_corpo(pr);
|
|
else
|
|
{
|
|
leggi_importi();
|
|
elementi--;
|
|
}
|
|
stampato_ultimo = stampero_ultimo;
|
|
}
|
|
|
|
elementi++;
|
|
ele_bis++;
|
|
|
|
if (elementi >= elementi_pagina(QUARTA))
|
|
{
|
|
jump_to_line(pr, riga_totali(QUARTA));
|
|
if (stampato_ultimo)
|
|
{
|
|
stampa_totali(pr); // Stampa totali e firma
|
|
stampati_totali = TRUE;
|
|
}
|
|
else
|
|
stampa_firma(pr); // Stampa solo la firma
|
|
|
|
next_page(pr);
|
|
elementi = 0;
|
|
ele_bis = 0;
|
|
}
|
|
break;
|
|
default:
|
|
CHECK(0, "Invalid Quadro A page");
|
|
break;
|
|
}
|
|
|
|
if (!stampato_ultimo)
|
|
{
|
|
if (indice.items() > 0)
|
|
cur = indice[++pos].pos();
|
|
else
|
|
++cur;
|
|
}
|
|
}
|
|
|
|
close_print();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool TStampaQuadroC::user_create()
|
|
{
|
|
_form = new TQuadroC("77QC", quadro());
|
|
|
|
TString sortkey(80);
|
|
sortkey.format("CODDITTA|TIPOA|216@->RAGSOC|CODANAGR|CODCAUS|PERC", LF_QUAC, LF_QUAC);
|
|
_cur = new TSorted_cursor(_form->TForm::relation(), sortkey);
|
|
|
|
return TRUE;
|
|
}
|