vb.net - Mix and Match Discount Code Advice -


I advise to implement i have two object receipt lines and discount i cashier scan items and a receipt item. If the added receipt line object has a discount id, then it is to see the discounts in the discounted item and issue a discount after verification. I have a problem in validation here, it scans this item in the form of cashier

ReceiptLine objects

line 1 itemid 1835 quantity 2 discountId 23 line2 itemid 1515 quantity 2 discountId 23 Line 3 1835 Quantity 2 DiscountId 23

Discount Item No. 23

Buy Itemid 1835 2 Buy Itemid 1515 1

Discount $ 1.00

Things that should handle the code continue

Cashier items in any order item quantity are allowed to discount any amount only When this purchase meets the discount object requirements, the purchase goes twice, or sometimes it is also discounted that many times

I can have the following code, and know where to go Do not have a clue for

  public sub GetDiscount (byVal newReceiptLine as ReceiptLine) Dim discountId integer = newReceiptLine.DiscountId slow discountLine form ReceiptLine = like me (function (as Receipt LAN) L.DiscountId = Discount ID) if not a discount line Not and let not discount anything. Discount is not then nothing newReceiptLine.Discount = discountLine.Discount otherwise newReceiptLine.Discount = new discount (discountId) finally newReceiptLine.Discount.IssueDiscount (Me) End Sub Public Sub IssueDiscount (ByVal receiptLines as ReceiptLines) dim discountLines list (ReceiptLine ) As in = receiptLines.FindAll (Function (as L ReceiptLine) l.DiscountId = _ id) as DiscountItem = _discountItems.Find each row ReceiptLine form discountLines in dim styleId = integer as line.StyleId dim item Work for (as discountItem (i) i.StyleId = styleId)? Formula I advise to apply all the discounts in a process. What happens if the customer decides they do not want the second item after all? 

If I was doing this then I have a applicable discount method:

  1. Clear all the current discounts, all items are discounted Leave in
  2. Go through each item in the receipt
  3. ... View discounts for items in the discount table.
  4. ... Check the status of that discount.
  5. ... if the customer receipt is satisfied condition:
  6. ...... Flag as discounted all participating objects (so you can apply them twice Can not be counted)
  7. ..... Add a discount to the receipt.

Because you clean the discount at the start of the process, whenever scan an item, you can run this process. In this way it remains dynamic, but it is very easy to manage.

should be free would not be a Diskaid I have the item before rebate should be item id can thus you add scenarios as much as you like off without touching your items and removed.


Comments