mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
update aging listing
This commit is contained in:
@@ -12,6 +12,7 @@ use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use App\Classes\General\Eloquent\ApplyFiltersToQuery;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use DateTime;
|
||||
|
||||
class ExportsAgingList implements WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, FromQuery
|
||||
{
|
||||
@@ -19,10 +20,12 @@ class ExportsAgingList implements WithHeadings, WithHeadingRow, WithMapping, Sho
|
||||
|
||||
private $filters;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->filters = [
|
||||
"has_invoice_status_in"=>[2],"packing_list_ordered_by_invoice_date"=>true,
|
||||
"with_aging_column"=>true
|
||||
"has_invoice_status_in" => [2],
|
||||
"packing_list_ordered_by_invoice_date" => true,
|
||||
"with_aging_column" => true
|
||||
];
|
||||
}
|
||||
|
||||
@@ -31,12 +34,11 @@ class ExportsAgingList implements WithHeadings, WithHeadingRow, WithMapping, Sho
|
||||
return [
|
||||
'Company Name',
|
||||
'Customer Marking',
|
||||
'Order Number',
|
||||
'Invoice No',
|
||||
'Invoice Date',
|
||||
'Current',
|
||||
'1-30 DAYS',
|
||||
'31-60 DAYS',
|
||||
'61-90 DAYS',
|
||||
'91++ DAYS',
|
||||
'Days',
|
||||
'Amount',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -48,34 +50,48 @@ class ExportsAgingList implements WithHeadings, WithHeadingRow, WithMapping, Sho
|
||||
public function map($list): array
|
||||
{
|
||||
$marking = null;
|
||||
$orderNo = null;
|
||||
$name = null;
|
||||
$invDate = 'n/a';
|
||||
$invNo = 'n/a';
|
||||
$days = 'n/a';
|
||||
|
||||
if ($list->owner instanceof Order) {
|
||||
$inviterPivotInviteeReference = $list->owner->companyModule->inviters()->withPivot('invitee_reference')->first();
|
||||
|
||||
if ($inviterPivotInviteeReference) $marking = $inviterPivotInviteeReference->pivot->invitee_reference .'/'.$list->owner->reference;
|
||||
if ($inviterPivotInviteeReference) {
|
||||
$marking = $inviterPivotInviteeReference->pivot->invitee_reference;
|
||||
$orderNo = $list->owner->reference;
|
||||
}
|
||||
$name = $list->owner->companyModule->company->name;
|
||||
}
|
||||
|
||||
$transaction = $list->transactions()->whereIn('status', [ApprovalStatus::APPROVED])->first();
|
||||
if ($transaction) {
|
||||
$invDate = date_format($transaction->updated_at,'d-m-Y');
|
||||
$amt = number_format($transaction->amount,2);
|
||||
|
||||
$invoiceDate = $transaction->created_at;
|
||||
$invDate = date_format($invoiceDate, 'd-m-Y');
|
||||
$invNo = $transaction->bill_no;
|
||||
$amt = number_format($transaction->amount, 2);
|
||||
|
||||
$currentDate = new DateTime();
|
||||
$interval = $currentDate->diff($invoiceDate);
|
||||
$days = $interval->format('%a');
|
||||
}
|
||||
|
||||
return [
|
||||
$name,
|
||||
$marking,
|
||||
$orderNo,
|
||||
$invNo,
|
||||
$invDate,
|
||||
$this->dueDateColumn(0, $list->due_date_number, $amt),
|
||||
$this->dueDateColumn(1, $list->due_date_number, $amt),
|
||||
$this->dueDateColumn(2, $list->due_date_number, $amt),
|
||||
$this->dueDateColumn(3, $list->due_date_number, $amt),
|
||||
$this->dueDateColumn(4, $list->due_date_number, $amt),
|
||||
$days,
|
||||
$amt,
|
||||
];
|
||||
}
|
||||
|
||||
private function dueDateColumn($colNum, $dueDateNumber, $amt) {
|
||||
private function dueDateColumn($colNum, $dueDateNumber, $amt)
|
||||
{
|
||||
if ($colNum == $dueDateNumber) return $amt;
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user