Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- invoiceContent = []
- var total = 0
- foreach ( invoiceContent as item ) {
- itemPrice = item.snapshot.price
- quantity = item.quantity
- itemTotal = 0
- if(item.offer!=null) {
- itemPrice = item.offer.price
- quantity = item.offer.quantity
- }
- if(item.variant!=null) {
- itemPrice = item.variant.price
- }
- if(item.variant==null && item.offer==null && item.snapshot.tiers!=null) {
- foreach(item.snapshot.tiers as tier) {
- if(item.quantity>=tier.quantity) {
- itemPrice = tier.price
- }
- }
- }
- itemTotal = itemPrice * quantity
- total = total + itemTotal
- invoiceContent.push({
- name: item.name,
- price: itemPrice,
- quantity: quantity,
- unit: item.unit,
- total: itemTotal
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement