Coverage for src/sideshow/enum.py: 100%

101 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-02-19 19:16 -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 * 

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 (ORDER_UOM_CASE, "Cases"), 

72 (ORDER_UOM_UNIT, "Units"), 

73 (ORDER_UOM_KILOGRAM, "Kilograms"), 

74 (ORDER_UOM_POUND, "Pounds"), 

75]) 

76""" 

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

78 

79These codes are referenced by: 

80 

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

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

83""" 

84 

85 

86class PendingCustomerStatus(Enum): 

87 """ 

88 Enum values for 

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

90 """ 

91 PENDING = 'pending' 

92 READY = 'ready' 

93 RESOLVED = 'resolved' 

94 

95 

96class PendingProductStatus(Enum): 

97 """ 

98 Enum values for 

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

100 """ 

101 PENDING = 'pending' 

102 READY = 'ready' 

103 RESOLVED = 'resolved' 

104 

105 

106######################################## 

107# Order Item Status 

108######################################## 

109 

110ORDER_ITEM_STATUS_UNINITIATED = 1 

111""" 

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

113useful but exists as a possibility just in case. 

114""" 

115 

116ORDER_ITEM_STATUS_INITIATED = 10 

117""" 

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

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

120""" 

121 

122ORDER_ITEM_STATUS_PAID_BEFORE = 50 

123""" 

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

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

126some reason. 

127""" 

128 

129# TODO: deprecate / remove this one 

130ORDER_ITEM_STATUS_PAID = ORDER_ITEM_STATUS_PAID_BEFORE 

131 

132ORDER_ITEM_STATUS_READY = 100 

133""" 

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

135purchase order. 

136""" 

137 

138ORDER_ITEM_STATUS_PLACED = 200 

139""" 

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

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

142""" 

143 

144ORDER_ITEM_STATUS_RECEIVED = 300 

145""" 

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

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

148""" 

149 

150ORDER_ITEM_STATUS_CONTACTED = 350 

151""" 

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

153and awaiting their pickup. 

154""" 

155 

156ORDER_ITEM_STATUS_CONTACT_FAILED = 375 

157""" 

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

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

160""" 

161 

162ORDER_ITEM_STATUS_DELIVERED = 500 

163""" 

164Indicates the customer has picked up the item. 

165""" 

166 

167ORDER_ITEM_STATUS_PAID_AFTER = 550 

168""" 

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

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

171the tail end. 

172""" 

173 

174ORDER_ITEM_STATUS_CANCELED = 900 

175""" 

176Indicates the order item has been canceled. 

177""" 

178 

179ORDER_ITEM_STATUS_REFUND_PENDING = 910 

180""" 

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

182(pending) refund. 

183""" 

184 

185ORDER_ITEM_STATUS_REFUNDED = 920 

186""" 

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

188given a refund. 

189""" 

190 

191ORDER_ITEM_STATUS_RESTOCKED = 930 

192""" 

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

194was canceled. 

195""" 

196 

197ORDER_ITEM_STATUS_EXPIRED = 940 

198""" 

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

200""" 

201 

202ORDER_ITEM_STATUS_INACTIVE = 950 

203""" 

204Indicates the order item has become inactive. 

205""" 

206 

207ORDER_ITEM_STATUS = OrderedDict([ 

208 (ORDER_ITEM_STATUS_UNINITIATED, "uninitiated"), 

209 (ORDER_ITEM_STATUS_INITIATED, "initiated"), 

210 (ORDER_ITEM_STATUS_PAID_BEFORE, "paid"), 

211 (ORDER_ITEM_STATUS_READY, "ready"), 

212 (ORDER_ITEM_STATUS_PLACED, "placed"), 

213 (ORDER_ITEM_STATUS_RECEIVED, "received"), 

214 (ORDER_ITEM_STATUS_CONTACTED, "contacted"), 

215 (ORDER_ITEM_STATUS_CONTACT_FAILED, "contact failed"), 

216 (ORDER_ITEM_STATUS_DELIVERED, "delivered"), 

217 (ORDER_ITEM_STATUS_PAID_AFTER, "paid"), 

218 (ORDER_ITEM_STATUS_CANCELED, "canceled"), 

219 (ORDER_ITEM_STATUS_REFUND_PENDING, "refund pending"), 

220 (ORDER_ITEM_STATUS_REFUNDED, "refunded"), 

221 (ORDER_ITEM_STATUS_RESTOCKED, "restocked"), 

222 (ORDER_ITEM_STATUS_EXPIRED, "expired"), 

223 (ORDER_ITEM_STATUS_INACTIVE, "inactive"), 

224]) 

225""" 

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

227 

228These codes are referenced by: 

229 

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

231""" 

232 

233 

234######################################## 

235# Order Item Event Type 

236######################################## 

237 

238ORDER_ITEM_EVENT_INITIATED = 10 

