Coverage for .tox / coverage / lib / python3.11 / site-packages / sideshow / enum.py: 100%

103 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2025-12-15 17:10 -0600

1# -*- coding: utf-8; -*- 

2################################################################################ 

3# 

4# Sideshow -- Case/Special Order Tracker 

5# Copyright © 2024-2025 Lance Edgar 

6# 

7# This file is part of Sideshow. 

8# 

9# Sideshow is free software: you can redistribute it and/or modify it 

10# under the terms of the GNU General Public License as published by 

11# the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

14# Sideshow is distributed in the hope that it will be useful, but 

15# WITHOUT ANY WARRANTY; without even the implied warranty of 

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 

17# General Public License for more details. 

18# 

19# You should have received a copy of the GNU General Public License 

20# along with Sideshow. If not, see <http://www.gnu.org/licenses/>. 

21# 

22################################################################################ 

23""" 

24Enum Values 

25""" 

26 

27from enum import Enum 

28from collections import OrderedDict 

29 

30from wuttjamaican.enum import * # pylint: disable=wildcard-import,unused-wildcard-import 

31 

32 

33ORDER_UOM_CASE = "CS" 

34""" 

35UOM code for ordering a "case" of product. 

36 

37Sideshow will treat "case" orders somewhat differently as compared to 

38"unit" orders. 

39""" 

40 

41ORDER_UOM_UNIT = "EA" 

42""" 

43UOM code for ordering a "unit" of product. 

44 

45This is the default "unit" UOM but in practice all others are treated 

46the same by Sideshow, whereas "case" orders are treated somewhat 

47differently. 

48""" 

49 

50ORDER_UOM_KILOGRAM = "KG" 

51""" 

52UOM code for ordering a "kilogram" of product. 

53 

54This is treated same as "unit" by Sideshow. However it should 

55(probably?) only be used for items where 

56e.g. :attr:`~sideshow.db.model.orders.OrderItem.product_weighed` is 

57true. 

58""" 

59 

60ORDER_UOM_POUND = "LB" 

61""" 

62UOM code for ordering a "pound" of product. 

63 

64This is treated same as "unit" by Sideshow. However it should 

65(probably?) only be used for items where 

66e.g. :attr:`~sideshow.db.model.orders.OrderItem.product_weighed` is 

67true. 

68""" 

69 

70ORDER_UOM = OrderedDict( 

71 [ 

72 (ORDER_UOM_CASE, "Cases"), 

73 (ORDER_UOM_UNIT, "Units"), 

74 (ORDER_UOM_KILOGRAM, "Kilograms"), 

75 (ORDER_UOM_POUND, "Pounds"), 

76 ] 

77) 

78""" 

79Dict of possible code -> label options for ordering unit of measure. 

80 

81These codes are referenced by: 

82 

83* :attr:`sideshow.db.model.batch.neworder.NewOrderBatchRow.order_uom` 

84* :attr:`sideshow.db.model.orders.OrderItem.order_uom` 

85""" 

86 

87 

88class PendingCustomerStatus(Enum): 

89 """ 

90 Enum values for 

91 :attr:`sideshow.db.model.customers.PendingCustomer.status`. 

92 """ 

93 

94 PENDING = "pending" 

95 READY = "ready" 

96 RESOLVED = "resolved" 

97 IGNORED = "ignored" 

98 

99 

100class PendingProductStatus(Enum): 

101 """ 

102 Enum values for 

103 :attr:`sideshow.db.model.products.PendingProduct.status`. 

104 """ 

105 

106 PENDING = "pending" 

107 READY = "ready" 

108 RESOLVED = "resolved" 

109 IGNORED = "ignored" 

110 

111 

112######################################## 

113# Order Item Status 

114######################################## 

115 

116ORDER_ITEM_STATUS_UNINITIATED = 1 

117""" 

118Indicates the item is "not yet initiated" - this probably is not 

119useful but exists as a possibility just in case. 

120""" 

121 

122ORDER_ITEM_STATUS_INITIATED = 10 

123""" 

124Indicates the item is "initiated" (aka. created) but not yet "ready" 

125for buyer/PO. This may imply the price needs confirmation etc. 

126""" 

127 

128ORDER_ITEM_STATUS_PAID_BEFORE = 50 

129""" 

130Indicates the customer has fully paid for the item, up-front before 

131the buyer places PO etc. It implies the item is not yet "ready" for 

132some reason. 

133""" 

134 

135# TODO: deprecate / remove this one 

136ORDER_ITEM_STATUS_PAID = ORDER_ITEM_STATUS_PAID_BEFORE 

137 

138ORDER_ITEM_STATUS_READY = 100 

139""" 

140Indicates the item is "ready" for buyer to include it on a vendor 

141purchase order. 

142""" 

143 

144ORDER_ITEM_STATUS_PLACED = 200 

145""" 

146Indicates the buyer has placed a vendor purchase order which includes 

147this item. The item is thereby "on order" until the truck arrives. 

148""" 

149 

150ORDER_ITEM_STATUS_RECEIVED = 300 

