From bcd80377cf235a375a68079db0d854cbc4c7dd27 Mon Sep 17 00:00:00 2001 From: jayvirsinh_gohil Date: Tue, 11 Jan 2022 15:06:07 +0530 Subject: [PATCH] solve payment issue --- app/Models/Payment.php | 4 ++-- app/Models/PaymentMethod.php | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/Models/Payment.php b/app/Models/Payment.php index e1e8ee54..72b85ac0 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -442,7 +442,7 @@ class Payment extends Model implements HasMedia $serial = (new SerialNumberFormatter()) ->setModel(new Payment()) - ->setCompany(request()->header('company')) + ->setCompany($invoice->company_id) ->setCustomer($invoice->customer_id) ->setNextNumbers(); @@ -455,7 +455,7 @@ class Payment extends Model implements HasMedia $data['exchange_rate'] = $invoice->exchange_rate; $data['base_amount'] = $data['amount'] * $data['exchange_rate']; $data['currency_id'] = $invoice->currency_id; - $data['company_id'] = request()->header('company'); + $data['company_id'] = $invoice->company_id; $data['transaction_id'] = $transaction->id; $payment = Payment::create($data); diff --git a/app/Models/PaymentMethod.php b/app/Models/PaymentMethod.php index ea115df1..898fbd36 100644 --- a/app/Models/PaymentMethod.php +++ b/app/Models/PaymentMethod.php @@ -36,6 +36,11 @@ class PaymentMethod extends Model return $this->belongsTo(Company::class); } + public function scopeWhereCompanyId($query, $id) + { + $query->where('company_id', $id); + } + public function scopeWhereCompany($query) { $query->where('company_id', request()->header('company')); @@ -48,7 +53,7 @@ class PaymentMethod extends Model public function scopeWhereSearch($query, $search) { - $query->where('name', 'LIKE', '%' . $search . '%'); + $query->where('name', 'LIKE', '%'.$search.'%'); } public function scopeApplyFilters($query, array $filters) @@ -88,8 +93,7 @@ class PaymentMethod extends Model public static function getSettings($id) { - $settings = PaymentMethod::whereCompany() - ->find($id) + $settings = PaymentMethod::find($id) ->settings; return $settings;