239""" 

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

241:term:`order` is first created. 

242""" 

243 

244ORDER_ITEM_EVENT_PRICE_CONFIRMED = 20 

245""" 

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

247to do that. 

248""" 

249 

250ORDER_ITEM_EVENT_PAYMENT_RECEIVED = 50 

251""" 

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

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

254on app configuration etc. 

255""" 

256 

257# TODO: deprecate / remove this 

258ORDER_ITEM_EVENT_PAID = ORDER_ITEM_EVENT_PAYMENT_RECEIVED 

259 

260ORDER_ITEM_EVENT_READY = 100 

261""" 

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

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

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

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

266""" 

267 

268ORDER_ITEM_EVENT_CUSTOMER_RESOLVED = 120 

269""" 

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

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

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

273""" 

274 

275ORDER_ITEM_EVENT_PRODUCT_RESOLVED = 140 

276""" 

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

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

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

280""" 

281 

282ORDER_ITEM_EVENT_PLACED = 200 

283""" 

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

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

286""" 

287 

288ORDER_ITEM_EVENT_REORDER = 210 

289""" 

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

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

292""" 

293 

294ORDER_ITEM_EVENT_RECEIVED = 300 

295""" 

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

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

298in to pick it up. 

299""" 

300 

301ORDER_ITEM_EVENT_CONTACTED = 350 

302""" 

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

304being on hand and ready for pickup. 

305""" 

306 

307ORDER_ITEM_EVENT_CONTACT_FAILED = 375 

308""" 

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

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

311or email on file. 

312""" 

313 

314ORDER_ITEM_EVENT_DELIVERED = 500 

315""" 

316Indicates the customer has picked up the item. 

317""" 

318 

319ORDER_ITEM_EVENT_STATUS_CHANGE = 700 

320""" 

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

322ideally contain a note with further explanation. 

323""" 

324 

325ORDER_ITEM_EVENT_NOTE_ADDED = 750 

326""" 

327Indicates an arbitrary note was added. 

328""" 

329 

330ORDER_ITEM_EVENT_CANCELED = 900 

331""" 

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

333""" 

334 

335ORDER_ITEM_EVENT_REFUND_PENDING = 910 

336""" 

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

338""" 

339 

340ORDER_ITEM_EVENT_REFUNDED = 920 

341""" 

342Indicates the customer has been refunded for the item. 

343""" 

344 

345ORDER_ITEM_EVENT_RESTOCKED = 930 

346""" 

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

348being canceled. 

349""" 

350 

351ORDER_ITEM_EVENT_EXPIRED = 940 

352""" 

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

354""" 

355 

356ORDER_ITEM_EVENT_INACTIVE = 950 

357""" 

358Indicates the order item has become inactive. 

359""" 

360 

361ORDER_ITEM_EVENT_OTHER = 999 

362""" 

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

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

365""" 

366 

367ORDER_ITEM_EVENT = OrderedDict([ 

368 (ORDER_ITEM_EVENT_INITIATED, "initiated"), 

369 (ORDER_ITEM_EVENT_PRICE_CONFIRMED, "price confirmed"), 

370 (ORDER_ITEM_EVENT_PAYMENT_RECEIVED, "payment received"), 

371 (ORDER_ITEM_EVENT_READY, "ready to proceed"), 

372 (ORDER_ITEM_EVENT_CUSTOMER_RESOLVED, "customer resolved"), 

373 (ORDER_ITEM_EVENT_PRODUCT_RESOLVED, "product resolved"), 

374 (ORDER_ITEM_EVENT_PLACED, "placed with vendor"), 

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

376 (ORDER_ITEM_EVENT_RECEIVED, "received from vendor"), 

377 (ORDER_ITEM_EVENT_CONTACTED, "customer contacted"), 

378 (ORDER_ITEM_EVENT_CONTACT_FAILED, "contact failed"), 

379 (ORDER_ITEM_EVENT_DELIVERED, "delivered"), 

380 (ORDER_ITEM_EVENT_STATUS_CHANGE, "changed status"), 

381 (ORDER_ITEM_EVENT_NOTE_ADDED, "added note"), 

382 (ORDER_ITEM_EVENT_CANCELED, "canceled"), 

383 (ORDER_ITEM_EVENT_REFUND_PENDING, "refund pending"), 

384 (ORDER_ITEM_EVENT_REFUNDED, "refunded"), 

385 (ORDER_ITEM_EVENT_RESTOCKED, "restocked"), 

386 (ORDER_ITEM_EVENT_EXPIRED, "expired"), 

387 (ORDER_ITEM_EVENT_INACTIVE, "inactive"), 

388 (ORDER_ITEM_EVENT_OTHER, "other"), 

389]) 

390""" 

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

392types. 

393 

394These codes are referenced by: 

395 

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

397"""