Subversion Repositories SmartDukaan

Rev

Rev 1348 | Rev 1970 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
94 ashish 1
'''
2
Created on 23-Mar-2010
3
 
4
@author: ashish
5
'''
122 ashish 6
from shop2020.thriftpy.model.v1.catalog.ttypes import  Item,\
1341 chandransh 7
    ItemInventory, Warehouse, VendorItemPricing, Vendor
94 ashish 8
import time
122 ashish 9
from shop2020.utils.Utils import to_java_date
94 ashish 10
 
11
def to_t_item(item):
12
    t_item = Item()
576 chandransh 13
    if item is None:
14
        return t_item
94 ashish 15
    t_item.id = item.id
963 chandransh 16
    t_item.productGroup = item.product_group
17
    t_item.brand = item.brand
591 chandransh 18
    t_item.modelNumber = item.model_number
19
    t_item.modelName = item.model_name
609 chandransh 20
    t_item.color = item.color
591 chandransh 21
    t_item.category = item.category
122 ashish 22
    t_item.catalogItemId = item.catalog_item_id
23
    t_item.weight = item.weight
24
    t_item.featureId = item.feature_id
25
    t_item.featureDescription = item.feature_description
26
    if item.startDate:
27
        t_item.startDate = to_java_date(item.startDate)
28
    if item.addedOn:
29
        t_item.addedOn = to_java_date(item.addedOn)
609 chandransh 30
    if item.updatedOn:
31
        t_item.updatedOn = to_java_date(item.updatedOn)
122 ashish 32
    t_item.itemStatus = item.status
609 chandransh 33
 
501 rajveer 34
    if item.sellingPrice:
609 chandransh 35
        t_item.sellingPrice = item.sellingPrice
36
    if item.dealerPrice:
37
        t_item.dealerPrice = item.dealerPrice    
630 chandransh 38
    if item.mrp:
501 rajveer 39
        t_item.mrp = item.mrp    
630 chandransh 40
    if item.mop:
501 rajveer 41
        t_item.mop = item.mop
724 chandransh 42
    if item.transfer_price:
43
        t_item.transferPrice = item.transfer_price
94 ashish 44
    t_item.itemInventory = to_t_item_inventory(item.currentInventory, item.id)
122 ashish 45
 
609 chandransh 46
    if item.bestDealText:
47
        t_item.bestDealText = item.bestDealText
48
    if item.bestDealValue:
49
        t_item.bestDealValue = item.bestDealValue
50
 
1910 varun.gupt 51
    t_item.defaultForEntity = item.defaultForEntity
122 ashish 52
    t_item.otherInfo = to_t_other_info(item)
94 ashish 53
    return t_item
122 ashish 54
 
55
def to_t_other_info(item):
56
    t_other_info = {}
57
    for item_info in item.iteminfo:
58
        t_other_info[item_info.key] = item_info.value
94 ashish 59
 
60
def to_t_item_inventory(item_inventory_list, item_id):
61
    t_item_inventory = ItemInventory()
62
    t_item_inventory.id = item_id
63
    t_item_inventory.availability = {}
64
    for inventory_item in item_inventory_list:
122 ashish 65
        t_item_inventory.availability[inventory_item.warehouse.id] = inventory_item.availibility
483 rajveer 66
#        need review again        
67
#        if inventory_item.checkedOn:
68
#            t_item_inventory.lastCheckedOn = to_java_date(inventory_item.checkedOn)
94 ashish 69
    return t_item_inventory
70
 
71
def to_t_warehouse(warehouse):
72
    t_warehouse = Warehouse()
73
    t_warehouse.id = warehouse.id
759 chandransh 74
    t_warehouse.displayName = warehouse.displayName
94 ashish 75
    t_warehouse.location = warehouse.location
122 ashish 76
    t_warehouse.warehouseStatus = warehouse.status
483 rajveer 77
    t_warehouse.tinNumber = warehouse.tinNumber
78
    t_warehouse.pincode = warehouse.pincode
1308 chandransh 79
    t_warehouse.vendor = warehouse.vendor.name
494 rajveer 80
    if warehouse.vendorString:
483 rajveer 81
        t_warehouse.vendorString = warehouse.vendorString
122 ashish 82
    if warehouse.addedOn:
83
        t_warehouse.addedOn = to_java_date(warehouse.addedOn)
483 rajveer 84
    if warehouse.lastCheckedOn:
85
        t_warehouse.lastCheckedOn = to_java_date(warehouse.lastCheckedOn)
122 ashish 86
    return t_warehouse
1341 chandransh 87
 
88
def to_t_vendor(vendor):
89
    t_vendor = Vendor()
90
    t_vendor.id = vendor.id
91
    t_vendor.name = vendor.name
1348 chandransh 92
    return t_vendor
1341 chandransh 93
 
94
def to_t_vendor_item_pricing(vendor_item_pricing):
95
    t_vendor_item_pricing = VendorItemPricing()
1348 chandransh 96
    t_vendor_item_pricing.vendorId = vendor_item_pricing.vendor.id
97
    t_vendor_item_pricing.itemId = vendor_item_pricing.item.id
1341 chandransh 98
    t_vendor_item_pricing.transferPrice = vendor_item_pricing.transfer_price
99
    t_vendor_item_pricing.dealerPrice = vendor_item_pricing.dealerPrice
1348 chandransh 100
    t_vendor_item_pricing.mop = vendor_item_pricing.mop
101
    return t_vendor_item_pricing