Added import for min_amt for consumables

This commit is contained in:
Oskar Stenberg 2021-07-12 11:46:19 +02:00
parent 60b8320b4b
commit 5b5874499d
5 changed files with 11 additions and 3 deletions

View file

@ -41,9 +41,12 @@ class ConsumableImporter extends ItemImporter
$consumable = new Consumable(); $consumable = new Consumable();
$this->item['model_number'] = $this->findCsvMatch($row, "model_number");; $this->item['model_number'] = $this->findCsvMatch($row, "model_number");;
$this->item['item_no'] = $this->findCsvMatch($row, "item_number"); $this->item['item_no'] = $this->findCsvMatch($row, "item_number");
$this->item['min_amt'] = $this->findCsvMatch($row, "minimum quantity");
$this->log("min_amt " . $this->item["min_amt"]);
$consumable->fill($this->sanitizeItemForStoring($consumable)); $consumable->fill($this->sanitizeItemForStoring($consumable));
//FIXME: this disables model validation. Need to find a way to avoid double-logs without breaking everything. //FIXME: this disables model validation. Need to find a way to avoid double-logs without breaking everything.
$consumable->unsetEventDispatcher(); $consumable->unsetEventDispatcher();
$this->log(implode(",", $this->item));
if ($consumable->save()) { if ($consumable->save()) {
$consumable->logCreate('Imported using CSV Importer'); $consumable->logCreate('Imported using CSV Importer');
$this->log("Consumable " . $this->item["name"] . ' was created'); $this->log("Consumable " . $this->item["name"] . ' was created');

View file

@ -75,6 +75,7 @@ abstract class Importer
'department' => 'department', 'department' => 'department',
'manager_first_name' => 'manager first name', 'manager_first_name' => 'manager first name',
'manager_last_name' => 'manager last name', 'manager_last_name' => 'manager last name',
'min_amt' => 'minimum quantity',
]; ];
/** /**
* Map of item fields->csv names * Map of item fields->csv names
@ -195,11 +196,11 @@ abstract class Importer
$val = $default; $val = $default;
$key = $this->lookupCustomKey($key); $key = $this->lookupCustomKey($key);
// $this->log("Custom Key: ${key}"); $this->log("Custom Key: ${key}");
if (array_key_exists($key, $array)) { if (array_key_exists($key, $array)) {
$val = Encoding::toUTF8(trim($array[ $key ])); $val = Encoding::toUTF8(trim($array[ $key ]));
} }
// $this->log("${key}: ${val}"); $this->log("${key}: ${val}");
return $val; return $val;
} }

View file

@ -29,6 +29,7 @@
| serial number | serial | Asset, license | | serial number | serial | Asset, license |
| status | status | Asset ? All | | status | status | Asset ? All |
| supplier | supplier | Asset ? All | | supplier | supplier | Asset ? All |
| minimum quantity | min_amt | Consumable |
| termination date | termination_date | License | | termination date | termination_date | License |
| warranty months | warranty_months | Asset | | warranty months | warranty_months | Asset |
| User Related Fields | assigned_to | Asset | | User Related Fields | assigned_to | Asset |

View file

@ -68,6 +68,7 @@ class Consumable extends SnipeModel
'purchase_cost', 'purchase_cost',
'purchase_date', 'purchase_date',
'qty', 'qty',
'min_amt',
'requestable' 'requestable'
]; ];

View file

@ -155,6 +155,7 @@
consumables: [ consumables: [
{id: 'item_no', text: "Item Number"}, {id: 'item_no', text: "Item Number"},
{id: 'model_number', text: "Model Number"}, {id: 'model_number', text: "Model Number"},
{id: 'min_amt', text: "Minimum Quantity"},
], ],
licenses: [ licenses: [
{id: 'asset_tag', text: 'Assigned To Asset'}, {id: 'asset_tag', text: 'Assigned To Asset'},
@ -210,6 +211,7 @@
.sort(sorter); .sort(sorter);
case 'consumable': case 'consumable':
console.log('Returned consumable');
return this.columnOptions.general return this.columnOptions.general
.concat(this.columnOptions.consumables) .concat(this.columnOptions.consumables)
.sort(sorter); .sort(sorter);