Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1.  
  2. invoiceContent = []
  3.  
  4. var total = 0
  5. foreach ( invoiceContent as item ) {
  6. itemPrice = item.snapshot.price
  7. quantity = item.quantity
  8. itemTotal = 0
  9. if(item.offer!=null) {
  10. itemPrice = item.offer.price
  11. quantity = item.offer.quantity
  12. }
  13. if(item.variant!=null) {
  14. itemPrice = item.variant.price
  15. }
  16. if(item.variant==null && item.offer==null && item.snapshot.tiers!=null) {
  17. foreach(item.snapshot.tiers as tier) {
  18. if(item.quantity>=tier.quantity) {
  19. itemPrice = tier.price
  20. }
  21. }
  22. }
  23.  
  24. itemTotal = itemPrice * quantity
  25. total = total + itemTotal
  26.  
  27. invoiceContent.push({
  28. name: item.name,
  29. price: itemPrice,
  30. quantity: quantity,
  31. unit: item.unit,
  32. total: itemTotal
  33. })
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement