Sage MAS 90 and 200 Sage MAS 500 blogs Product Feedback Support Training
Reply
Sage MAS Partner
VKZIMM
Posts: 768
Registered: 11-10-2008
0
Accepted Solution

PO Line Discount Script

Please be kind, this is my first try at scripting.   Mas90 v4.4 Service Pack 4

If a vendor has a discount which I add as a UDF in the Purchase Order Header, I want to calculate the cost of the item

based on the cost manually entered  minus the discount.  I cannot use the Price Level maintenance, because they will manually enter the cost.   I have a PO Header UDF for discount, PO Line UDF for Y/N if I applied the Discount. Doing this at Pre-write of the record.

Getting Error 88 Invalid/Unknown Property name in SY_MAINT.PVC

 

TmpDisc=0

TmpApply="N"

TmpCost=0

retVal=oBusObj.GetValue("UDF_DISCAPPLIED$",TmpApply)
retVal=oBusObj.GetValue("UDF_DISCOUNT",TmpDisc)

retVal=oBusObj.GetValue("UnitCost",TmpCost)

if TmpApply <> "Y" then

 retVal = oBusObj.GetValue("UnitCost", TmpCost)

 retVal = oBusObj.SetValue("UDF_DISCAPPLIED$", "Y")

 retVal = oBusObj.SetValue("UnitCost",TmpCost*TmpDisc)

End if

retVal = oBusObj

Super Contributor
DFeller
Posts: 2,944
Registered: 10-28-2008

Re: PO Line Discount Script

It appears you have this line in there twice:

 

retVal=oBusObj.GetValue("UnitCost",TmpCost)

 

Also I think you can take out this line:

 

retVal = oBusObj

 

Dawn

Sage MAS Partner
VKZIMM
Posts: 768
Registered: 11-10-2008
0

Re: PO Line Discount Script

[ Edited ]

Thanks Dawn!

 

No more error, but I still have 1 problem.

 

How can I get the new values to display after I change it?

 

Thank you in advance.

Sage MAS Partner
VKZIMM
Posts: 768
Registered: 11-10-2008
0

Re: PO Line Discount Script

Since this is my first script, I have a change in plans.

I will not show the Unit Cost field, but created a Unit Cost UDF field for Entry which would be the full amount and I will calculate the unit cost from that amount.  That works well and during entry all is fine, but if I make a change to the UDF Unit Cost, the Extension is calculated correct, but on the bottom of the screen the Total is not updated.  If I go to the totals tab and back to the Lines tab, then the screen Total displays correctly.

This is my script which is done Column Post Validate on my UDF Unit Cost field

TmpDisc=0
TmpCost=0
TmpAmt=0
TmpQty=0
retVal=oHeaderObj.GetValue("UDF_DISCPCT",TmpDisc)
retVal=oBusObj.GetValue("UDF_NEWCOST",TmpCost)
retVal=oBusObj.GetValue("UDF_DISCAMT",TmpAmt)
retVal=oBusObj.GetValue("QuantityOrdered",TmpQty)
retVal=oBusObj.SetValue("UnitCost",(TmpCost-(TmpCost*TmpDisc)))
retVal=oBusObj.SetValue("UDF_DISCAMT",(TmpCost*TmpDisc))

Thank you in advance.