Wednesday, June 14, 2023

Adding validation for Invoice date in Pending vendor Invoice using x++ in D365

Adding validation for Invoice date in Pending vendor Invoice using x++ in D365.


[ExtensionOf(formStr(VendEditInvoice))]
final class VendEditInvoice_Extension
{
    void postInvoice()
    {
        VendInvoiceInfoSubLine  vendInvoiceInfoSubLine;
        VendInvoiceInfoLine     vendInvoiceInfoLine;
        VendPackingSlipJour     vendPackingSlipJour;
        VendInvoiceInfoTable    vendInvoiceInfoTable = this.VendInvoiceInfoTable;

        select firstonly DeliveryDate from vendPackingSlipJour order by vendPackingSlipJour.DeliveryDate desc
            join vendInvoiceInfoSubLine
                where vendInvoiceInfoSubLine.DocumentId == vendPackingSlipJour.PackingSlipId
	    join vendInvoiceInfoLine
		where vendInvoiceInfoSubLine.LineRefRecId == vendInvoiceInfoLine.RecId &&
		    vendInvoiceInfoLine.ParmId == vendInvoiceInfoTable.ParmId &&
		    vendInvoiceInfoLine.TableRefId == vendInvoiceInfoTable.TableRefId;

        if (vendPackingSlipJour.DeliveryDate > vendInvoiceInfoTable.DocumentDate)
        {
            throw Global::error('Invoice date should be greater than Receipt date');
        }
		
        next postInvoice();
    }

}


Keep daxing!!

No comments:

Post a Comment