Subversion Repositories SmartDukaan

Rev

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

Rev 2120 Rev 2129
Line 135... Line 135...
135
        ds_item.comments = item.comments
135
        ds_item.comments = item.comments
136
    
136
    
137
    if item.catalogItemId:
137
    if item.catalogItemId:
138
        ds_item.catalog_item_id = item.catalogItemId
138
        ds_item.catalog_item_id = item.catalogItemId
139
 
139
 
140
    if item.mrp:
140
    ds_item.mrp = item.mrp
141
        ds_item.mrp = item.mrp
141
    ds_item.sellingPrice = item.sellingPrice
-
 
142
    
142
    if item.mop:
143
    if item.mop:
143
        ds_item.mop = item.mop
144
        ds_item.mop = item.mop
144
    if item.sellingPrice:
-
 
145
        ds_item.sellingPrice = item.sellingPrice
-
 
146
    if item.dealerPrice:
145
    if item.dealerPrice:
147
        ds_item.dealerPrice = item.dealerPrice
146
        ds_item.dealerPrice = item.dealerPrice
148
    if item.transferPrice:
147
    if item.transferPrice:
149
        ds_item.transfer_price = item.transferPrice
148
        ds_item.transfer_price = item.transferPrice
150
    if item.weight:
149
    if item.weight:
151
        ds_item.weight = item.weight
150
        ds_item.weight = item.weight
-
 
151
    
-
 
152
    """
152
    if item.itemStatus:
153
    if item.itemStatus:
153
        ds_item.status = item.itemStatus
154
        ds_item.status = item.itemStatus
154
    if item.status_description:
155
    if item.status_description:
155
        ds_item.status_description = item.status_description
156
        ds_item.status_description = item.status_description
-
 
157
    """
156
    
158
    
157
    if item.startDate:
159
    if item.startDate:
158
        ds_item.startDate = to_py_date(item.startDate)
160
        ds_item.startDate = to_py_date(item.startDate)
159
    if item.retireDate:
161
    if item.retireDate:
160
        ds_item.retireDate = to_py_date(item.retireDate)
162
        ds_item.retireDate = to_py_date(item.retireDate)
Line 162... Line 164...
162
    if item.featureId:
164
    if item.featureId:
163
        ds_item.feature_id = item.featureId
165
        ds_item.feature_id = item.featureId
164
    if item.featureDescription:
166
    if item.featureDescription:
165
        ds_item.feature_description = item.featureDescription
167
        ds_item.feature_description = item.featureDescription
166
    
168
    
167
    if item.bestDealText:
-
 
168
        ds_item.bestDealText = item.bestDealText
169
    ds_item.bestDealText = item.bestDealText
169
    if item.bestDealValue:
-
 
170
        ds_item.bestDealValue = item.bestDealValue
170
    ds_item.bestDealValue = item.bestDealValue
171
    
-
 
172
    ds_item.bestSellingRank = item.bestSellingRank
171
    ds_item.bestSellingRank = item.bestSellingRank
173
    ds_item.defaultForEntity = item.defaultForEntity
172
    ds_item.defaultForEntity = item.defaultForEntity
174
    
-
 
175
    ds_item.updated_on = datetime.datetime.now()
173
    ds_item.updated_on = datetime.datetime.now()
176
    
174
    
177
    session.commit();
175
    session.commit();
178
    return ds_item.id
176
    return ds_item.id
179
 
177
 
Line 739... Line 737...
739
    
737
    
740
    session.commit()
738
    session.commit()
741
    return
739
    return
742
 
740
 
743
def validate_item_prices(item):
741
def validate_item_prices(item):
744
    if item.mrp != "" and item.sellingPrice != "" and item.mrp < item.sellingPrice:
742
    if item.mrp == None or item.sellingPrice == None or item.mrp == "" or item.sellingPrice == "":
-
 
743
        return
-
 
744
    if item.mrp < item.sellingPrice:
745
        print "[BAD MRP and SP:] for {0} {1} {2} {3}. MRP={4}, SP={5}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(item.mrp), str(item.sellingPrice))
