Subversion Repositories SmartDukaan

Rev

Rev 20745 | Blame | Compare with Previous | Last modification | View Log | RSS feed

from shop2020.thriftpy.logistics.ttypes import Provider as TProvider, AwbUpdate as TAwbUpdate, \
        ProviderDetails as TProviderDetails, PickupStore as TPickupStore, BluedartAttributes as TBluedartAttributes
from shop2020.utils.Utils import to_java_date


def to_t_provider(provider):
    t_provider = TProvider()
    t_provider.id = provider.id
    t_provider.name = provider.name
    t_provider.pickup = provider.pickup
    t_provider.details = []
    for detail in provider.details:
        if detail.active:
            t_provider.details.append(to_t_proivder_details(detail))
    if provider.bundleWeightLimit:
        t_provider.bundleWeightLimit = provider.bundleWeightLimit
    t_provider.groupShipmentAllowed = provider.groupShipmentAllowed
    t_provider.maxCodLimit = provider.maxCodLimit
    return t_provider

def to_t_proivder_details(detail):
    t_provider_details = TProviderDetails()
    t_provider_details.accountNo = detail.accountNo
    t_provider_details.email = detail.email
    t_provider_details.logisticLocation = detail.logisticLocation
    t_provider_details.deliveryType = detail.type
    return t_provider_details 

def to_t_awbupdate(update):
    t_update = TAwbUpdate()
    t_update.awbNumber    = update.awbNumber
    t_update.providerId = update.providerId
    t_update.location     = update.location
    t_update.status  = update.status
    t_update.description  = update.description
    t_update.date    = to_java_date(update.date)
    return t_update

def to_t_pickup_store(store):
    t_store = TPickupStore()
    t_store.id = store.id
    t_store.hotspotId = store.hotspotId 
    t_store.name = store.name
    t_store.line1 = store.line_1
    t_store.line2 = store.line_2
    t_store.city = store.city
    t_store.state = store.state
    t_store.pin = store.pin
    t_store.phone = store.phone
    t_store.email = store.email
    t_store.zone = store.zone
    t_store.bdm = store.bdm
    t_store.bdmEmail = store.bdmEmail
    return t_store

def to_t_bluedart_attribute(bluedartAttr):
    t_bluedart_attr = TBluedartAttributes()
    t_bluedart_attr.logisticsTransactionId = bluedartAttr.logisticsTransactionId
    t_bluedart_attr.name = bluedartAttr.name
    t_bluedart_attr.value = bluedartAttr.value
    return t_bluedart_attr