accounting mapping - export invoice

This commit is contained in:
edmondlang
2023-07-07 01:18:58 +08:00
parent 0fd6fa0c3f
commit 1dab99cc49
2 changed files with 74 additions and 45 deletions
@@ -15,6 +15,7 @@ use Maatwebsite\Excel\Concerns\WithMapping;
use Illuminate\Http\Request;
use Carbon\Carbon;
use App\Classes\Modules\Accounting\Processors\ListShippingPortalTransactions;
use App\Classes\ValueObjects\Constants\ShippingTransactionType;
use App\Classes\ValueObjects\Constants\TransactionType;
class ExportsInvoiceTransactions implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
@@ -70,64 +71,53 @@ class ExportsInvoiceTransactions implements FromQuery, WithHeadings, WithHeading
$row = null;
if($transaction->system == 'EXCHANGE') {
$row = (App()->make($transaction->owner_type))::where('id', $transaction->owner_id)->first();
$company = $row->owner->owner;
$row = (App()->make($transaction->owner_type))->where('id', $transaction->owner_id)->first();
$company = $row->type === TransactionType::PAYMENT ? $row->owner->company : $row->owner->owner;
return [
'<<New>>',
$transaction->updated_at->format('m/d/Y H:m'),
$company->debtor,
$transaction->type === TransactionType::PAYMENT ? $row->owner->marking : $company->reference,
'',
'MYR',
$booking->marking,
'',
'PLEASE REFER TO THE ATTACHED APPENDIX REF ' . $booking->marking,
'',
1,
round($transaction->amount, 2),
'500-0000',
'CIEF'
];
// return [
// '<<New>>',
// $row->updated_at->format('m/d/Y H:m'),
// $company->debtor,
// $transaction->type === TransactionType::PAYMENT ? $row->owner->marking : null,
// 'MYR',
// $transaction->bill_no,
// 'W1',
// 'CREDIT SALES',
// '',
// 1,
// round($transaction->amount, 2),
// '500-0000',
// 'WALLET'
// ];
}
else {
$row = (App()->make(ListShippingPortalTransactions::class))->execute([
'id' => $transaction->owner_id,
])[0];
$booking = $row->owner;
return [
'<<New>>',
$row->updated_at->format('m/d/Y H:m'),
$company->debtor,
$row->type === TransactionType::PAYMENT ? $booking->marking : $company->reference,
'',
'MYR',
$transaction->bill_no,
'W1',
'CREDIT SALES',
$row->type === TransactionType::PAYMENT ? $booking->marking : $row->bill_no,
$row->type === TransactionType::PAYMENT ? '' : 'W1',
$row->type === TransactionType::PAYMENT ? 'PLEASE REFER TO THE ATTACHED APPENDIX REF ' . $booking->marking : 'CREDIT SALES',
'',
1,
round($transaction->amount, 2),
round($row->amount, 2),
'500-0000',
'WALLET'
'CIEF'
];
}
else {
$row = (App()->make(ListShippingPortalTransactions::class))->execute([
'id' => $transaction->owner_id,
'with_company' => true,
])[0];
$order = $row['order'];
$company_module = $order['company_module'];
return [
'<<New>>',
$row['updated_at'],
$company_module['debtor'],
$row['type'] === ShippingTransactionType::PAYMENT ? $order['reference'] : $company_module['marking'],
'',
'MYR',
$row['type'] === ShippingTransactionType::PAYMENT ? $order['reference'] : $row['bill_no'],
$row['type'] === ShippingTransactionType::PAYMENT ? '' : 'W1',
$row['type'] === ShippingTransactionType::PAYMENT ? 'PLEASE REFER TO THE ATTACHED APPENDIX REF `' . $order['reference'] : 'CREDIT SALES',
'',
1,
round($row['amount'], 2),
'500-0000',
'CIEF'
];
}
}
}
@@ -0,0 +1,39 @@
<?php
namespace App\Classes\ValueObjects\Constants;
final class ShippingTransactionType
{
// public const PAYMENT_ATTEMPT = 0;
public const SHIPPING_INVOICE = 1;
public const PAYMENT = 2;
// public const BILL = 3;
// public const PERFORMA = 4;
public const TOP_UP = 5;
// public const REFUND = 6;
// public const PURCHASE_ORDER = 7;
// public const SUPPLIER_DELIVER = 8;
public const CREDIT_NOTE = 9;
public const WITHDRAW = 10;
public const DEBIT_NOTE = 11;
public const TRANSFER_FEE = 12;
public const CASH_BACK = 13;
// public const SHIPPING_COST = 14;
public const GROUP_PAYMENT = 15;
}