Fix Komisi
This commit is contained in:
@@ -21,7 +21,7 @@ class PaymentController extends Controller
|
|||||||
// return $request->toArray();
|
// return $request->toArray();
|
||||||
$appointments = Appointment::query()
|
$appointments = Appointment::query()
|
||||||
->where('sPaymentStatus', 'settlement')
|
->where('sPaymentStatus', 'settlement')
|
||||||
->with(['healthCare', 'detail', 'user', 'doctor', 'doctor.user']);
|
->with(['healthCare', 'healthCare.commission', 'detail', 'user', 'doctor', 'doctor.user']);
|
||||||
|
|
||||||
if ($request->has('search')) {
|
if ($request->has('search')) {
|
||||||
$appointments->where(function ($query) use ($request) {
|
$appointments->where(function ($query) use ($request) {
|
||||||
|
|||||||
@@ -14,7 +14,12 @@ class LinksehatPaymentResource extends JsonResource
|
|||||||
*/
|
*/
|
||||||
public function toArray($request)
|
public function toArray($request)
|
||||||
{
|
{
|
||||||
return parent::toArray($request);
|
$data = parent::toArray($request);
|
||||||
|
|
||||||
|
$data['share_komisi'] = $this->share_komisi;
|
||||||
|
$data['share_konsultasi'] = $this->share_konsultasi;
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
|
||||||
// return [
|
// return [
|
||||||
// // 'healthcare_name' => $this->healthCare->name ?? '',
|
// // 'healthcare_name' => $this->healthCare->name ?? '',
|
||||||
|
|||||||
@@ -115,6 +115,32 @@ class Appointment extends Model
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function shareKonsultasi(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
get: function() {
|
||||||
|
return ((float) $this->detail->sPaymentDetails['gross_amount'] ?? 0) - $this->nAdminFee;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function shareKomisi(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
get: function() {
|
||||||
|
// return $this->healthCare->commission;
|
||||||
|
if ( $this->nIDJenisBooking == 3 ) { // Telekonsultasi Sekarang
|
||||||
|
return $this->shareKonsultasi * ($this->healthCare->commission->nCommissionATC) / 100;
|
||||||
|
}
|
||||||
|
else if ( $this->nIDJenisBooking == 2 ) { // Telekonsultasi
|
||||||
|
return $this->shareKonsultasi * ($this->healthCare->commission->nCommissionTC) / 100;
|
||||||
|
}
|
||||||
|
else { // Walk In
|
||||||
|
return $this->shareKonsultasi * ($this->nCommission) / 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function appointmentDetail()
|
public function appointmentDetail()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ class Healthcare extends Model
|
|||||||
|
|
||||||
protected $primaryKey = 'nID';
|
protected $primaryKey = 'nID';
|
||||||
|
|
||||||
|
public function commission()
|
||||||
|
{
|
||||||
|
return $this->hasOne(HealthcareCommission::class, 'nIDHealthcare', 'nID')->where('sStatus', 1);
|
||||||
|
}
|
||||||
|
|
||||||
public function jadwalDokter()
|
public function jadwalDokter()
|
||||||
{
|
{
|
||||||
return $this->hasMany(JadwalDokter::class, 'nIDHealthCare', 'nID');
|
return $this->hasMany(JadwalDokter::class, 'nIDHealthCare', 'nID');
|
||||||
|
|||||||
27
app/Models/OLDLMS/HealthcareCommission.php
Normal file
27
app/Models/OLDLMS/HealthcareCommission.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\OLDLMS;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class HealthcareCommission extends Model
|
||||||
|
{
|
||||||
|
use HasFactory, SoftDeletes;
|
||||||
|
|
||||||
|
const CREATED_AT = 'dCreateOn';
|
||||||
|
const UPDATED_AT = 'dUpdateOn';
|
||||||
|
const DELETED_AT = 'dDeleteOn';
|
||||||
|
|
||||||
|
protected $connection = 'oldlms';
|
||||||
|
|
||||||
|
protected $table = 'tx_healthcare_commission';
|
||||||
|
|
||||||
|
protected $primaryKey = 'nID';
|
||||||
|
|
||||||
|
public function healthcare()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Healthcare::class, 'nIDHealthcare', 'nID');
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user