745
        print "[BAD MRP and SP:] for {0} {1} {2} {3}. MRP={4}, SP={5}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(item.mrp), str(item.sellingPrice))
746
        raise InventoryServiceException(101, "[BAD MRP and SP:] for {0} {1} {2} {3}. MRP={4}, SP={5}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(item.mrp), str(item.sellingPrice)))
746
        raise InventoryServiceException(101, "[BAD MRP and SP:] for {0} {1} {2} {3}. MRP={4}, SP={5}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(item.mrp), str(item.sellingPrice)))
747
    return
747
    return
748
    
748
    
749
def validate_vendor_prices(item, vendorPrices):
749
def validate_vendor_prices(item, vendorPrices):
750
    if item.mrp != "" and vendorPrices.mop != "" and item.mrp <  vendorPrices.mop:
750
    if item.mrp != None and item.mrp != "" and vendorPrices.mop != "" and item.mrp <  vendorPrices.mop:
751
        print "[BAD MRP and MOP:] for {0} {1} {2} {3}. MRP={4}. MOP={5}, Vendor={6}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(item.mrp), str(vendorPrices.mop), str(vendorPrices.vendorId))
751
        print "[BAD MRP and MOP:] for {0} {1} {2} {3}. MRP={4}. MOP={5}, Vendor={6}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(item.mrp), str(vendorPrices.mop), str(vendorPrices.vendorId))
752
        raise InventoryServiceException(101, "[BAD MRP and MOP:] for {0} {1} {2} {3}. MRP={4}. MOP={5}, Vendor={6}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(item.mrp), str(vendorPrices.mop), str(vendorPrices.vendorId)))
752
        raise InventoryServiceException(101, "[BAD MRP and MOP:] for {0} {1} {2} {3}. MRP={4}. MOP={5}, Vendor={6}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(item.mrp), str(vendorPrices.mop), str(vendorPrices.vendorId)))
753
    if vendorPrices.mop != "" and vendorPrices.transferPrice != "" and vendorPrices.transferPrice > vendorPrices.mop:
753
    if vendorPrices.mop != "" and vendorPrices.transferPrice != "" and vendorPrices.transferPrice > vendorPrices.mop:
754
        print "[BAD MOP and TP:] for {0} {1} {2} {3}. TP={4}. MOP={5}, Vendor={6}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(vendorPrices.transferPrice), str(vendorPrices.mop), str(vendorPrices.vendorId))
754
        print "[BAD MOP and TP:] for {0} {1} {2} {3}. TP={4}. MOP={5}, Vendor={6}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(vendorPrices.transferPrice), str(vendorPrices.mop), str(vendorPrices.vendorId))
755
        raise InventoryServiceException(101, "[BAD MOP and TP:] for {0} {1} {2} {3}. TP={4}. MOP={5}, Vendor={6}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(vendorPrices.transferPrice), str(vendorPrices.mop), str(vendorPrices.vendorId)))
755
        raise InventoryServiceException(101, "[BAD MOP and TP:] for {0} {1} {2} {3}. TP={4}. MOP={5}, Vendor={6}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(vendorPrices.transferPrice), str(vendorPrices.mop), str(vendorPrices.vendorId)))
Line 757... Line 757...
757
 
757
 
758
def get_all_vendors():
758
def get_all_vendors():
759
    return Vendor.query.all()
759
    return Vendor.query.all()
760
 
760
 
761
def check_similar_item(product_group, brand, model_number, color):
761
def check_similar_item(product_group, brand, model_number, color):
-
 
762
    query = Item.query
-
 
763
    if product_group:
762
    item = Item.query.filter_by(product_group=product_group,brand=brand,model_number=model_number,color=color).first()
764
        query = query.filter_by(product_group=product_group)
-
 
765
    if brand:
-
 
766
        query = query.filter_by(brand=brand)
-
 
767
    if model_number:
-
 
768
        query = query.filter_by(model_number=model_number)
-
 
769
    if color:
-
 
770
        query = query.filter_by(color=color)
-
 
771
    item = query.first()
763
    if item is None:
772
    if item is None:
764
        return 0
773
        return 0
765
    else:
774
    else:
766
        return item.id
775
        return item.id
767
 
776