Subversion Repositories SmartDukaan

Rev

Rev 132 | Blame | Last modification | View Log | RSS feed

'''
Created on 29-Mar-2010

@author: ashish
'''
from shop2020.thriftpy.model.v1.order.ttypes import PaymentStatus,\
    ShipmentStatus, TransactionStatus, TransactionServiceException

status_payment_failure=10
status_payment_success=11
status_shipment_shipped=20
status_shipment_in_transit=21
status_shipment_delivered=22
status_shipment_yet_to_ship=23
status_transaction_init=30
status_transaction_submitted_for_processing=31
status_transaction_order_fulfilment=32
status_transaction_completed=33
status_transaction_billed=34
status_transaction_shipped=35

t_mapping = {
               status_payment_failure : PaymentStatus.FAILURE,
               status_payment_success : PaymentStatus.SUCCESS,
               status_shipment_shipped : ShipmentStatus.SHIPPED,
               status_shipment_in_transit : ShipmentStatus.IN_TRANSIT,
               status_shipment_delivered : ShipmentStatus.DELIVERY_SUCCESS,
               status_transaction_init : TransactionStatus.INIT,
               status_transaction_billed : TransactionStatus.BILLED,
               status_transaction_submitted_for_processing : TransactionStatus.SUBMITTED_FOR_PROCESSING,
               status_transaction_order_fulfilment : TransactionStatus.ORDER_FULFILLMENT,
               status_transaction_completed : TransactionStatus.COMPLETED,
               status_transaction_shipped : TransactionStatus.SHIPPED,
               status_shipment_yet_to_ship : ShipmentStatus.YET_TO_SHIP
           }

c_mapping = {
                 PaymentStatus.FAILURE : status_payment_failure,
                 PaymentStatus.SUCCESS : status_payment_success,
                 ShipmentStatus.SHIPPED : status_shipment_shipped,
                 ShipmentStatus.IN_TRANSIT : status_shipment_in_transit,
                 ShipmentStatus.DELIVERY_SUCCESS : status_shipment_delivered,
                 ShipmentStatus.YET_TO_SHIP : status_shipment_yet_to_ship, 
                 TransactionStatus.INIT : status_transaction_init, 
                 TransactionStatus.SUBMITTED_FOR_PROCESSING : status_transaction_submitted_for_processing, 
                 TransactionStatus.ORDER_FULFILLMENT : status_transaction_order_fulfilment, 
                 TransactionStatus.COMPLETED : status_transaction_completed,
                 TransactionStatus.BILLED : status_transaction_billed,
                 TransactionStatus.SHIPPED :  status_transaction_shipped
             }

def get_t_status(status):
    try:
        return t_mapping[status]
    except:
        raise TransactionServiceException(101,"%s is invalid status "%(str(status)))
    

def get_c_status(status):
    try:
        return c_mapping[status]
    except:
        raise TransactionServiceException(101,"%s is invalid status "%(str(status)))