Thank you for visiting our Partner Zone. This area is an exclusive space for MYOB Partners. Find out how to Partner with MYOB.
I have an Item Bill that I am trying to insert nad I am getting the error "Lines" "the line total is unbalanced".
I understand what that means, however,
lines.Total = 314.7
lines.BillQuantity = 9
lines.UnitPrice = 34.97
Now 9 x 34.97 = 314.73 != 314.7
so I have calculated a discount percentage as follows:
lines.DiscountPercent = 100 * (lines.Total / (lines.BillQuantity * line.UnitPrice) - 1)
which, in this case, gives -0.0095319797922028405299780800
Working this back through:
lines.BillQuantity*lines.UnitPrice*(1+lines.DiscountPercent/100) = 314.69999999999999999999999999
Now 314.7 != 314.69999999999999999999999999 but it can't get any closer!
The rounding errors are baked into .net. How do I overcome this?