diff --git a/app/Http/Transformers/AccessoriesTransformer.php b/app/Http/Transformers/AccessoriesTransformer.php index deb75fc3db..94e3e8ccf8 100644 --- a/app/Http/Transformers/AccessoriesTransformer.php +++ b/app/Http/Transformers/AccessoriesTransformer.php @@ -59,7 +59,11 @@ class AccessoriesTransformer 'purchase_date' => ($accessory->purchase_date) ? Helper::getFormattedDateObject($accessory->purchase_date, 'date') : null, 'purchase_cost' => Helper::formatCurrencyOutput($accessory->purchase_cost), 'total_cost' => Helper::formatCurrencyOutput($accessory->totalCostSum()), - 'order_number' => ($accessory->order_number) ? e($accessory->order_number) : null, + // Parent-level order_number was renamed to legacy_order_number + // and dropped from the transformer output. Historical order + // numbers now live on QuantityAdjust action_log rows. API + // consumers looking up a PO should query action_logs directly + // or search via free-text (searchableRelations covers it). 'min_qty' => ($accessory->min_amt) ? (int) $accessory->min_amt : null, // Legacy - should phase out - replaced by below, for the bootstrap table formatter 'min_amt' => ($accessory->min_amt) ? (int) $accessory->min_amt : null, 'remaining_qty' => (int) ($accessory->qty - $accessory->checkouts_count), // Legacy - should phase out - replaced by below, for the bootstrap table formatter diff --git a/app/Http/Transformers/ComponentsTransformer.php b/app/Http/Transformers/ComponentsTransformer.php index 68bd29e3a3..cf50c88fca 100644 --- a/app/Http/Transformers/ComponentsTransformer.php +++ b/app/Http/Transformers/ComponentsTransformer.php @@ -51,7 +51,8 @@ class ComponentsTransformer 'tag_color' => $component->manufacturer->tag_color ? e($component->manufacturer->tag_color) : null, ] : null, 'model_number' => ($component->model_number) ? e($component->model_number) : null, - 'order_number' => e($component->order_number), + // See AccessoriesTransformer for why order_number is no longer + // in the parent-level output. 'purchase_date' => Helper::getFormattedDateObject($component->purchase_date, 'date'), 'purchase_cost' => Helper::formatCurrencyOutput($component->purchase_cost), 'total_cost' => Helper::formatCurrencyOutput($component->totalCostSum()), diff --git a/app/Http/Transformers/ConsumablesTransformer.php b/app/Http/Transformers/ConsumablesTransformer.php index 52523b7793..e68ca57677 100644 --- a/app/Http/Transformers/ConsumablesTransformer.php +++ b/app/Http/Transformers/ConsumablesTransformer.php @@ -56,7 +56,8 @@ class ConsumablesTransformer 'model_number' => ($consumable->model_number != '') ? e($consumable->model_number) : null, 'remaining' => $consumable->numRemaining(), 'percent_remaining' => round($consumable->percentRemaining()), - 'order_number' => e($consumable->order_number), + // See AccessoriesTransformer for why order_number is no longer + // in the parent-level output. 'purchase_cost' => Helper::formatCurrencyOutput($consumable->purchase_cost), 'total_cost' => Helper::formatCurrencyOutput($consumable->totalCostSum()), 'purchase_date' => Helper::getFormattedDateObject($consumable->purchase_date, 'date'), diff --git a/app/Models/Accessory.php b/app/Models/Accessory.php index 420851657b..e6bf089c76 100755 --- a/app/Models/Accessory.php +++ b/app/Models/Accessory.php @@ -55,7 +55,6 @@ class Accessory extends SnipeModel 'model_number', 'name', 'notes', - 'order_number', 'purchase_cost', 'purchase_date', ]; @@ -71,6 +70,12 @@ class Accessory extends SnipeModel 'location' => ['name'], 'manufacturer' => ['name'], 'supplier' => ['name'], + // Historical order numbers moved to per-QuantityAdjust action_log + // rows when the parent column was renamed to legacy_order_number. + // Free-text search hits them through the AdjustsQuantity trait's + // quantityAdjustLogs relation so "PO-123" still surfaces any + // accessory replenished under that PO at any point in its life. + 'quantityAdjustLogs' => ['order_number'], ]; protected $searchableCounts = [ @@ -110,7 +115,7 @@ class Accessory extends SnipeModel 'company_id', 'location_id', 'name', - 'order_number', + 'legacy_order_number', 'purchase_cost', 'purchase_date', 'model_number', @@ -403,29 +408,6 @@ class Accessory extends SnipeModel return (int) $this->numCheckedOut(); } - /** - * Hide the parent-level order_number from every read (info panel, - * API output, forms). A single order_number on inventory that gets - * replenished across many POs misrepresents current state — each - * replenishment carries its own on the QuantityAdjust action_log. - * - * The column is also intentionally NOT editable via the edit form - * (form field removed, controller ignores the input). Correction of - * a create-time typo isn't supported today; the plan for that is a - * dedicated Orders model built out from the action_log history if - * customers ask for it. Until then, action_logs are the source of - * truth for order references on these inventory-style models. - * - * Anything that needs the raw stored value must read it via - * getRawOriginal('order_number') or getAttributes()['order_number']. - * Asset is intentionally NOT given this accessor because assets are - * per-unit; a single order_number is genuinely a real property there. - */ - public function getOrderNumberAttribute(): ?string - { - return null; - } - /** * Check how many items of an accessory remain. * diff --git a/app/Models/Component.php b/app/Models/Component.php index 599544ddd4..da432d3f2b 100644 --- a/app/Models/Component.php +++ b/app/Models/Component.php @@ -84,7 +84,7 @@ class Component extends SnipeModel 'purchase_cost', 'purchase_date', 'min_amt', - 'order_number', + 'legacy_order_number', 'qty', 'serial', 'notes', @@ -99,7 +99,6 @@ class Component extends SnipeModel */ protected $searchableAttributes = [ 'name', - 'order_number', 'serial', 'purchase_cost', 'purchase_date', @@ -119,6 +118,10 @@ class Component extends SnipeModel 'supplier' => ['name'], 'manufacturer' => ['name'], 'adminuser' => ['first_name', 'last_name', 'display_name'], + // See Accessory::$searchableRelations for why order_number rides + // through the QuantityAdjust action_log rather than the parent's + // (now legacy_order_number) column. + 'quantityAdjustLogs' => ['order_number'], ]; public static function booted() @@ -323,17 +326,6 @@ class Component extends SnipeModel return (int) $this->numCheckedOut(true); } - /** - * See Accessory::getOrderNumberAttribute for the rationale. Column - * is hidden from every read and no longer editable via the edit - * form; the create-time value is captured onto the create action_log - * and after that adjustments carry their own order_number per event. - */ - public function getOrderNumberAttribute(): ?string - { - return null; - } - /** * @return BelongsToMany * diff --git a/app/Models/Consumable.php b/app/Models/Consumable.php index d36a1eda2f..df2e874321 100644 --- a/app/Models/Consumable.php +++ b/app/Models/Consumable.php @@ -81,7 +81,7 @@ class Consumable extends SnipeModel 'manufacturer_id', 'supplier_id', 'name', - 'order_number', + 'legacy_order_number', 'model_number', 'purchase_cost', 'purchase_date', @@ -100,7 +100,6 @@ class Consumable extends SnipeModel */ protected $searchableAttributes = [ 'name', - 'order_number', 'purchase_cost', 'purchase_date', 'item_no', @@ -120,6 +119,10 @@ class Consumable extends SnipeModel 'manufacturer' => ['name'], 'supplier' => ['name'], 'adminuser' => ['first_name', 'last_name', 'display_name'], + // See Accessory::$searchableRelations for why order_number rides + // through the QuantityAdjust action_log rather than the parent's + // (now legacy_order_number) column. + 'quantityAdjustLogs' => ['order_number'], ]; /** @@ -351,17 +354,6 @@ class Consumable extends SnipeModel return (int) $this->numCheckedOut(); } - /** - * See Accessory::getOrderNumberAttribute for the rationale. Column - * is hidden from every read and no longer editable via the edit - * form; the create-time value is captured onto the create action_log - * and after that adjustments carry their own order_number per event. - */ - public function getOrderNumberAttribute(): ?string - { - return null; - } - /** * Checks the number of available consumables * diff --git a/app/Models/Traits/AdjustsQuantity.php b/app/Models/Traits/AdjustsQuantity.php index 25cb1ad484..0a748451ed 100644 --- a/app/Models/Traits/AdjustsQuantity.php +++ b/app/Models/Traits/AdjustsQuantity.php @@ -5,6 +5,7 @@ namespace App\Models\Traits; use App\Enums\ActionType; use App\Models\Actionlog; use DomainException; +use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Support\Facades\DB; /** @@ -46,6 +47,19 @@ trait AdjustsQuantity return 0; } + /** + * Every QuantityAdjust action_log row for this model. Exposed as a + * relation so free-text search on inventory-style models can hit + * historical order_number values through $searchableRelations even + * though the parent's own order_number column is gone. Also useful + * for the history-tab display and any per-item PO lookup. + */ + public function quantityAdjustLogs(): MorphMany + { + return $this->morphMany(Actionlog::class, 'item') + ->where('action_type', ActionType::QuantityAdjust->value); + } + /** * Apply a signed delta to the on-hand quantity and log the change. * diff --git a/database/factories/AccessoryFactory.php b/database/factories/AccessoryFactory.php index 0d7196cf90..6535c43106 100644 --- a/database/factories/AccessoryFactory.php +++ b/database/factories/AccessoryFactory.php @@ -38,7 +38,6 @@ class AccessoryFactory extends Factory 'category_id' => Category::factory()->forAccessories(), 'model_number' => $this->faker->numberBetween(1000000, 50000000), 'location_id' => Location::factory(), - 'order_number' => $this->faker->regexify('[A-Z]{3}[0-9]{4}'), 'purchase_cost' => $this->faker->randomFloat(2, 5, 250), 'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get())->format('Y-m-d'), 'qty' => 1, diff --git a/database/factories/ComponentFactory.php b/database/factories/ComponentFactory.php index 9b41f6032d..ed639c2cf8 100644 --- a/database/factories/ComponentFactory.php +++ b/database/factories/ComponentFactory.php @@ -38,7 +38,6 @@ class ComponentFactory extends Factory 'min_amt' => $this->faker->numberBetween($min = 1, $max = 2), 'model_number' => $this->faker->numberBetween(1000000, 50000000), 'name' => $this->faker->text(20), - 'order_number' => $this->faker->regexify('[A-Z]{3}[0-9]{4}'), 'purchase_cost' => $this->faker->randomFloat(2), 'purchase_date' => $this->faker->dateTime()->format('Y-m-d'), 'qty' => $this->faker->numberBetween(3, 10), diff --git a/database/factories/ConsumableFactory.php b/database/factories/ConsumableFactory.php index 53759cd670..b6849ae3ef 100644 --- a/database/factories/ConsumableFactory.php +++ b/database/factories/ConsumableFactory.php @@ -34,7 +34,6 @@ class ConsumableFactory extends Factory 'item_no' => $this->faker->numberBetween(1000000, 50000000), 'min_amt' => $this->faker->numberBetween($min = 1, $max = 2), 'name' => $this->faker->words(3, true), - 'order_number' => $this->faker->regexify('[A-Z]{3}[0-9]{4}'), 'purchase_cost' => $this->faker->randomFloat(2, 1, 50), 'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get())->format('Y-m-d'), 'qty' => $this->faker->numberBetween(5, 10), diff --git a/database/migrations/2026_08_03_140000_rename_order_number_to_legacy_on_inventory_tables.php b/database/migrations/2026_08_03_140000_rename_order_number_to_legacy_on_inventory_tables.php new file mode 100644 index 0000000000..ce13781df4 --- /dev/null +++ b/database/migrations/2026_08_03_140000_rename_order_number_to_legacy_on_inventory_tables.php @@ -0,0 +1,40 @@ +renameColumn('order_number', 'legacy_order_number'); + }); + } + } + + public function down(): void + { + foreach (['accessories', 'consumables', 'components'] as $table) { + Schema::table($table, function (Blueprint $t) { + $t->renameColumn('legacy_order_number', 'order_number'); + }); + } + } +}; diff --git a/tests/Feature/Accessories/Api/IndexAccessoryTest.php b/tests/Feature/Accessories/Api/IndexAccessoryTest.php index 28fd52ef3c..9c9082fdc4 100644 --- a/tests/Feature/Accessories/Api/IndexAccessoryTest.php +++ b/tests/Feature/Accessories/Api/IndexAccessoryTest.php @@ -119,7 +119,6 @@ class IndexAccessoryTest extends TestCase implements TestsFullMultipleCompaniesS $targetAccessory = Accessory::factory()->create([ 'name' => 'Target Accessory', 'company_id' => $targetCompany->id, - 'order_number' => 'ORDER-A', 'category_id' => $targetCategory->id, 'manufacturer_id' => $targetManufacturer->id, 'supplier_id' => $targetSupplier->id, @@ -130,7 +129,6 @@ class IndexAccessoryTest extends TestCase implements TestsFullMultipleCompaniesS $otherAccessory = Accessory::factory()->create([ 'name' => 'Other Accessory', 'company_id' => $otherCompany->id, - 'order_number' => 'ORDER-B', 'category_id' => $otherCategory->id, 'manufacturer_id' => $otherManufacturer->id, 'supplier_id' => $otherSupplier->id, @@ -138,9 +136,11 @@ class IndexAccessoryTest extends TestCase implements TestsFullMultipleCompaniesS 'notes' => 'NOTE-B', ]); + // order_number was dropped from the filters list when the parent + // column was renamed to legacy_order_number and current order + // numbers moved to the QuantityAdjust action_log per event. $filters = [ 'company_id' => $targetCompany->id, - 'order_number' => 'ORDER-A', 'category_id' => $targetCategory->id, 'manufacturer_id' => $targetManufacturer->id, 'supplier_id' => $targetSupplier->id, diff --git a/tests/Feature/Accessories/Api/StoreAccessoryTest.php b/tests/Feature/Accessories/Api/StoreAccessoryTest.php index b6104e3e6e..da85ee79b7 100644 --- a/tests/Feature/Accessories/Api/StoreAccessoryTest.php +++ b/tests/Feature/Accessories/Api/StoreAccessoryTest.php @@ -49,11 +49,14 @@ class StoreAccessoryTest extends TestCase implements TestsFullMultipleCompaniesS $manufacturer = Manufacturer::factory()->create(); $supplier = Supplier::factory()->create(); + // order_number in the request body silently drops here — the parent + // column was renamed to legacy_order_number and taken out of the + // fillable set. Real order-number tracking lives on QuantityAdjust + // action_log rows created via the adjust-quantity endpoint. $this->actingAsForApi(User::factory()->createAccessories()->create()) ->postJson(route('api.accessories.store'), [ 'name' => 'My Awesome Accessory', 'qty' => 2, - 'order_number' => '12345', 'purchase_cost' => 100.00, 'purchase_date' => '2024-09-18', 'model_number' => '98765', @@ -67,7 +70,6 @@ class StoreAccessoryTest extends TestCase implements TestsFullMultipleCompaniesS $this->assertDatabaseHas('accessories', [ 'name' => 'My Awesome Accessory', 'qty' => 2, - 'order_number' => '12345', 'purchase_cost' => 100.00, 'purchase_date' => '2024-09-18', 'model_number' => '98765', diff --git a/tests/Feature/Accessories/Api/UpdateAccessoryTest.php b/tests/Feature/Accessories/Api/UpdateAccessoryTest.php index 8a880fc438..b00ee06624 100644 --- a/tests/Feature/Accessories/Api/UpdateAccessoryTest.php +++ b/tests/Feature/Accessories/Api/UpdateAccessoryTest.php @@ -101,7 +101,6 @@ class UpdateAccessoryTest extends TestCase implements TestsFullMultipleCompanies $accessory = Accessory::factory()->create([ 'name' => 'A Name to Change', 'qty' => 5, - 'order_number' => 'A12345', 'purchase_cost' => 99.99, 'model_number' => 'ABC098', 'category_id' => $categoryA->id, @@ -112,11 +111,11 @@ class UpdateAccessoryTest extends TestCase implements TestsFullMultipleCompanies ]); // Payload shape preserved: qty / order_number / supplier_id are - // all accepted on update again. supplier_id writes through to - // the model. qty change routes through adjustQuantity (asserted - // in the dedicated test below). order_number rides on the - // QuantityAdjust log but stays hidden on the parent by the - // model accessor. + // all accepted on update. supplier_id writes through to the model. + // qty change routes through adjustQuantity (asserted in the + // dedicated test below). order_number rides on the QuantityAdjust + // log entry created by that qty change; the parent's own + // legacy_order_number column is not written to on update. $this->actingAsForApi(User::factory()->editAccessories()->create()) ->patchJson(route('api.accessories.update', $accessory), [ 'name' => 'A New Name', @@ -135,7 +134,6 @@ class UpdateAccessoryTest extends TestCase implements TestsFullMultipleCompanies $accessory = $accessory->fresh(); $this->assertEquals('A New Name', $accessory->name); $this->assertEquals(10, $accessory->qty); - $this->assertEquals('A12345', $accessory->getRawOriginal('order_number')); // create-time value; QuantityAdjust log carries the new one $this->assertEquals($supplierB->id, $accessory->supplier_id); $this->assertEquals(199.99, $accessory->purchase_cost); $this->assertEquals('XYZ123', $accessory->model_number); diff --git a/tests/Feature/Accessories/Ui/CreateAccessoriesTest.php b/tests/Feature/Accessories/Ui/CreateAccessoriesTest.php index bb63a62a32..43a7ae898f 100644 --- a/tests/Feature/Accessories/Ui/CreateAccessoriesTest.php +++ b/tests/Feature/Accessories/Ui/CreateAccessoriesTest.php @@ -54,6 +54,10 @@ class CreateAccessoriesTest extends TestCase $manufacturer = Manufacturer::factory()->create(); $supplier = Supplier::factory()->create(); + // order_number was dropped from the create payload when the parent + // column was renamed to legacy_order_number and taken out of + // fillable. Order-number tracking lives on QuantityAdjust action_log + // rows now. $data = [ 'category_id' => $category->id, 'company_id' => $company->id, @@ -63,7 +67,6 @@ class CreateAccessoriesTest extends TestCase 'model_number' => '12345', 'name' => 'My Accessory Name', 'notes' => 'Some notes here', - 'order_number' => '9876', 'purchase_cost' => '99.98', 'purchase_date' => '2024-09-04', 'qty' => '3', diff --git a/tests/Feature/Accessories/Ui/UpdateAccessoryTest.php b/tests/Feature/Accessories/Ui/UpdateAccessoryTest.php index a7625f44f7..9c06716818 100644 --- a/tests/Feature/Accessories/Ui/UpdateAccessoryTest.php +++ b/tests/Feature/Accessories/Ui/UpdateAccessoryTest.php @@ -60,7 +60,6 @@ class UpdateAccessoryTest extends TestCase 'manufacturer_id' => (string) $accessory->manufacturer_id, 'location_id' => (string) $accessory->location_id, 'model_number' => $accessory->model_number, - 'order_number' => $accessory->order_number, 'purchase_date' => $accessory->purchase_date, 'purchase_cost' => $accessory->purchase_cost, 'min_amt' => $accessory->min_amt, @@ -90,13 +89,10 @@ class UpdateAccessoryTest extends TestCase 'qty' => 5, ]); - // qty and order_number are still ignored by the web edit form - // (qty flows through the adjust-quantity modal, order_number - // stays hidden by the model accessor). supplier_id is now - // editable again — imperfect single-value semantics accepted - // for the info-panel display. - $originalOrderNumber = $accessory->getRawOriginal('order_number'); - + // qty is still ignored by the web edit form (flows through the + // adjust-quantity modal). order_number in the POST body silently + // drops because the parent column was renamed to legacy_order_number + // and taken out of fillable. supplier_id is editable again. $this->actingAs(User::factory()->editAccessories()->create()) ->put(route('accessories.update', $accessory), [ 'redirect_option' => 'index', @@ -107,7 +103,6 @@ class UpdateAccessoryTest extends TestCase 'manufacturer_id' => (string) $manufacturerB->id, 'location_id' => (string) $locationB->id, 'model_number' => 'changed 1234', - 'order_number' => 'changed 5678', 'purchase_date' => '2024-10-11', 'purchase_cost' => '83.52', 'qty' => '7', @@ -124,7 +119,6 @@ class UpdateAccessoryTest extends TestCase 'manufacturer_id' => $manufacturerB->id, 'location_id' => $locationB->id, 'model_number' => 'changed 1234', - 'order_number' => $originalOrderNumber, // untouched by update 'purchase_date' => '2024-10-11', 'purchase_cost' => '83.52', 'qty' => '5', // unchanged from factory value; edit ignores qty diff --git a/tests/Feature/Components/Api/ComponentIndexTest.php b/tests/Feature/Components/Api/ComponentIndexTest.php index b0794bb948..46e58c70dd 100644 --- a/tests/Feature/Components/Api/ComponentIndexTest.php +++ b/tests/Feature/Components/Api/ComponentIndexTest.php @@ -77,7 +77,6 @@ class ComponentIndexTest extends TestCase $targetComponent = Component::factory()->create([ 'name' => 'Target Component', 'company_id' => $targetCompany->id, - 'order_number' => 'COMP-ORDER-A', 'category_id' => $targetCategory->id, 'supplier_id' => $targetSupplier->id, 'manufacturer_id' => $targetManufacturer->id, @@ -89,7 +88,6 @@ class ComponentIndexTest extends TestCase $otherComponent = Component::factory()->create([ 'name' => 'Other Component', 'company_id' => $otherCompany->id, - 'order_number' => 'COMP-ORDER-B', 'category_id' => $otherCategory->id, 'supplier_id' => $otherSupplier->id, 'manufacturer_id' => $otherManufacturer->id, @@ -98,10 +96,12 @@ class ComponentIndexTest extends TestCase 'notes' => 'COMP-NOTES-B', ]); + // order_number was dropped from the filters list when the parent + // column was renamed to legacy_order_number and current order + // numbers moved to the QuantityAdjust action_log per event. $filters = [ 'name' => 'Target Component', 'company_id' => $targetCompany->id, - 'order_number' => 'COMP-ORDER-A', 'category_id' => $targetCategory->id, 'supplier_id' => $targetSupplier->id, 'manufacturer_id' => $targetManufacturer->id, diff --git a/tests/Feature/Consumables/Api/ConsumableIndexTest.php b/tests/Feature/Consumables/Api/ConsumableIndexTest.php index e4316c79e4..f4e24802e9 100644 --- a/tests/Feature/Consumables/Api/ConsumableIndexTest.php +++ b/tests/Feature/Consumables/Api/ConsumableIndexTest.php @@ -102,7 +102,6 @@ class ConsumableIndexTest extends TestCase $targetConsumable = Consumable::factory()->create([ 'name' => 'Target Consumable', 'company_id' => $targetCompany->id, - 'order_number' => 'CONS-ORDER-A', 'category_id' => $targetCategory->id, 'model_number' => 'CONS-MODEL-A', 'manufacturer_id' => $targetManufacturer->id, @@ -114,7 +113,6 @@ class ConsumableIndexTest extends TestCase $otherConsumable = Consumable::factory()->create([ 'name' => 'Other Consumable', 'company_id' => $otherCompany->id, - 'order_number' => 'CONS-ORDER-B', 'category_id' => $otherCategory->id, 'model_number' => 'CONS-MODEL-B', 'manufacturer_id' => $otherManufacturer->id, @@ -123,10 +121,12 @@ class ConsumableIndexTest extends TestCase 'notes' => 'CONS-NOTES-B', ]); + // order_number was dropped from the filters list when the parent + // column was renamed to legacy_order_number and current order + // numbers moved to the QuantityAdjust action_log per event. $filters = [ 'name' => 'Target Consumable', 'company_id' => $targetCompany->id, - 'order_number' => 'CONS-ORDER-A', 'category_id' => $targetCategory->id, 'model_number' => 'CONS-MODEL-A', 'manufacturer_id' => $targetManufacturer->id, diff --git a/tests/Feature/Consumables/Ui/CreateConsumableTest.php b/tests/Feature/Consumables/Ui/CreateConsumableTest.php index 49d08b8ca7..3e3517b3aa 100644 --- a/tests/Feature/Consumables/Ui/CreateConsumableTest.php +++ b/tests/Feature/Consumables/Ui/CreateConsumableTest.php @@ -30,6 +30,10 @@ class CreateConsumableTest extends TestCase implements TestsPermissionsRequireme public function test_can_create_consumable() { + // order_number was dropped from the create payload when the parent + // column was renamed to legacy_order_number and taken out of + // fillable. Order-number tracking lives on QuantityAdjust action_log + // rows now. $data = [ 'company_id' => Company::factory()->create()->id, 'name' => 'My Consumable', @@ -39,7 +43,6 @@ class CreateConsumableTest extends TestCase implements TestsPermissionsRequireme 'location_id' => Location::factory()->create()->id, 'model_number' => '1234', 'item_no' => '5678', - 'order_number' => '908', 'purchase_date' => '2024-12-05', 'purchase_cost' => '89.45', 'qty' => '10', diff --git a/tests/Feature/Consumables/Ui/UpdateConsumableTest.php b/tests/Feature/Consumables/Ui/UpdateConsumableTest.php index 6031c40fb1..71a634177f 100644 --- a/tests/Feature/Consumables/Ui/UpdateConsumableTest.php +++ b/tests/Feature/Consumables/Ui/UpdateConsumableTest.php @@ -61,14 +61,12 @@ class UpdateConsumableTest extends TestCase { $consumable = Consumable::factory()->create(); $originalQty = (int) $consumable->qty; - $originalOrderNumber = $consumable->getRawOriginal('order_number'); $newSupplier = Supplier::factory()->create(); - // qty and order_number are still ignored by the web edit form - // (qty flows through the adjust-quantity modal, order_number - // stays hidden by the model accessor). supplier_id is editable - // again — imperfect single-value semantics accepted for the - // info-panel display. + // qty is still ignored by the web edit form (flows through the + // adjust-quantity modal). order_number in the POST body silently + // drops because the parent column was renamed to legacy_order_number + // and taken out of fillable. supplier_id is editable again. $editable = [ 'company_id' => Company::factory()->create()->id, 'name' => 'My Consumable', @@ -95,7 +93,6 @@ class UpdateConsumableTest extends TestCase $this->assertDatabaseHas('consumables', $editable + [ 'qty' => $originalQty, - 'order_number' => $originalOrderNumber, 'supplier_id' => $newSupplier->id, ]); }