fix(shayegan): send the customer detail code on account create

Hesabgar fails when it must invent the account number. Send the subsidiary code plus the customer id as AccountNumber.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-02 10:57:57 +03:30
co-authored by Cursor
parent c96e5820fe
commit 1cd6c61e0f
3 changed files with 45 additions and 0 deletions
@@ -3,6 +3,8 @@
فرمت هر خط:
- YYYY-MM-DD | موضوع | مسیر فایل(ها) | نکتهٔ ۱ خطی
- 2026-11-02 | PDF وب‌سرویس شایگان | `docs/shayegan/shayegan.pdf` صفحه ارسال حساب | نمونهٔ رسمی `AccountNumber` نمی‌فرستد؛ `MoinNumber` + `UpdateKind=0` + `AccountTypeId=1`. فرمول `12101530` در PDF نیست
- 2026-11-02 | سه سطح شایگان | `ShayeganSyncService::registerCustomer` + migration `2026_11_02_000001` | کل 121، معین `12101`، تفصیلی = معین+کد کاربری (`12101530`). `1210101` غلط است
- 2026-11-01 | پیامک تبدیل | `CopperConvertRequestService::notifyCustomer` | بعد از تأیید یا رد، پیامک جدا به موبایل مشتری؛ خطا پیامک سفارش را برنمی‌گرداند
- 2026-11-01 | درخواست تبدیل مس | `CopperConvertRequestService` + `copper_convert_requests` + `POST customer/copper-convert-request` + `admin/copper-convert-request/{id}/approve` | تأیید = فروش دارایی و خرید حلقه با quote_unit_price؛ مهاجرت `2026_11_01_000001`
- 2026-10-28 | شایگان کالا/مشتری | `products.shayegan_item_number` + `ShayeganSyncService::registerCustomer` Account/Put + `ensureCustomerAccountNumber` | بانک 10001 و معین 12101 در settings؛ ItemNumber per-product
+4
View File
@@ -121,9 +121,13 @@ class ShayeganSyncService
$name = 'مشتری ' . $customer->id;
}
// کل ۱۲۱ داخل معین است. تفصیلی = معین + کد کاربری. مثال: 12101 و مشتری 530 → 12101530
$requestedAccountNumber = $moinRaw . ((string) (int) $customer->id);
$guid = (string) Str::uuid();
$put = [[
'MoinNumber' => $moinNumber,
'AccountNumber' => $requestedAccountNumber,
'AccountTypeId' => null,
'AccountName' => mb_substr($name, 0, 200),
'Mobile' => trim((string) ($customer->mobile ?? '')) ?: null,
@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
/**
* سه سطح: کل 121، معین 12101، تفصیلی = معین + کد کاربری (12101530).
* مقدار 1210101 اشتباه بود و به 12101 برمی‌گردد. مقدار دیگر دست نمی‌خورد.
*/
return new class extends Migration
{
public function up(): void
{
if (! Schema::hasTable('settings')) {
return;
}
$row = DB::table('settings')->where('key', 'shayegan_moin_customer')->first();
if (! $row) {
return;
}
$current = trim((string) ($row->value ?? ''));
$update = [
'description' => 'معین Account/Put. کل ۱۲۱ داخل همین کد است. شماره تفصیلی = این مقدار + کد کاربری. مثال: 12101 و مشتری 530 → 12101530.',
'updated_at' => now(),
];
if ($current === '' || $current === '1210101') {
$update['value'] = '12101';
}
DB::table('settings')->where('key', 'shayegan_moin_customer')->update($update);
}
public function down(): void
{
}
};