3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-08-18 11:15:42 +00:00

Rename order number field

This commit is contained in:
snipe
2026-08-03 14:21:03 +01:00
parent 3c7fe91c86
commit 0f17dfd98e
20 changed files with 114 additions and 94 deletions

View File

@ -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,

View File

@ -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',

View File

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

View File

@ -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',

View File

@ -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

View File

@ -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,

View File

@ -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,

View File

@ -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',

View File

@ -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,
]);
}