Deactivate: Supplier Invoice Date cannot be greater than Posting Date

Hi,
Can someone please guide, how can i remove this restriction.

Best Regards,

Any help please?

You could edit the posting date to match the invoice date

check the “Edit Posting Date and Time”

image

Thanks but i want posting to be in today’s date when we received invoice whereas the invoice date was a day or two earlier when the vendor created the invoices. Any solution to this please?

Well you already have an option to do that

I am not sure how you are getting the above error… it only shows when you enter a date of that is after the posting date !!!

But based on the remark above you want to just input the Posting date as of today when you receive the invoice and mention the supplier date (shown in the image) which is 2 or 3 days before the posting date

I explained above incorrectly.
Actually I need that the posting date is let say of 31st March 2022 but the invoice date is 1st April 2022.

The reason for this is that some recurring vendors raise voice on 1st of every month (and practically sometimes they take a few days due to their internal workings and raise within 5/6 days of month end). However, the expense itself now pertains to previous month i.e. to month of March. if we book this expense in april it will not be correct and cause uneven expense distribution over months therefore in order to keep expense monthly reporting straight that expense needs to be booked in the month it pertains to e.g. March 2022 in above example. So now when I edit posting date and select the posting date to be 31st March 2022 but enter inovice date as 1st April 2022 the system does not accept it. It gives error.

I hope i have been able to explain my issue clearly.

hi @usmanalikhan

This is not possible

In cases like this… when you want to book the invoice for March but you received the invoice in April… the best solution is not to enter the Supplier invoice date. This way you will be able to post the invoice for March.

if you need to enter the supplier invoice… then mention them under the Remarks in the “Accounting Details” section

Can I make any change in doctype or even backend code to remove this restriction? :frowning:

Definitely; anything can be modified, if you really need to.

I’ve actually had to solve Due Dates before, for one of my clients.

To solve a problem like this, I normally start by performing a global search for keywords. In this case, I searched for all *.py and *.js files with the phrase: "Supplier Invoice Date cannot be greater"

The code throwing this error is inside a function named 'validate_supplier_invoice()' , in the Purchase Invoice DocType’s main file: 'purchase_invoice.py'

Screenshot below.

Alter the function, or prevent it from being called, and you’ll be 1 step closer.

try this simple hack by 2 one/two lines server script

  1. before validate event

doc.bill_date_temp = doc.bill_date
doc.bill_date = ''
  1. before save event

doc.bill_date = doc.bill_date_temp

FYI. I used this tricky to bypass standard validation for other use cases too.

3 Likes

That is a really clever workaround, @szufisher. I love it. :smile:

1 Like

Thanks a lot! It did the trick!!!