mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-05 09:08:09 +01:00
Merge pull request #449 from marcosgdf/odt-discounts
Created function to retrieve total discounted amount of a commonobject
This commit is contained in:
@@ -54,6 +54,8 @@ For users:
|
||||
- New: [ task #210 ] Can choose cash account during POS login
|
||||
- New: [ task #104 ] Can create an invoice from several orders
|
||||
- New: Update libs/tools/logo for DoliWamp (now use PHP 5.3).
|
||||
- New: Added ODT Template tag {object_total_discount}
|
||||
|
||||
New experimental modules:
|
||||
- New: Add margin management module.
|
||||
- New: Add commissions management module.
|
||||
@@ -81,6 +83,7 @@ For developers:
|
||||
expedition, order supplier and order invoice (lines included), intervention card, project, tasks.
|
||||
- New: Add ChromePHP output into syslog module.
|
||||
- New: Add PRODUCT_PRICE_MODIFY trigger.
|
||||
- New: Created function to retrieve total amount of discount of an invoice/proposal...
|
||||
|
||||
For translators:
|
||||
- New: Update language files (de, tr, pt, ca, es, en, fr).
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
|
||||
*
|
||||
* 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
|
||||
@@ -2214,6 +2215,27 @@ abstract class CommonObject
|
||||
return $nb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that returns the total amount of discounts applied.
|
||||
*
|
||||
* @return false|float False is returned if the discount couldn't be retrieved
|
||||
*/
|
||||
function getTotalDiscount()
|
||||
{
|
||||
$sql = 'SELECT (SUM(`subprice`) - SUM(`total_ht`)) as `discount` FROM '.MAIN_DB_PREFIX.$this->table_element.'det WHERE `'.$this->fk_element.'` = '.$this->id;
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$result = $this->db->fetch_object($query);
|
||||
|
||||
return price2num($result->discount);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set extra parameters
|
||||
*
|
||||
|
||||
@@ -115,6 +115,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
||||
'object_total_ht'=>price($object->total_ht,0,$outputlangs),
|
||||
'object_total_vat'=>price($object->total_tva,0,$outputlangs),
|
||||
'object_total_ttc'=>price($object->total_ttc,0,$outputlangs),
|
||||
'object_total_discount' => price($object->getTotalDiscount(), 0, $outputlangs),
|
||||
'object_vatrate'=>vatrate($object->tva),
|
||||
'object_note_private'=>$object->note,
|
||||
'object_note'=>$object->note_public,
|
||||
|
||||
@@ -124,6 +124,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures
|
||||
'object_total_ht'=>price($object->total_ht,0,$outputlangs),
|
||||
'object_total_vat'=>price($object->total_tva,0,$outputlangs),
|
||||
'object_total_ttc'=>price($object->total_ttc,0,$outputlangs),
|
||||
'object_total_discount' => price($object->getTotalDiscount(), 0, $outputlangs),
|
||||
'object_vatrate'=>(isset($object->tva)?vatrate($object->tva):''),
|
||||
'object_note_private'=>$object->note,
|
||||
'object_note'=>$object->note_public,
|
||||
|
||||
@@ -114,6 +114,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
|
||||
'object_total_ht'=>price($object->total_ht,0,$outputlangs),
|
||||
'object_total_vat'=>price($object->total_tva,0,$outputlangs),
|
||||
'object_total_ttc'=>price($object->total_ttc,0,$outputlangs),
|
||||
'object_total_discount' => price($object->getTotalDiscount(), 0, $outputlangs),
|
||||
'object_vatrate'=>vatrate($object->tva),
|
||||
'object_note_private'=>$object->note,
|
||||
'object_note'=>$object->note_public,
|
||||
|
||||
Reference in New Issue
Block a user