2
0
forked from Wavyzz/dolibarr

ER: Review & add a totalVAT in pdf

This commit is contained in:
aspangaro
2015-05-14 08:26:41 +02:00
parent bba0349ab6
commit 766c58724a
3 changed files with 45 additions and 36 deletions

View File

@@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -23,9 +24,9 @@
*/ */
require_once DOL_DOCUMENT_ROOT.'/core/modules/expensereport/modules_expensereport.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/expensereport/modules_expensereport.php';
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php"); require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'); require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
@@ -252,7 +253,7 @@ class pdf_standard extends ModeleExpenseReport
$tab_height = 110; $tab_height = 110;
$tab_height_newpage = 110; $tab_height_newpage = 110;
// Affiche notes // Show notes
$notetoshow=empty($object->note_public)?'':$object->note_public; $notetoshow=empty($object->note_public)?'':$object->note_public;
if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
{ {
@@ -340,9 +341,10 @@ class pdf_standard extends ModeleExpenseReport
$pdf->MultiCell($this->posxtva-$this->posxprojet-1, 3,$object->lines[$i]->projet_ref, 0, 'C'); $pdf->MultiCell($this->posxtva-$this->posxprojet-1, 3,$object->lines[$i]->projet_ref, 0, 'C');
// VAT Rate // VAT Rate
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY($this->posxtva, $curY); $pdf->SetXY($this->posxtva, $curY);
$pdf->MultiCell($this->posxup-$this->posxtva-1, 3,vatrate($object->lines[$i]->tva_taux,true), 0, 'R'); $pdf->MultiCell($this->posxup-$this->posxtva-1, 3,$vat_rate, 0, 'R');
// Unit price // Unit price
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
@@ -439,6 +441,13 @@ class pdf_standard extends ModeleExpenseReport
$pdf->MultiCell($this->page_largeur - $this->marge_gauche - 160, 5, price($object->total_ht), 1, 'R'); $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 160, 5, price($object->total_ht), 1, 'R');
$pdf->SetFillColor(248,248,248); $pdf->SetFillColor(248,248,248);
$posy+=5;
$pdf->SetXY(100, $posy);
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell(60, 5, $outputlangs->transnoentities("TotalVAT"), 1,'L');
$pdf->SetXY(160, $posy);
$pdf->MultiCell($this->page_largeur - $this->marge_gauche - 160, 5, price($object->total_tva),1, 'R');
$posy+=5; $posy+=5;
$pdf->SetXY(100, $posy); $pdf->SetXY(100, $posy);
$pdf->SetFont('','B', 10); $pdf->SetFont('','B', 10);
@@ -766,7 +775,7 @@ class pdf_standard extends ModeleExpenseReport
// Unit price // Unit price
$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
$pdf->SetXY($this->posxup-1, $tab_top+1); $pdf->SetXY($this->posxup-1, $tab_top+1);
$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("UP"),'','C'); $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceU"),'','C');
// Quantity // Quantity
$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);

View File

