-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbill.js
165 lines (160 loc) · 4.27 KB
/
bill.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
const { BaseItem } = require("./itemv2");
const SubItem = {
type: "object",
properties: {
name: {
type: "string",
title: "Display name of the option/variation/etc",
default: "",
examples: ["Soy Milk", "Extra Hot"]
},
amount: {
type: "integer",
title: "The cost of a single instance of this item.",
description:
"The cost is represented in the lowest denomination (eg cents). For discounts this should be negative.",
examples: [100, 0]
}
},
required: ["name", "amount"]
};
const BillItem = {
type: "object",
properties: Object.assign({}, BaseItem.properties, {
subItems: {
type: "array",
items: SubItem
}
}),
required: BaseItem.required
};
const BillPayment = {
type: "object",
properties: {
name: {
type: "string",
description: "Method of payment or payment label",
minLength: 1,
examples: ["Cash", "App Payment - John Smith"]
},
total: {
type: "integer",
description:
"The total amount paid on this payment instance *inclusive of tips and loyalty credit*. Successful payments should be listed as a positive integer. Reversals as a negative integer.",
examples: [1200]
},
refId: {
type: "string",
title: "Reference ID",
description:
"Optionally provide a reference to the record of this payment to another system.",
examples: ["PAY0012", "229383773878"],
minLength: 1
},
tip: {
type: "integer",
description: "Tip included in in this payment.",
minimum: 1,
examples: [100]
},
payment: {
type: "integer",
description:
"Amount actually paid by the user, including tips. (total - tips - payment) will provide the amount the user received in loyalty benefits on this order (credit or discounts)",
minimum: 1,
examples: [100]
}
},
required: ["name", "total"]
};
const Bill = {
type: "object",
title: "Bill",
description:
"Represents a bill for items to be paid by one or more customers",
properties: {
id: {
type: "string",
title: "Unique ID for this bill",
description:
"The bill ID is the identifier for this bill from a non-LOKE system, typically the remote service's bill ID.",
minLength: 3,
examples: ["BILL001"]
},
table: {
type: "string",
description: "Table number if applicable.",
minLength: 1,
examples: ["16"]
},
currency: {
type: "string",
title: "Bill currency.",
description: "Currency used on this bill.",
enum: ["AUD", "NZD", "SGD", "GBP"]
},
tipsAllowed: {
type: "boolean",
title: "Tips Allowed",
description: "Can tips be attched to this bill"
},
items: {
type: "array",
description:
"List of items associated with this bill. *NOTE: may include discounts.*",
items: BillItem
},
total: {
type: "integer",
description:
"Total amount that must be paid on this bill, ignoring any payments currently made. *Inclusive of any tax.*",
minimum: 1,
examples: [1100]
},
tax: {
type: ["null", "integer"],
description:
"Tax amount included on bill. This is highly recommended as it provided better feedback to the customer, but not required.",
minimum: 0,
examples: [100]
},
balance: {
type: "integer",
description:
"Balance remaining on this bill. This will be the total, minus any payments already made on the bill.",
minimum: 0,
examples: [500]
},
payments: {
type: "array",
description: "Any existing payments made on this bill.",
items: BillPayment
},
created: {
type: "string",
format: "date-time",
description: "Timestamp this bill was created."
},
updated: {
type: "string",
format: "date-time",
description: "Timestamp this bill was last updated."
},
completed: {
type: "string",
format: "date-time",
description: "Timestamp this bill was completed (if applicable)."
}
},
required: [
"id",
"currency",
"items",
"total",
"balance",
"payments",
"created",
"updated"
]
};
module.exports = { Bill, BillItem, BillPayment };