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

103 statements  

« prev     ^ index     » next       coverage.py v7.16.1, created at 2026-09-22 12:21 -0500

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 

32ORDER_UOM_CASE = "CS" 

33""" 

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

35 

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

37"unit" orders. 

38""" 

39 

40ORDER_UOM_UNIT = "EA" 

41""" 

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

43 

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

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

46differently. 

47""" 

48 

49ORDER_UOM_KILOGRAM = "KG" 

50""" 

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

52 

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

54(probably?) only be used for items where 

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

56true. 

57""" 

58 

59ORDER_UOM_POUND = "LB" 

60""" 

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

62 

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

64(probably?) only be used for items where 

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

66true. 

67""" 

68 

69ORDER_UOM = OrderedDict( 

70 [ 

71 (ORDER_UOM_CASE, "Cases"), 

72 (ORDER_UOM_UNIT, "Units"), 

73 (ORDER_UOM_KILOGRAM, "Kilograms"), 

74 (ORDER_UOM_POUND, "Pounds"), 

75 ] 

76) 

77""" 

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

79 

80These codes are referenced by: 

81 

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

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

84""" 

85 

86 

87class PendingCustomerStatus(Enum): 

88 """ 

89 Enum values for 

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

91 """ 

92 

93 PENDING = "pending" 

94 READY = "ready" 

95 RESOLVED = "resolved" 

96 IGNORED = "ignored" 

97 

98 

99class PendingProductStatus(Enum): 

100 """ 

101 Enum values for 

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

103 """ 

104 

105 PENDING = "pending" 

106 READY = "ready" 

107 RESOLVED = "resolved" 

108 IGNORED = "ignored" 

109 

110 

111######################################## 

112# Order Item Status 

113######################################## 

114 

115ORDER_ITEM_STATUS_UNINITIATED = 1 

116""" 

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

118useful but exists as a possibility just in case. 

119""" 

120 

121ORDER_ITEM_STATUS_INITIATED = 10 

122""" 

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

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

125""" 

126 

127ORDER_ITEM_STATUS_PAID_BEFORE = 50 

128""" 

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

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

131some reason. 

132""" 

133 

134# TODO: deprecate / remove this one 

135ORDER_ITEM_STATUS_PAID = ORDER_ITEM_STATUS_PAID_BEFORE 

136 

137ORDER_ITEM_STATUS_READY = 100 

138""" 

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

140purchase order. 

141""" 

142 

143ORDER_ITEM_STATUS_PLACED = 200 

144""" 

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

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

147""" 

148 

149ORDER_ITEM_STATUS_RECEIVED = 300 

150""" 

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

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

153""" 

154 

155ORDER_ITEM_STATUS_CONTACTED = 350 

156""" 

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

158and awaiting their pickup. 

159""" 

160 

161ORDER_ITEM_STATUS_CONTACT_FAILED = 375 

162""" 

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

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

165""" 

166 

167ORDER_ITEM_STATUS_DELIVERED = 500 

168""" 

169Indicates the customer has picked up the item. 

170""" 

171 

172ORDER_ITEM_STATUS_PAID_AFTER = 550 

173""" 

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

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

176the tail end. 

177""" 

178 

179ORDER_ITEM_STATUS_CANCELED = 900 

180""" 

181Indicates the order item has been canceled. 

182""" 

183 

184ORDER_ITEM_STATUS_REFUND_PENDING = 910 

185""" 

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

187(pending) refund. 

188""" 

189 

190ORDER_ITEM_STATUS_REFUNDED = 920 

191""" 

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

193given a refund. 

194""" 

195 

196ORDER_ITEM_STATUS_RESTOCKED = 930 

197""" 

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

199was canceled. 

200""" 

201 

202ORDER_ITEM_STATUS_EXPIRED = 940 

203""" 

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

205""" 

206 

207ORDER_ITEM_STATUS_INACTIVE = 950 

208""" 

209Indicates the order item has become inactive. 

210""" 

211 

212ORDER_ITEM_STATUS = OrderedDict( 

213 [ 

214 (ORDER_ITEM_STATUS_UNINITIATED, "uninitiated"), 

215 (ORDER_ITEM_STATUS_INITIATED, "initiated"), 

216 (ORDER_ITEM_STATUS_PAID_BEFORE, "paid"), 

217 (ORDER_ITEM_STATUS_READY, "ready"), 

218 (ORDER_ITEM_STATUS_PLACED, "placed"), 

219 (ORDER_ITEM_STATUS_RECEIVED, "received"), 

220 (ORDER_ITEM_STATUS_CONTACTED, "contacted"), 

221 (ORDER_ITEM_STATUS_CONTACT_FAILED, "contact failed"), 

222 (ORDER_ITEM_STATUS_DELIVERED, "delivered"), 

223 (ORDER_ITEM_STATUS_PAID_AFTER, "paid"), 

224 (ORDER_ITEM_STATUS_CANCELED, "canceled"), 

225 (ORDER_ITEM_STATUS_REFUND_PENDING, "refund pending"), 

226 (ORDER_ITEM_STATUS_REFUNDED, "refunded"), 

227 (ORDER_ITEM_STATUS_RESTOCKED, "restocked"), 

228 (ORDER_ITEM_STATUS_EXPIRED, "expired"), 

229 (ORDER_ITEM_STATUS_INACTIVE, "inactive"), 

230 ] 

231) 