@@ -879,7 +879,7 @@ if ($action == "addline")
$tmp = calcul_price_total($qty, $up, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type); $tmp = calcul_price_total($qty, $up, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type);
$object_ligne->total_ttc = $tmp[2]; $object_ligne->total_ttc = $tmp[2];
$object_ligne->tva_taux = GETPOST('vatrate'); $object_ligne->tva_tx = GETPOST('vatrate');
$object_ligne->total_ht = $tmp[0]; $object_ligne->total_ht = $tmp[0];
$object_ligne->total_tva = $tmp[1]; $object_ligne->total_tva = $tmp[1];
@@ -1008,9 +1008,9 @@ if ($action == "updateligne" )
/* /*
* Generer ou regenerer le document PDF * Generate or regenerate the PDF document
*/ */
if ($action == 'builddoc') // En get ou en post if ($action == 'builddoc') // GET or POST
{ {
$depl = new ExpenseReport($db, 0, $_GET['id']); $depl = new ExpenseReport($db, 0, $_GET['id']);
$depl->fetch($id); $depl->fetch($id);
@@ -1639,7 +1639,7 @@ else
$formproject->select_projects(-1, $objp->fk_projet,'fk_projet', 0, 0, 0, 1); $formproject->select_projects(-1, $objp->fk_projet,'fk_projet', 0, 0, 0, 1);
print '</td>'; print '</td>';
// Sélect type // Select type
print '<td style="text-align:center;">'; print '<td style="text-align:center;">';
select_type_fees_id($objp->type_fees_code,'fk_c_type_fees'); select_type_fees_id($objp->type_fees_code,'fk_c_type_fees');
print '</td>'; print '</td>';
@@ -1649,17 +1649,17 @@ else
print '<textarea class="flat_ndf" name="comments" class="centpercent">'.$objp->comments.'</textarea>'; print '<textarea class="flat_ndf" name="comments" class="centpercent">'.$objp->comments.'</textarea>';
print '</td>'; print '</td>';
// Sélection TVA // Select VAT
print '<td style="text-align:right;">'; print '<td style="text-align:right;">';
print $form->load_tva('fk_c_tva', (isset($_POST["fk_c_tva"])?$_POST["fk_c_tva"]:$objp->tva_taux), $mysoc, ''); print $form->load_tva('fk_c_tva', (isset($_POST["fk_c_tva"])?$_POST["fk_c_tva"]:$objp->tva_tx), $mysoc, '');
print '</td>'; print '</td>';
// Prix unitaire // Unit price
print '<td style="text-align:right;">'; print '<td style="text-align:right;">';
print '<input type="text" size="6" name="value_unit" value="'.$objp->value_unit.'" />'; print '<input type="text" size="6" name="value_unit" value="'.$objp->value_unit.'" />';
print '</td>'; print '</td>';
// Quantité // Quantity
print '<td style="text-align:right;">'; print '<td style="text-align:right;">';
print '<input type="text" size="4" name="qty" value="'.$objp->qty.'" />'; print '<input type="text" size="4" name="qty" value="'.$objp->qty.'" />';
print '</td>'; print '</td>';
@@ -1744,7 +1744,7 @@ else
print '</select>'; print '</select>';
print '</td>'; print '</td>';
// Prix unitaire // Unit price
print '<td style="text-align:right;">'; print '<td style="text-align:right;">';
print '<input type="text" size="6" name="value_unit" value="'.GETPOST('value_unit').'">'; print '<input type="text" size="6" name="value_unit" value="'.GETPOST('value_unit').'">';
print '</td>'; print '</td>';
@@ -1805,7 +1805,7 @@ if ($action != 'create' && $action != 'edit')
{ {
if ($object->fk_user_author == $user->id) if ($object->fk_user_author == $user->id)
{ {
// Modifier // Modify
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>';
// Validate // Validate
@@ -1816,7 +1816,7 @@ if ($action != 'create' && $action != 'edit')
if ($user->rights->expensereport->supprimer) if ($user->rights->expensereport->supprimer)
{ {
// Supprimer // Delete
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
} }
} }
@@ -1831,7 +1831,7 @@ if ($action != 'create' && $action != 'edit')
{ {
if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
{ {
// Modifier // Modify
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>';
// Brouillonner (le statut refusée est identique à brouillon) // Brouillonner (le statut refusée est identique à brouillon)
@@ -1841,7 +1841,7 @@ if ($action != 'create' && $action != 'edit')
if ($user->rights->expensereport->supprimer) if ($user->rights->expensereport->supprimer)
{ {
// Supprimer // Delete
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
} }
} }
@@ -1874,9 +1874,9 @@ if ($action != 'create' && $action != 'edit')
{ {
//if($object->fk_user_validator==$user->id) //if($object->fk_user_validator==$user->id)
//{ //{
// Valider // Validate
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=validate&id='.$id.'">'.$langs->trans('Approve').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=validate&id='.$id.'">'.$langs->trans('Approve').'</a>';
// Refuser // Deny
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=refuse&id='.$id.'">'.$langs->trans('Deny').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=refuse&id='.$id.'">'.$langs->trans('Deny').'</a>';
//} //}
@@ -1888,7 +1888,7 @@ if ($action != 'create' && $action != 'edit')
if($user->rights->expensereport->supprimer) if($user->rights->expensereport->supprimer)
{ {
// Supprimer // Delete
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
} }
} }
@@ -1899,7 +1899,7 @@ if ($action != 'create' && $action != 'edit')
*/ */
if ($user->rights->expensereport->to_paid && $object->fk_statut == 5) if ($user->rights->expensereport->to_paid && $object->fk_statut == 5)
{ {
// Payer // Pay
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=paid&id='.$id.'">'.$langs->trans('TO_PAID').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=paid&id='.$id.'">'.$langs->trans('TO_PAID').'</a>';
// Cancel // Cancel
@@ -1910,7 +1910,7 @@ if ($action != 'create' && $action != 'edit')
if($user->rights->expensereport->supprimer) if($user->rights->expensereport->supprimer)
{ {
// Supprimer // Delete
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
} }
} }
@@ -1922,11 +1922,11 @@ if ($action != 'create' && $action != 'edit')
*/ */
if ($user->rights->expensereport->approve && $user->rights->expensereport->to_paid && $object->fk_statut==6) if ($user->rights->expensereport->approve && $user->rights->expensereport->to_paid && $object->fk_statut==6)
{ {
// Annuler // Cancel
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&id='.$id.'">'.$langs->trans('Cancel').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&id='.$id.'">'.$langs->trans('Cancel').'</a>';
if($user->rights->expensereport->supprimer) if($user->rights->expensereport->supprimer)
{ {
// Supprimer // Delete
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
} }
} }
@@ -1944,7 +1944,7 @@ if ($action != 'create' && $action != 'edit')
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$id.'">'.$langs->trans('ReOpen').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$id.'">'.$langs->trans('ReOpen').'</a>';
} }
// Supprimer // Delete
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
} }
@@ -1959,7 +1959,7 @@ print '</div>';
print '<div style="width:50%">'; print '<div style="width:50%">';
/* /*
* Documents generes * Generate documents
*/ */
if($user->rights->expensereport->export && $object->fk_statut>0 && $action != 'edit') if($user->rights->expensereport->export && $object->fk_statut>0 && $action != 'edit')
{ {

View File

@@ -540,7 +540,7 @@ class ExpenseReport extends CommonObject
$line->total_ttc=120; $line->total_ttc=120;
$line->qty=1; $line->qty=1;
$line->fk_c_tva=20; $line->fk_c_tva=20;
$line->tva_taux=20; $line->tva_tx=20;
$line->value_unit=120; $line->value_unit=120;
$line->fk_expensereport=0; $line->fk_expensereport=0;
$line->type_fees_code='TRA'; $line->type_fees_code='TRA';
@@ -761,7 +761,7 @@ class ExpenseReport extends CommonObject
$deplig->type_fees_code = $objp->code_type_fees; $deplig->type_fees_code = $objp->code_type_fees;
$deplig->type_fees_libelle = $objp->libelle_type_fees; $deplig->type_fees_libelle = $objp->libelle_type_fees;
$deplig->tva_taux = $objp->taux_tva; $deplig->tva_tx = $objp->vatrate;
$deplig->projet_ref = $objp->ref_projet; $deplig->projet_ref = $objp->ref_projet;
$deplig->projet_title = $objp->title_projet; $deplig->projet_title = $objp->title_projet;
@@ -1207,7 +1207,7 @@ class ExpenseReport extends CommonObject
$this->db->begin(); $this->db->begin();
// Select du taux de tva par rapport au code // Select du taux de tva par rapport au code
$sql = "SELECT t.taux as taux_tva"; $sql = "SELECT t.taux as vatrate";
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t"; $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t";
$sql.= " WHERE t.rowid = ".$c_tva; $sql.= " WHERE t.rowid = ".$c_tva;
$result = $this->db->query($sql); $result = $this->db->query($sql);
@@ -1217,7 +1217,7 @@ class ExpenseReport extends CommonObject
$total_ttc = $qty*$value_unit; $total_ttc = $qty*$value_unit;
$total_ttc = number_format($total_ttc,2,'.',''); $total_ttc = number_format($total_ttc,2,'.','');
$tx_tva = $objp_tva->taux_tva/100; $tx_tva = $objp_tva->vatrate/100;
$tx_tva = $tx_tva + 1; $tx_tva = $tx_tva + 1;
$total_ht = $total_ttc/$tx_tva; $total_ht = $total_ttc/$tx_tva;
$total_ht = number_format($total_ht,2,'.',''); $total_ht = number_format($total_ht,2,'.','');
@@ -1239,7 +1239,7 @@ class ExpenseReport extends CommonObject
$ligne->total_ht = $total_ht; $ligne->total_ht = $total_ht;
$ligne->total_tva = $total_tva; $ligne->total_tva = $total_tva;
$ligne->total_ttc = $total_ttc; $ligne->total_ttc = $total_ttc;
$ligne->tva_taux = $objp_tva->taux_tva; $ligne->tva_tx = $objp_tva->vatrate;
$ligne->rowid = $rowid; $ligne->rowid = $rowid;
// Select des infos sur le type fees // Select des infos sur le type fees
@@ -1487,7 +1487,7 @@ class ExpenseReportLine
var $projet_ref; var $projet_ref;
var $projet_title; var $projet_title;
var $tva_taux; var $tva_tx;
var $total_ht; var $total_ht;
var $total_tva; var $total_tva;
@@ -1512,7 +1512,7 @@ class ExpenseReportLine
function fetch($rowid) function fetch($rowid)
{ {
$sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_projet, fde.date,'; $sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_projet, fde.date,';
$sql.= ' fde.fk_c_tva as tva_taux, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,'; $sql.= ' fde.fk_c_tva as tva_tx, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,';
$sql.= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,'; $sql.= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,';
$sql.= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref'; $sql.= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref';
$sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde'; $sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde';
@@ -1539,7 +1539,7 @@ class ExpenseReportLine
$this->type_fees_libelle = $objp->type_fees_libelle; $this->type_fees_libelle = $objp->type_fees_libelle;
$this->projet_ref = $objp->projet_ref; $this->projet_ref = $objp->projet_ref;
$this->projet_title = $objp->projet_title; $this->projet_title = $objp->projet_title;
$this->tva_taux = $objp->tva_taux; $this->tva_tx = $objp->tva_tx;
$this->total_ht = $objp->total_ht; $this->total_ht = $objp->total_ht;
$this->total_tva = $objp->total_tva; $this->total_tva = $objp->total_tva;
$this->total_ttc = $objp->total_ttc; $this->total_ttc = $objp->total_ttc;