mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
fixing the structure of export receipt to autocount and import receipt to exchange map failed
This commit is contained in:
@@ -34,19 +34,12 @@ class ExportsInvoiceTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
$header = [];
|
||||
if ($this->request->input('type') == 'invoices') {
|
||||
$header[] = 'DocNo';
|
||||
$header[] = 'DocDate';
|
||||
$header[] = 'DebtorCode';
|
||||
} else {
|
||||
$header[] = 'OrNo';
|
||||
$header[] = 'OrDate';
|
||||
$header[] = 'CreditorCode';
|
||||
}
|
||||
$header[] = 'Ref';
|
||||
$header[] = ($this->request->input('type') == 'invoices' ? 'DebtorName' : 'CreditorName');
|
||||
$header = array_merge($header, [
|
||||
$header = [
|
||||
'DocNo',
|
||||
'DocDate',
|
||||
'DebtorCode',
|
||||
'Ref',
|
||||
'DebtorName',
|
||||
'CurrencyCode',
|
||||
'ShipInfo',
|
||||
'ItemCode',
|
||||
@@ -56,7 +49,7 @@ class ExportsInvoiceTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
'UnitPrice',
|
||||
'AccNo',
|
||||
'DeptNo'
|
||||
]);
|
||||
];
|
||||
return $header;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
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 Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\General\Eloquent\ApplyFiltersToQuery;
|
||||
use App\Models\StatementTransaction;
|
||||
use App\Models\Company;
|
||||
|
||||
class ExportsReceiptTransactions implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
||||
{
|
||||
use Exportable;
|
||||
|
||||
private $request;
|
||||
private $counter = 1;
|
||||
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
$header = [
|
||||
'DocNo',
|
||||
'DocDate',
|
||||
'DebtorCode',
|
||||
'Description',
|
||||
'DocNo2',
|
||||
'ProjNo',
|
||||
'DeptNo',
|
||||
'CurrencyCode',
|
||||
'ToHomeRate',
|
||||
'ToDebtorRate',
|
||||
'Note',
|
||||
'PaymentMethod',
|
||||
'ChequeNo',
|
||||
'PaymentAmt',
|
||||
'BankCharge',
|
||||
'ToBankRate',
|
||||
'BankChargeTaxType',
|
||||
'BankChargeTaxRefNo',
|
||||
'BankChargeProjNo',
|
||||
'BankChargeDeptNo',
|
||||
'PaymentBy',
|
||||
'FloatDay',
|
||||
'IsRCHQ',
|
||||
'RCHQDate',
|
||||
'KnockOffDocType',
|
||||
'KnockOffDocNo',
|
||||
'KnockOffAmt',
|
||||
'',
|
||||
];
|
||||
return $header;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
$data = (new ApplyFiltersToQuery())->execute(StatementTransaction::query(), json_decode($this->request->input('filter'), true));
|
||||
if ($this->request->has('bankStatementTransactionId')) $data = $data->whereIn('id',json_decode($this->request->input('bankStatementTransactionId'), true));
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param StatementTransaction $transaction
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function map($transaction): array
|
||||
{
|
||||
$statementTransactionOwner = $transaction->owners()->whereIn('status', [ApprovalStatus::APPROVED])->first();
|
||||
$logArray = [
|
||||
'counter' => $this->counter,
|
||||
'system' => $statementTransactionOwner->system,
|
||||
'StatementTransactionOwner_id' => $statementTransactionOwner->id,
|
||||
'transaction_table_id' => $statementTransactionOwner->owner_id,
|
||||
];
|
||||
$this->counter += 1;
|
||||
$logArray = json_encode($logArray);
|
||||
|
||||
$filePath = storage_path('logs/exports_receipt_transactions.log');
|
||||
$errorFilePath = storage_path('logs/exports_receipt_transactions_error.log');
|
||||
$textToAppend = Carbon::now()->format('[Y-m-d H:i:s]') . ' ' . $logArray . PHP_EOL;
|
||||
file_put_contents($filePath, $textToAppend, FILE_APPEND);
|
||||
|
||||
$company = Company::where('name',$transaction->transaction_description_2)->first();
|
||||
|
||||
return [
|
||||
'<<New>>',
|
||||
Carbon::parse($transaction->posting_date)->format('d/m/Y'),
|
||||
($company ? $company->debtor : null),
|
||||
$transaction->transaction_description,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'MYR',
|
||||
1,
|
||||
1,
|
||||
'',
|
||||
'MBB',
|
||||
'',
|
||||
$transaction->amount,
|
||||
'',
|
||||
1,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'0',
|
||||
'',
|
||||
'',
|
||||
'RI',
|
||||
$transaction->transaction_ref,
|
||||
$transaction->amount,
|
||||
'',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
use App\Classes\Modules\Exports\Services\ExportsImportedInvoiceMappeds;
|
||||
use App\Models\TransactionMappingLog;
|
||||
use App\Classes\Modules\Exports\Services\ExportsReceiptTransactions;
|
||||
|
||||
class ExportCustomersToExcelController
|
||||
{
|
||||
@@ -61,7 +62,14 @@ class ExportCustomersToExcelController
|
||||
|
||||
public function invoiceTransactions(Request $request){
|
||||
$exportsTransactions = new ExportsInvoiceTransactions($request);
|
||||
$response = $exportsTransactions->download(($request->input('type') == 'invoices' ? 'invoice-transactions' : 'receipt-transactions').'.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
$response = $exportsTransactions->download('invoice-transactions.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function receiptTransactions(Request $request){
|
||||
$exportsTransactions = new ExportsReceiptTransactions($request);
|
||||
$response = $exportsTransactions->download('receipt-transactions.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ use App\Models\TransactionMappingLog;
|
||||
use App\Classes\ValueObjects\Response\ApiResponseObject;
|
||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ImportStatementReceiptsController
|
||||
{
|
||||
@@ -78,11 +79,11 @@ class ImportStatementReceiptsController
|
||||
|
||||
private function mappingExchange(Array $row) {
|
||||
$date = $row['date'];
|
||||
$transactions = Transaction::where('original_amount', $row['local_payment_amount'])->whereRaw("DATE(created_at) = '$date'")
|
||||
->whereHas('issuerCompany', function($q) use($row) {
|
||||
$q->where('debtor',$row['debtor_code']);
|
||||
})
|
||||
->get();
|
||||
$transactions = Transaction::getReceiverWithJoinStatementTransactionAndOwner($row)->select('transactions.*')->where('statement_transactions.amount', $row['payment_amount'])->whereRaw("DATE(posting_date) = '$date'")->get();
|
||||
|
||||
if ($transactions && $transactions->count() == 0) {
|
||||
$transactions = Transaction::getReceiverWithJoinStatementTransactionAndOwner($row)->select('transactions.*')->where(DB::raw('FLOOR(statement_transactions.amount)'), floor($row['payment_amount']))->whereRaw("DATE(posting_date) = '$date'")->get();
|
||||
}
|
||||
|
||||
if ($transactions && $transactions->count() == 1) {
|
||||
foreach ($transactions as $key => $transaction) {
|
||||
|
||||
+3
-2
@@ -267,7 +267,7 @@ export default {
|
||||
exportInvoiceToAutoCount(){
|
||||
const checkedStatementTransactions = this.getCheckedStatementOwners();
|
||||
|
||||
let route = this.route('invoiceTransactions.export')+'?type=invoices&filter='+JSON.stringify(this.filter);
|
||||
let route = this.route('invoiceTransactions.export')+'?filter='+JSON.stringify(this.filter);
|
||||
if (checkedStatementTransactions) {
|
||||
route += '&bankStatementTransactionId='+checkedStatementTransactions;
|
||||
}
|
||||
@@ -277,7 +277,8 @@ export default {
|
||||
exportReceiptToAutoCount(){
|
||||
const checkedStatementTransactions = this.getCheckedStatementOwners();
|
||||
|
||||
let route = this.route('invoiceTransactions.export')+'?type=receipts&filter='+JSON.stringify(this.filter);
|
||||
this.filter['statement_transaction_owner_type_in'] = [3,4,5,7,13,14];
|
||||
let route = this.route('receiptTransactions.export')+'?filter='+JSON.stringify(this.filter);
|
||||
if (checkedStatementTransactions) {
|
||||
route += '&bankStatementTransactionId='+checkedStatementTransactions;
|
||||
}
|
||||
|
||||
@@ -261,6 +261,7 @@ Route::get('/export/payment-transactions/f614e339d7058904a831aad742e24d55', 'Exp
|
||||
Route::get('/export/wallet-transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@walletTransactions')->name('walletTransactions.export');
|
||||
Route::get('/export/booking-transactions', 'Exports\ExportCustomersToExcelController@bookingTransactions')->name('export.transactions.booking');
|
||||
Route::get('/export/invoice-transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@invoiceTransactions')->name('invoiceTransactions.export');
|
||||
Route::get('/export/invoice-transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@receiptTransactions')->name('receiptTransactions.export');
|
||||
Route::get('/export/imported-invoice-mapped', 'Exports\ExportCustomersToExcelController@importedInvoiceMapped')->name('importedInvoiceMapped.export');
|
||||
|
||||
Route::get('/products', function (\App\Classes\Modules\Exports\Services\ExportsProducts $exportsProducts) {
|
||||
|
||||
Reference in New Issue
Block a user