changed logic in production order importer
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 17s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 19s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 16s
Laravel Pint / pint (pull_request) Successful in 4m19s
Laravel Larastan / larastan (pull_request) Failing after 4m39s

This commit is contained in:
dhanabalan
2026-11-30 11:54:26 +05:30
parent a513843bf1
commit 78b1aa6869

View File

@@ -251,10 +251,20 @@ class ProductionOrderImporter extends Importer
$prodOrd = $prefix.$nextSeq;
}
$prefixSerial = $plantCod.$year.$month;
$wareHouseNo = $plant->warehouse_number ?? null;
$prefixSerial = $plantCod.$wareHouseNo.$year.$month;
$last = ProductionOrder::where('to_serial_number', 'like', "{$prefixSerial}%")->orderByDesc('to_serial_number')->first();
if (!$last && !empty($wareHouseNo)) {
$oldPrefixSerial = $plantCod . $year . $month;
$last = ProductionOrder::where('to_serial_number', 'like', "{$oldPrefixSerial}%")
->orderByDesc('to_serial_number')
->first();
}
if ($last) {
$lastSeq = (int) substr($last->to_serial_number, -6);
$startSeq = str_pad(($lastSeq + 1), 6, '0', STR_PAD_LEFT);