mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-27 16:34:00 +00:00
Merge branch 'dillon/90-e-invoice-f-2' into vapor/production
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
<?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\Modules\Bookings\Processors\RegenerateInvoiceBookingProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
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\Booking;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
class ProcessCreditNoteReportV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var array */
|
||||
private $details;
|
||||
|
||||
/**
|
||||
* ProcessCreditNoteReportV2CommandJob constructor.
|
||||
* @param array $details
|
||||
*/
|
||||
public function __construct(array $details)
|
||||
{
|
||||
$this->details = $details;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Processing single record for E-Invoice from Credit Note Report Import.');
|
||||
$start = new Carbon();
|
||||
|
||||
$docNo = $this->details['docno'] ?? null;
|
||||
$docDate = $this->details['docdate'] ?? null;
|
||||
$debtorCode = $this->details['debtorcode'] ?? null;
|
||||
$ref = $this->details['ref'] ?? null;
|
||||
$description = $this->details['description'] ?? null;
|
||||
$reason = $this->details['reason'] ?? null;
|
||||
$deptNo = $this->details['deptno'] ?? null;
|
||||
$qty = $this->details['qty'] ?? null;
|
||||
$unitPrice = $this->details['unitprice'] ?? null;
|
||||
$accNo = $this->details['accno'] ?? null;
|
||||
$submitEinvoice = $this->details['submiteinvoice'] ?? null;
|
||||
$einvoiceIssueDateTime = $this->details['einvoiceissuedatetime'] ?? null;
|
||||
$consolidatedEinvoice = $this->details['consolidatedeinvoice'] ?? null;
|
||||
$eInvoiceValidationLink = $this->details['einvoicevalidationlink'] ?? null;
|
||||
|
||||
Log::info("Processing Credit Note Report:", [
|
||||
'DocNo' => $docNo,
|
||||
'DocDate' => $docDate,
|
||||
'DebtorCode' => $debtorCode,
|
||||
'Ref' => $ref,
|
||||
'Description' => $description,
|
||||
'Reason' => $reason,
|
||||
'DeptNo' => $deptNo,
|
||||
'Qty' => $qty,
|
||||
'UnitPrice' => $unitPrice,
|
||||
'AccNo' => $accNo,
|
||||
'SubmitEinvoice' => $submitEinvoice,
|
||||
'EInvoiceIssueDateTime' => $einvoiceIssueDateTime,
|
||||
'ConsolidatedEinvoice' => $consolidatedEinvoice,
|
||||
'EInvoiceValidationLink' => $eInvoiceValidationLink,
|
||||
]);
|
||||
|
||||
$booking = Booking::where('marking', $ref)->first();
|
||||
if($booking){
|
||||
if($docNo != "" && $docNo != "<<New>>"){
|
||||
$payments = $booking->transactions()->payments()->get();
|
||||
foreach ($payments as $payment) {
|
||||
$refundTransaction = $payment->transactions()->refunds()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->latest()->first();
|
||||
if($refundTransaction){
|
||||
$this->updateOrCreateKeyValuePair($refundTransaction, KVPKey::AUTOCOUNT_DOCNO_CREDIT_NOTE, $docNo);
|
||||
if($eInvoiceValidationLink){
|
||||
$this->updateOrCreateKeyValuePair($refundTransaction, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK_CREDIT_NOTE, $eInvoiceValidationLink);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Processing single record for E-Invoice from Credit Note Report 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,10 +75,13 @@ class UpdateBookingAmountWithPOLogic extends AbstractControllerLogic
|
||||
$booking = $this->fetchesBooking->execute(['id' => $request->route('id') ?? $id]);
|
||||
$outstandingAmount = $this->calculatesBookingOutstanding->execute($booking);
|
||||
$bookingAttribute = $booking->attributesKVP()->where('key', "BOOKING_AMOUNT_UPDATE")->first();
|
||||
$paidAmount = floatval($this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id)) - floatval($this->calculatesBookingRefundAmount->execute($booking, $booking->fix_currency_id));
|
||||
$refundAmount = $this->calculatesBookingRefundAmount->execute($booking, $booking->fix_currency_id);
|
||||
$paidAmount = floatval($this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id)) - floatval($refundAmount);
|
||||
|
||||
if($paidAmount > 0 && $outstandingAmount > 0 && !$bookingAttribute){
|
||||
throw new MalformedRequestException('Purchase Order at this point can only be edited after editing the booking amount');
|
||||
if($refundAmount != $outstandingAmount){
|
||||
throw new MalformedRequestException('Purchase Order at this point can only be edited after editing the booking amount');
|
||||
}
|
||||
}
|
||||
|
||||
if($bookingAttribute){
|
||||
|
||||
@@ -105,6 +105,24 @@ class ImportExcelLogic extends AbstractControllerLogic
|
||||
'knockoffdocno'
|
||||
];
|
||||
|
||||
$creditNoteReportHeader = [
|
||||
'docno',
|
||||
'docdate',
|
||||
'debtorcode',
|
||||
'ref',
|
||||
'description',
|
||||
'reason',
|
||||
'deptno',
|
||||
'qty',
|
||||
'unitprice',
|
||||
'accno',
|
||||
'submiteinvoice',
|
||||
'einvoiceissuedatetime',
|
||||
'consolidatedeinvoice',
|
||||
'einvoicevalidationlink'
|
||||
];
|
||||
|
||||
|
||||
if ($reportType === 'Sales Invoice Report') {
|
||||
$optionalColumn = 'einvoicevalidationlink';
|
||||
|
||||
@@ -115,12 +133,16 @@ class ImportExcelLogic extends AbstractControllerLogic
|
||||
throw new MalformedRequestException('Uploaded Excel file format is incorrect. Column headers do not match expected format.');
|
||||
}
|
||||
|
||||
} elseif ($reportType === 'Customers Report' && $normalizedHeader !== $customersReportHeader) {
|
||||
}
|
||||
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) {
|
||||
throw new MalformedRequestException('Uploaded Excel file format is incorrect. Column headers do not match expected format.');
|
||||
}
|
||||
elseif ($reportType === 'Credit Note Report' && $normalizedHeader !== $creditNoteReportHeader) {
|
||||
throw new MalformedRequestException('Uploaded Excel file format is incorrect. Column headers do not match expected format.');
|
||||
}
|
||||
|
||||
if ($reportType === 'Sales Invoice Report') {
|
||||
$this->processSalesInvoiceReport($sheet);
|
||||
@@ -134,6 +156,15 @@ class ImportExcelLogic extends AbstractControllerLogic
|
||||
'data' => $result
|
||||
];
|
||||
}
|
||||
else if ($reportType === 'Credit Note Report') {
|
||||
$result = $this->processCreditNoteReport($sheet);
|
||||
$result = [
|
||||
'message' => empty($result)
|
||||
? ''
|
||||
: 'Some data are unprocessed: ',
|
||||
'data' => $result
|
||||
];
|
||||
}
|
||||
else{
|
||||
throw new MalformedRequestException('Cannot process report type: ' . $reportType);
|
||||
}
|
||||
@@ -155,7 +186,7 @@ class ImportExcelLogic extends AbstractControllerLogic
|
||||
}
|
||||
|
||||
private function processSalesInvoiceReport($sheet){
|
||||
$rows = $sheet->skip(1);
|
||||
$rows = $sheet->skip(1);
|
||||
|
||||
foreach ($rows as $index => $details) {
|
||||
$docNo = $details[0] ?? null;
|
||||
@@ -254,4 +285,70 @@ class ImportExcelLogic extends AbstractControllerLogic
|
||||
|
||||
return $unprocessedKnockOffs;
|
||||
}
|
||||
|
||||
private function processCreditNoteReport($sheet){
|
||||
$unprocessedDocNos = [];
|
||||
$rows = $sheet->skip(1);
|
||||
|
||||
foreach ($rows as $index => $details) {
|
||||
$docNo = $details[0] ?? null;
|
||||
$docDate = $details[1] ?? null;
|
||||
$debtorCode = $details[2] ?? null;
|
||||
$ref = $details[3] ?? null;
|
||||
$description = $details[4] ?? null;
|
||||
$reason = $details[5] ?? null;
|
||||
$deptNo = $details[6] ?? null;
|
||||
$qty = $details[7] ?? null;
|
||||
$unitPrice = $details[8] ?? null;
|
||||
$accNo = $details[9] ?? null;
|
||||
$submitEinvoice = $details[10] ?? null;
|
||||
$einvoiceIssueDateTime = $details[11] ?? null;
|
||||
$consolidatedEinvoice = $details[12] ?? null;
|
||||
$eInvoiceValidationLink = $details[13] ?? null;
|
||||
|
||||
Log::info("Row {$index} processCreditNoteReport:", [
|
||||
'DocNo' => $docNo,
|
||||
'DocDate' => $docDate,
|
||||
'DebtorCode' => $debtorCode,
|
||||
'Ref' => $ref,
|
||||
'Description' => $description,
|
||||
'Reason' => $reason,
|
||||
'DeptNo' => $deptNo,
|
||||
'Qty' => $qty,
|
||||
'UnitPrice' => $unitPrice,
|
||||
'AccNo' => $accNo,
|
||||
'SubmitEinvoice' => $submitEinvoice,
|
||||
'EInvoiceIssueDateTime' => $einvoiceIssueDateTime,
|
||||
'ConsolidatedEinvoice' => $consolidatedEinvoice,
|
||||
'EInvoiceValidationLink' => $eInvoiceValidationLink,
|
||||
]);
|
||||
|
||||
$booking = Booking::where('marking', $ref)->first();
|
||||
if($booking){
|
||||
if($docNo != "" && $docNo != "<<New>>"){
|
||||
$payments = $booking->transactions()->payments()->get();
|
||||
$processed = false;
|
||||
foreach ($payments as $payment) {
|
||||
$refundTransaction = $payment->transactions()->refunds()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->latest()->first();
|
||||
if($refundTransaction){
|
||||
$this->updateOrCreateKeyValuePair($refundTransaction, KVPKey::AUTOCOUNT_DOCNO_CREDIT_NOTE, $docNo);
|
||||
if($eInvoiceValidationLink){
|
||||
$this->updateOrCreateKeyValuePair($refundTransaction, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK_CREDIT_NOTE, $eInvoiceValidationLink);
|
||||
}
|
||||
$processed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!$processed){
|
||||
$unprocessedDocNos[] = $docNo;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
$unprocessedDocNos[] = $docNo;
|
||||
}
|
||||
}
|
||||
|
||||
return $unprocessedDocNos;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use Maatwebsite\Excel\Concerns\WithChunkReading;
|
||||
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 Illuminate\Support\Facades\Log;
|
||||
|
||||
class AutoCountDataImport implements ToCollection, WithHeadingRow, WithChunkReading
|
||||
@@ -40,10 +41,14 @@ 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 (FULL PAYMENT) [AR RECEIVE PAYMENT]') {
|
||||
ProcessPaymentReportV2CommandJob::dispatch($row->toArray());
|
||||
}
|
||||
else{
|
||||
else if ($this->reportType === 'Credit Note Report') {
|
||||
ProcessCreditNoteReportV2CommandJob::dispatch($row->toArray());
|
||||
}
|
||||
else {
|
||||
throw new MalformedRequestException('Cannot process report type: ' . $this->reportType);
|
||||
}
|
||||
}
|
||||
@@ -77,6 +82,23 @@ class AutoCountDataImport implements ToCollection, WithHeadingRow, WithChunkRead
|
||||
'knockoffdocno'
|
||||
];
|
||||
|
||||
$creditNoteReportHeader = [
|
||||
'docno',
|
||||
'docdate',
|
||||
'debtorcode',
|
||||
'ref',
|
||||
'description',
|
||||
'reason',
|
||||
'deptno',
|
||||
'qty',
|
||||
'unitprice',
|
||||
'accno',
|
||||
'submiteinvoice',
|
||||
'einvoiceissuedatetime',
|
||||
'consolidatedeinvoice',
|
||||
'einvoicevalidationlink'
|
||||
];
|
||||
|
||||
if ($reportType === 'Sales Invoice Report' &&
|
||||
$header !== $salesInvoiceHeader &&
|
||||
$header !== [...$salesInvoiceHeader, $optionalColumn]) {
|
||||
@@ -88,5 +110,8 @@ class AutoCountDataImport implements ToCollection, WithHeadingRow, WithChunkRead
|
||||
elseif ($reportType === '01R - RECEIVE PAYMENT (FULL 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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+27
-15
@@ -46,6 +46,8 @@ class GenerateCreditNotePdfV2Logic
|
||||
{
|
||||
$pdfTemplateName = 'pages.pdfs.credit_note_v2'; //default since e-invoice implementation
|
||||
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
|
||||
$autoCountInvoiceId = '';
|
||||
$autoCountEInvoiceValidationLink = 'CIEF';
|
||||
|
||||
if($transaction->type === TransactionType::REFUND){
|
||||
//Retrieve TransactionType::CREDIT_NOTE
|
||||
@@ -91,23 +93,25 @@ class GenerateCreditNotePdfV2Logic
|
||||
|
||||
if($eInvoiceStarted) {
|
||||
$eInvoiceStarted = false; //reset to re-evaluate second time
|
||||
$autoCountInvoiceId = '';
|
||||
$autoCountEInvoiceValidationLink = '';
|
||||
|
||||
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE)->first();
|
||||
if($metadata){
|
||||
$autoCountInvoiceId = $metadata->value;
|
||||
}
|
||||
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK)->first();
|
||||
if($metadata){
|
||||
$autoCountEInvoiceValidationLink = $metadata->value;
|
||||
}
|
||||
$kvp = KeyValuePair::where('key', KVPKey::TRANSACTION_MODEL_CLASS)->where('value', $transaction->id)->first();
|
||||
$refundTransaction = $kvp ? $kvp->owner : null;
|
||||
if($refundTransaction && $refundTransaction->type === TransactionType::REFUND){
|
||||
$metadata = $refundTransaction->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_CREDIT_NOTE)->first();
|
||||
if($metadata){
|
||||
$autoCountInvoiceId = $metadata->value;
|
||||
}
|
||||
$metadata = $refundTransaction->attributesKVP()->where('key', KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK_CREDIT_NOTE)->first();
|
||||
if($metadata){
|
||||
$autoCountEInvoiceValidationLink = $metadata->value;
|
||||
}
|
||||
|
||||
Log::info('autoCountInvoiceId: ' . $autoCountInvoiceId);
|
||||
Log::info('autoCountEInvoiceValidationLink: ' . $autoCountEInvoiceValidationLink);
|
||||
Log::info('AUTOCOUNT_DOCNO_CREDIT_NOTE: ' . $autoCountInvoiceId);
|
||||
Log::info('AUTOCOUNT_EINVOICE_VALIDATION_LINK_CREDIT_NOTE: ' . $autoCountEInvoiceValidationLink);
|
||||
|
||||
if($autoCountInvoiceId && $autoCountEInvoiceValidationLink){
|
||||
$eInvoiceStarted = true;
|
||||
if($autoCountInvoiceId && $autoCountEInvoiceValidationLink){
|
||||
$eInvoiceStarted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +131,15 @@ class GenerateCreditNotePdfV2Logic
|
||||
Log::info('Based on booking created date, E-Credit Note not yet started. / Not Yet Ready.');
|
||||
}
|
||||
|
||||
$pdf = LaravelMpdf::loadView($pdfTemplateName, ['transaction' => $transaction, 'booking' => $booking, 'supplier' => $supplier, 'date' => $date, 'brn' => $brn,]);
|
||||
$pdf = LaravelMpdf::loadView($pdfTemplateName, [
|
||||
'transaction' => $transaction,
|
||||
'booking' => $booking,
|
||||
'supplier' => $supplier,
|
||||
'date' => $date,
|
||||
'brn' => $brn,
|
||||
'autocountId' => $autoCountInvoiceId,
|
||||
'autocountEInvoiceValidationLink' => $autoCountEInvoiceValidationLink,
|
||||
]);
|
||||
|
||||
$exportFileName = 'CreditNote.pdf';
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
|
||||
+3
-3
@@ -125,9 +125,9 @@ class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic
|
||||
$this->updatesTransactionStatus->execute($po_transaction, (float) number_format($po_transaction->amount, 2, '.', '') === (float) number_format((float)$booking->fix_amount - $refundTransaction->original_amount, 2, '.', '') ? ApprovalStatus::PENDING_VERIFICATION : ApprovalStatus::PENDING_SUBMISSION);
|
||||
}
|
||||
|
||||
$request['fix_amount'] = $booking->fix_amount - $refundTransaction->original_amount;
|
||||
$request->route()->setParameter('id', $booking->id);
|
||||
$this->updateBookingAmountLogic->execute($request);
|
||||
// $request['fix_amount'] = $booking->fix_amount - $refundTransaction->original_amount;
|
||||
// $request->route()->setParameter('id', $booking->id);
|
||||
// $this->updateBookingAmountLogic->execute($request);
|
||||
}
|
||||
|
||||
if ($supplierRefundTransaction) {
|
||||
|
||||
@@ -11,9 +11,13 @@ 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';
|
||||
|
||||
public const AUTOCOUNT_EINVOICE_VALIDATION_LINK_CREDIT_NOTE = 'AUTOCOUNT_EINVOICE_VALIDATION_LINK_CN';
|
||||
|
||||
public const CREDIT_NOTE_APPROVAL_DATE = 'CREDIT_NOTE_APPROVAL_DATE';
|
||||
|
||||
public const TRANSACTION_MODEL_CLASS = 'App\Models\Transaction';
|
||||
|
||||
@@ -14,7 +14,12 @@ class ImportController extends Controller
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
public function officialReceipt(Request $request, ImportExcelLogic $logic): JsonResponse
|
||||
public function officialReceipt(Request $request, ImportExcelLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
public function creditNote(Request $request, ImportExcelLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ class BookingResource extends JsonResource
|
||||
$eInvoice = true;
|
||||
}
|
||||
|
||||
$outStandingAmountWithRefund = floatval((App()->make(CalculatesBookingOutstanding::class))->execute($this->resource)) - floatval((App()->make(CalculatesBookingRefundAmount::class))->execute($this->resource, $this->fix_currency_id));
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'company' => new CompanyResource($this->company),
|
||||
@@ -48,7 +50,8 @@ class BookingResource extends JsonResource
|
||||
'amount' => $this->fix_amount,
|
||||
'floating_amount' => floatval((App()->make(CalculatesBookingFloatingAmount::class))->execute($this->resource, $this->fix_currency_id)),
|
||||
'paid_amount' => floatval((App()->make(CalculatesBookingPayableAmount::class))->execute($this->resource, $this->fix_currency_id)) - floatval((App()->make(CalculatesBookingRefundAmount::class))->execute($this->resource, $this->fix_currency_id)),
|
||||
// 'outstanding_amount' => floatval((App()->make(CalculatesBookingOutstanding::class))->execute($this->resource)) + floatval((App()->make(CalculatesBookingRefundAmount::class))->execute($this->resource, $this->fix_currency_id)),
|
||||
'outstanding_amount_with_refund' => $outStandingAmountWithRefund > 0 ? $outStandingAmountWithRefund : 0,
|
||||
'refunded_amount' => floatval((App()->make(CalculatesBookingRefundAmount::class))->execute($this->resource, $this->fix_currency_id)),
|
||||
'outstanding_amount' => floatval((App()->make(CalculatesBookingOutstanding::class))->execute($this->resource)),
|
||||
'fixed_currency' => new CurrencyResource($this->fixedCurrency),
|
||||
'convertible_currency' => new CurrencyResource($this->convertibleCurrency),
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Http\Resources;
|
||||
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingRefundAmount;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\KVPKey;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Booking;
|
||||
use Carbon\Carbon;
|
||||
@@ -37,6 +38,14 @@ class TransactionResource extends JsonResource
|
||||
}
|
||||
//Check if Transaction of type PAYMENT has an override for recipient bank - ends
|
||||
|
||||
$eInvoice = false;
|
||||
if($booking && $this->type === TransactionType::REFUND){
|
||||
$kvp = $this->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_CREDIT_NOTE)->first();
|
||||
if($kvp){
|
||||
$eInvoice = true;
|
||||
}
|
||||
}
|
||||
|
||||
$days = $this->created_at->endOfDay()->addWeekdays($booking->service_id === 3 ? 3 : 1);
|
||||
return [
|
||||
'id' => $this->id,
|
||||
@@ -72,7 +81,8 @@ class TransactionResource extends JsonResource
|
||||
'remarks' => RemarkResource::collection($this->remarks),
|
||||
'redemption' => new VoucherRedemptionResource($this->voucherRedemption),
|
||||
'bank' => ((int) $this->type === TransactionType::PAYMENT) ? new BankResource($bank) : null, //When a transaction (of type payment) has an override recipient bank details on booking, this is NOT null
|
||||
'bank_recipient_edited' => $isEditedBankRecipient
|
||||
'bank_recipient_edited' => $isEditedBankRecipient,
|
||||
'e_invoice' => $this->when($this->type === TransactionType::REFUND, $eInvoice),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,6 +146,7 @@ export default {
|
||||
allowedReportTypes: [
|
||||
'Sales Invoice Report',
|
||||
'01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT]',
|
||||
'Credit Note Report'
|
||||
]
|
||||
}
|
||||
},
|
||||
@@ -169,6 +170,7 @@ 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'),
|
||||
'Credit Note Report': route('api.import.credit_note'),
|
||||
};
|
||||
|
||||
return importRoutesMap[reportType] || '';
|
||||
|
||||
@@ -403,7 +403,7 @@
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
<div :class="['text-right', showDownloadCreditNote && refund.status === 2 ? 'col-3' : 'col-5']">
|
||||
<div class="text-right col-3">
|
||||
<div class="font-heading fs-10 muted all-caps">Amount</div>
|
||||
<div class="font-heading fs-10">
|
||||
<div class="font-heading fs-10">{{refund.currency.short_code}} {{(Math.round((refund.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}</div>
|
||||
@@ -412,7 +412,7 @@
|
||||
<div class="font-heading fs-10">{{refund.original_currency.short_code}} {{(Math.round((refund.original_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2" v-if="showDownloadCreditNote && refund.status === 2">
|
||||
<div class="col-2" v-if="refund.status === 2">
|
||||
<div class="row no-margin justify-content-end">
|
||||
<div class="font-heading all-caps fs-10 m-b-5 text-right">Credit Note</div>
|
||||
<!-- Allow Credit Note to be downloaded for company NOT opted in E-Invoice -->
|
||||
@@ -425,7 +425,15 @@
|
||||
<i class="fa fa-file-image-o fs-10"></i>
|
||||
</div>
|
||||
</a>
|
||||
<!-- cief todo: 90 - E Credit Note incomplete (for company opted in E-Invoice)-->
|
||||
<!-- E Credit Note (for company opted in E-Invoice)-->
|
||||
<a v-else>
|
||||
<a target=”_blank” @click="downloadCreditNote(refund.id)"
|
||||
v-if="refund.e_invoice && refund.booking && refund.booking.company && refund.booking.company.e_invoice">
|
||||
<div class="icon-thumbnail fs-11 text-white icon-25 bg-primary btn-rounded float-left m-r-0 pointer">
|
||||
<i class="fa fa-file-image-o fs-10"></i>
|
||||
</div>
|
||||
</a>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -500,7 +508,6 @@
|
||||
bank_id: 1
|
||||
},
|
||||
section: 'bookingDetailSection',
|
||||
eInvoiceStartDate: window.E_INVOICE_START_DATE || ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -545,11 +552,6 @@
|
||||
showEditBookingAmount(){
|
||||
return this.data.booking.company.employee.status === 2 && this.data.booking.company.status === 2 && (Math.round((this.data.booking.outstanding_amount + Number.EPSILON) * 100) / 100) > 0;
|
||||
},
|
||||
showDownloadCreditNote() {
|
||||
const today = new Date();
|
||||
const einvoiceStartDate = new Date(this.eInvoiceStartDate);
|
||||
return today > einvoiceStartDate;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
clickExpand(){
|
||||
|
||||
+18
-2
@@ -100,7 +100,7 @@
|
||||
<div class="font-heading fs-12">{{this.data.fixed_currency.short_code}} {{(Math.round((this.data.paid_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-end m-b-10 ">
|
||||
<div class="row align-items-end m-b-10">
|
||||
<div class="col">
|
||||
<div class="font-heading all-caps fs-12">Floating Amount:</div>
|
||||
</div>
|
||||
@@ -108,7 +108,15 @@
|
||||
<div class="font-heading fs-12">{{this.data.fixed_currency.short_code}} {{(Math.round((this.data.floating_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-end bold text-danger">
|
||||
<div class="row align-items-end bold text-danger" v-if="this.data.refunded_amount">
|
||||
<div class="col">
|
||||
<div class="font-heading all-caps fs-12">OutStanding Total:</div>
|
||||
</div>
|
||||
<div class="col-auto text-right">
|
||||
<div class="font-heading fs-12">{{this.data.fixed_currency.short_code}} {{(Math.round((this.data.outstanding_amount_with_refund + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-end bold m-t-10 text-danger" v-else>
|
||||
<div class="col">
|
||||
<div class="font-heading all-caps fs-12">OutStanding Total:</div>
|
||||
</div>
|
||||
@@ -116,6 +124,14 @@
|
||||
<div class="font-heading fs-12">{{this.data.fixed_currency.short_code}} {{(Math.round((this.data.outstanding_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-end bold m-t-10 text-danger" v-if="this.data.refunded_amount">
|
||||
<div class="col">
|
||||
<div class="font-heading all-caps fs-12">Refunded Total:</div>
|
||||
</div>
|
||||
<div class="col-auto text-right">
|
||||
<div class="font-heading fs-12">{{this.data.fixed_currency.short_code}} {{(Math.round((this.data.refunded_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-20" v-if="data.company.employee.status === 2 && data.company.status === 2 && (Math.round((this.data.outstanding_amount + Number.EPSILON) * 100) / 100) > 0">
|
||||
<div class="col">
|
||||
<button id="payment-btn" class="btn btn-sm all-caps b-rad-none btn-success btn-block" @click="makePayment()">Make Payment</button>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
$credit_title = 'E-Credit';
|
||||
$bill_no = $transaction->bill_no;
|
||||
@endphp
|
||||
<div class="separator"><strong><i>{{ $bill_no }}</i></strong></div>
|
||||
<div class="separator"><strong><i>{{ $autocountId }}</i></strong></div>
|
||||
</htmlpageheader>
|
||||
<table>
|
||||
<tr>
|
||||
@@ -36,6 +36,7 @@
|
||||
</div>
|
||||
|
||||
<div class="ref">Ref# {{ $booking->marking }}</div>
|
||||
<div class="ref">EI# {{ $autocountId ?? 'NONE'}}</div>
|
||||
<div class="date">Date: {{ $date->toDateString() }}</div>
|
||||
<div> </div>
|
||||
</div>
|
||||
@@ -123,12 +124,12 @@
|
||||
<tbody>
|
||||
<tr align="center">
|
||||
<td>
|
||||
<img src="{{ url(config('qr.qr_code_img_url') . 'http://e-invoice uuid link') }}" style="width: 230px; height: 230px;" />
|
||||
<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>http://e-invoice uuid link</strong></h2>
|
||||
<h2 style="margin: 0 !important;"><strong>{{ $autocountEInvoiceValidationLink }}</strong></h2>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
-1
@@ -6,7 +6,6 @@
|
||||
})(window,document,'script','dataLayer','GTM-TQKCPCD');</script>
|
||||
<!-- End Google Tag Manager -->
|
||||
<script>
|
||||
window.E_INVOICE_START_DATE = @json(env('E_INVOICE_START_DATE', '2025-05-01 00:00:00'));
|
||||
window.LARAVEL_VAPOR_ENABLED = @json(env('LARAVEL_VAPOR_ENABLED', false));
|
||||
</script>
|
||||
<meta http-equiv="content-type" content="text/html;charset=UTF-8"/>
|
||||
|
||||
@@ -23,4 +23,5 @@ Route::group(['prefix' => 'export', 'as' => 'export.', 'namespace' => 'Exports']
|
||||
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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user