151""" 

152Indicates the item has been received as part of a vendor delivery. 

153The item is thereby "on hand" until customer comes in for pickup. 

154""" 

155 

156ORDER_ITEM_STATUS_CONTACTED = 350 

157""" 

158Indicates the customer has been notified that the item is "on hand" 

159and awaiting their pickup. 

160""" 

161 

162ORDER_ITEM_STATUS_CONTACT_FAILED = 375 

163""" 

164Indicates the attempt(s) to notify customer have failed. The item is 

165on hand but the customer does not know to pickup. 

166""" 

167 

168ORDER_ITEM_STATUS_DELIVERED = 500 

169""" 

170Indicates the customer has picked up the item. 

171""" 

172 

173ORDER_ITEM_STATUS_PAID_AFTER = 550 

174""" 

175Indicates the customer has fully paid for the item, as part of their 

176pickup. This completes the cycle for orders which require payment on 

177the tail end. 

178""" 

179 

180ORDER_ITEM_STATUS_CANCELED = 900 

181""" 

182Indicates the order item has been canceled. 

183""" 

184 

185ORDER_ITEM_STATUS_REFUND_PENDING = 910 

186""" 

187Indicates the order item has been canceled, and the customer is due a 

188(pending) refund. 

189""" 

190 

191ORDER_ITEM_STATUS_REFUNDED = 920 

192""" 

193Indicates the order item has been canceled, and the customer has been 

194given a refund. 

195""" 

196 

197ORDER_ITEM_STATUS_RESTOCKED = 930 

198""" 

199Indicates the product has been restocked, e.g. after the order item 

200was canceled. 

201""" 

202 

203ORDER_ITEM_STATUS_EXPIRED = 940 

204""" 

205Indicates the order item and/or product has expired. 

206""" 

207 

208ORDER_ITEM_STATUS_INACTIVE = 950 

209""" 

210Indicates the order item has become inactive. 

211""" 

212 

213ORDER_ITEM_STATUS = OrderedDict( 

214 [ 

215 (ORDER_ITEM_STATUS_UNINITIATED, "uninitiated"), 

216 (ORDER_ITEM_STATUS_INITIATED, "initiated"), 

217 (ORDER_ITEM_STATUS_PAID_BEFORE, "paid"), 

218 (ORDER_ITEM_STATUS_READY, "ready"), 

219 (ORDER_ITEM_STATUS_PLACED, "placed"), 

220 (ORDER_ITEM_STATUS_RECEIVED, "received"), 

221 (ORDER_ITEM_STATUS_CONTACTED, "contacted"), 

222 (ORDER_ITEM_STATUS_CONTACT_FAILED, "contact failed"), 

223 (ORDER_ITEM_STATUS_DELIVERED, "delivered"), 

224 (ORDER_ITEM_STATUS_PAID_AFTER, "paid"), 

225 (ORDER_ITEM_STATUS_CANCELED, "canceled"), 

226 (ORDER_ITEM_STATUS_REFUND_PENDING, "refund pending"), 

227 (ORDER_ITEM_STATUS_REFUNDED, "refunded"), 

228 (ORDER_ITEM_STATUS_RESTOCKED, "restocked"), 

229 (ORDER_ITEM_STATUS_EXPIRED, "expired"), 

230 (ORDER_ITEM_STATUS_INACTIVE, "inactive"), 

231 ] 

232) 

233""" 

234Dict of possible code -> label options for :term:`order item` status. 

235 

236These codes are referenced by: 

237 

238* :attr:`sideshow.db.model.orders.OrderItem.status_code` 

239""" 

240 

241 

242######################################## 

243# Order Item Event Type 

244######################################## 

245 

246ORDER_ITEM_EVENT_INITIATED = 10 

247""" 

248Indicates the item was "initiated" - this occurs when the 

249:term:`order` is first created. 

250""" 

251 

252ORDER_ITEM_EVENT_PRICE_CONFIRMED = 20 

253""" 

254Indicates the item's price was confirmed by a user who is authorized 

255to do that. 

256""" 

257 

258ORDER_ITEM_EVENT_PAYMENT_RECEIVED = 50 

259""" 

260Indicates payment was received for the item. This may occur toward 

261the beginning, or toward the end, of the item's life cycle depending 

262on app configuration etc. 

263""" 

264 

265# TODO: deprecate / remove this 

266ORDER_ITEM_EVENT_PAID = ORDER_ITEM_EVENT_PAYMENT_RECEIVED 

267 

268ORDER_ITEM_EVENT_READY = 100 

269""" 

270Indicates the item has become "ready" for buyer placement on a new 

271vendor purchase order. Often this will occur when the :term:`order` 

272is first created, if the data is suitable. However this may be 

273delayed if e.g. the price needs confirmation. 

274""" 

275 

276ORDER_ITEM_EVENT_CUSTOMER_RESOLVED = 120 

277""" 

278Indicates the customer for the :term:`order` has been assigned to a 

279"proper" (existing) account. This may happen (after the fact) if the 

280order was first created with a new/unknown customer. 

281""" 

282 

283ORDER_ITEM_EVENT_PRODUCT_RESOLVED = 140 

