Merge branch 'vapor/production' into dillon/90-e-invoice-f-2

This commit is contained in:
Dillon Ngo
2025-11-25 10:04:51 +08:00
16 changed files with 570 additions and 40 deletions
@@ -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 . '.');
}
@@ -0,0 +1,91 @@
<?php
namespace App\Classes\Jobs\Commands\V2;
use App\Classes\Modules\Accounts\DataTransferObjects\KeyValuePairObject;
use App\Classes\Modules\Accounts\Services\CreatesKeyValuePair;
use App\Classes\Modules\Accounts\Services\UpdatesKeyValuePair;
use App\Classes\ValueObjects\Constants\KVPKey;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use App\Models\Transaction;
use Illuminate\Support\Facades\Log;
use PhpOffice\PhpSpreadsheet\Shared\Date;
class ProcessSalesDepositByWalletPaymentEntryV2CommandJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/** @var array */
private $details;
/**
* ProcessSalesDepositByWalletPaymentEntryV2CommandJob constructor.
* @param array $details
*/
public function __construct(array $details)
{
$this->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 != "<<New>>"){
$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);
}
}
@@ -0,0 +1,97 @@
<?php
namespace App\Classes\Jobs\Commands\V2;
use App\Classes\Modules\Accounts\DataTransferObjects\KeyValuePairObject;
use App\Classes\Modules\Accounts\Services\CreatesKeyValuePair;
use App\Classes\Modules\Accounts\Services\UpdatesKeyValuePair;
use App\Classes\ValueObjects\Constants\KVPKey;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use App\Models\Transaction;
use Illuminate\Support\Facades\Log;
use PhpOffice\PhpSpreadsheet\Shared\Date;
class ProcessSalesDepositByWalletRefundEntryV2CommandJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/** @var array */
private $details;
/**
* ProcessSalesDepositByWalletRefundEntryV2CommandJob constructor.
* @param array $details
*/
public function __construct(array $details)
{
$this->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 != "<<New>>"){
$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);
}
}
@@ -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);
@@ -0,0 +1,77 @@
<?php
namespace App\Classes\Modules\Exports\Services;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Models\Transaction;
use App\Models\Wallet;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromQuery;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
class ExportsSalesDepositByWallet1PaymentEntry implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
{
use Exportable;
protected $startDate;
protected $endDate;
public function __construct($startDate = null, $endDate = null) {
$this->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 [
'<<New>>', //DocNo
$formattedDocumentDate, //DocDate
$company ? $company->debtor : '', //DebtorCode
$transaction->bill_no, //Description
'C', //DeptNo
'WALLET DEPOSIT - EXC', //PaymentMethod
number_format($transaction->amount, 2), //PaymentAmt
];
}
}
@@ -0,0 +1,89 @@
<?php
namespace App\Classes\Modules\Exports\Services;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\KVPKey;
use App\Models\Transaction;
use App\Models\Wallet;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromQuery;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
class ExportsSalesDepositByWallet2RefundEntry implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
{
use Exportable;
protected $startDate;
protected $endDate;
public function __construct($startDate = null, $endDate = null) {
$this->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 [
'<<New>>', //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
];
}
}
@@ -0,0 +1,79 @@
<?php
namespace App\Classes\Modules\Exports\Services;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Models\Transaction;
use App\Models\Wallet;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromQuery;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
class ExportsSalesDepositByWallet3DepositEntry implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
{
use Exportable;
protected $startDate;
protected $endDate;
public function __construct($startDate = null, $endDate = null) {
$this->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 [
'<<New>>', //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
];
}
}
@@ -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)
@@ -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.');
}
}
}
@@ -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;
@@ -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';
}
@@ -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
@@ -23,4 +23,9 @@ class ImportController extends Controller
{
return $logic->execute($request);
}
public function salesDeposit(Request $request, ImportExcelLogic $logic): JsonResponse
{
return $logic->execute($request);
}
}
@@ -18,10 +18,12 @@
<div>
1. Sales Invoice Report → Filters by Payment Date<br/>
2. Customers Report → Filters by E-Invoice Requested Date<br/>
3. 01D - RECEIVE PAYMENT (FULL PAYMENT) [AR DEPOSIT ENTRY] → Filters by Payment Date<br/>
4. 01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT] → Filters by Payment Date<br/>
3. 01D - Sales Deposit Received [AR DEPOSIT ENTRY] → Filters by Payment Date<br/>
4. 01R - RECEIVE PAYMENT [AR RECEIVE PAYMENT] → Filters by Payment Date<br/>
5. Credit Note Report → Filters by Credit Note Created Date<br/>
6. Wallet Top Up Report → Filters by Top Up Date<br/>
6. 01DRW - Sales Deposit by Wallet [AR PAYMENT ENTRY] → Filters by Created Date<br/>
7. 01DRF - Sales Deposit by Wallet [AR REFUND ENTRY] → Filters by Created Date<br/>
8. 01DD - Sales Deposit by Wallet [AR DEPOSIT ENTRY] → Filters by Created Date<br/>
</div>
">
<i class="fa fa-info-circle"></i>
@@ -44,10 +46,12 @@
<div>
1. Sales Invoice Report → Filters by Payment Date<br/>
2. Customers Report → Filters by E-Invoice Requested Date<br/>
3. 01D - RECEIVE PAYMENT (FULL PAYMENT) [AR DEPOSIT ENTRY] → Filters by Payment Date<br/>
4. 01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT] → Filters by Payment Date<br/>
3. 01D - Sales Deposit Received [AR DEPOSIT ENTRY] → Filters by Payment Date<br/>
4. 01R - RECEIVE PAYMENT [AR RECEIVE PAYMENT] → Filters by Payment Date<br/>
5. Credit Note Report → Filters by Credit Note Created Date<br/>
6. Wallet Top Up Report → Filters by Top Up Date<br/>
6. 01DRW - Sales Deposit by Wallet [AR PAYMENT ENTRY] → Filters by Created Date<br/>
7. 01DRF - Sales Deposit by Wallet [AR REFUND ENTRY] → Filters by Created Date<br/>
8. 01DD - Sales Deposit by Wallet [AR DEPOSIT ENTRY] → Filters by Created Date<br/>
</div>
">
<i class="fa fa-info-circle"></i>
@@ -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}`;
@@ -75,7 +75,7 @@
<div class="note">
<strong>Note:</strong> All items purchased are subject to our Terms & Conditions. Please refer to our official website for more information.
</div>
<br><br>
<br>
<table style="width: 100%; border-spacing: 0;">
<tbody>
@@ -84,12 +84,12 @@
<table style="border-spacing:10px 10px;">
<tbody>
<tr>
<td style="border-bottom: solid 2p·x #000000;">
<td style="border-bottom: solid 2px #000000;">
<div class="bank-info">
Please transfer the payment to:<br>
Bank: Maybank Berhad<br>
Account Name: CIEF Worldwide Sdn Bhd<br>
Account No: 568603010762<br>
<span style="font-size: 20px;">Please transfer the payment to:</span><br>
<span style="font-size: 20px;">Bank: Maybank Berhad</span><br>
<span style="font-size: 20px;">Account Name: CIEF Worldwide Sdn Bhd</span><br>
<span style="font-size: 20px;">Account No: 568603010762</span><br>
</div>
</td>
</tr>
@@ -100,7 +100,7 @@
<div style="display: inline-block; text-align: center; max-width: 230px; width: 100%;">
<img src="{{ url(config('qr.qr_code_img_url') . $autocountEInvoiceValidationLink ) }}"
style="width: 40%; height: auto; display: block;" />
style="width: 25%; height: auto; display: block;" />
<div style="margin-top: 5px;
word-break: break-word;
+4 -1
View File
@@ -18,11 +18,14 @@ Route::group(['prefix' => 'export', 'as' => 'export.', 'namespace' => 'Exports']
Route::get('/receive-payment-deposit-entry', [ExportController::class, 'receivePaymentDepositEntry'])->name('receive_payment_deposit_entry');
Route::get('/receive-payment-for-booking', [ExportController::class, 'receivePaymentDepositForBooking'])->name('receive_payment_for_booking');
Route::get('/wallet-top-up-deposit-entry', [ExportController::class, 'walletTopUpDepositEntry'])->name('wallet_top_up_deposit_entry');
Route::get('/sales-deposit-by-wallet-payment-entry', [ExportController::class, 'salesDepositByWalletPaymentEntry'])->name('sales_deposit_by_wallet_payment_entry');
Route::get('/sales-deposit-by-wallet-refund-entry', [ExportController::class, 'salesDepositByWalletRefundEntry'])->name('sales_deposit_by_wallet_refund_entry');
Route::get('/sales-deposit-by-wallet-deposit-entry', [ExportController::class, 'salesDepositByWalletDepositEntry'])->name('sales_deposit_by_wallet_deposit_entry');
});
});
Route::group(['prefix' => 'import', 'as' => 'import.', 'namespace' => 'Imports'], function () {
Route::post('/import/sales-invoice', [ImportController::class, 'salesInvoices'])->name('sales_invoices');
Route::post('/import/offical-receipt', [ImportController::class, 'officialReceipt'])->name('official_receipt');
Route::post('/import/credit-note', [ImportController::class, 'creditNote'])->name('credit_note');
Route::post('/import/sales-deposit', [ImportController::class, 'salesDeposit'])->name('sales_deposit');
});