Allow zero-costs

Currently, the `parepareItem` method checks to see if the cost and notes evaluate to false. If so, it checks from the product list.

However, we need the ability to set cost to zero explicitly through the API. This allows a user to pass null, which will use the default. Otherwise, passing 0 will persist.
This commit is contained in:
Adam Engebretson 2015-11-05 12:39:33 -06:00
parent 0953fbe7cd
commit 303de7a0b6

View File

@ -214,13 +214,13 @@ class InvoiceApiController extends Controller
}
// if only the product key is set we'll load the cost and notes
if ($item['product_key'] && (!$item['cost'] || !$item['notes'])) {
if ($item['product_key'] && (is_null($item['cost']) || is_null($item['notes']))) {
$product = Product::findProductByKey($item['product_key']);
if ($product) {
if (!$item['cost']) {
if (is_null($item['cost'])) {
$item['cost'] = $product->cost;
}
if (!$item['notes']) {
if (is_null($item['notes'])) {
$item['notes'] = $product->notes;
}
}