Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A difficult Question
Message
 
To
20/06/2006 13:16:41
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01130294
Message ID:
01130300
Views:
21
>Dear Experts
>
>A customer goes to a shop and purchase five products (from A to E)
>
>The shopkeeper makes bill of =1815
>Now customer asks for discount of = 615
>He want to pay only 1200 instead of =1815
>
>How to adjust rates so that the bill amount will be 1200 with out any changes in quantity
>Product and Rate table is attached.
>
>Item-Qty--Rate--Amount
>A----13----60----780
>B----8-----40----320
>C----7-----35----245
>D----18----15----270
>E----25----8-----200
>
>Bill Amount= 1815
>
>Please help

I think the loss must be distibuted to all products, relative to their part of total sum:
You could do something like:
SELECT Product, ROUND(615 * (1815/Ammount) * 0.01, 2) AS Discount;
FROM MyBillCursor;
INTO CURSOR crsTest
The last product must take all differensies from ROUND() to make a Bill 1200:
SELECT Product, ROUND(615 * (Ammount/1815), 2) AS Discount;
       FROM MyBillCursor;
INTO CURSOR crsDiff
lnTotalDisc = 0
SCAN
   lnUpdateRate = crsDiff.Discount
   IF lnTotalDisc + crsDiff.Discount > 615
      lnUpdateRate = 615 - lnTotalDisc
   ENDIF
   UPDATE MyBillCursor SET Ammount = lnUpdateRate WHERE Product = crsDiff.Product
ENDSCAN
This code will works if producs are Unique in MyBillCursor, but you get the idea.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform