Skip to content

A free open source IT asset/license management system

Updated views with recalculated purchase costs

snipe9c502a9d199a
diff --git a/resources/views/accessories/edit.blade.php b/resources/views/accessories/edit.blade.php
index 61a6200195..7cdc7fd245 100644
--- a/resources/views/accessories/edit.blade.php
+++ b/resources/views/accessories/edit.blade.php
@@ -115,6 +115,12 @@
<x-input.quantity :item="$item" min="0" />
@endif
+ <x-input.supplier-select
+ :label="trans('general.default_supplier')"
+ name="default_supplier_id"
+ :selected="old('default_supplier_id', $item->default_supplier_id)"
+ />
+
<x-input.minimum-quantity :item="$item" />
<x-form.row
diff --git a/resources/views/account/view-assets.blade.php b/resources/views/account/view-assets.blade.php
index b416ae0e4f..57a6d5ad2c 100755
--- a/resources/views/account/view-assets.blade.php
+++ b/resources/views/account/view-assets.blade.php
@@ -711,7 +711,7 @@
<td>{{ $accessory->name }}</td>
@can('self.view_purchase_cost')
<td>
- {!! Helper::formatCurrencyOutput($accessory->purchase_cost) !!}
+ {!! Helper::formatCurrencyOutput($accessory->lastOrderDefaults()['unit_cost'] ?? null) !!}
</td>
@endcan
@@ -758,7 +758,7 @@
<td>{{ $consumable->name }}</td>
@can('self.view_purchase_cost')
<td>
- {!! Helper::formatCurrencyOutput($consumable->purchase_cost) !!}
+ {!! Helper::formatCurrencyOutput($consumable->lastOrderDefaults()['unit_cost'] ?? null) !!}
</td>
@endcan
<td>{{ Helper::getFormattedDateObject($consumable->pivot->created_at, 'datetime', false) }}</td>
diff --git a/resources/views/blade/modals/adjust-quantity.blade.php b/resources/views/blade/modals/adjust-quantity.blade.php
index a7ef4b1345..d140a41882 100644
--- a/resources/views/blade/modals/adjust-quantity.blade.php
+++ b/resources/views/blade/modals/adjust-quantity.blade.php
@@ -29,34 +29,49 @@
<p class="help-block">{{ trans('general.adjust_quantity_amount_help') }}</p>
</div>
- <div class="form-group">
- <label for="adjustQuantityOrder">{{ trans('general.order_number') }}</label>
- <input type="text" class="form-control" id="adjustQuantityOrder" name="order_number" maxlength="191">
- </div>
+ {{-- Acquisition-only fields (order_number, supplier,
+ unit cost, currency). Shown for positive qty
+ changes and hidden by snipeit.js when the amount
+ is 0 or negative — those cases are corrections
+ or losses rather than purchases, so purchase
+ metadata doesn't apply. --}}
+ <div id="adjustQuantityAcquisitionFields">
+ <div class="form-group">
+ <label for="adjustQuantityOrder">{{ trans('general.order_number') }}</label>
+ <input type="text" class="form-control" id="adjustQuantityOrder" name="order_number" maxlength="191">
+ </div>
- {{-- Inlined js-data-ajax select instead of <x-input.supplier-select>
- for the same reason the file-upload input is inlined below: the
- shared component uses a Bootstrap 3 horizontal-form scaffold
- (col-md-3 label + col-md-7 input) that collides with the
- modal-footer top border. snipeit.js auto-initializes any
- .js-data-ajax select. --}}
- <div class="form-group">
- <label for="adjustQuantitySupplier">{{ trans('general.supplier') }}</label>
- <select
- class="js-data-ajax form-control"
- data-endpoint="suppliers"
- data-placeholder="{{ trans('general.select_supplier') }}"
- name="supplier_id"
- id="adjustQuantitySupplier"
- style="width: 100%"
- aria-label="{{ trans('general.supplier') }}"
- >
- <option value=""></option>
- </select>
+ {{-- Inlined js-data-ajax select instead of <x-input.supplier-select>
+ for the same reason the file-upload input is inlined below: the
+ shared component uses a Bootstrap 3 horizontal-form scaffold
+ (col-md-3 label + col-md-7 input) that collides with the
+ modal-footer top border. snipeit.js auto-initializes any
+ .js-data-ajax select. --}}
+ <div class="form-group">
+ <label for="adjustQuantitySupplier">{{ trans('general.supplier') }}</label>
+ <select
+ class="js-data-ajax form-control"
+ data-endpoint="suppliers"
+ data-placeholder="{{ trans('general.select_supplier') }}"
+ name="supplier_id"
+ id="adjustQuantitySupplier"
+ style="width: 100%"
+ aria-label="{{ trans('general.supplier') }}"
+ >
+ <option value=""></option>
+ </select>
+ </div>
</div>
<div class="form-group">
- <label for="adjustQuantityPurchaseDate">{{ trans('general.purchase_date') }}</label>
+ {{-- Label swaps between "Purchase Date" (positive qty)
+ and "Date" (0 or negative) via snipeit.js. --}}
+ <label
+ for="adjustQuantityPurchaseDate"
+ id="adjustQuantityPurchaseDateLabel"
+ data-label-purchase="{{ trans('general.purchase_date') }}"
+ data-label-generic="{{ trans('general.date') }}"
+ >{{ trans('general.purchase_date') }}</label>
{{-- Pre-populated with today's date because most --}}
{{-- adjust events happen the day they are recorded. --}}
{{-- Editable, and snipeit.js resets to today on --}}
@@ -80,7 +95,7 @@
event (Snipe-IT's historical currency handling
is squishy already). Placeholder hints at the
system default without stamping it. --}}
- <div class="row">
+ <div class="row" id="adjustQuantityCostRow">
<div class="col-md-8 form-group" style="padding-right: 5px;">
<label for="adjustQuantityUnitCost">{{ trans('general.unit_cost') }}</label>
<input
diff --git a/resources/views/components/edit.blade.php b/resources/views/components/edit.blade.php
index 7fd7eccd94..802ecbe885 100644
--- a/resources/views/components/edit.blade.php
+++ b/resources/views/components/edit.blade.php
@@ -121,6 +121,12 @@
<x-input.quantity :item="$item" />
@endif
+ <x-input.supplier-select
+ :label="trans('general.default_supplier')"
+ name="default_supplier_id"
+ :selected="old('default_supplier_id', $item->default_supplier_id)"
+ />
+
<x-form.row
:label="trans('general.notes')"
:$item
diff --git a/resources/views/consumables/edit.blade.php b/resources/views/consumables/edit.blade.php
index 05eb938bcb..dd081f70e2 100644
--- a/resources/views/consumables/edit.blade.php
+++ b/resources/views/consumables/edit.blade.php
@@ -121,6 +121,12 @@
<x-input.quantity :item="$item"/>
@endif
+ <x-input.supplier-select
+ :label="trans('general.default_supplier')"
+ name="default_supplier_id"
+ :selected="old('default_supplier_id', $item->default_supplier_id)"
+ />
+
<x-form.row
:label="trans('general.notes')"
:$item
diff --git a/resources/views/users/view.blade.php b/resources/views/users/view.blade.php
index ec86d11131..800e783fe1 100755
--- a/resources/views/users/view.blade.php
+++ b/resources/views/users/view.blade.php
@@ -452,8 +452,7 @@
<td>{{ Helper::getFormattedDateObject($accessory->pivot->created_at, 'datetime', false) }}</td>
<td>{{ $accessory->pivot->note }}</td>
<td>
- {{-- Prefer the last OrderItem's price so this table matches the accessory info-panel's "last unit cost". Falls back to parent for legacy rows. --}}
- {!! Helper::formatCurrencyOutput($accessory->lastOrderDefaults()['unit_cost'] ?? $accessory->purchase_cost) !!}
+ {!! Helper::formatCurrencyOutput($accessory->lastOrderDefaults()['unit_cost'] ?? null) !!}
</td>
<td class="hidden-print">
@can('checkin', $accessory)
@@ -496,8 +495,7 @@
<tr>
<td>{!! $consumable->present()->nameUrl() !!}</td>
<td>
- {{-- Same "last order unit cost" preference as the accessories table above. --}}
- {!! Helper::formatCurrencyOutput($consumable->lastOrderDefaults()['unit_cost'] ?? $consumable->purchase_cost) !!}
+ {!! Helper::formatCurrencyOutput($consumable->lastOrderDefaults()['unit_cost'] ?? null) !!}
</td>
<td>{{ Helper::getFormattedDateObject($consumable->pivot->created_at, 'datetime', false) }}</td>
<td>{{ $consumable->pivot->note }}</td>