mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Lookup product details when importing invoice CSV
This commit is contained in:
parent
3151fb9085
commit
6e89fcd0cb
@ -108,6 +108,30 @@ class BaseTransformer extends TransformerAbstract
|
|||||||
return isset($this->maps[ENTITY_PRODUCT][$name]) ? $this->maps[ENTITY_PRODUCT][$name] : null;
|
return isset($this->maps[ENTITY_PRODUCT][$name]) ? $this->maps[ENTITY_PRODUCT][$name] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $name
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
public function getProductNotes($name)
|
||||||
|
{
|
||||||
|
$name = strtolower(trim($name));
|
||||||
|
|
||||||
|
return isset($this->maps['product_notes'][$name]) ? $this->maps['product_notes'][$name] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $name
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
public function getProductCost($name)
|
||||||
|
{
|
||||||
|
$name = strtolower(trim($name));
|
||||||
|
|
||||||
|
return isset($this->maps['product_cost'][$name]) ? $this->maps['product_cost'][$name] : null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param $name
|
||||||
*
|
*
|
||||||
|
@ -38,8 +38,8 @@ class InvoiceTransformer extends BaseTransformer
|
|||||||
'invoice_items' => [
|
'invoice_items' => [
|
||||||
[
|
[
|
||||||
'product_key' => $this->getString($data, 'product'),
|
'product_key' => $this->getString($data, 'product'),
|
||||||
'notes' => $this->getString($data, 'notes'),
|
'notes' => $this->getString($data, 'notes') ?: $this->getProductNotes($this->getString($data, 'product')),
|
||||||
'cost' => $this->getFloat($data, 'amount'),
|
'cost' => $this->getFloat($data, 'amount') ?: $this->getProductCost($this->getString($data, 'product')),
|
||||||
'qty' => $this->getFloat($data, 'quantity') ?: 1,
|
'qty' => $this->getFloat($data, 'quantity') ?: 1,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
@ -911,6 +911,8 @@ class ImportService
|
|||||||
{
|
{
|
||||||
if ($key = strtolower(trim($product->product_key))) {
|
if ($key = strtolower(trim($product->product_key))) {
|
||||||
$this->maps['product'][$key] = $product->id;
|
$this->maps['product'][$key] = $product->id;
|
||||||
|
$this->maps['product_notes'][$key] = $product->notes;
|
||||||
|
$this->maps['product_cost'][$key] = $product->cost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user