mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-21 05:23:58 +00:00
Merge branch 'dillon/90-e-invoice-e-1' into vapor/staging
This commit is contained in:
@@ -15,7 +15,7 @@ use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Models\Booking;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||
|
||||
class ProcessSalesInvoiceReportV2CommandJob implements ShouldQueue
|
||||
{
|
||||
@@ -81,6 +81,9 @@ class ProcessSalesInvoiceReportV2CommandJob implements ShouldQueue
|
||||
if($eInvoiceValidationLink){
|
||||
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK, $eInvoiceValidationLink);
|
||||
}
|
||||
if($docDate){
|
||||
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCDATE_INVOICE, is_numeric($docDate) ? $this->convertDocDateToString($docDate) : $docDate);
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
@@ -100,4 +103,12 @@ class ProcessSalesInvoiceReportV2CommandJob implements ShouldQueue
|
||||
(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,81 @@
|
||||
<?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 ExportsWalletTopUpDepositEntryReport 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',
|
||||
'DepositPaymentMethod',
|
||||
'CurrencyCode',
|
||||
'PaymentMethod',
|
||||
'PaymentAmt',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
$type = TransactionType::TOP_UP;
|
||||
$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
|
||||
$company ? $company->debtor : '', //DebtorCode
|
||||
$formattedDocumentDate, //DocDate
|
||||
'Wallet Deposit', //Description
|
||||
'C', //DeptNo
|
||||
'WALLET DEPOSIT - EXC', //DepositPaymentMethod
|
||||
'MYR', //CurrencyCode
|
||||
'MBB', //PaymentMethod
|
||||
number_format($transaction->amount, 2), //PaymentAmt
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -63,9 +63,6 @@ class CreateInvoiceDocumentProcessor
|
||||
if ($bookingCreatedDate->isAfter($eInvoiceStartDate)) {
|
||||
$lastPaymentTransaction = $booking->transactions()->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::COMPLETED, ApprovalStatus::APPROVED])->latest()->first();
|
||||
$documentDate = $lastPaymentTransaction->created_at;
|
||||
// if(Carbon::parse($booking->updated_at)->isAfter($lastPaymentTransaction->created_at)){ //cief todo: 90 - Batch generate E-Invoice date incorrect
|
||||
// $documentDate = $booking->updated_at;
|
||||
// }
|
||||
}
|
||||
|
||||
if($document_type === DocumentType::EINVOICE){
|
||||
@@ -77,8 +74,14 @@ class CreateInvoiceDocumentProcessor
|
||||
if($metadata){
|
||||
$autoCountEInvoiceValidationLink = $metadata->value;
|
||||
}
|
||||
$lastDayOfMonth = $documentDate->copy()->endOfMonth();
|
||||
$documentDate = $lastDayOfMonth;
|
||||
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCDATE_INVOICE)->first();
|
||||
if($metadata){
|
||||
$documentDate = Carbon::parse($metadata->value);
|
||||
}
|
||||
else{
|
||||
$lastDayOfMonth = $documentDate->copy()->endOfMonth();
|
||||
$documentDate = $lastDayOfMonth;
|
||||
}
|
||||
}
|
||||
$payment = $booking->transactions()->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::COMPLETED, ApprovalStatus::APPROVED])->first();
|
||||
$refundAmount = $payment->transactions()->refunds()->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED])->sum('amount');
|
||||
|
||||
@@ -29,5 +29,5 @@ final class DocumentType {
|
||||
public const BILL_GROUP_PAYMENT_PROOF = 'BILL_GROUP_PAYMENT_PROOF';
|
||||
|
||||
public const RECEIPT_VOUCHER = 'RECEIPT_VOUCHER';
|
||||
public const EINVOICE = 'E_INVOICE'; //cief todo: 90 - why is there no E-CREDITNOTE
|
||||
public const EINVOICE = 'E_INVOICE';
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ class KVPKey
|
||||
|
||||
public const AUTOCOUNT_DOCNO_OFFICIAL_RECEIPT = 'AUTOCOUNT_DOCNO_OR';
|
||||
|
||||
public const AUTOCOUNT_DOCDATE_INVOICE = 'AUTOCOUNT_DOCDATE_I';
|
||||
|
||||
public const AUTOCOUNT_EINVOICE_VALIDATION_LINK = 'AUTOCOUNT_EINVOICE_VALIDATION_LINK';
|
||||
|
||||
public const CREDIT_NOTE_APPROVAL_DATE = 'CREDIT_NOTE_APPROVAL_DATE';
|
||||
|
||||
@@ -12,6 +12,7 @@ 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\ExportsWalletTopUpDepositEntryReport;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ExportController
|
||||
@@ -46,6 +47,12 @@ class ExportController
|
||||
return $this->handleExport($exporter, '01R- RECEIVE PAYMENT (FULL 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');
|
||||
}
|
||||
|
||||
private function getValidatedDates(Request $request): array
|
||||
{
|
||||
$validated = $request->validate([
|
||||
|
||||
@@ -142,6 +142,7 @@ export default {
|
||||
'01D - RECEIVE PAYMENT (FULL PAYMENT) [AR DEPOSIT ENTRY]',
|
||||
'01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT]',
|
||||
'Credit Note Report',
|
||||
'Wallet Top Up Report',
|
||||
];
|
||||
},
|
||||
handleExportClick(){
|
||||
@@ -156,6 +157,7 @@ export default {
|
||||
'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'),
|
||||
'Credit Note Report': route('api.export.transactions.ar_credit_note'),
|
||||
'Wallet Top Up Report': route('api.export.transactions.wallet_top_up_deposit_entry'),
|
||||
};
|
||||
|
||||
let url = `${routesMap[reportType]}?startDate=${this.parameters.startDate}&endDate=${this.parameters.endDate}`;
|
||||
|
||||
+10
-3
File diff suppressed because one or more lines are too long
@@ -92,21 +92,22 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
<td align="center" width="20%" style="float: right;">
|
||||
<table width="100%">
|
||||
<tbody>
|
||||
<tr align="center">
|
||||
<td>
|
||||
<img src="{{ url(config('qr.qr_code_img_url') . $autocountEInvoiceValidationLink ) }}" style="width: 230px; height: 230px;" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr align="center">
|
||||
<td>
|
||||
<h2 style="margin: 0 !important;"><strong>{{ $autocountEInvoiceValidationLink }}</strong></h2>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<td width="20%" valign="top" align="center">
|
||||
<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;" />
|
||||
|
||||
<div style="margin-top: 5px;
|
||||
word-break: break-word;
|
||||
overflow-wrap: break-word;
|
||||
white-space: normal;
|
||||
font-size: 12px;
|
||||
line-height: 1.2;
|
||||
text-align: center;">
|
||||
<strong>{{ $autocountEInvoiceValidationLink }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -16,6 +16,7 @@ Route::group(['prefix' => 'export', 'as' => 'export.', 'namespace' => 'Exports']
|
||||
Route::get('/ar-credit-note', [ExportController::class, 'arCreditNote'])->name('ar_credit_note');
|
||||
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');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user