Validation on Purchase Invoice screen

By | June 30, 2021

As we know in Purchase Invoice screen, Supplier Document No and Supplier Invoice Date fields are mandatory. In Sage X3, while creating Purchase Invoice transaction, user can enter same No and Date for different invoice numbers. But one of our client requested to add a validation for the Purchase Invoice where, if the Supplier, Supplier Invoice date and Gross amount (Invoice-tax) are same but supplier doc number is different then an alert notification should be displayed on the screen.

For Example: – A purchase Invoice is created against the vendor: V03941 with supplier invoice no(Doc number): CHNCNT208-2021 and invoice Date: 09/08/20, and having gross amount: 168000

Consider below screenshot for reference:

New Stuff: How to enable “Accounting Cancellation” option on Purchase Invoice Screen

[PI 1 - Supplier Doc No and Date]
[PI 1 – Supplier Doc No and Date]
[PI 1 - (Invoice-tax)]
[PI 1 – (Invoice-tax)]

If the user is trying to create new purchase invoice with the same supplier invoice date: 09/08/20, gross amount: 168000 but different invoice number: CHICNT390-2021 then the system should show a pop-up/warning regarding the same.

Consider below screenshot for reference:

[PI 2 - Supplier Doc No and Date]
[PI 2 – Supplier Doc No and Date]
[PI 2 - (Invoice-tax)]
[PI 2 – (Invoice-tax)]

For this purpose, we did a customization on Purchase Invoice screen. Refer below code:

######################################################################

If !clalev([ZPIH]) : Local File PINVOICE[ZPIH] : Endif
FOR [F:ZPIH] WHERE [F:ZPIH]NUM<>[M:PIH0]NUM and [F:ZPIH]BPRVCR<>”” and [F:ZPIH]BPRVCR=[M:PIH1]BPRVCR and [F:ZPIH]BPRDAT=[M:PIH1]BPRDAT AND [F:ZPIH]AMTNOT=[M:PIH4]TOTLINAMT

if [M:PIH1]BPRVCR = [F:ZPIH]BPRVCR AND [M:PIH0]BPR = [F:ZPIH]BPR and [F:ZPIH]BPRDAT=[M:PIH1]BPRDAT AND [F:ZPIH]AMTNOT=[M:PIH4]TOTLINAMT

INFBOX “Supplier Document Number, Supplier Inv Date and Amount already exist for Invoice No : ” + [F:ZPIH]NUM
OK = 0
GOK = 0
GPE = 1
mkstat=2
break

endif

NEXT

######################################################################

Add the above code in VERIF_MOD and VERIF_CRE events on SPEPIH script.

After adding the above code if user try to create new purchase invoice with the same supplier invoice date, gross amount but different supplier doc number then the system will show a pop-up/warning regarding the same and It will restrict user to create purchase invoice.

Warning message]
Warning message]

Hence with the help of this customization, we can restrict a Purchase Invoice creation on the basis of Supplier Document No, Supplier Invoice Date and Gross Amount.