mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
30 lines
982 B
PHP
30 lines
982 B
PHP
<?php
|
|
|
|
namespace App\Classes\Helpers;
|
|
|
|
class InvoiceDocumentsHelper
|
|
{
|
|
public static function calculateSubtotal($po_order_transaction, $currencyRate) {
|
|
$subtotal = "0";
|
|
foreach ($po_order_transaction->transactionDetails as $transaction_detail) {
|
|
$unitPrice = bcdiv((string)$transaction_detail->price, (string)$currencyRate, 5);
|
|
$itemTotal = bcmul($unitPrice, (string)$transaction_detail->quantity, 5);
|
|
$subtotal = bcadd($subtotal, $itemTotal, 5);
|
|
}
|
|
return $subtotal;
|
|
}
|
|
|
|
public static function getVoucherDiscount($voucher_redemption) {
|
|
return $voucher_redemption ? bcmul((string)$voucher_redemption->value, "-1", 2) : "0";
|
|
}
|
|
|
|
public static function roundUp($number, $decimals) {
|
|
$factor = pow(10, $decimals);
|
|
if ($number > 0) {
|
|
return ceil($number * $factor) / $factor;
|
|
} else {
|
|
return floor($number * $factor) / $factor;
|
|
}
|
|
}
|
|
}
|