232""" 

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

234 

235These codes are referenced by: 

236 

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

238""" 

239 

240 

241######################################## 

242# Order Item Event Type 

243######################################## 

244 

245ORDER_ITEM_EVENT_INITIATED = 10 

246""" 

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

248:term:`order` is first created. 

249""" 

250 

251ORDER_ITEM_EVENT_PRICE_CONFIRMED = 20 

252""" 

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

254to do that. 

255""" 

256 

257ORDER_ITEM_EVENT_PAYMENT_RECEIVED = 50 

258""" 

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

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

261on app configuration etc. 

262""" 

263 

264# TODO: deprecate / remove this 

265ORDER_ITEM_EVENT_PAID = ORDER_ITEM_EVENT_PAYMENT_RECEIVED 

266 

267ORDER_ITEM_EVENT_READY = 100 

268""" 

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

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

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

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

273""" 

274 

275ORDER_ITEM_EVENT_CUSTOMER_RESOLVED = 120 

276""" 

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

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

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

280""" 

281 

282ORDER_ITEM_EVENT_PRODUCT_RESOLVED = 140 

283""" 

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

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

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

287""" 

288 

289ORDER_ITEM_EVENT_PLACED = 200 

290""" 

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

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

293""" 

294 

295ORDER_ITEM_EVENT_REORDER = 210 

296""" 

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

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

299""" 

300 

301ORDER_ITEM_EVENT_RECEIVED = 300 

302""" 

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

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

305in to pick it up. 

306""" 

307 

308ORDER_ITEM_EVENT_CONTACTED = 350 

309""" 

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

311being on hand and ready for pickup. 

312""" 

313 

314ORDER_ITEM_EVENT_CONTACT_FAILED = 375 

315""" 

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

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

318or email on file. 

319""" 

320 

321ORDER_ITEM_EVENT_DELIVERED = 500 

322""" 

323Indicates the customer has picked up the item. 

324""" 

325 

326ORDER_ITEM_EVENT_STATUS_CHANGE = 700 

327""" 

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

329ideally contain a note with further explanation. 

330""" 

331 

332ORDER_ITEM_EVENT_NOTE_ADDED = 750 

333""" 

334Indicates an arbitrary note was added. 

335""" 

336 

337ORDER_ITEM_EVENT_CANCELED = 900 

338""" 

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

340""" 

341 

342ORDER_ITEM_EVENT_REFUND_PENDING = 910 

343""" 

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

345""" 

346 

347ORDER_ITEM_EVENT_REFUNDED = 920 

348""" 

349Indicates the customer has been refunded for the item. 

350""" 

351 

352ORDER_ITEM_EVENT_RESTOCKED = 930 

353""" 

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

355being canceled. 

356""" 

357 

358ORDER_ITEM_EVENT_EXPIRED = 940 

359""" 

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

361""" 

362 

363ORDER_ITEM_EVENT_INACTIVE = 950 

364""" 

365Indicates the order item has become inactive. 

366""" 

367 

368ORDER_ITEM_EVENT_OTHER = 999 

369""" 

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

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

372""" 

373 

374ORDER_ITEM_EVENT = OrderedDict( 

375 [ 

376 (ORDER_ITEM_EVENT_INITIATED, "initiated"), 

377 (ORDER_ITEM_EVENT_PRICE_CONFIRMED, "price confirmed"), 

378 (ORDER_ITEM_EVENT_PAYMENT_RECEIVED, "payment received"), 

379 (ORDER_ITEM_EVENT_READY, "ready to proceed"), 

380 (ORDER_ITEM_EVENT_CUSTOMER_RESOLVED, "customer resolved"), 

381 (ORDER_ITEM_EVENT_PRODUCT_RESOLVED, "product resolved"), 

382 (ORDER_ITEM_EVENT_PLACED, "placed with vendor"), 

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

384 (ORDER_ITEM_EVENT_RECEIVED, "received from vendor"), 

385 (ORDER_ITEM_EVENT_CONTACTED, "customer contacted"), 

386 (ORDER_ITEM_EVENT_CONTACT_FAILED, "contact failed"), 

387 (ORDER_ITEM_EVENT_DELIVERED, "delivered"), 

388 (ORDER_ITEM_EVENT_STATUS_CHANGE, "changed status"), 

389 (ORDER_ITEM_EVENT_NOTE_ADDED, "added note"), 

390 (ORDER_ITEM_EVENT_CANCELED, "canceled"), 

391 (ORDER_ITEM_EVENT_REFUND_PENDING, "refund pending"), 

392 (ORDER_ITEM_EVENT_REFUNDED, "refunded"), 

393 (ORDER_ITEM_EVENT_RESTOCKED, "restocked"), 

394 (ORDER_ITEM_EVENT_EXPIRED, "expired"), 

395 (ORDER_ITEM_EVENT_INACTIVE, "inactive"), 

396 (ORDER_ITEM_EVENT_OTHER, "other"), 

397 ] 

398) 

399""" 

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

401types. 

402 

403These codes are referenced by: 

404 

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

406"""