| Line 519... |
Line 519... |
| 519 |
billing_warehouse_retid = None
|
519 |
billing_warehouse_retid = None
|
| 520 |
|
520 |
|
| 521 |
if not ignoreAvailability:
|
521 |
if not ignoreAvailability:
|
| 522 |
for entry in CurrentInventorySnapshot.query.filter_by(item_id = item_id).all():
|
522 |
for entry in CurrentInventorySnapshot.query.filter_by(item_id = item_id).all():
|
| 523 |
#if entry.availability > entry.reserved:
|
523 |
#if entry.availability > entry.reserved:
|
| 524 |
warehousesAvailability[entry.warehouse_id] = entry
|
524 |
warehousesAvailability[entry.warehouse_id] = [entry.availability, entry.reserved]
|
| 525 |
|
525 |
|
| 526 |
if len(ignoredWhs) > 0:
|
526 |
if len(ignoredWhs) > 0:
|
| 527 |
for whid in ignoredWhs:
|
527 |
for whid in ignoredWhs:
|
| 528 |
if warehousesAvailability.has_key(whid):
|
528 |
if warehousesAvailability.has_key(whid):
|
| 529 |
warehousesAvailability[whid].availability = 0
|
529 |
warehousesAvailability[whid][0] = 0
|
| 530 |
|
530 |
|
| 531 |
for warehouse in warehouses.values():
|
531 |
for warehouse in warehouses.values():
|
| 532 |
if not ignoreAvailability:
|
532 |
if not ignoreAvailability:
|
| 533 |
#TODO Mistake no entry for this warehouse.id in warehouseswithAvailab
|
533 |
#TODO Mistake no entry for this warehouse.id in warehouseswithAvailab
|
| 534 |
if warehouse.id not in warehousesAvailability:
|
534 |
if warehouse.id not in warehousesAvailability:
|
| Line 537... |
Line 537... |
| 537 |
if warehouse.billingWarehouseId in availabilityForBillingWarehouses:
|
537 |
if warehouse.billingWarehouseId in availabilityForBillingWarehouses:
|
| 538 |
if warehouse.billingWarehouseId is not None or warehouse.billingWarehouseId != 0:
|
538 |
if warehouse.billingWarehouseId is not None or warehouse.billingWarehouseId != 0:
|
| 539 |
availabilityForBillingWarehouses[warehouse.billingWarehouseId] = availabilityForBillingWarehouses[warehouse.billingWarehouseId] + entry.availability - entry.reserved
|
539 |
availabilityForBillingWarehouses[warehouse.billingWarehouseId] = availabilityForBillingWarehouses[warehouse.billingWarehouseId] + entry.availability - entry.reserved
|
| 540 |
else:
|
540 |
else:
|
| 541 |
if warehouse.billingWarehouseId is not None or warehouse.billingWarehouseId != 0:
|
541 |
if warehouse.billingWarehouseId is not None or warehouse.billingWarehouseId != 0:
|
| 542 |
availabilityForBillingWarehouses[warehouse.billingWarehouseId] = entry.availability - entry.reserved
|
542 |
availabilityForBillingWarehouses[warehouse.billingWarehouseId] = entry[0] - entry[1]
|
| 543 |
if entry.availability <= entry.reserved:
|
543 |
if entry[0] <= entry[1]:
|
| 544 |
continue
|
544 |
continue
|
| 545 |
total_availability += entry.availability - entry.reserved
|
545 |
total_availability += entry[0] - entry[1]
|
| 546 |
|
546 |
|
| 547 |
# Missing transfer price cases should not impact warehouse assignment
|
547 |
# Missing transfer price cases should not impact warehouse assignment
|
| 548 |
transferPrice = None
|
548 |
transferPrice = None
|
| 549 |
if item_pricing.has_key(warehouse.vendor_id):
|
549 |
if item_pricing.has_key(warehouse.vendor_id):
|
| 550 |
transferPrice = item_pricing[warehouse.vendor_id].transfer_price
|
550 |
transferPrice = item_pricing[warehouse.vendor_id].transfer_price
|