284""" 

285Indicates the product for the :term:`order item` has been assigned to 

286a "proper" (existing) product record. This may happen (after the 

287fact) if the order was first created with a new/unknown product. 

288""" 

289 

290ORDER_ITEM_EVENT_PLACED = 200 

291""" 

292Indicates the buyer has placed a vendor purchase order which includes 

293this item. So the item is "on order" until the truck arrives. 

294""" 

295 

296ORDER_ITEM_EVENT_REORDER = 210 

297""" 

298Indicates the item was not received with the delivery on which it was 

299expected, and must be re-ordered from vendor. 

300""" 

301 

302ORDER_ITEM_EVENT_RECEIVED = 300 

303""" 

304Indicates the receiver has found the item while receiving a vendor 

305delivery. The item is set aside and is "on hand" until customer comes 

306in to pick it up. 

307""" 

308 

309ORDER_ITEM_EVENT_CONTACTED = 350 

310""" 

311Indicates the customer has been contacted, to notify them of the item 

312being on hand and ready for pickup. 

313""" 

314 

315ORDER_ITEM_EVENT_CONTACT_FAILED = 375 

316""" 

317Indicates an attempt was made to contact the customer, to notify them 

318of item being on hand, but the attempt failed, e.g. due to bad phone 

319or email on file. 

320""" 

321 

322ORDER_ITEM_EVENT_DELIVERED = 500 

323""" 

324Indicates the customer has picked up the item. 

325""" 

326 

327ORDER_ITEM_EVENT_STATUS_CHANGE = 700 

328""" 

329Indicates a manual status change was made. Such an event should 

330ideally contain a note with further explanation. 

331""" 

332 

333ORDER_ITEM_EVENT_NOTE_ADDED = 750 

334""" 

335Indicates an arbitrary note was added. 

336""" 

337 

338ORDER_ITEM_EVENT_CANCELED = 900 

339""" 

340Indicates the :term:`order item` was canceled. 

341""" 

342 

343ORDER_ITEM_EVENT_REFUND_PENDING = 910 

344""" 

345Indicates the customer is due a (pending) refund for the item. 

346""" 

347 

348ORDER_ITEM_EVENT_REFUNDED = 920 

349""" 

350Indicates the customer has been refunded for the item. 

351""" 

352 

353ORDER_ITEM_EVENT_RESTOCKED = 930 

354""" 

355Indicates the product has been restocked, e.g. due to the order item 

356being canceled. 

357""" 

358 

359ORDER_ITEM_EVENT_EXPIRED = 940 

360""" 

361Indicates the order item (or its product) has expired. 

362""" 

363 

364ORDER_ITEM_EVENT_INACTIVE = 950 

365""" 

366Indicates the order item has become inactive. 

367""" 

368 

369ORDER_ITEM_EVENT_OTHER = 999 

370""" 

371Arbitrary event type which does not signify anything in particular. 

372If used, the event should be given an explanatory note. 

373""" 

374 

375ORDER_ITEM_EVENT = OrderedDict( 

376 [ 

377 (ORDER_ITEM_EVENT_INITIATED, "initiated"), 

378 (ORDER_ITEM_EVENT_PRICE_CONFIRMED, "price confirmed"), 

379 (ORDER_ITEM_EVENT_PAYMENT_RECEIVED, "payment received"), 

380 (ORDER_ITEM_EVENT_READY, "ready to proceed"), 

381 (ORDER_ITEM_EVENT_CUSTOMER_RESOLVED, "customer resolved"), 

382 (ORDER_ITEM_EVENT_PRODUCT_RESOLVED, "product resolved"), 

383 (ORDER_ITEM_EVENT_PLACED, "placed with vendor"), 

384 (ORDER_ITEM_EVENT_REORDER, "marked for re-order"), 

385 (ORDER_ITEM_EVENT_RECEIVED, "received from vendor"), 

386 (ORDER_ITEM_EVENT_CONTACTED, "customer contacted"), 

387 (ORDER_ITEM_EVENT_CONTACT_FAILED, "contact failed"), 

388 (ORDER_ITEM_EVENT_DELIVERED, "delivered"), 

389 (ORDER_ITEM_EVENT_STATUS_CHANGE, "changed status"), 

390 (ORDER_ITEM_EVENT_NOTE_ADDED, "added note"), 

391 (ORDER_ITEM_EVENT_CANCELED, "canceled"), 

392 (ORDER_ITEM_EVENT_REFUND_PENDING, "refund pending"), 

393 (ORDER_ITEM_EVENT_REFUNDED, "refunded"), 

394 (ORDER_ITEM_EVENT_RESTOCKED, "restocked"), 

395 (ORDER_ITEM_EVENT_EXPIRED, "expired"), 

396 (ORDER_ITEM_EVENT_INACTIVE, "inactive"), 

397 (ORDER_ITEM_EVENT_OTHER, "other"), 

398 ] 

399) 

400""" 

401Dict of possible code -> label options for :term:`order item` event 

402types. 

403 

404These codes are referenced by: 

405 

406* :attr:`sideshow.db.model.orders.OrderItemEvent.type_code` 

407"""