fixed bugs
This commit is contained in:
@@ -1367,20 +1367,22 @@ class SingleOrderController extends Controller
|
|||||||
|
|
||||||
foreach ($spreadLines as $line) {
|
foreach ($spreadLines as $line) {
|
||||||
$perUnit = (float) ($line['per_unit'] ?? 0);
|
$perUnit = (float) ($line['per_unit'] ?? 0);
|
||||||
$total = $perUnit * $amount;
|
$total = (int) round($perUnit * $amount);
|
||||||
$spreadTotal += $total;
|
$spreadTotal += $total;
|
||||||
|
$amountLabel = rtrim(rtrim(number_format($amount, 4, '.', ''), '0'), '.');
|
||||||
$receiptLines[] = array_merge($line, [
|
$receiptLines[] = array_merge($line, [
|
||||||
'amount_units' => $amount,
|
'amount_units' => $amount,
|
||||||
'total' => $total,
|
'total' => $total,
|
||||||
'line_text' => ($line['detail'] ?? number_format($perUnit) . ' ریال / گرم')
|
'line_text' => ($line['detail'] ?? number_format($perUnit) . ' ریال / گرم')
|
||||||
. ($amount > 0
|
. ($amount > 0
|
||||||
? (' × ' . rtrim(rtrim(number_format($amount, 4, '.', ''), '0'), '.') . ' گرم = ' . number_format($total) . ' ریال')
|
? (' × ' . $amountLabel . ' گرم = ' . number_format($total) . ' ریال')
|
||||||
: ''),
|
: ''),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// اگر اقلام ذخیره نشده بود، حداقل یک خط از اختلاف واقعی بساز
|
// اگر اقلام ذخیره نشده بود، حداقل یک خط از اختلاف واقعی بساز
|
||||||
if ($receiptLines === [] && $data['fee'] > 0) {
|
if ($receiptLines === [] && $data['fee'] > 0) {
|
||||||
|
$feeTotal = (int) round((float) $data['total_fee']);
|
||||||
$receiptLines[] = [
|
$receiptLines[] = [
|
||||||
'kind' => 'spread',
|
'kind' => 'spread',
|
||||||
'key' => $data['fee_source_key'] ?? 'fee',
|
'key' => $data['fee_source_key'] ?? 'fee',
|
||||||
@@ -1388,17 +1390,17 @@ class SingleOrderController extends Controller
|
|||||||
'is_percent' => false,
|
'is_percent' => false,
|
||||||
'per_unit' => $data['fee'],
|
'per_unit' => $data['fee'],
|
||||||
'amount_units' => $amount,
|
'amount_units' => $amount,
|
||||||
'total' => $data['total_fee'],
|
'total' => $feeTotal,
|
||||||
'detail' => number_format($data['fee']) . ' ریال / گرم',
|
'detail' => number_format($data['fee']) . ' ریال / گرم',
|
||||||
'line_text' => number_format($data['fee']) . ' ریال / گرم × '
|
'line_text' => number_format($data['fee']) . ' ریال / گرم × '
|
||||||
. rtrim(rtrim(number_format($amount, 4, '.', ''), '0'), '.')
|
. rtrim(rtrim(number_format($amount, 4, '.', ''), '0'), '.')
|
||||||
. ' گرم = ' . number_format($data['total_fee']) . ' ریال',
|
. ' گرم = ' . number_format($feeTotal) . ' ریال',
|
||||||
];
|
];
|
||||||
$spreadTotal = (float) $data['total_fee'];
|
$spreadTotal = $feeTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
$scGold = (float) ($data['service_charge'] ?? 0);
|
$scGold = (float) ($data['service_charge'] ?? 0);
|
||||||
$scRial = (float) ($data['service_charge_price'] ?? 0);
|
$scRial = (int) round((float) ($data['service_charge_price'] ?? 0));
|
||||||
$scPct = (float) ($data['service_charge_percentage'] ?? 0);
|
$scPct = (float) ($data['service_charge_percentage'] ?? 0);
|
||||||
|
|
||||||
if ($scGold > 0 || $scRial > 0) {
|
if ($scGold > 0 || $scRial > 0) {
|
||||||
@@ -1433,12 +1435,18 @@ class SingleOrderController extends Controller
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$baseTotal = (int) round($amount * $priceOriginal);
|
||||||
|
$customerTotal = (int) round((float) ($data['total_price'] ?? ($amount * $price)));
|
||||||
|
$spreadTotal = (int) round($spreadTotal);
|
||||||
$grandTotal = $spreadTotal + $scRial;
|
$grandTotal = $spreadTotal + $scRial;
|
||||||
|
|
||||||
$data['fee_breakdown'] = [
|
$data['fee_breakdown'] = [
|
||||||
'uses_app_price' => (bool) ($data['_fee_uses_app_price'] ?? false),
|
'uses_app_price' => (bool) ($data['_fee_uses_app_price'] ?? false),
|
||||||
'amount_units' => $amount,
|
'amount_units' => $amount,
|
||||||
'price_original' => $priceOriginal,
|
'price_original' => $priceOriginal,
|
||||||
'price_customer' => $price,
|
'price_customer' => $price,
|
||||||
|
'base_total' => $baseTotal,
|
||||||
|
'customer_total' => $customerTotal,
|
||||||
'spread_per_unit' => (float) $data['fee'],
|
'spread_per_unit' => (float) $data['fee'],
|
||||||
'spread_total' => $spreadTotal,
|
'spread_total' => $spreadTotal,
|
||||||
'service_charge_gold' => $scGold,
|
'service_charge_gold' => $scGold,
|
||||||
|
|||||||
Reference in New Issue
Block a user