3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-02-04 18:45:45 +00:00

Replace qty with quantity

This commit is contained in:
Marcus Moore
2025-12-16 14:55:00 -08:00
parent b05970acf4
commit ab363596fd
17 changed files with 34 additions and 34 deletions

View File

@ -35,7 +35,7 @@ class MigrateLicenseSeatQuantitiesInActionLogs extends Command
ActionType::AddSeats->value,
ActionType::DeleteSeats->value,
])
->where('qty', '=', 1)
->where('quantity', '=', 1)
->orderBy('id');
$count = $query->count();
@ -57,13 +57,13 @@ class MigrateLicenseSeatQuantitiesInActionLogs extends Command
$this->error('Could not parse quantity from ID: {id}', ['id' => $log->id]);
}
if ($log->qty !== (int) $quantityFromNote) {
if ($log->quantity !== (int) $quantityFromNote) {
$this->info(vsprintf('Updating id: %s to quantity %s', [
'id' => $log->id,
'new_quantity' => $quantityFromNote,
]));
DB::table('action_logs')->where('id', $log->id)->update(['qty' => (int) $quantityFromNote]);
DB::table('action_logs')->where('id', $log->id)->update(['quantity' => (int) $quantityFromNote]);
}
});
});

View File

@ -15,20 +15,20 @@ class CheckoutableCheckedOut
public $checkedOutBy;
public $note;
public $originalValues;
public int $qty;
public int $quantity;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($checkoutable, $checkedOutTo, User $checkedOutBy, $note, $originalValues = [], $qty = 1)
public function __construct($checkoutable, $checkedOutTo, User $checkedOutBy, $note, $originalValues = [], $quantity = 1)
{
$this->checkoutable = $checkoutable;
$this->checkedOutTo = $checkedOutTo;
$this->checkedOutBy = $checkedOutBy;
$this->note = $note;
$this->originalValues = $originalValues;
$this->qty = $qty;
$this->quantity = $quantity;
}
}

View File

@ -185,7 +185,7 @@ class ActionlogsTransformer
'name' => e($actionlog->target->display_name) ?? null,
'type' => e($actionlog->targetType()),
] : null,
'qty' => $this->getQuantity($actionlog),
'quantity' => $this->getQuantity($actionlog),
'note' => ($actionlog->note) ? Helper::parseEscapedMarkedownInline($actionlog->note): null,
'signature_file' => ($actionlog->accept_signature) ? route('log.signature.view', ['filename' => $actionlog->accept_signature ]) : null,
'log_meta' => ((isset($clean_meta)) && (is_array($clean_meta))) ? $clean_meta: null,
@ -338,7 +338,7 @@ class ActionlogsTransformer
private function getQuantity(Actionlog $actionlog): ?int
{
if (!$actionlog->qty) {
if (!$actionlog->quantity) {
return null;
}
@ -347,7 +347,7 @@ class ActionlogsTransformer
return null;
}
return (int) $actionlog->qty;
return (int) $actionlog->quantity;
}

View File

@ -52,7 +52,7 @@ class LogListener
$event->checkedOutTo,
$event->checkoutable->last_checkout,
$event->originalValues,
$event->qty
$event->quantity
);
}
@ -72,7 +72,7 @@ class LogListener
$logaction->note = $event->acceptance->note;
$logaction->action_type = 'accepted';
$logaction->action_date = $event->acceptance->accepted_at;
$logaction->qty = $event->acceptance->qty ?? 1;
$logaction->quantity = $event->acceptance->qty ?? 1;
// TODO: log the actual license seat that was checked out
if ($event->acceptance->checkoutable instanceof LicenseSeat) {
@ -91,7 +91,7 @@ class LogListener
$logaction->note = $event->acceptance->note;
$logaction->action_type = 'declined';
$logaction->action_date = $event->acceptance->declined_at;
$logaction->qty = $event->acceptance->qty ?? 1;
$logaction->quantity = $event->acceptance->qty ?? 1;
// TODO: log the actual license seat that was checked out
if ($event->acceptance->checkoutable instanceof LicenseSeat) {

View File

@ -223,7 +223,7 @@ class License extends Depreciable
$logAction->created_by = auth()->id() ?: 1; // We don't have an id while running the importer from CLI.
$logAction->note = "deleted {$change} seats";
$logAction->target_id = null;
$logAction->qty = $change;
$logAction->quantity = $change;
$logAction->logaction('delete seats');
return true;
@ -260,7 +260,7 @@ class License extends Depreciable
$logAction->created_by = auth()->id() ?: 1; // Importer.
$logAction->note = "added {$change} seats";
$logAction->target_id = null;
$logAction->qty = $change;
$logAction->quantity = $change;
$logAction->logaction('add seats');
}

View File

@ -40,7 +40,7 @@ trait Loggable
* @since [v3.4]
* @return \App\Models\Actionlog
*/
public function logCheckout($note, $target, $action_date = null, $originalValues = [], $qty = 1)
public function logCheckout($note, $target, $action_date = null, $originalValues = [], $quantity = 1)
{
$log = new Actionlog;
@ -94,7 +94,7 @@ trait Loggable
$log->note = $note;
$log->action_date = $action_date;
$log->qty = $qty;
$log->quantity = $quantity;
$changed = [];
$array_to_flip = array_keys($fields_array);

View File

@ -118,7 +118,7 @@ class HistoryPresenter extends Presenter
'formatter' => 'fileDownloadButtonsFormatter',
],
[
'field' => 'qty',
'field' => 'quantity',
'searchable' => false,
'sortable' => true,
'visible' => true,

View File

@ -12,7 +12,7 @@ return new class extends Migration
public function up(): void
{
Schema::table('action_logs', function (Blueprint $table) {
$table->integer('qty')->default(1)->after('expected_checkin');
$table->integer('quantity')->default(1)->after('expected_checkin');
});
}
@ -22,7 +22,7 @@ return new class extends Migration
public function down(): void
{
Schema::table('action_logs', function (Blueprint $table) {
$table->dropColumn('qty');
$table->dropColumn('quantity');
});
}
};

View File

@ -43,7 +43,7 @@ class AccessoryAcceptanceTest extends TestCase
'target_type' => User::class,
'item_id' => $accessory->id,
'item_type' => Accessory::class,
'qty' => 2,
'quantity' => 2,
]);
}
@ -76,7 +76,7 @@ class AccessoryAcceptanceTest extends TestCase
'target_type' => User::class,
'item_id' => $accessory->id,
'item_type' => Accessory::class,
'qty' => 2,
'quantity' => 2,
]);
}

