-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscopes.js
41 lines (37 loc) · 1.27 KB
/
scopes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"use strict"
const { order } = require('../build/index')
const theOrder = {
total: 16,
shipping: 4,
items: [{ id: 'a', price: 4, total: 16, qty: 4 }],
invoiced: [
{ items: [{ id: 'a', price: 4, total: 5, qty: 1 }],
shipping: 1,
total: 3 },
{ items: [{ id: 'a', price: 4, total: 2, qty: 1 }],
shipping: 1,
total: 5 }],
refunded: [{ items: [{ id: 'a', price: 4, total: 3, qty: 1 }],
shipping: 1,
total: 4 }],
canceled: [{ items: [{ id: 'a', price: 4, total: 4, qty: 1 }],
shipping: 1,
total: 3 }] }
// Invoiced and not refunded amount, items, shipping
console.log(
order.sales.total(theOrder).ir,
order.sales.items(theOrder).ir,
order.sales.shipping(theOrder).ir)
// 4 [ { id: 'a', price: 4, total: 4, qty: 1 } ] 1
// Not canceled and not invoiced amount, items, shipping
console.log(
order.sales.total(theOrder).ci,
order.sales.items(theOrder).ci,
order.sales.shipping(theOrder).ci)
// 5 [ { id: 'a', price: 4, total: 5, qty: 1 } ] 1
// Not canceled and not refunded amount, items
console.log(
order.sales.total(theOrder).cr,
order.sales.items(theOrder).cr,
order.sales.shipping(theOrder).cr)
// 9 [ { id: 'a', price: 4, total: 9, qty: 2 } ] 2