fixed some bugs

This commit is contained in:
2026-07-23 17:53:10 +03:30
parent a405075230
commit d8b685524b
3 changed files with 15 additions and 17 deletions
@@ -1490,12 +1490,15 @@ class SingleOrderController extends Controller
$scPct = (float) ($data['service_charge_percentage'] ?? 0);
if ($scGold > 0 || $scRial > 0) {
$feeAsset = (string) ($data['fee_asset'] ?? 'rial');
$fromMetal = $feeAsset === 'gold';
$assetLabel = $fromMetal ? 'از فلز/مقدار' : 'از ریال';
$goldLabel = rtrim(rtrim(number_format($scGold, 4, '.', ''), '0'), '.') . ' گرم';
$detailParts = [];
if ($scPct > 0) {
$detailParts[] = rtrim(rtrim(number_format($scPct, 4, '.', ''), '0'), '.') . '%';
}
if ($scGold > 0 && $priceOriginal > 0) {
if ($fromMetal && $scGold > 0 && $priceOriginal > 0) {
$detailParts[] = $goldLabel . ' × ' . number_format($priceOriginal) . ' = ' . number_format($scRial) . ' ریال';
} elseif ($scRial > 0 && $priceOriginal > 0) {
$goldEquiv = $scRial / $priceOriginal;
@@ -1504,15 +1507,17 @@ class SingleOrderController extends Controller
} else {
$detailParts[] = number_format($scRial) . ' ریال';
}
$detailParts[] = $assetLabel;
$receiptLines[] = [
'kind' => 'service_charge',
'key' => 'service_charge',
'label' => 'کارمزد معامله',
'label' => 'کارمزد معامله · ' . $assetLabel,
'is_percent' => $scPct > 0,
'raw' => $scPct,
'gold' => $scGold,
'rial' => $scRial,
'fee_asset' => $feeAsset,
'per_unit' => $amount > 0 ? ($scRial / $amount) : 0,
'amount_units' => $amount,
'total' => $scRial,