View File

@ -38,7 +38,7 @@ class ConsumableAcceptanceTest extends TestCase
'target_type' => User::class,
'item_id' => $consumable->id,
'item_type' => Consumable::class,
'qty' => 2,
'quantity' => 2,
]);
}
@ -71,7 +71,7 @@ class ConsumableAcceptanceTest extends TestCase
'target_type' => User::class,
'item_id' => $consumable->id,
'item_type' => Consumable::class,
'qty' => 2,
'quantity' => 2,
]);
}
}

View File

@ -121,7 +121,7 @@ class AccessoryCheckoutTest extends TestCase implements TestsPermissionsRequirem
'target_type' => User::class,
'item_id' => $accessory->id,
'item_type' => Accessory::class,
'qty' => 2,
'quantity' => 2,
'created_by' => $admin->id,
]);

View File

@ -120,7 +120,7 @@ class ComponentCheckoutTest extends TestCase implements TestsFullMultipleCompani
'location_id' => $location->id,
'item_type' => Component::class,
'item_id' => $component->id,
'qty' => 2,
'quantity' => 2,
]);
}

View File

@ -69,7 +69,7 @@ class ConsumableCheckoutTest extends TestCase
'target_type' => User::class,
'target_id' => $user->id,
'action_type' => 'checkout',
'qty' => 2,
'quantity' => 2,
]);
}

View File

@ -81,7 +81,7 @@ class AccessoryCheckoutTest extends TestCase
'target_type' => User::class,
'item_id' => $accessory->id,
'item_type' => Accessory::class,
'qty' => 1,
'quantity' => 1,
'note' => 'oh hi there',
]);
$this->assertHasTheseActionLogs($accessory, ['create', 'checkout']);
@ -109,7 +109,7 @@ class AccessoryCheckoutTest extends TestCase
'target_type' => User::class,
'item_id' => $accessory->id,
'item_type' => Accessory::class,
'qty' => 3,
'quantity' => 3,
'note' => 'oh hi there',
]);
$this->assertHasTheseActionLogs($accessory, ['create', 'checkout']);
@ -137,7 +137,7 @@ class AccessoryCheckoutTest extends TestCase
'target_type' => Location::class,
'item_id' => $accessory->id,
'item_type' => Accessory::class,
'qty' => 3,
'quantity' => 3,
'note' => 'oh hi there',
]);
$this->assertHasTheseActionLogs($accessory, ['create', 'checkout']);
@ -165,7 +165,7 @@ class AccessoryCheckoutTest extends TestCase
'target_type' => Asset::class,
'item_id' => $accessory->id,
'item_type' => Accessory::class,
'qty' => 3,
'quantity' => 3,
'note' => 'oh hi there',
]);
$this->assertHasTheseActionLogs($accessory, ['create', 'checkout']);

View File

@ -119,7 +119,7 @@ class ComponentsCheckoutTest extends TestCase
'target_type' => Asset::class,
'item_id' => $component->id,
'item_type' => Component::class,
'qty' => 2,
'quantity' => 2,
'created_by' => $admin->id,
]);
}

View File

@ -171,7 +171,7 @@ class ConsumableCheckoutTest extends TestCase
'target_type' => User::class,
'item_id' => $consumable->id,
'item_type' => Consumable::class,
'qty' => 2,
'quantity' => 2,
'created_by' => $admin->id,
]);
}

View File

@ -25,7 +25,7 @@ class LicenseTest extends TestCase
'item_id' => $license->id,
'deleted_at' => null,
// relevant for this test:
'qty' => 4,
'quantity' => 4,
'note' => 'added 4 seats',
]);
}
@ -46,7 +46,7 @@ class LicenseTest extends TestCase
'item_id' => $license->id,
'deleted_at' => null,
// relevant for this test:
'qty' => 3,
'quantity' => 3,
'note' => 'deleted 3 seats',
]);
}