feat: update sms units to kilogram transactions notes price source label and trading closed message

This commit is contained in:
2026-11-18 18:25:34 +03:30
parent 0004192cbc
commit 3ce2c48438
19 changed files with 382 additions and 49 deletions
+18 -4
View File
@@ -2,7 +2,9 @@
namespace App\Services;
use App\Http\Controllers\Controller;
use App\Models\Order;
use App\Models\Product;
use App\Models\TransactionsAdmin;
use Throwable;
@@ -38,7 +40,7 @@ class AccountingLedgerService
'wallet' => null,
'transaction_id' => null,
'cash' => (int) round((float) ($order->total_price ?? 0)),
'note' => $this->tradeNote((int) ($order->direction ?? 0)),
'note' => $this->tradeNote((int) ($order->direction ?? 0), $order),
'type' => 1,
'gold' => (float) ($order->amount ?? 0),
'balance_cash' => 0,
@@ -51,9 +53,21 @@ class AccountingLedgerService
}
}
/** توضیح سند معامله — همسان با desc ته‌حساب تا گزارشات و حسابداری یکی دیده شوند. */
public function tradeNote(int $direction): string
/** توضیح سند معامله — بر اساس نام محصول سفارش */
public function tradeNote(int $direction, ?Order $order = null): string
{
return $direction === 1 ? 'خرید آبشده' : ($direction === 2 ? 'فروش آبشده' : 'معامله');
$productTitle = null;
if ($order) {
$productTitle = $order->product?->title;
if (! $productTitle && $order->product_id) {
$productTitle = Product::query()->whereKey($order->product_id)->value('title');
}
}
$productTitle = trim((string) $productTitle);
if ($productTitle === '') {
$productTitle = Controller::mainWalletProductLabel() ?: 'مس';
}
return $direction === 1 ? ('خرید ' . $productTitle) : ($direction === 2 ? ('فروش ' . $productTitle) : 'معامله');
}
}