Subversion Repositories SmartDukaan

Rev

Rev 5504 | Rev 6241 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5504 Rev 5944
Line 1... Line 1...
1
'''
1
'''
2
Created on 23-Mar-2010
2
Created on 23-Mar-2010
3
 
3
 
4
@author: ashish
4
@author: ashish
5
'''
5
'''
6
from shop2020.thriftpy.model.v1.catalog.ttypes import Item, ItemInventory, \
6
from shop2020.thriftpy.model.v1.catalog.ttypes import Item, \
7
    Warehouse, VendorItemPricing, Vendor, Category, VendorItemMapping, \
-
 
8
    SourceItemPricing, Source, ItemType, \
7
    Category, SourceItemPricing, Source, ItemType, \
9
    ProductNotificationRequest as TProductNotificationRequest, \
8
    ProductNotificationRequest as TProductNotificationRequest, \
10
    ProductNotificationRequestCount as TProductNotificationRequestCount, \
9
    ProductNotificationRequestCount as TProductNotificationRequestCount, \
11
    InventoryType, WarehouseType, VoucherItemMapping
10
    VoucherItemMapping
12
from shop2020.utils.Utils import to_java_date
11
from shop2020.utils.Utils import to_java_date
13
import time
-
 
14
 
12
 
15
def to_t_item(item):
13
def to_t_item(item):
16
    t_item = Item()
14
    t_item = Item()
17
    if item is None:
15
    if item is None:
18
        return t_item
16
        return t_item
Line 62... Line 60...
62
    t_item.hasItemNo = item.hasItemNo
60
    t_item.hasItemNo = item.hasItemNo
63
    t_item.clearance = item.clearance
61
    t_item.clearance = item.clearance
64
    
62
    
65
    return t_item
63
    return t_item
66
 
64
 
67
def to_t_item_inventory(item_inventory_list, item_id):
-
 
68
    t_item_inventory = ItemInventory()
-
 
69
    t_item_inventory.id = item_id
-
 
70
    t_item_inventory.availability = {}
-
 
71
    t_item_inventory.reserved = {}
-
 
72
    for inventory_item in item_inventory_list:
-
 
73
        t_item_inventory.availability[inventory_item.warehouse.id] = inventory_item.availability
-
 
74
        t_item_inventory.reserved[inventory_item.warehouse.id] = inventory_item.reserved
-
 
75
#        need review again        
-
 
76
#        if inventory_item.checkedOn:
-
 
77
#            t_item_inventory.lastCheckedOn = to_java_date(inventory_item.checkedOn)
-
 
78
    return t_item_inventory
-
 
79
 
-
 
80
def to_t_warehouse(warehouse):
-
 
81
    t_warehouse = Warehouse()
-
 
82
    t_warehouse.id = warehouse.id
-
 
83
    t_warehouse.displayName = warehouse.displayName
-
 
84
    t_warehouse.location = warehouse.location
-
 
85
    t_warehouse.tinNumber = warehouse.tinNumber
-
 
86
    t_warehouse.pincode = warehouse.pincode
-
 
87
    t_warehouse.billingType = warehouse.billingType
-
 
88
    t_warehouse.vendor = to_t_vendor(warehouse.vendor)
-
 
89
    t_warehouse.billingWarehouseId = warehouse.billingWarehouseId
-
 
90
    t_warehouse.shippingWarehouseId = warehouse.shippingWarehouseId
-
 
91
    t_warehouse.isAvailabilityMonitored = warehouse.isAvailabilityMonitored
-
 
92
    t_warehouse.transferDelayInHours = warehouse.transferDelayInHours
-
 
93
    t_warehouse.inventoryType = InventoryType._NAMES_TO_VALUES[warehouse.inventoryType]
-
 
94
    t_warehouse.warehouseType = WarehouseType._NAMES_TO_VALUES[warehouse.warehouseType]
-
 
95
    if warehouse.vendorString:
-
 
96
        t_warehouse.vendorString = warehouse.vendorString
-
 
97
    if warehouse.addedOn:
-
 
98
        t_warehouse.addedOn = to_java_date(warehouse.addedOn)
-
 
99
    if warehouse.lastCheckedOn:
-
 
100
        t_warehouse.lastCheckedOn = to_java_date(warehouse.lastCheckedOn)
-
 
101
    return t_warehouse
-
 
102
 
-
 
103
def to_t_vendor(vendor):
-
 
104
    t_vendor = Vendor()
-
 
105
    t_vendor.id = vendor.id
-
 
106
    t_vendor.name = vendor.name
-
 
107
    return t_vendor
-
 
108
 
-
 
109
def to_t_vendor_item_pricing(vendor_item_pricing):
-
 
110
    t_vendor_item_pricing = VendorItemPricing()
-
 
111
    t_vendor_item_pricing.vendorId = vendor_item_pricing.vendor.id
-
 
112
    t_vendor_item_pricing.itemId = vendor_item_pricing.item.id
-
 
113
    t_vendor_item_pricing.transferPrice = vendor_item_pricing.transfer_price
-
 
114
    t_vendor_item_pricing.dealerPrice = vendor_item_pricing.dealerPrice
-
 
115
    t_vendor_item_pricing.mop = vendor_item_pricing.mop
-
 
116
    return t_vendor_item_pricing
-
 
117
 
-
 
118
def to_t_vendor_item_mapping(vendor_item_mapping):
-
 
119
    t_vendor_item_mapping = VendorItemMapping()
-
 
120
    t_vendor_item_mapping.vendorId = vendor_item_mapping.vendor.id
-
 
121
    t_vendor_item_mapping.itemId = vendor_item_mapping.item.id
-
 
122
    t_vendor_item_mapping.itemKey = vendor_item_mapping.item_key
-
 
123
    return t_vendor_item_mapping
-
 
124
 
-
 
125
def to_t_voucher_item_mapping(voucher):
65
def to_t_voucher_item_mapping(voucher):
126
    t_voucher = VoucherItemMapping()
66
    t_voucher = VoucherItemMapping()
127
    t_voucher.voucherType = voucher.voucherType
67
    t_voucher.voucherType = voucher.voucherType
128
    t_voucher.itemId = voucher.item.id
68
    t_voucher.itemId = voucher.item.id
129
    t_voucher.amount = voucher.amount
69
    t_voucher.amount = voucher.amount