Admin Workflow - Fix new unclear workflow requirement

This commit is contained in:
Dillon Ngo
2025-02-28 15:51:29 +08:00
parent 3b0f81c842
commit 623fc45442
9 changed files with 324 additions and 112 deletions
@@ -106,33 +106,34 @@ class FetchNextQuestionV1AdminWFProcessor
$questions = $this->listsQuestions->execute(['questionnaire_set_id' => $questionnaireSetId, 'question_number' => $question_number]);
if($previousAnswer['answer'] === '1688_order_verified' && count($questions) == 0){
$questionMetadata = $questionContext['questionMetadata'] ?? null;
$processed = $questionMetadata['amount_processed'];
$amount = $questionMetadata['amount'];
$amountProcessed = $questionMetadata['amount_processed'];
$amountPaid = $questionMetadata['paid_amount'];
$wallet = $booking->company->wallets()->first();
$walletAmount = $wallet->amount;
if ($processed === $amount) {
if ($amountProcessed === $amountPaid) {
$question_number = '1688_proceed_order';
}
else if ($processed < $amount) {
else if ($amountProcessed > $amountPaid) {
$outstanding = $this->calculatesBookingOutstanding->execute($booking) + $this->calculatesBookingRefundAmount->execute($booking, $booking->fix_currency_id);
$differenceUnder = $amount - $processed;
$conversionObject = new CurrencyConversionObject(floatval(str_replace(',', '', $differenceUnder)), $booking->convertible_currency_id, $booking->service_id, $booking->fix_currency_id === 1 ? 0:1, PaymentMethodType::PAYMENT_METHODS['wallet']);
$differenceUnderPayinCNY = $amountProcessed - $amountPaid;
$conversionObject = new CurrencyConversionObject(floatval(str_replace(',', '', $differenceUnderPayinCNY)), $booking->convertible_currency_id, $booking->service_id, $booking->fix_currency_id === 1 ? 0:1, PaymentMethodType::PAYMENT_METHODS['wallet']);
$configurations = $this->fetchBookingQuotation->execute($booking->company, $conversionObject);
$underpay = $configurations->getTotal();
$amountUnderpay = $configurations->getTotal();
if($underpay > round($outstanding, 2)) {
$question_number = '1688_underpaid_order_3';
}
else if($walletAmount > $underpay) {
// if($amountUnderpay > round($outstanding, 2)) {
// $question_number = '1688_underpaid_order_3';
// }
if($walletAmount > $amountUnderpay) {
$question_number = '1688_underpaid_order_1';
}
else {
$question_number = '1688_underpaid_order_2';
}
} else {
}
else {
$question_number = '1688_overpaid_order';
}
}