Add API view for marking "receiving complete" for receiving batch
This commit is contained in:
parent
675660e130
commit
8cbabfbb95
|
@ -95,6 +95,27 @@ class ReceivingBatchViews(APIBatchView):
|
|||
def get(self):
|
||||
return self._get()
|
||||
|
||||
def mark_receiving_complete(self):
|
||||
"""
|
||||
Mark the given batch as "receiving complete".
|
||||
"""
|
||||
batch = self.get_object()
|
||||
|
||||
if batch.executed:
|
||||
return {'error': "Batch {} has already been executed: {}".format(
|
||||
batch.id_str, batch.description)}
|
||||
|
||||
if batch.complete:
|
||||
return {'error': "Batch {} is already marked complete: {}".format(
|
||||
batch.id_str, batch.description)}
|
||||
|
||||
if batch.receiving_complete:
|
||||
return {'error': "Receiving is already complete for batch {}: {}".format(
|
||||
batch.id_str, batch.description)}
|
||||
|
||||
batch.receiving_complete = True
|
||||
return self._get(obj=batch)
|
||||
|
||||
def eligible_purchases(self):
|
||||
uuid = self.request.params.get('vendor_uuid')
|
||||
vendor = self.Session.query(model.Vendor).get(uuid) if uuid else None
|
||||
|
@ -135,6 +156,13 @@ class ReceivingBatchViews(APIBatchView):
|
|||
route_prefix = cls.get_route_prefix()
|
||||
permission_prefix = cls.get_permission_prefix()
|
||||
collection_url_prefix = cls.get_collection_url_prefix()
|
||||
object_url_prefix = cls.get_object_url_prefix()
|
||||
|
||||
# mark receiving complete
|
||||
config.add_route('{}.mark_receiving_complete'.format(route_prefix), '{}/{{uuid}}/mark-receiving-complete'.format(object_url_prefix))
|
||||
config.add_view(cls, attr='mark_receiving_complete', route_name='{}.mark_receiving_complete'.format(route_prefix),
|
||||
permission='{}.edit'.format(permission_prefix),
|
||||
renderer='json')
|
||||
|
||||
# eligible purchases
|
||||
config.add_route('{}.eligible_purchases'.format(route_prefix), '{}/eligible-purchases'.format(collection_url_prefix),
|
||||
|
|
Loading…
Reference in a new issue