There is a problem with the ledger records for suppliers where advance payments are erroneously classified as credit ledger entries under app/Utils/TransactionUtil.php line 5064
ie
'credit' => in_array($transaction->type, ['purchase', 'sell_return']) || ($transaction->sub_type == 'sell_discount') ? $transaction->final_total : '',
I solved this by simply changing the ledger entry under, payments to:
$ledger[] = [
'date' => $payment->paid_on,
'ref_no' => $payment->payment_ref_no,
'type' => $transaction_types['payment'],
'location' => $payment->location_name,
'payment_status' => '',
'total' => '',
'payment_method' => !empty($paymentTypes[$payment->method]) ? $paymentTypes[$payment->method] : '',
'payment_method_key' => $payment->method,
'debit' => $payment->amount,
'credit' => '',
'others' => $note
];
On the premise that all payments are inevitably debit records and the attempt to classify ADVANCE payments as such at app/Utils/TransactionUtil.php line 5064, fails:
'debit' => in_array($payment->transaction_type, ['purchase', 'sell_return', 'opening_balance']) || $payment->is_return == 1 ? $payment->amount : '',
because $payment->transaction_type is Null and $payment->is_return == 1 is false.