From 303de7a0b6c5bc8e2492456dfd0219a9bd840fc0 Mon Sep 17 00:00:00 2001 From: Adam Engebretson Date: Thu, 5 Nov 2015 12:39:33 -0600 Subject: [PATCH] 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. --- app/Http/Controllers/InvoiceApiController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/InvoiceApiController.php b/app/Http/Controllers/InvoiceApiController.php index 2a9bae80eab8..b0d7aede0710 100644 --- a/app/Http/Controllers/InvoiceApiController.php +++ b/app/Http/Controllers/InvoiceApiController.php @@ -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; } }