Subversion Repositories SmartDukaan

Rev

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

Rev 6751 Rev 6778
Line 542... Line 542...
542
            total_availability += entry[0] - entry[1]
542
            total_availability += entry[0] - entry[1]
543
 
543
 
544
        # Missing transfer price cases should not impact warehouse assignment
544
        # Missing transfer price cases should not impact warehouse assignment
545
        transferPrice = None
545
        transferPrice = None
546
        if item_pricing.has_key(warehouse.vendor_id):
546
        if item_pricing.has_key(warehouse.vendor_id):
547
            transferPrice = item_pricing[warehouse.vendor_id].transfer_price
547
            transferPrice = item_pricing[warehouse.vendor_id].nlc
548
        if minTransferPrice is None or (transferPrice and minTransferPrice > transferPrice):
548
        if minTransferPrice is None or (transferPrice and minTransferPrice > transferPrice):
549
            warehouse_retid = warehouse.id
549
            warehouse_retid = warehouse.id
550
            billing_warehouse_retid = warehouse.billingWarehouseId
550
            billing_warehouse_retid = warehouse.billingWarehouseId
551
            minTransferPrice = transferPrice
551
            minTransferPrice = transferPrice
552
    
552
    
Line 639... Line 639...
639
    if vendor id is -1 then we calculate an average transfer price to be populated
639
    if vendor id is -1 then we calculate an average transfer price to be populated
640
    at the time of order creation. This will be later updated with actual transfer price
640
    at the time of order creation. This will be later updated with actual transfer price
641
    at the time of billing.
641
    at the time of billing.
642
    '''
642
    '''
643
    if(vendorId == -1):
643
    if(vendorId == -1):
644
        total = 0
644
        tp_total = 0
-
 
645
        nlc_total = 0
645
        try:
646
        try:
646
            item_pricings = []
647
            item_pricings = []
647
            item = __get_item_from_master(item_id)
648
            item = __get_item_from_master(item_id)
648
            if item.preferredVendor is not None:
649
            if item.preferredVendor is not None:
649
                item_pricing = VendorItemPricing.query.filter_by(item_id=item_id, vendor_id=item.preferredVendor).first()
650
                item_pricing = VendorItemPricing.query.filter_by(item_id=item_id, vendor_id=item.preferredVendor).first()
Line 651... Line 652...
651
                    item_pricings.append(item_pricing)                    
652
                    item_pricings.append(item_pricing)                    
652
            else :
653
            else :
653
                item_pricings = VendorItemPricing.query.filter_by(item_id=item_id).all()
654
                item_pricings = VendorItemPricing.query.filter_by(item_id=item_id).all()
654
            if item_pricings:
655
            if item_pricings:
655
                for item_pricing in item_pricings:
656
                for item_pricing in item_pricings:
656
                    total += item_pricing.transfer_price
657
                    tp_total += item_pricing.transfer_price
-
 
658
                    nlc_total += item_pricing.nlc
657
                avg = total / len(item_pricings)
659
                tp_avg = tp_total / len(item_pricings)
-
 
660
                nlc_avg = nlc_total / len(item_pricings)
658
                item_pricing.transfer_price = avg
661
                item_pricing.transfer_price = tp_avg
-
 
662
                item_pricing.nlc = nlc_avg
659
            else:
663
            else:
660
                item_pricing = VendorItemPricing()
664
                item_pricing = VendorItemPricing()
661
                item_pricing.transfer_price = item.sellingPrice
665
                item_pricing.transfer_price = item.sellingPrice
-
 
666
                item_pricing.nlc = item.sellingPrice
662
                vendor = Vendor()
667
                vendor = Vendor()
663
                vendor.id = vendorId
668
                vendor.id = vendorId
664
                item_pricing.vendor = vendor
669
                item_pricing.vendor = vendor
665
                item_pricing.item_id = item_id
670
                item_pricing.item_id = item_id
666
                
671