get currency account, customer and vendor issues solved
This commit is contained in:
parent
26ac0acf61
commit
61262a5d4b
@ -211,25 +211,26 @@ class Accounts extends Controller
|
|||||||
|
|
||||||
public function currency()
|
public function currency()
|
||||||
{
|
{
|
||||||
$account_id = request('account_id');
|
$account_id = (int) request('account_id');
|
||||||
|
|
||||||
if (empty($account_id)) {
|
if (empty($account_id)) {
|
||||||
$account_id = setting('general.default_account');
|
return response()->json([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$account = Account::find($account_id);
|
$account = Account::find($account_id);
|
||||||
|
|
||||||
$currency_code = $account->currency_code;
|
if (empty($account)) {
|
||||||
|
return response()->json([]);
|
||||||
$currency = false;
|
|
||||||
$currencies = Currency::enabled()->pluck('name', 'code')->toArray();
|
|
||||||
|
|
||||||
if (array_key_exists($currency_code, $currencies)) {
|
|
||||||
$currency = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$currency) {
|
|
||||||
$currency_code = setting('general.default_currency');
|
$currency_code = setting('general.default_currency');
|
||||||
|
|
||||||
|
if (isset($account->currency_code)) {
|
||||||
|
$currencies = Currency::enabled()->pluck('name', 'code')->toArray();
|
||||||
|
|
||||||
|
if (array_key_exists($account->currency_code, $currencies)) {
|
||||||
|
$currency_code = $account->currency_code;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get currency object
|
// Get currency object
|
||||||
|
@ -304,21 +304,26 @@ class Vendors extends Controller
|
|||||||
|
|
||||||
public function currency()
|
public function currency()
|
||||||
{
|
{
|
||||||
$vendor_id = request('vendor_id');
|
$vendor_id = (int) request('vendor_id');
|
||||||
|
|
||||||
|
if (empty($vendor_id)) {
|
||||||
|
return response()->json([]);
|
||||||
|
}
|
||||||
|
|
||||||
$vendor = Vendor::find($vendor_id);
|
$vendor = Vendor::find($vendor_id);
|
||||||
|
|
||||||
$currency_code = $vendor->currency_code;
|
if (empty($vendor)) {
|
||||||
|
return response()->json([]);
|
||||||
$currency = false;
|
|
||||||
$currencies = Currency::enabled()->pluck('name', 'code')->toArray();
|
|
||||||
|
|
||||||
if (array_key_exists($currency_code, $currencies)) {
|
|
||||||
$currency = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$currency) {
|
|
||||||
$currency_code = setting('general.default_currency');
|
$currency_code = setting('general.default_currency');
|
||||||
|
|
||||||
|
if (isset($vendor->currency_code)) {
|
||||||
|
$currencies = Currency::enabled()->pluck('name', 'code')->toArray();
|
||||||
|
|
||||||
|
if (array_key_exists($vendor->currency_code, $currencies)) {
|
||||||
|
$currency_code = $vendor->currency_code;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get currency object
|
// Get currency object
|
||||||
|
@ -340,21 +340,26 @@ class Customers extends Controller
|
|||||||
|
|
||||||
public function currency()
|
public function currency()
|
||||||
{
|
{
|
||||||
$customer_id = request('customer_id');
|
$customer_id = (int) request('customer_id');
|
||||||
|
|
||||||
|
if (empty($customer_id)) {
|
||||||
|
return response()->json([]);
|
||||||
|
}
|
||||||
|
|
||||||
$customer = Customer::find($customer_id);
|
$customer = Customer::find($customer_id);
|
||||||
|
|
||||||
$currency_code = $customer->currency_code;
|
if (empty($customer)) {
|
||||||
|
return response()->json([]);
|
||||||
$currency = false;
|
|
||||||
$currencies = Currency::enabled()->pluck('name', 'code')->toArray();
|
|
||||||
|
|
||||||
if (array_key_exists($currency_code, $currencies)) {
|
|
||||||
$currency = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$currency) {
|
|
||||||
$currency_code = setting('general.default_currency');
|
$currency_code = setting('general.default_currency');
|
||||||
|
|
||||||
|
if (isset($customer->currency_code)) {
|
||||||
|
$currencies = Currency::enabled()->pluck('name', 'code')->toArray();
|
||||||
|
|
||||||
|
if (array_key_exists($customer->currency_code, $currencies)) {
|
||||||
|
$currency_code = $customer->currency_code;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get currency object
|
// Get currency object
|
||||||
|
Loading…
x
Reference in New Issue
Block a user