Add "all" enum values for custorder item status, event

also attach "initiated" event(s) when creating new custorder
This commit is contained in:
Lance Edgar 2021-09-27 12:31:12 -04:00
parent 39504fdec9
commit 25483a21a0
2 changed files with 71 additions and 7 deletions

View file

@ -381,11 +381,16 @@ class CustomerOrderBatchHandler(BatchHandler):
def convert(row, i): def convert(row, i):
item = model.CustomerOrderItem() item = model.CustomerOrderItem()
item.sequence = i item.sequence = i
item.status_code = self.enum.CUSTORDER_ITEM_STATUS_ORDERED item.status_code = self.enum.CUSTORDER_ITEM_STATUS_INITIATED
for field in row_fields: for field in row_fields:
setattr(item, field, getattr(row, field)) setattr(item, field, getattr(row, field))
order.items.append(item) order.items.append(item)
# attach event
item.events.append(model.CustomerOrderItemEvent(
type_code=self.enum.CUSTORDER_ITEM_EVENT_INITIATED,
user=user))
self.progress_loop(convert, batch.active_rows(), progress, self.progress_loop(convert, batch.active_rows(), progress,
message="Converting batch rows to order items") message="Converting batch rows to order items")

View file

@ -56,6 +56,8 @@ The following enumerations are provided:
from __future__ import unicode_literals, absolute_import from __future__ import unicode_literals, absolute_import
from rattail.util import OrderedDict
BATCH_ACTION_ADD = 'ADD' BATCH_ACTION_ADD = 'ADD'
BATCH_ACTION_ADD_REPLACE = 'ADDRPL' BATCH_ACTION_ADD_REPLACE = 'ADDRPL'
@ -90,13 +92,70 @@ CUSTORDER_STATUS = {
} }
CUSTORDER_ITEM_STATUS_ORDERED = 10 CUSTORDER_ITEM_STATUS_INITIATED = 10
# CUSTORDER_ITEM_STATUS_PAID = 20 # TODO: deprecate / remove this one
CUSTORDER_ITEM_STATUS_ORDERED = CUSTORDER_ITEM_STATUS_INITIATED
CUSTORDER_ITEM_STATUS_PAID = 20
CUSTORDER_ITEM_STATUS_PLACED = 30
CUSTORDER_ITEM_STATUS_RECEIVED = 40
CUSTORDER_ITEM_STATUS_CONTACTED = 50
CUSTORDER_ITEM_STATUS_CONTACT_FAILED = 60
CUSTORDER_ITEM_STATUS_DELIVERED = 70
CUSTORDER_ITEM_STATUS_CANCELED = 900
CUSTORDER_ITEM_STATUS_REFUND_PENDING = 910
CUSTORDER_ITEM_STATUS_REFUNDED = 920
CUSTORDER_ITEM_STATUS_RESTOCKED = 930
CUSTORDER_ITEM_STATUS_EXPIRED = 940
CUSTORDER_ITEM_STATUS_INACTIVE = 950
CUSTORDER_ITEM_STATUS = { CUSTORDER_ITEM_STATUS = OrderedDict([
CUSTORDER_ITEM_STATUS_ORDERED : "ordered", (CUSTORDER_ITEM_STATUS_INITIATED, "customer order initiated"),
# CUSTORDER_ITEM_STATUS_PAID : "paid", (CUSTORDER_ITEM_STATUS_PAID, "payment received"),
} (CUSTORDER_ITEM_STATUS_PLACED, "order placed with vendor"),
(CUSTORDER_ITEM_STATUS_RECEIVED, "received from vendor"),
(CUSTORDER_ITEM_STATUS_CONTACTED, "customer contacted"),
(CUSTORDER_ITEM_STATUS_CONTACT_FAILED, "unable to contact customer"),
(CUSTORDER_ITEM_STATUS_DELIVERED, "delivered to customer"),
(CUSTORDER_ITEM_STATUS_CANCELED, "canceled"),
(CUSTORDER_ITEM_STATUS_REFUND_PENDING, "refund pending"),
(CUSTORDER_ITEM_STATUS_REFUNDED, "refunded"),
(CUSTORDER_ITEM_STATUS_RESTOCKED, "restocked"),
(CUSTORDER_ITEM_STATUS_EXPIRED, "expired"),
(CUSTORDER_ITEM_STATUS_INACTIVE, "inactive"),
])
CUSTORDER_ITEM_EVENT_INITIATED = 10
CUSTORDER_ITEM_EVENT_PAID = 20
CUSTORDER_ITEM_EVENT_PLACED = 30
CUSTORDER_ITEM_EVENT_RECEIVED = 40
CUSTORDER_ITEM_EVENT_CONTACTED = 50
CUSTORDER_ITEM_EVENT_CONTACT_FAILED = 60
CUSTORDER_ITEM_EVENT_DELIVERED = 70
CUSTORDER_ITEM_EVENT_STATUS_CHANGE = 500 # nb. this is not in STATUS enum
CUSTORDER_ITEM_EVENT_CANCELED = 900
CUSTORDER_ITEM_EVENT_REFUND_PENDING = 910
CUSTORDER_ITEM_EVENT_REFUNDED = 920
CUSTORDER_ITEM_EVENT_RESTOCKED = 930
CUSTORDER_ITEM_EVENT_EXPIRED = 940
CUSTORDER_ITEM_EVENT_INACTIVE = 950
CUSTORDER_ITEM_EVENT = OrderedDict([
(CUSTORDER_ITEM_EVENT_INITIATED, "customer order initiated"),
(CUSTORDER_ITEM_EVENT_PAID, "payment received"),
(CUSTORDER_ITEM_EVENT_PLACED, "order placed with vendor"),
(CUSTORDER_ITEM_EVENT_RECEIVED, "received from vendor"),
(CUSTORDER_ITEM_EVENT_CONTACTED, "customer contacted"),
(CUSTORDER_ITEM_EVENT_CONTACT_FAILED, "unable to contact customer"),
(CUSTORDER_ITEM_EVENT_DELIVERED, "delivered to customer"),
(CUSTORDER_ITEM_EVENT_STATUS_CHANGE, "manual status change"),
(CUSTORDER_ITEM_EVENT_CANCELED, "canceled"),
(CUSTORDER_ITEM_EVENT_REFUND_PENDING, "refund pending"),
(CUSTORDER_ITEM_EVENT_REFUNDED, "refunded"),
(CUSTORDER_ITEM_EVENT_RESTOCKED, "restocked"),
(CUSTORDER_ITEM_EVENT_EXPIRED, "expired"),
(CUSTORDER_ITEM_EVENT_INACTIVE, "inactive"),
])
EMAIL_ATTEMPT_CREATED = 0 EMAIL_ATTEMPT_CREATED = 0