mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Handle currency symbol when setting product cost
This commit is contained in:
parent
ab91f76bfe
commit
a50ca5a328
@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
|||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
use App\Models\TaxRate;
|
use App\Models\TaxRate;
|
||||||
use App\Ninja\Datatables\ProductDatatable;
|
use App\Ninja\Datatables\ProductDatatable;
|
||||||
|
use App\Ninja\Repositories\ProductRepository;
|
||||||
use App\Services\ProductService;
|
use App\Services\ProductService;
|
||||||
use Auth;
|
use Auth;
|
||||||
use Input;
|
use Input;
|
||||||
@ -24,16 +25,22 @@ class ProductController extends BaseController
|
|||||||
*/
|
*/
|
||||||
protected $productService;
|
protected $productService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ProductRepository
|
||||||
|
*/
|
||||||
|
protected $productRepo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ProductController constructor.
|
* ProductController constructor.
|
||||||
*
|
*
|
||||||
* @param ProductService $productService
|
* @param ProductService $productService
|
||||||
*/
|
*/
|
||||||
public function __construct(ProductService $productService)
|
public function __construct(ProductService $productService, ProductRepository $productRepo)
|
||||||
{
|
{
|
||||||
//parent::__construct();
|
//parent::__construct();
|
||||||
|
|
||||||
$this->productService = $productService;
|
$this->productService = $productService;
|
||||||
|
$this->productRepo = $productRepo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,11 +144,7 @@ class ProductController extends BaseController
|
|||||||
$product = Product::createNew();
|
$product = Product::createNew();
|
||||||
}
|
}
|
||||||
|
|
||||||
$product->product_key = trim(Input::get('product_key'));
|
$this->productRepo->save(Input::all(), $product);
|
||||||
$product->notes = trim(Input::get('notes'));
|
|
||||||
$product->cost = trim(Input::get('cost'));
|
|
||||||
$product->fill(Input::all());
|
|
||||||
$product->save();
|
|
||||||
|
|
||||||
$message = $productPublicId ? trans('texts.updated_product') : trans('texts.created_product');
|
$message = $productPublicId ? trans('texts.updated_product') : trans('texts.created_product');
|
||||||
Session::flash('message', $message);
|
Session::flash('message', $message);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Ninja\Repositories;
|
namespace App\Ninja\Repositories;
|
||||||
|
|
||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
|
use Utils;
|
||||||
use DB;
|
use DB;
|
||||||
|
|
||||||
class ProductRepository extends BaseRepository
|
class ProductRepository extends BaseRepository
|
||||||
@ -64,6 +65,9 @@ class ProductRepository extends BaseRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
$product->fill($data);
|
$product->fill($data);
|
||||||
|
$product->product_key = trim($data['product_key']);
|
||||||
|
$product->notes = trim($data['notes']);
|
||||||
|
$product->cost = Utils::parseFloat($data['cost']);
|
||||||
$product->save();
|
$product->save();
|
||||||
|
|
||||||
return $product;
|
return $product;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user