From 7e791a64b4f5fb462a1991d728949ebdabefe322 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 1 May 2022 23:14:27 +0800 Subject: [PATCH] update code on export booking analytic data for Hybrid payment method --- .../ExportsAnalyticBookingTransactions.php | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/app/Classes/Modules/Exports/Services/ExportsAnalyticBookingTransactions.php b/app/Classes/Modules/Exports/Services/ExportsAnalyticBookingTransactions.php index 9861b78f..791c0de3 100644 --- a/app/Classes/Modules/Exports/Services/ExportsAnalyticBookingTransactions.php +++ b/app/Classes/Modules/Exports/Services/ExportsAnalyticBookingTransactions.php @@ -65,6 +65,18 @@ class ExportsAnalyticBookingTransactions implements FromQuery, WithHeadings, Wit $companyType[companyType::PERSONAL_BUSINESS] = 'PERSONAL_BUSINESS'; $payments = $booking->transactions()->where('type', 1)->whereIn('status', [2, 3]); + + $paymentmethondArray = PaymentMethodType::PAYMENT_METHODS_ID; + $paymentmethondArray[0] = 'Hybrid'; + $paymentMethod = ''; + foreach ($payments->get() as $payment) { + if ( $paymentMethod == '' ) { + $paymentMethod = $payment->payment_method; + } else if ( $payment->payment_method != $paymentMethod ) { + $paymentMethod = 0; // set it to Hybrid + } + } + $paymentMethod === '' ? '' : $paymentMethod = $paymentmethondArray[$paymentMethod]; $firstPayment = $payments->first(); @@ -74,23 +86,6 @@ class ExportsAnalyticBookingTransactions implements FromQuery, WithHeadings, Wit $lastPayment = $booking->transactions()->where('type', 1)->whereIn('status', [2, 3])->orderBy('id', 'desc')->first(); - $paymentMethod = ''; - foreach ($payments->get() as $payment) { - - if ( $paymentMethod == '' ) { - $paymentMethod = $payment->payment_method; - } else { - if ( $payment->payment_method != $paymentMethod ) { - $paymentMethod = 0; // set it to Hybrid - } - } - } - - $paymentmethondArray = PaymentMethodType::PAYMENT_METHODS_ID; - $paymentmethondArray[0] = 'Hybrid'; - - $paymentMethod == '' ? '' : $paymentMethod = $paymentmethondArray[$paymentMethod]; - return [ $booking->id, $booking->company_id,