changed logic in production order importer #1558

Merged
jothi merged 1 commits from ranjith-dev into master 2026-11-30 06:24:43 +00:00

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);