diff --git a/app/Classes/Jobs/Commands/V2/ProcessPaymentReportV2CommandJob.php b/app/Classes/Jobs/Commands/V2/ProcessPaymentReportV2CommandJob.php index 6537670d..3543fec3 100644 --- a/app/Classes/Jobs/Commands/V2/ProcessPaymentReportV2CommandJob.php +++ b/app/Classes/Jobs/Commands/V2/ProcessPaymentReportV2CommandJob.php @@ -35,7 +35,7 @@ class ProcessPaymentReportV2CommandJob implements ShouldQueue public function handle() { - Log::info(Carbon::now() . ': Start job - Processing single record from 01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT] Import.'); + Log::info(Carbon::now() . ': Start job - Processing single record from 01R - RECEIVE PAYMENT [AR RECEIVE PAYMENT] Import.'); $start = new Carbon(); $docNo = $this->details['docno'] ?? null; @@ -73,7 +73,7 @@ class ProcessPaymentReportV2CommandJob implements ShouldQueue $end = new Carbon(); $elapsedTime = $start->diff($end)->format('%H:%I:%S'); - Log::info(Carbon::now() . ': End job - Processing single record from 01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT] Import. ElapsedTime: ' . $elapsedTime . '.'); + Log::info(Carbon::now() . ': End job - Processing single record from 01R - RECEIVE PAYMENT [AR RECEIVE PAYMENT] Import. ElapsedTime: ' . $elapsedTime . '.'); } diff --git a/app/Classes/Jobs/Commands/V2/ProcessSalesDepositByWalletPaymentEntryV2CommandJob.php b/app/Classes/Jobs/Commands/V2/ProcessSalesDepositByWalletPaymentEntryV2CommandJob.php new file mode 100644 index 00000000..cf473be0 --- /dev/null +++ b/app/Classes/Jobs/Commands/V2/ProcessSalesDepositByWalletPaymentEntryV2CommandJob.php @@ -0,0 +1,91 @@ +details = $details; + } + + public function handle() + { + Log::info(Carbon::now() . ': Start job - Processing single record from 01DRW - Sales Deposit by Wallet [AR PAYMENT ENTRY] Import.'); + $start = new Carbon(); + + $docNo = $this->details['docno'] ?? null; + $docDate = $this->details['docdate'] ?? null; + $debtorCode = $this->details['debtorcode'] ?? null; + $description = $this->details['description'] ?? null; + $paymentMethod = $this->details['paymentmethod'] ?? null; + $paymentAmt = $this->details['paymentamt'] ?? null; + + Log::info("Processing Sales Deposit By Wallet [Payment Entry] Report:", [ + 'DocNo' => $docNo, + 'DocDate' => $docDate, + 'DebtorCode' => $debtorCode, + 'Description' => $description, + 'PaymentMethod' => $paymentMethod, + 'PaymentAmt' => $paymentAmt, + ]); + + $transaction = Transaction::where('bill_no', $description)->first(); + if($transaction){ + if($docNo != "" && $docNo != "<>"){ + $this->updateOrCreateKeyValuePair($transaction, KVPKey::AUTOCOUNT_DOCNO_SALES_DEPOSIT_BY_WALLET_OFFICIAL_RECEIPT, $docNo); + } + // if($docDate){ + // $this->updateOrCreateKeyValuePair($transaction, KVPKey::AUTOCOUNT_DOCDATE_OFFICIAL_RECEIPT, is_numeric($docDate) ? $this->convertDocDateToString($docDate) : $docDate); + // } + } + + $end = new Carbon(); + $elapsedTime = $start->diff($end)->format('%H:%I:%S'); + Log::info(Carbon::now() . ': End job - Processing single record from 01DRW - Sales Deposit by Wallet [AR PAYMENT ENTRY] Import. ElapsedTime: ' . $elapsedTime . '.'); + } + + + private function updateOrCreateKeyValuePair($booking, $key, $value) + { + $keyValuePairObject = new KeyValuePairObject($key, $value); + $metadata = $booking->attributesKVP()->where('key', $key)->first(); + + if ($metadata) { + (App()->make(UpdatesKeyValuePair::class))->execute($metadata, $keyValuePairObject); + } else { + (App()->make(CreatesKeyValuePair::class))->execute($booking, $keyValuePairObject); + } + } + + private function convertDocDateToString($value, $format = 'm/d/Y') { + if (is_numeric($value)) { + return Carbon::instance(Date::excelToDateTimeObject($value))->format($format); + } + return Carbon::parse($value)->format($format); + } +} diff --git a/app/Classes/Jobs/Commands/V2/ProcessSalesDepositByWalletRefundEntryV2CommandJob.php b/app/Classes/Jobs/Commands/V2/ProcessSalesDepositByWalletRefundEntryV2CommandJob.php new file mode 100644 index 00000000..b984fab2 --- /dev/null +++ b/app/Classes/Jobs/Commands/V2/ProcessSalesDepositByWalletRefundEntryV2CommandJob.php @@ -0,0 +1,97 @@ +details = $details; + } + + public function handle() + { + Log::info(Carbon::now() . ': Start job - Processing single record from 01DRF - Sales Deposit by Wallet [AR REFUND ENTRY] Import.'); + $start = new Carbon(); + + $docNo = $this->details['docno'] ?? null; + $debtorCode = $this->details['debtorcode'] ?? null; + $docDate = $this->details['docdate'] ?? null; + $description = $this->details['description'] ?? null; + $deptNo = $this->details['deptno'] ?? null; + $paymentMethod = $this->details['paymentmethod'] ?? null; + $knockOffDocType = $this->details['knockoffdoctype'] ?? null; + $knockOffDocNo = $this->details['knockoffdocno'] ?? null; + $knockOffAmt = $this->details['knockoffamt'] ?? null; + + Log::info("Processing Sales Deposit By Wallet [Refund Entry] Report:", [ + 'DocNo' => $docNo, + 'DebtorCode' => $debtorCode, + 'DocDate' => $docDate, + 'Description' => $description, + 'DeptNo' => $deptNo, + 'PaymentMethod' => $paymentMethod, + 'KnockOffDocType' => $knockOffDocType, + 'KnockOffDocNo' => $knockOffDocNo, + 'KnockOffAmt' => $knockOffAmt, + ]); + + $transaction = Transaction::where('bill_no', $description)->first(); + if($transaction){ + if($docNo != "" && $docNo != "<>"){ + $this->updateOrCreateKeyValuePair($transaction, KVPKey::AUTOCOUNT_DOCNO_SALES_DEPOSIT_BY_WALLET_REFUND, $docNo); + } + // if($docDate){ + // $this->updateOrCreateKeyValuePair($transaction, KVPKey::AUTOCOUNT_DOCDATE_REFUND, is_numeric($docDate) ? $this->convertDocDateToString($docDate) : $docDate); + // } + } + + $end = new Carbon(); + $elapsedTime = $start->diff($end)->format('%H:%I:%S'); + Log::info(Carbon::now() . ': End job - Processing single record from 01DRF - Sales Deposit by Wallet [AR REFUND ENTRY] Import. ElapsedTime: ' . $elapsedTime . '.'); + } + + + private function updateOrCreateKeyValuePair($booking, $key, $value) + { + $keyValuePairObject = new KeyValuePairObject($key, $value); + $metadata = $booking->attributesKVP()->where('key', $key)->first(); + + if ($metadata) { + (App()->make(UpdatesKeyValuePair::class))->execute($metadata, $keyValuePairObject); + } else { + (App()->make(CreatesKeyValuePair::class))->execute($booking, $keyValuePairObject); + } + } + + private function convertDocDateToString($value, $format = 'm/d/Y') { + if (is_numeric($value)) { + return Carbon::instance(Date::excelToDateTimeObject($value))->format($format); + } + + return Carbon::parse($value)->format($format); + } +} diff --git a/app/Classes/Modules/Bookings/Services/CalculatesBookingCurrencyAverageRate.php b/app/Classes/Modules/Bookings/Services/CalculatesBookingCurrencyAverageRate.php index aaa3e569..9f5241f2 100644 --- a/app/Classes/Modules/Bookings/Services/CalculatesBookingCurrencyAverageRate.php +++ b/app/Classes/Modules/Bookings/Services/CalculatesBookingCurrencyAverageRate.php @@ -6,6 +6,7 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\TransactionType; use App\Models\Booking; use Carbon\Carbon; +use Illuminate\Support\Facades\Log; class CalculatesBookingCurrencyAverageRate { @@ -37,13 +38,13 @@ class CalculatesBookingCurrencyAverageRate } if ($type == TransactionType::PAYMENT) { - if($generateEInvoiceRefund){ + + $totalPayment = $booking->fix_currency_id === 1 ? $booking->transactions()->payments()->complete()->sum('original_amount') : + $booking->transactions()->payments()->complete()->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total'); + + if($totalPayment === 0 || $generateEInvoiceRefund){ $totalPayment = $booking->fix_currency_id === 1 ? $booking->transactions()->payments()->where('status', ApprovalStatus::REFUNDED)->sum('original_amount') : - $booking->transactions()->payments()->where('status', ApprovalStatus::REFUNDED)->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total'); - } - else{ - $totalPayment = $booking->fix_currency_id === 1 ? $booking->transactions()->payments()->complete()->sum('original_amount') : - $booking->transactions()->payments()->complete()->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total'); + $booking->transactions()->payments()->where('status', ApprovalStatus::REFUNDED)->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total'); } return $this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id, $generateEInvoiceRefund) / ($totalPayment + $discount); diff --git a/app/Classes/Modules/Exports/Services/ExportsSalesDepositByWallet1PaymentEntry.php b/app/Classes/Modules/Exports/Services/ExportsSalesDepositByWallet1PaymentEntry.php new file mode 100644 index 00000000..7ea660ba --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsSalesDepositByWallet1PaymentEntry.php @@ -0,0 +1,77 @@ +startDate = $startDate ? Carbon::parse($startDate)->startOfDay() : Carbon::now()->subMonths(1); + $this->endDate = $endDate ? Carbon::parse($endDate)->endOfDay() : Carbon::now(); + } + + public function headings(): array + { + return [ + 'DocNo', + 'DocDate', + 'DebtorCode', + 'Description', + 'DeptNo', + 'PaymentMethod', + 'PaymentAmt', + ]; + } + + /** + * @return \Illuminate\Support\Collection|mixed + */ + public function query() + { + $type = TransactionType::PAYMENT; + $query = Transaction::query(); + $query->where('owner_type', Wallet::class); + $query->where('type', $type); + $query->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + $query->whereBetween('created_at', [$this->startDate, $this->endDate]); + + return $query; + } + + /** + * @param Transaction $transaction + * @return array + */ + public function map($transaction): array + { + $formattedDocumentDate = Carbon::parse($transaction->created_at)->format('m/d/Y'); + $owner = $transaction->owner; + $company = $owner->owner; + return [ + '<>', //DocNo + $formattedDocumentDate, //DocDate + $company ? $company->debtor : '', //DebtorCode + $transaction->bill_no, //Description + 'C', //DeptNo + 'WALLET DEPOSIT - EXC', //PaymentMethod + number_format($transaction->amount, 2), //PaymentAmt + ]; + } +} diff --git a/app/Classes/Modules/Exports/Services/ExportsSalesDepositByWallet2RefundEntry.php b/app/Classes/Modules/Exports/Services/ExportsSalesDepositByWallet2RefundEntry.php new file mode 100644 index 00000000..58f59bd1 --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsSalesDepositByWallet2RefundEntry.php @@ -0,0 +1,89 @@ +startDate = $startDate ? Carbon::parse($startDate)->startOfDay() : Carbon::now()->subMonths(1); + $this->endDate = $endDate ? Carbon::parse($endDate)->endOfDay() : Carbon::now(); + } + + public function headings(): array + { + return [ + 'DocNo', + 'DebtorCode', + 'DocDate', + 'Description', + 'DeptNo', + 'PaymentMethod', + 'KnockOffDocType', + 'KnockOffDocNo', + 'KnockOffAmt', + ]; + } + + /** + * @return \Illuminate\Support\Collection|mixed + */ + public function query() + { + $type = TransactionType::PAYMENT; + $query = Transaction::query(); + $query->where('owner_type', Wallet::class); + $query->where('type', $type); + $query->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + $query->whereBetween('created_at', [$this->startDate, $this->endDate]); + + return $query; + } + + /** + * @param Transaction $transaction + * @return array + */ + public function map($transaction): array + { + $formattedDocumentDate = Carbon::parse($transaction->created_at)->format('m/d/Y'); + $owner = $transaction->owner; + $company = $owner->owner; + + $knockOffDocNo = ''; + $transactionKVP = $transaction->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_SALES_DEPOSIT_BY_WALLET_OFFICIAL_RECEIPT)->first(); + if($transactionKVP){ + $knockOffDocNo = $transactionKVP->value; + } + + return [ + '<>', //DocNo + $company ? $company->debtor : '', //DebtorCode + $formattedDocumentDate, //DocDate + $transaction->bill_no, //Description + 'C', //DeptNo + 'DEPOSIT IN TRANSIT', //PaymentMethod + 'RP', //KnockOffDocType + $knockOffDocNo, //KnockOffDocNo + number_format($transaction->amount, 2), //KnockOffAmt + ]; + } +} diff --git a/app/Classes/Modules/Exports/Services/ExportsSalesDepositByWallet3DepositEntry.php b/app/Classes/Modules/Exports/Services/ExportsSalesDepositByWallet3DepositEntry.php new file mode 100644 index 00000000..5a67fd1b --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsSalesDepositByWallet3DepositEntry.php @@ -0,0 +1,79 @@ +startDate = $startDate ? Carbon::parse($startDate)->startOfDay() : Carbon::now()->subMonths(1); + $this->endDate = $endDate ? Carbon::parse($endDate)->endOfDay() : Carbon::now(); + } + + public function headings(): array + { + return [ + 'DocNo', + 'DocDate', + 'DebtorCode', + 'Description', + 'DeptNo', + 'DepositPaymentMethod', + 'PaymentMethod', + 'PaymentAmt', + ]; + } + + /** + * @return \Illuminate\Support\Collection|mixed + */ + public function query() + { + $type = TransactionType::PAYMENT; + $query = Transaction::query(); + $query->where('owner_type', Wallet::class); + $query->where('type', $type); + $query->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + $query->whereBetween('created_at', [$this->startDate, $this->endDate]); + + return $query; + } + + /** + * @param Transaction $transaction + * @return array + */ + public function map($transaction): array + { + $formattedDocumentDate = Carbon::parse($transaction->created_at)->format('m/d/Y'); + $owner = $transaction->owner; + $company = $owner->owner; + return [ + '<>', //DocNo + $formattedDocumentDate, //DocDate + $company ? $company->debtor : '', //DebtorCode + $transaction->bill_no, //Description + 'C', //DeptNo + 'SALES DEPOSIT - EXC', //DepositPaymentMethod + 'DEPOSIT IN TRANSIT', //PaymentMethod + number_format($transaction->amount, 2), //PaymentAmt + ]; + } +} diff --git a/app/Classes/Modules/Imports/ControllersLogic/ImportExcelLogic.php b/app/Classes/Modules/Imports/ControllersLogic/ImportExcelLogic.php index 377407a2..02fef6ae 100644 --- a/app/Classes/Modules/Imports/ControllersLogic/ImportExcelLogic.php +++ b/app/Classes/Modules/Imports/ControllersLogic/ImportExcelLogic.php @@ -137,7 +137,7 @@ class ImportExcelLogic extends AbstractControllerLogic elseif ($reportType === 'Customers Report' && $normalizedHeader !== $customersReportHeader) { throw new MalformedRequestException('Uploaded Excel file format is incorrect. Column headers do not match expected format.'); } - elseif ($reportType === '01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT]' && $normalizedHeader !== $paymentReportHeader) { + elseif ($reportType === '01R - RECEIVE PAYMENT [AR RECEIVE PAYMENT]' && $normalizedHeader !== $paymentReportHeader) { throw new MalformedRequestException('Uploaded Excel file format is incorrect. Column headers do not match expected format.'); } elseif ($reportType === 'Credit Note Report' && $normalizedHeader !== $creditNoteReportHeader) { @@ -147,7 +147,7 @@ class ImportExcelLogic extends AbstractControllerLogic if ($reportType === 'Sales Invoice Report') { $this->processSalesInvoiceReport($sheet); } - else if ($reportType === '01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT]'){ + else if ($reportType === '01R - RECEIVE PAYMENT [AR RECEIVE PAYMENT]'){ $result = $this->processPaymentReport($sheet); $result = [ 'message' => empty($result) diff --git a/app/Classes/Modules/Imports/Services/AutoCountDataImport.php b/app/Classes/Modules/Imports/Services/AutoCountDataImport.php index 85d47a7b..9d36edb0 100644 --- a/app/Classes/Modules/Imports/Services/AutoCountDataImport.php +++ b/app/Classes/Modules/Imports/Services/AutoCountDataImport.php @@ -10,6 +10,8 @@ use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Jobs\Commands\V2\ProcessPaymentReportV2CommandJob; use App\Classes\Jobs\Commands\V2\ProcessSalesInvoiceReportV2CommandJob; use App\Classes\Jobs\Commands\V2\ProcessCreditNoteReportV2CommandJob; +use App\Classes\Jobs\Commands\V2\ProcessSalesDepositByWalletPaymentEntryV2CommandJob; +use App\Classes\Jobs\Commands\V2\ProcessSalesDepositByWalletRefundEntryV2CommandJob; use Illuminate\Support\Facades\Log; class AutoCountDataImport implements ToCollection, WithHeadingRow, WithChunkReading @@ -42,12 +44,18 @@ class AutoCountDataImport implements ToCollection, WithHeadingRow, WithChunkRead if ($this->reportType === 'Sales Invoice Report') { ProcessSalesInvoiceReportV2CommandJob::dispatch($row->toArray()); } - elseif ($this->reportType === '01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT]') { + elseif ($this->reportType === '01R - RECEIVE PAYMENT [AR RECEIVE PAYMENT]') { ProcessPaymentReportV2CommandJob::dispatch($row->toArray()); } else if ($this->reportType === 'Credit Note Report') { ProcessCreditNoteReportV2CommandJob::dispatch($row->toArray()); } + else if ($this->reportType === '01DRW - Sales Deposit by Wallet [AR PAYMENT ENTRY]') { + ProcessSalesDepositByWalletPaymentEntryV2CommandJob::dispatch($row->toArray()); + } + else if ($this->reportType === '01DRF - Sales Deposit by Wallet [AR REFUND ENTRY]') { + ProcessSalesDepositByWalletRefundEntryV2CommandJob::dispatch($row->toArray()); + } else { throw new MalformedRequestException('Cannot process report type: ' . $this->reportType); } @@ -99,6 +107,28 @@ class AutoCountDataImport implements ToCollection, WithHeadingRow, WithChunkRead 'einvoicevalidationlink' ]; + $salesDepositByWalletPaymentEntryReportHeader = [ + 'docno', + 'docdate', + 'debtorcode', + 'description', + 'deptno', + 'paymentmethod', + 'paymentamt', + ]; + + $salesDepositByWalletRefundEntryReportHeader = [ + 'docno', + 'debtorcode', + 'docdate', + 'description', + 'deptno', + 'paymentmethod', + 'knockoffdoctype', + 'knockoffdocno', + 'knockoffamt', + ]; + if ($reportType === 'Sales Invoice Report' && $header !== $salesInvoiceHeader && $header !== [...$salesInvoiceHeader, $optionalColumn]) { @@ -107,11 +137,17 @@ class AutoCountDataImport implements ToCollection, WithHeadingRow, WithChunkRead elseif ($reportType === 'Customers Report' && $header !== $customersReportHeader) { throw new MalformedRequestException('Uploaded Excel file format is incorrect. Column headers do not match expected format.'); } - elseif ($reportType === '01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT]' && $header !== $paymentReportHeader) { + elseif ($reportType === '01R - RECEIVE PAYMENT [AR RECEIVE PAYMENT]' && $header !== $paymentReportHeader) { throw new MalformedRequestException('Uploaded Excel file format is incorrect. Column headers do not match expected format.'); } elseif ($reportType === 'Credit Note Report' && $header !== $creditNoteReportHeader) { throw new MalformedRequestException('Uploaded Excel file format is incorrect. Column headers do not match expected format.'); } + elseif ($reportType === '01DRW - Sales Deposit by Wallet [AR PAYMENT ENTRY]' && $header !== $salesDepositByWalletPaymentEntryReportHeader) { + throw new MalformedRequestException('Uploaded Excel file format is incorrect. Column headers do not match expected format.'); + } + elseif ($reportType === '01DRF - Sales Deposit by Wallet [AR REFUND ENTRY]' && $header !== $salesDepositByWalletRefundEntryReportHeader) { + throw new MalformedRequestException('Uploaded Excel file format is incorrect. Column headers do not match expected format.'); + } } } diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionV2Processor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionV2Processor.php index bba4cf8b..1b6a671e 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionV2Processor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionV2Processor.php @@ -5,6 +5,7 @@ namespace App\Classes\Modules\Transactions\Processors; use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Modules\Bookings\Services\CalculatesBookingPayableAmount; use App\Classes\Modules\Bookings\Services\CalculatesBookingTransferredAmount; +use App\Classes\Modules\Bookings\Services\CalculatesBookingRefundAmount; use App\Classes\Modules\ServiceTypes\Services\FetchesServiceConfigurations; use App\Classes\Modules\Transactions\Services\ListsTransactions; use App\Classes\Modules\Transactions\Services\CreatesTransaction; @@ -55,6 +56,9 @@ class CreateInvoiceTransactionV2Processor /** @var CreateInvoiceDocumentProcessor */ private $invoiceDocumentProcessor; + /** @var CalculatesBookingRefundAmount */ + private $calculatesBookingRefundAmount; + /** * CreateInvoiceTransactionV2Processor constructor. @@ -69,8 +73,9 @@ class CreateInvoiceTransactionV2Processor * @param FetchesCompany $fetchesCompany * @param UpdatesBookingStatus $updatesBookingStatus * @param CreateInvoiceDocumentProcessor $invoiceDocumentProcessor + * @param CalculatesBookingRefundAmount $calculatesBookingRefundAmount */ - public function __construct(ListsTransactions $listsTransactions, CreatesTransaction $createsTransaction, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculatesBookingPaidAmount $calculatesBookingPaidAmount, CalculatesBookingPayableAmount $calculatesBookingPayableAmount, CalculatesBookingTransferredAmount $calculatesBookingTransferredAmount, FetchesServiceConfigurations $fetchesServiceConfigurations, CalculatesBookingCurrencyAverageRate $calculatesBookingCurrencyAverageRate, FetchesCompany $fetchesCompany, UpdatesBookingStatus $updatesBookingStatus, CreateInvoiceDocumentProcessor $invoiceDocumentProcessor) + public function __construct(ListsTransactions $listsTransactions, CreatesTransaction $createsTransaction, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculatesBookingPaidAmount $calculatesBookingPaidAmount, CalculatesBookingPayableAmount $calculatesBookingPayableAmount, CalculatesBookingTransferredAmount $calculatesBookingTransferredAmount, FetchesServiceConfigurations $fetchesServiceConfigurations, CalculatesBookingCurrencyAverageRate $calculatesBookingCurrencyAverageRate, FetchesCompany $fetchesCompany, UpdatesBookingStatus $updatesBookingStatus, CreateInvoiceDocumentProcessor $invoiceDocumentProcessor, CalculatesBookingRefundAmount $calculatesBookingRefundAmount) { $this->createsTransaction = $createsTransaction; $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; @@ -81,6 +86,7 @@ class CreateInvoiceTransactionV2Processor $this->fetchesCompany = $fetchesCompany; $this->updatesBookingStatus = $updatesBookingStatus; $this->invoiceDocumentProcessor = $invoiceDocumentProcessor; + $this->calculatesBookingRefundAmount = $calculatesBookingRefundAmount; } @@ -105,8 +111,13 @@ class CreateInvoiceTransactionV2Processor } $payable_amount = $this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id, $generateEInvoiceRefund); + $refund_amount = $this->calculatesBookingRefundAmount->execute($booking, $booking->fix_currency_id); $booking_amount = $booking->fix_amount; + if ((float) $booking_amount === (float) $refund_amount && !$generateEInvoice) { + return; + } + // confirm that booking amount has been fully paid if ((float) $booking_amount > (float) $payable_amount) { return; diff --git a/app/Classes/ValueObjects/Constants/KVPKey.php b/app/Classes/ValueObjects/Constants/KVPKey.php index 97703206..0eebe6bc 100644 --- a/app/Classes/ValueObjects/Constants/KVPKey.php +++ b/app/Classes/ValueObjects/Constants/KVPKey.php @@ -11,7 +11,7 @@ class KVPKey public const AUTOCOUNT_DOCNO_OFFICIAL_RECEIPT = 'AUTOCOUNT_DOCNO_OR'; public const AUTOCOUNT_DOCDATE_INVOICE = 'AUTOCOUNT_DOCDATE_I'; - + public const AUTOCOUNT_DOCNO_CREDIT_NOTE = 'AUTOCOUNT_DOCNO_CN'; public const AUTOCOUNT_EINVOICE_VALIDATION_LINK = 'AUTOCOUNT_EINVOICE_VALIDATION_LINK'; @@ -24,4 +24,10 @@ class KVPKey public const BOOKING_EINVOICE_ELIGIBLE = 'BOOKING_EINVOICE_ELIGIBLE'; + public const AUTOCOUNT_DOCNO_SALES_DEPOSIT_BY_WALLET_OFFICIAL_RECEIPT = 'AUTOCOUNT_DOCNO_SALES_DEPOSIT_BY_WALLET_OR'; + + public const AUTOCOUNT_DOCNO_SALES_DEPOSIT_BY_WALLET_REFUND = 'AUTOCOUNT_DOCNO_SALES_DEPOSIT_BY_WALLET_RF'; + + + } diff --git a/app/Http/Controllers/Exports/ExportController.php b/app/Http/Controllers/Exports/ExportController.php index c1c6b1b5..b6266ead 100644 --- a/app/Http/Controllers/Exports/ExportController.php +++ b/app/Http/Controllers/Exports/ExportController.php @@ -13,6 +13,9 @@ use App\Classes\Modules\Exports\Services\ExportsARCreditNoteReport; use App\Classes\Modules\Exports\Services\ExportsCompanies; use App\Classes\Modules\Exports\Services\ExportsReceivePaymentDepositEntryReport; use App\Classes\Modules\Exports\Services\ExportsReceivePaymentForBookingReport; +use App\Classes\Modules\Exports\Services\ExportsSalesDepositByWallet1PaymentEntry; +use App\Classes\Modules\Exports\Services\ExportsSalesDepositByWallet2RefundEntry; +use App\Classes\Modules\Exports\Services\ExportsSalesDepositByWallet3DepositEntry; use App\Classes\Modules\Exports\Services\ExportsWalletTopUpDepositEntryReport; use Carbon\Carbon; @@ -45,19 +48,37 @@ class ExportController public function receivePaymentDepositEntry(Request $request){ [$startDate, $endDate] = $this->getValidatedDates($request); $exporter = new ExportsReceivePaymentDepositEntryReport($startDate, $endDate); - return $this->handleExport($exporter, '01D - EXCHANGE - RECEIVE PAYMENT (FULL PAYMENT) [AR DEPOSIT ENTRY].xls'); + return $this->handleExport($exporter, '01D - Sales Deposit Received [AR DEPOSIT ENTRY].xls'); } public function receivePaymentDepositForBooking(Request $request){ [$startDate, $endDate] = $this->getValidatedDates($request); $exporter = new ExportsReceivePaymentForBookingReport($startDate, $endDate); - return $this->handleExport($exporter, '01R- RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT].xls'); + return $this->handleExport($exporter, '01R - RECEIVE PAYMENT [AR RECEIVE PAYMENT].xls'); } public function walletTopUpDepositEntry(Request $request){ [$startDate, $endDate] = $this->getValidatedDates($request); $exporter = new ExportsWalletTopUpDepositEntryReport($startDate, $endDate); - return $this->handleExport($exporter, 'Exchange Wallet Top Up - AR Deposit Entry.xls'); + return $this->handleExport($exporter, 'WALLET TOP UP REPORT [Wallet Deposit Received].xls'); + } + + public function salesDepositByWalletPaymentEntry(Request $request){ + [$startDate, $endDate] = $this->getValidatedDates($request); + $exporter = new ExportsSalesDepositByWallet1PaymentEntry($startDate, $endDate); + return $this->handleExport($exporter, '01DRW - Sales Deposit by Wallet [AR PAYMENT ENTRY].xls'); + } + + public function salesDepositByWalletRefundEntry(Request $request){ + [$startDate, $endDate] = $this->getValidatedDates($request); + $exporter = new ExportsSalesDepositByWallet2RefundEntry($startDate, $endDate); + return $this->handleExport($exporter, '01DRF - Sales Deposit by Wallet [AR REFUND ENTRY].xls'); + } + + public function salesDepositByWalletDepositEntry(Request $request){ + [$startDate, $endDate] = $this->getValidatedDates($request); + $exporter = new ExportsSalesDepositByWallet3DepositEntry($startDate, $endDate); + return $this->handleExport($exporter, '01DD - Sales Deposit by Wallet [AR DEPOSIT ENTRY].xls'); } private function getValidatedDates(Request $request): array diff --git a/app/Http/Controllers/Imports/ImportController.php b/app/Http/Controllers/Imports/ImportController.php index 79bfc0f0..e6595876 100644 --- a/app/Http/Controllers/Imports/ImportController.php +++ b/app/Http/Controllers/Imports/ImportController.php @@ -23,4 +23,9 @@ class ImportController extends Controller { return $logic->execute($request); } + + public function salesDeposit(Request $request, ImportExcelLogic $logic): JsonResponse + { + return $logic->execute($request); + } } diff --git a/resources/assets/vue/components/bookings/elements/DownloadUploadComponent.vue b/resources/assets/vue/components/bookings/elements/DownloadUploadComponent.vue index db55e7b0..81f1a195 100644 --- a/resources/assets/vue/components/bookings/elements/DownloadUploadComponent.vue +++ b/resources/assets/vue/components/bookings/elements/DownloadUploadComponent.vue @@ -18,10 +18,12 @@
1. Sales Invoice Report → Filters by Payment Date
2. Customers Report → Filters by E-Invoice Requested Date
- 3. 01D - RECEIVE PAYMENT (FULL PAYMENT) [AR DEPOSIT ENTRY] → Filters by Payment Date
- 4. 01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT] → Filters by Payment Date
+ 3. 01D - Sales Deposit Received [AR DEPOSIT ENTRY] → Filters by Payment Date
+ 4. 01R - RECEIVE PAYMENT [AR RECEIVE PAYMENT] → Filters by Payment Date
5. Credit Note Report → Filters by Credit Note Created Date
- 6. Wallet Top Up Report → Filters by Top Up Date
+ 6. 01DRW - Sales Deposit by Wallet [AR PAYMENT ENTRY] → Filters by Created Date
+ 7. 01DRF - Sales Deposit by Wallet [AR REFUND ENTRY] → Filters by Created Date
+ 8. 01DD - Sales Deposit by Wallet [AR DEPOSIT ENTRY] → Filters by Created Date
"> @@ -44,10 +46,12 @@
1. Sales Invoice Report → Filters by Payment Date
2. Customers Report → Filters by E-Invoice Requested Date
- 3. 01D - RECEIVE PAYMENT (FULL PAYMENT) [AR DEPOSIT ENTRY] → Filters by Payment Date
- 4. 01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT] → Filters by Payment Date
+ 3. 01D - Sales Deposit Received [AR DEPOSIT ENTRY] → Filters by Payment Date
+ 4. 01R - RECEIVE PAYMENT [AR RECEIVE PAYMENT] → Filters by Payment Date
5. Credit Note Report → Filters by Credit Note Created Date
- 6. Wallet Top Up Report → Filters by Top Up Date
+ 6. 01DRW - Sales Deposit by Wallet [AR PAYMENT ENTRY] → Filters by Created Date
+ 7. 01DRF - Sales Deposit by Wallet [AR REFUND ENTRY] → Filters by Created Date
+ 8. 01DD - Sales Deposit by Wallet [AR DEPOSIT ENTRY] → Filters by Created Date
"> @@ -148,8 +152,10 @@ export default { generateEInvoicesUrl: null, allowedReportTypes: [ 'Sales Invoice Report', - '01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT]', - 'Credit Note Report' + '01R - RECEIVE PAYMENT [AR RECEIVE PAYMENT]', + 'Credit Note Report', + '01DRW - Sales Deposit by Wallet [AR PAYMENT ENTRY]', + '01DRF - Sales Deposit by Wallet [AR REFUND ENTRY]', ] } }, @@ -172,8 +178,10 @@ export default { const importRoutesMap = { 'Sales Invoice Report': route('api.import.sales_invoices'), - '01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT]': route('api.import.official_receipt'), + '01R - RECEIVE PAYMENT [AR RECEIVE PAYMENT]': route('api.import.official_receipt'), 'Credit Note Report': route('api.import.credit_note'), + '01DRW - Sales Deposit by Wallet [AR PAYMENT ENTRY]': route('api.import.sales_deposit'), + '01DRF - Sales Deposit by Wallet [AR REFUND ENTRY]': route('api.import.sales_deposit'), }; return importRoutesMap[reportType] || ''; @@ -185,10 +193,13 @@ export default { 'Sales Invoice Report', 'Sales Invoice Report (with refund)', 'Customers Report', - '01D - RECEIVE PAYMENT (FULL PAYMENT) [AR DEPOSIT ENTRY]', - '01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT]', + '01D - Sales Deposit Received [AR DEPOSIT ENTRY]', + '01R - RECEIVE PAYMENT [AR RECEIVE PAYMENT]', 'Credit Note Report', - 'Wallet Top Up Report', + //'WALLET TOP UP REPORT [Wallet Deposit Received]', + '01DRW - Sales Deposit by Wallet [AR PAYMENT ENTRY]', + '01DRF - Sales Deposit by Wallet [AR REFUND ENTRY]', + '01DD - Sales Deposit by Wallet [AR DEPOSIT ENTRY]' ]; }, handleExportClick(){ @@ -201,10 +212,13 @@ export default { 'Sales Invoice Report': route('api.export.bookings.sales_invoices'), 'Sales Invoice Report (with refund)': route('api.export.bookings.sales_invoices_w_refund'), 'Customers Report': route('api.export.companies.customers_data'), - '01D - RECEIVE PAYMENT (FULL PAYMENT) [AR DEPOSIT ENTRY]': route('api.export.transactions.receive_payment_deposit_entry'), - '01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT]': route('api.export.transactions.receive_payment_for_booking'), + '01D - Sales Deposit Received [AR DEPOSIT ENTRY]': route('api.export.transactions.receive_payment_deposit_entry'), + '01R - RECEIVE PAYMENT [AR RECEIVE PAYMENT]': route('api.export.transactions.receive_payment_for_booking'), 'Credit Note Report': route('api.export.transactions.ar_credit_note'), - 'Wallet Top Up Report': route('api.export.transactions.wallet_top_up_deposit_entry'), + //'WALLET TOP UP REPORT [Wallet Deposit Received]': route('api.export.transactions.wallet_top_up_deposit_entry'), + '01DRW - Sales Deposit by Wallet [AR PAYMENT ENTRY]': route('api.export.transactions.sales_deposit_by_wallet_payment_entry'), + '01DRF - Sales Deposit by Wallet [AR REFUND ENTRY]': route('api.export.transactions.sales_deposit_by_wallet_refund_entry'), + '01DD - Sales Deposit by Wallet [AR DEPOSIT ENTRY]': route('api.export.transactions.sales_deposit_by_wallet_deposit_entry'), }; let url = `${routesMap[reportType]}?startDate=${this.parameters.startDate}&endDate=${this.parameters.endDate}`; diff --git a/resources/views/pages/pdfs/e_invoice.blade.php b/resources/views/pages/pdfs/e_invoice.blade.php index c62a8d75..529cd01c 100644 --- a/resources/views/pages/pdfs/e_invoice.blade.php +++ b/resources/views/pages/pdfs/e_invoice.blade.php @@ -75,7 +75,7 @@
Note: All items purchased are subject to our Terms & Conditions. Please refer to our official website for more information.
-

+
@@ -84,12 +84,12 @@
- @@ -100,7 +100,7 @@
+ style="width: 25%; height: auto; display: block;" />
+
- Please transfer the payment to:
- Bank: Maybank Berhad
- Account Name: CIEF Worldwide Sdn Bhd
- Account No: 568603010762
+ Please transfer the payment to:
+ Bank: Maybank Berhad
+ Account Name: CIEF Worldwide Sdn Bhd
+ Account No: 568603010762