Subversion Repositories SmartDukaan

Rev

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

Rev 4295 Rev 4307
Line 821... Line 821...
821
 
821
 
822
def get_item_pricing(item_id, vendorId):
822
def get_item_pricing(item_id, vendorId):
823
    item = Item.query.filter_by(id=item_id).first()
823
    item = Item.query.filter_by(id=item_id).first()
824
    if item is None:
824
    if item is None:
825
        raise InventoryServiceException(101, "Bad Item")
825
        raise InventoryServiceException(101, "Bad Item")
-
 
826
    '''
-
 
827
    if vendor id is -1 then we calculate an average transfer price to be populated
-
 
828
    at the time of order creation. This will be later updated with actual transfer price
-
 
829
    at the time of billing.
826
    
830
    '''
-
 
831
    if(vendorId == -1):
-
 
832
        try:
-
 
833
            item_pricings = VendorItemPricing.query.filter_by(item=item).all()
-
 
834
            if (item_pricings.length != 0):
-
 
835
                for item_pricing in item_pricings:
-
 
836
                    total =+ item_pricing
-
 
837
                avg = total / (item_pricings.length)
-
 
838
            else:
-
 
839
                avg = item.sellingPrice
-
 
840
            return avg
-
 
841
        except:
-
 
842
            raise InventoryServiceException(101, "Item pricing not found ")
827
    vendor = Vendor.get_by(id=vendorId)    
843
    vendor = Vendor.get_by(id=vendorId)    
828
    try:
844
    try:
829
        item_pricing = VendorItemPricing.query.filter_by(vendor=vendor, item=item).one()
845
        item_pricing = VendorItemPricing.query.filter_by(vendor=vendor, item=item).one()
830
        return item_pricing
846
        return item_pricing
831
    except MultipleResultsFound:
847
    except MultipleResultsFound: