| Line 606... |
Line 606... |
| 606 |
warehouse = warehouses[warehouse_retid]
|
606 |
warehouse = warehouses[warehouse_retid]
|
| 607 |
billingWarehouseId = warehouse.billingWarehouseId
|
607 |
billingWarehouseId = warehouse.billingWarehouseId
|
| 608 |
|
608 |
|
| 609 |
# Fetching billing warehouse of a Good billable warehouse corresponding to the virtual one
|
609 |
# Fetching billing warehouse of a Good billable warehouse corresponding to the virtual one
|
| 610 |
if not warehouse.billingWarehouseId:
|
610 |
if not warehouse.billingWarehouseId:
|
| 611 |
for w in Warehouse.query.filter_by(vendor_id = warehouse.vendor_id, inventoryType = InventoryType._VALUES_TO_NAMES[InventoryType.GOOD]).all():
|
611 |
for w in Warehouse.query.filter_by(vendor_id = warehouse.vendor_id, inventoryType = InventoryType._VALUES_TO_NAMES[InventoryType.GOOD], logisticsLocation=w.logisticsLocation).all():
|
| 612 |
if w.billingWarehouseId:
|
612 |
if w.billingWarehouseId:
|
| 613 |
billingWarehouseId = w.billingWarehouseId
|
613 |
billingWarehouseId = w.billingWarehouseId
|
| 614 |
break
|
614 |
break
|
| 615 |
|
615 |
|
| 616 |
expectedDelay = item.expectedDelay
|
616 |
expectedDelay = item.expectedDelay
|
| Line 631... |
Line 631... |
| 631 |
|
631 |
|
| 632 |
if warehouse.warehouseType == WarehouseType.THIRD_PARTY:
|
632 |
if warehouse.warehouseType == WarehouseType.THIRD_PARTY:
|
| 633 |
expectedDelay = expectedDelay + __get_vendor_holiday_delay(warehouse.vendor_id, expectedDelay)
|
633 |
expectedDelay = expectedDelay + __get_vendor_holiday_delay(warehouse.vendor_id, expectedDelay)
|
| 634 |
|
634 |
|
| 635 |
total_availability = 0
|
635 |
total_availability = 0
|
| 636 |
for entry in CurrentInventorySnapshot.query.join(CurrentInventorySnapshot.warehouse).filter_by(item_id = item_id).all():
|
636 |
for entry in CurrentInventorySnapshot.query.filter_by(item_id = item_id).all():
|
| 637 |
if entry.warehouse_id not in ignoredWhs:
|
637 |
if entry.warehouse_id not in ignoredWhs:
|
| 638 |
if entry.warehouse_id not in ourGoodWarehouses and entry.warehouse_id not in ourGoodWarehouses:
|
638 |
if entry.warehouse_id not in ourGoodWarehouses and entry.warehouse_id not in thirdpartyWarehouses:
|
| 639 |
continue
|
639 |
continue
|
| 640 |
if entry.warehouse_id in ourGoodWarehouses and ourGoodWarehouses[entry.warehouse_id].billingWarehouseId == billingWarehouseId:
|
640 |
if entry.warehouse_id in ourGoodWarehouses and ourGoodWarehouses[entry.warehouse_id].billingWarehouseId == billingWarehouseId:
|
| 641 |
total_availability += entry.availability - entry.reserved - entry.held
|
641 |
total_availability += entry.availability - entry.reserved - entry.held
|
| 642 |
elif entry.warehouse_id in thirdpartyWarehouses:
|
642 |
elif entry.warehouse_id in thirdpartyWarehouses:
|
| 643 |
vendorId = thirdpartyWarehouses[entry.warehouse_id].vendor_id
|
643 |
vendorId = thirdpartyWarehouses[entry.warehouse_id].vendor_id
|
| 644 |
for goodWarehouse in ourGoodWarehouses.values():
|
644 |
for goodWarehouse in ourGoodWarehouses.values():
|
| 645 |
if goodWarehouse.vendor_id==vendorId and goodWarehouse.billingWarehouseId == billingWarehouseId:
|
645 |
if goodWarehouse.vendor_id==vendorId and goodWarehouse.billingWarehouseId == billingWarehouseId and warehouse.logisticsLocation==goodWarehouse.logisticsLocation:
|
| 646 |
total_availability += entry.availability - entry.reserved - entry.held
|
646 |
total_availability += entry.availability - entry.reserved - entry.held
|
| 647 |
break
|
647 |
break
|
| 648 |
|
648 |
|
| 649 |
item_availability_cache = ItemAvailabilityCache.get_by(itemId=item_id, sourceId=source_id)
|
649 |
item_availability_cache = ItemAvailabilityCache.get_by(itemId=item_id, sourceId=source_id)
|
| 650 |
if item_availability_cache is None:
|
650 |
if item_availability_cache is None:
|
| Line 654... |
Line 654... |
| 654 |
item_availability_cache.warehouseId = int(warehouse_retid)
|
654 |
item_availability_cache.warehouseId = int(warehouse_retid)
|
| 655 |
item_availability_cache.expectedDelay = expectedDelay
|
655 |
item_availability_cache.expectedDelay = expectedDelay
|
| 656 |
item_availability_cache.billingWarehouseId = billingWarehouseId
|
656 |
item_availability_cache.billingWarehouseId = billingWarehouseId
|
| 657 |
item_availability_cache.sellingPrice = item.sellingPrice
|
657 |
item_availability_cache.sellingPrice = item.sellingPrice
|
| 658 |
item_availability_cache.totalAvailability = total_availability
|
658 |
item_availability_cache.totalAvailability = total_availability
|
| - |
|
659 |
#item_availability_cache.location = warehouse.logisticsLocation
|
| 659 |
item_availability_cache.weight = 1000*item.weight if item.weight else 300
|
660 |
item_availability_cache.weight = 1000*item.weight if item.weight else 300
|
| 660 |
session.commit()
|
661 |
session.commit()
|
| 661 |
|
662 |
|
| 662 |
def __get_warehouse_with_min_transfer_price(warehouses, ignoredWhs, item_id, item_pricing, ignoreAvailability):
|
663 |
def __get_warehouse_with_min_transfer_price(warehouses, ignoredWhs, item_id, item_pricing, ignoreAvailability):
|
| 663 |
warehouse_retid = -1
|
664 |
warehouse_retid = -1
|