| Line 323... |
Line 323... |
| 323 |
"""
|
323 |
"""
|
| 324 |
try:
|
324 |
try:
|
| 325 |
lineitems = LineItem.query.filter_by(purchaseOrder_id = purchaseOrderId, itemId = itemId).all()
|
325 |
lineitems = LineItem.query.filter_by(purchaseOrder_id = purchaseOrderId, itemId = itemId).all()
|
| 326 |
if lineitems:
|
326 |
if lineitems:
|
| 327 |
if lineitems[0].unfulfilledQuantity < quantity:
|
327 |
if lineitems[0].unfulfilledQuantity < quantity:
|
| 328 |
raise PurchaseServiceException(101, 'Can fulfill only ' + str(lineitems[0].unfulfilledQuantity) + 'quantity')
|
328 |
raise PurchaseServiceException(101, 'Can fulfill only ' + str(lineitems[0].unfulfilledQuantity) + ' quantity')
|
| 329 |
else:
|
329 |
else:
|
| 330 |
lineitems[0].unfulfilledQuantity -= quantity
|
330 |
lineitems[0].unfulfilledQuantity = lineitems[0].unfulfilledQuantity - quantity
|
| 331 |
if not lineitems[0].unfulfilledQuantity:
|
331 |
if not lineitems[0].unfulfilledQuantity:
|
| 332 |
lineitems[0].fulfilled = 1
|
332 |
lineitems[0].fulfilled = 1
|
| - |
|
333 |
session.commit()
|
| 333 |
if not LineItem.query.filter_by(purchaseOrder_id = purchaseOrderId, fulfilled = 0).all():
|
334 |
if not LineItem.query.filter_by(purchaseOrder_id = purchaseOrderId, fulfilled = 0).all():
|
| 334 |
purchaseOrder = self.getPurchaseOrder(purchaseOrderId)
|
335 |
purchaseOrder = PurchaseOrder.get_by(id=purchaseOrderId)
|
| 335 |
purchaseOrder.status = POStatus.CLOSED
|
336 |
purchaseOrder.status = POStatus.CLOSED
|
| 336 |
session.commit()
|
337 |
session.commit()
|
| 337 |
return
|
338 |
return
|
| 338 |
|
339 |
|
| 339 |
raise PurchaseServiceException(101, 'No lineitem found with this itemId: ' + str(itemId) + ' in PO Id: ' + str(purchaseOrderId) )
|
340 |
raise PurchaseServiceException(101, 'No lineitem found with this itemId: ' + str(itemId) + ' in PO Id: ' + str(purchaseOrderId) )
|