[-] BO : #PSCFV-3112 - Fix bug with payment by cheque and multishipping
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@16294 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -27,6 +27,10 @@
|
||||
|
||||
class OrderInvoiceCore extends ObjectModel
|
||||
{
|
||||
const TAX_EXCL = 0;
|
||||
const TAX_INCL = 1;
|
||||
const DETAIL = 2;
|
||||
|
||||
/** @var integer */
|
||||
public $id_order;
|
||||
|
||||
@@ -496,7 +500,68 @@ class OrderInvoiceCore extends ObjectModel
|
||||
*/
|
||||
public function getRestPaid()
|
||||
{
|
||||
return round($this->total_paid_tax_incl - $this->getTotalPaid(), 2);
|
||||
return round($this->total_paid_tax_incl + $this->getSiblingTotal() - $this->getTotalPaid(), 2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return collection of order invoice object linked to the payments of the current order invoice object
|
||||
*
|
||||
* @since 1.5.0.14
|
||||
*/
|
||||
public function getSibling()
|
||||
{
|
||||
$query = new DbQuery();
|
||||
$query->select('oip2.id_order_invoice');
|
||||
$query->from('order_invoice_payment', 'oip1');
|
||||
$query->innerJoin('order_invoice_payment', 'oip2',
|
||||
'oip2.id_order_payment = oip1.id_order_payment AND oip2.id_order_invoice <> oip1.id_order_invoice');
|
||||
$query->where('oip1.id_order_invoice = '.$this->id);
|
||||
|
||||
$invoices = Db::getInstance()->executeS($query);
|
||||
if (!$invoices)
|
||||
return array();
|
||||
|
||||
$invoice_list = array();
|
||||
foreach ($invoices as $invoice)
|
||||
$invoice_list[] = $invoice['id_order_invoice'];
|
||||
|
||||
$payments = new Collection('OrderInvoice');
|
||||
$payments->where('id_order_invoice', 'IN', $invoice_list);
|
||||
|
||||
return $payments;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return total to paid of sibling invoices
|
||||
*
|
||||
* @param int $mod TAX_EXCL, TAX_INCL, DETAIL
|
||||
*
|
||||
* @since 1.5.0.14
|
||||
*/
|
||||
public function getSiblingTotal($mod = OrderInvoice::TAX_INCL)
|
||||
{
|
||||
$query = new DbQuery();
|
||||
$query->select('SUM(oi.total_paid_tax_incl) as total_paid_tax_incl, SUM(oi.total_paid_tax_excl) as total_paid_tax_excl');
|
||||
$query->from('order_invoice_payment', 'oip1');
|
||||
$query->innerJoin('order_invoice_payment', 'oip2',
|
||||
'oip2.id_order_payment = oip1.id_order_payment AND oip2.id_order_invoice <> oip1.id_order_invoice');
|
||||
$query->leftJoin('order_invoice', 'oi',
|
||||
'oi.id_order_invoice = oip2.id_order_invoice');
|
||||
$query->where('oip1.id_order_invoice = '.$this->id);
|
||||
|
||||
$row = Db::getInstance()->getRow($query);
|
||||
|
||||
switch ($mod)
|
||||
{
|
||||
case OrderInvoice::TAX_EXCL:
|
||||
return $row['total_paid_tax_excl'];
|
||||
case OrderInvoice::TAX_INCL:
|
||||
return $row['total_paid_tax_incl'];
|
||||
default:
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user