I can not enter payments that are bigger than the invoice amount


#1

Good day,

It seems like when I add payment smaller than the invoice amount then no problem.

but when I want to add payment amounts bigger than the invoice amount then I get the error(s) below

kindly help as I am not a programmer at all :frowning:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI::$mdl_payment_custom

Filename: MX/Controller.php

Line Number: 61

Backtrace:

File: /home/inynorsp/public_html/application/third_party/MX/Controller.php
Line: 61
Function: _error_handler

File: /home/inynorsp/public_html/application/modules/payments/controllers/Payments.php
Line: 118
Function: __get

File: /home/inynorsp/public_html/index.php
Line: 325
Function: require_once

Fatal error : Call to a member function get_by_payid() on null in /home/inynorsp/public_html/application/modules/payments/controllers/Payments.php on line 118

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/inynorsp/public_html/vendor/codeigniter/framework/system/core/Exceptions.php:271)

Filename: core/Common.php

Line Number: 570

Backtrace:

A PHP Error was encountered

Severity: Error

Message: Call to a member function get_by_payid() on null

Filename: controllers/Payments.php

Line Number: 118

Backtrace:


#2

It seems like Fatal error: Call to a member function get_by_payid() on null in /home/invoicesraynorsp/public_html/application/modules/payments/controllers/Payments.php on line 118

Any help will be very much appreciated


#3

I suspect this error is not related to the amount paid.

Please retry and send the URL that is loaded when this error happens.
(You can remove your domain details from the URL)

It seems like the payment form is trying to load or reload the form again, but the payment reference is not set (it might be very well because the payment was not done the first time around)


#4

Actually, I stand corrected, I located the error, and will be pushing a fix soon.


#5

https://development.invoiceplane.com/browse/IP-750


#6

Thanks and much appreciated.

I’ll keep watching this post for the fix.

Thanks


#7

I have pushed a fix and it is awaiting review,

If you are conversant with the development process and working from git you can pull the branch to test it.


#8

Thanks so much for the patch.

Now it states: “Payment amount cannot exceed invoice balance.”

If added a bigger amount… is it possible to add it to a clients credit? And then can automatically be applied to a next invoice of the client?


#9

You can add this to your own application. This will accept the values, However, it will not be added to the next invoice.

The payments model contains the validation rule that you can remove.
I have given an example below of what your change will look like

application/modules/payments/models/Mdl_payments.php

class Mdl_Payments extends Response_Model
{
               : <snip>
    public function validation_rules()
    {
        return array(
            'invoice_id' => array(
                'field' => 'invoice_id',
                'label' => trans('invoice'),
                'rules' => 'required'
            ),
            'payment_date' => array(
                'field' => 'payment_date',
                'label' => trans('date'),
                'rules' => 'required'
            ),
            'payment_amount' => array(
                'field' => 'payment_amount',
                'label' => trans('payment'),
//              'rules' => 'required|callback_validate_payment_amount'      <== OLD RULES
                'rules' => 'required'                      <== NEW RULES
            ),
            'payment_method_id' => array(
                'field' => 'payment_method_id',
                'label' => trans('payment_method')
            ),
            'payment_note' => array(
                'field' => 'payment_note',
                'label' => trans('note')
            )
        );
    }
               : <snip>
}