From 7d198583a427190e2b32436d50dbe44b992cf753 Mon Sep 17 00:00:00 2001 From: R Date: Thu, 6 Apr 2023 07:32:47 +0700 Subject: [PATCH] Fix Commision --- app/Models/OLDLMS/Appointment.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/app/Models/OLDLMS/Appointment.php b/app/Models/OLDLMS/Appointment.php index 70011769..32801ab7 100644 --- a/app/Models/OLDLMS/Appointment.php +++ b/app/Models/OLDLMS/Appointment.php @@ -119,7 +119,16 @@ class Appointment extends Model { return Attribute::make( get: function() { - return ((float) $this->detail->sPaymentDetails['gross_amount'] ?? 0) - $this->nAdminFee; + $consulPrice = ((float) $this->detail->sPaymentDetails['gross_amount'] ?? 0) - $this->nAdminFee; + if ( $this->nIDJenisBooking == 3 ) { // Telekonsultasi Sekarang + return $consulPrice * (100-$this->healthCare->commission->nCommissionATC) / 100; + } + else if ( $this->nIDJenisBooking == 2 ) { // Telekonsultasi + return $consulPrice * (100-$this->healthCare->commission->nCommissionTC) / 100; + } + else { // Walk In + return $consulPrice * (100-$this->healthCare->commission->nCommission) / 100; + } } ); } @@ -128,15 +137,15 @@ class Appointment extends Model { return Attribute::make( get: function() { - // return $this->healthCare->commission; + $consulPrice = ((float) $this->detail->sPaymentDetails['gross_amount'] ?? 0) - $this->nAdminFee; if ( $this->nIDJenisBooking == 3 ) { // Telekonsultasi Sekarang - return $this->shareKonsultasi * ($this->healthCare->commission->nCommissionATC) / 100; + return $consulPrice * ($this->healthCare->commission->nCommissionATC) / 100; } else if ( $this->nIDJenisBooking == 2 ) { // Telekonsultasi - return $this->shareKonsultasi * ($this->healthCare->commission->nCommissionTC) / 100; + return $consulPrice * ($this->healthCare->commission->nCommissionTC) / 100; } else { // Walk In - return $this->shareKonsultasi * ($this->nCommission) / 100; + return $consulPrice * ($this->healthCare->commission->nCommission) / 100; } } );