Changeset - 25483a21a057
[Not reviewed]
0 2 0
Lance Edgar (lance) - 3 years ago 2021-09-27 11:31:12
lance@edbob.org
Add "all" enum values for custorder item status, event

also attach "initiated" event(s) when creating new custorder
2 files changed with 72 insertions and 8 deletions:
0 comments (0 inline, 0 general)
rattail/batch/custorder.py
Show inline comments
 
@@ -378,17 +378,22 @@ class CustomerOrderBatchHandler(BatchHandler):
 
            'payment_transaction_number',
 
        ]
 

	
 
        def convert(row, i):
 
            item = model.CustomerOrderItem()
 
            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:
 
                setattr(item, field, getattr(row, field))
 
            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,
 
                           message="Converting batch rows to order items")
 

	
 
        session = orm.object_session(batch)
 
        session.add(order)
 
        session.flush()
rattail/enum.py
Show inline comments
 
@@ -53,12 +53,14 @@ The following enumerations are provided:
 
   Units of measure for use with products (e.g. each, pound).  These are taken
 
   from the SIL specification.
 
"""
 

	
 
from __future__ import unicode_literals, absolute_import
 

	
 
from rattail.util import OrderedDict
 

	
 

	
 
BATCH_ACTION_ADD                = 'ADD'
 
BATCH_ACTION_ADD_REPLACE        = 'ADDRPL'
 
BATCH_ACTION_CHANGE             = 'CHANGE'
 
BATCH_ACTION_LOAD               = 'LOAD'
 
BATCH_ACTION_REMOVE             = 'REMOVE'
 
@@ -87,19 +89,76 @@ CUSTORDER_STATUS_ORDERED                = 10
 
CUSTORDER_STATUS = {
 
    CUSTORDER_STATUS_ORDERED            : "ordered",
 
    # CUSTORDER_STATUS_PAID               : "paid",
 
}
 

	
 

	
 
CUSTORDER_ITEM_STATUS_ORDERED           = 10
 
# CUSTORDER_ITEM_STATUS_PAID              = 20
 

	
 
CUSTORDER_ITEM_STATUS = {
 
    CUSTORDER_ITEM_STATUS_ORDERED       : "ordered",
 
    # CUSTORDER_ITEM_STATUS_PAID          : "paid",
 
}
 
CUSTORDER_ITEM_STATUS_INITIATED         = 10
 
# 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 = OrderedDict([
 
    (CUSTORDER_ITEM_STATUS_INITIATED,           "customer order initiated"),
 
    (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_SUCCESS           = 1
 
EMAIL_ATTEMPT_FAILURE           = 2
 
# EMAIL_ATTEMPT_BOUNCED           = 3
0 comments (0 inline, 0 general)