show localtaxes on einstein pdf model
This commit is contained in:
parent
e8e4cc08de
commit
b9cdde88c7
@ -119,6 +119,8 @@ class pdf_einstein extends ModelePDFCommandes
|
|||||||
$this->tva=array();
|
$this->tva=array();
|
||||||
$this->localtax1=array();
|
$this->localtax1=array();
|
||||||
$this->localtax2=array();
|
$this->localtax2=array();
|
||||||
|
$this->localtax1_type=array();
|
||||||
|
$this->localtax2_type=array();
|
||||||
$this->atleastoneratenotnull=0;
|
$this->atleastoneratenotnull=0;
|
||||||
$this->atleastonediscount=0;
|
$this->atleastonediscount=0;
|
||||||
}
|
}
|
||||||
@ -370,16 +372,24 @@ class pdf_einstein extends ModelePDFCommandes
|
|||||||
if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
|
if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
|
||||||
|
|
||||||
$vatrate=(string) $object->lines[$i]->tva_tx;
|
$vatrate=(string) $object->lines[$i]->tva_tx;
|
||||||
$localtax1rate=(string) $object->lines[$i]->localtax1_tx;
|
|
||||||
$localtax2rate=(string) $object->lines[$i]->localtax2_tx;
|
|
||||||
|
|
||||||
if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
|
if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
|
||||||
if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]='';
|
if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]='';
|
||||||
if (! isset($this->localtax1[$localtax1rate])) $this->localtax1[$localtax1rate]='';
|
|
||||||
if (! isset($this->localtax2[$localtax2rate])) $this->localtax2[$localtax2rate]='';
|
|
||||||
$this->tva[$vatrate] += $tvaligne;
|
$this->tva[$vatrate] += $tvaligne;
|
||||||
$this->localtax1[$localtax1rate]+=$localtax1ligne;
|
|
||||||
$this->localtax2[$localtax2rate]+=$localtax2ligne;
|
// Search local taxes
|
||||||
|
$sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
|
||||||
|
$sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$object->client->country_code."'";
|
||||||
|
$sql .= " AND t.taux = ".$vatrate." AND t.active = 1";
|
||||||
|
|
||||||
|
$resqlt=$this->db->query($sql);
|
||||||
|
if ($resqlt)
|
||||||
|
{
|
||||||
|
$objt = $this->db->fetch_object($resqlt);
|
||||||
|
$this->localtax1[$objt->localtax1_type][$objt->localtax1]+=$localtax1ligne;
|
||||||
|
$this->localtax2[$objt->localtax2_type][$objt->localtax2]+=$localtax2ligne;
|
||||||
|
}
|
||||||
|
|
||||||
// Add line
|
// Add line
|
||||||
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
|
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
|
||||||
@ -701,6 +711,84 @@ class pdf_einstein extends ModelePDFCommandes
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//Local tax 1 before VAT
|
||||||
|
if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
|
||||||
|
{
|
||||||
|
foreach( $this->localtax1 as $localtax_type => $localtax_rate ) {
|
||||||
|
switch ($localtax_type) {
|
||||||
|
case '1':
|
||||||
|
case '3':
|
||||||
|
case '5':
|
||||||
|
case '7':
|
||||||
|
continue 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
foreach( $localtax_rate as $tvakey => $tvaval )
|
||||||
|
{
|
||||||
|
if ($tvakey>0) // On affiche pas taux 0
|
||||||
|
{
|
||||||
|
//$this->atleastoneratenotnull++;
|
||||||
|
|
||||||
|
$index++;
|
||||||
|
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
|
||||||
|
|
||||||
|
$tvacompl='';
|
||||||
|
if (preg_match('/\*/',$tvakey))
|
||||||
|
{
|
||||||
|
$tvakey=str_replace('*','',$tvakey);
|
||||||
|
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
|
||||||
|
}
|
||||||
|
$totalvat = $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' ';
|
||||||
|
$totalvat.=vatrate($tvakey,1).$tvacompl;
|
||||||
|
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
|
||||||
|
|
||||||
|
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
|
||||||
|
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Local tax 2 before VAT
|
||||||
|
if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
|
||||||
|
{
|
||||||
|
foreach( $this->localtax2 as $localtax_type => $localtax_rate ) {
|
||||||
|
switch ($localtax_type) {
|
||||||
|
case '1':
|
||||||
|
case '3':
|
||||||
|
case '5':
|
||||||
|
case '7':
|
||||||
|
continue 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
foreach( $localtax_rate as $tvakey => $tvaval )
|
||||||
|
{
|
||||||
|
if ($tvakey>0) // On affiche pas taux 0
|
||||||
|
{
|
||||||
|
//$this->atleastoneratenotnull++;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$index++;
|
||||||
|
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
|
||||||
|
|
||||||
|
$tvacompl='';
|
||||||
|
if (preg_match('/\*/',$tvakey))
|
||||||
|
{
|
||||||
|
$tvakey=str_replace('*','',$tvakey);
|
||||||
|
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
|
||||||
|
}
|
||||||
|
$totalvat = $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code).' ';
|
||||||
|
$totalvat.=vatrate($tvakey,1).$tvacompl;
|
||||||
|
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
|
||||||
|
|
||||||
|
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
|
||||||
|
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// VAT
|
||||||
foreach($this->tva as $tvakey => $tvaval)
|
foreach($this->tva as $tvakey => $tvaval)
|
||||||
{
|
{
|
||||||
if ($tvakey > 0) // On affiche pas taux 0
|
if ($tvakey > 0) // On affiche pas taux 0
|
||||||
@ -724,71 +812,65 @@ class pdf_einstein extends ModelePDFCommandes
|
|||||||
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
|
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (! $this->atleastoneratenotnull) // If no vat at all
|
|
||||||
{
|
|
||||||
$index++;
|
|
||||||
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
|
|
||||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1);
|
|
||||||
|
|
||||||
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
|
//Local tax 1 after VAT
|
||||||
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);
|
if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
|
||||||
|
|
||||||
// Total LocalTax1
|
|
||||||
if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0)
|
|
||||||
{
|
{
|
||||||
$index++;
|
foreach( $this->localtax1 as $localtax_type => $localtax_rate ) {
|
||||||
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
|
switch ($localtax_type) {
|
||||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->country_code), $useborder, 'L', 1);
|
case '2':
|
||||||
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
|
case '4':
|
||||||
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1);
|
case '6':
|
||||||
|
continue 2;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
foreach( $localtax_rate as $tvakey => $tvaval )
|
||||||
// Total LocalTax2
|
|
||||||
if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0)
|
|
||||||
{
|
{
|
||||||
|
if ($tvakey>0) // On affiche pas taux 0
|
||||||
|
{
|
||||||
|
//$this->atleastoneratenotnull++;
|
||||||
|
|
||||||
$index++;
|
$index++;
|
||||||
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
|
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
|
||||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->country_code), $useborder, 'L', 1);
|
|
||||||
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
|
$tvacompl='';
|
||||||
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1);
|
if (preg_match('/\*/',$tvakey))
|
||||||
|
{
|
||||||
|
$tvakey=str_replace('*','',$tvakey);
|
||||||
|
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
|
||||||
}
|
}
|
||||||
|
$totalvat = $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' ';
|
||||||
|
if ($localtax_type == '7') { // amount on order
|
||||||
|
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
|
||||||
|
|
||||||
|
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
|
||||||
|
$pdf->MultiCell($largcol2, $tab2_hl, price($tvakey), 0, 'R', 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
|
|
||||||
{
|
|
||||||
//Local tax 1
|
|
||||||
foreach($this->localtax1 as $tvakey => $tvaval)
|
|
||||||
{
|
|
||||||
if ($tvakey!=0) // On affiche pas taux 0
|
|
||||||
{
|
|
||||||
//$this->atleastoneratenotnull++;
|
|
||||||
|
|
||||||
$index++;
|
|
||||||
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
|
|
||||||
|
|
||||||
$tvacompl='';
|
|
||||||
if (preg_match('/\*/',$tvakey))
|
|
||||||
{
|
|
||||||
$tvakey=str_replace('*','',$tvakey);
|
|
||||||
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
|
|
||||||
}
|
|
||||||
$totalvat =$outputlangs->transnoentities("TotalLT1".$mysoc->country_code).' ';
|
|
||||||
$totalvat.=vatrate($tvakey,1).$tvacompl;
|
$totalvat.=vatrate($tvakey,1).$tvacompl;
|
||||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
|
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
|
||||||
|
|
||||||
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
|
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
|
||||||
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
|
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Local tax 2 after VAT
|
||||||
if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
|
if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
|
||||||
{
|
{
|
||||||
//Local tax 2
|
foreach( $this->localtax2 as $localtax_type => $localtax_rate ) {
|
||||||
foreach($this->localtax2 as $tvakey => $tvaval)
|
switch ($localtax_type) {
|
||||||
|
case '2':
|
||||||
|
case '4':
|
||||||
|
case '6':
|
||||||
|
continue 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
foreach( $localtax_rate as $tvakey => $tvaval )
|
||||||
{
|
{
|
||||||
if ($tvakey!=0) // On affiche pas taux 0
|
if ($tvakey>0) // On affiche pas taux 0
|
||||||
{
|
{
|
||||||
//$this->atleastoneratenotnull++;
|
//$this->atleastoneratenotnull++;
|
||||||
|
|
||||||
@ -801,7 +883,15 @@ class pdf_einstein extends ModelePDFCommandes
|
|||||||
$tvakey=str_replace('*','',$tvakey);
|
$tvakey=str_replace('*','',$tvakey);
|
||||||
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
|
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
|
||||||
}
|
}
|
||||||
$totalvat =$outputlangs->transnoentities("TotalLT2".$mysoc->country_code).' ';
|
$totalvat = $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code).' ';
|
||||||
|
|
||||||
|
if ($localtax_type == '7') { // amount on order
|
||||||
|
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
|
||||||
|
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
|
||||||
|
$pdf->MultiCell($largcol2, $tab2_hl, price($tvakey), 0, 'R', 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$totalvat.=vatrate($tvakey,1).$tvacompl;
|
$totalvat.=vatrate($tvakey,1).$tvacompl;
|
||||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
|
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
|
||||||
|
|
||||||
@ -811,6 +901,7 @@ class pdf_einstein extends ModelePDFCommandes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Total TTC
|
// Total TTC
|
||||||
$index++;
|
$index++;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user