Skip to content

Commit

Permalink
Merge branch 'master' of github.com:openprocurement/openprocurement.c…
Browse files Browse the repository at this point in the history
…ontracting.api
  • Loading branch information
vmaksymiv committed May 31, 2016
2 parents 907e61e + 7c232b2 commit dd8a9e3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 9 additions & 2 deletions openprocurement/contracting/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
contract_edit_role = (whitelist(
'title', 'title_en', 'title_ru', 'description', 'description_en',
'description_ru', 'status', 'period', 'value' , 'items', 'amountPaid',
'terminationDetails'
'terminationDetails', 'contract_amountPaid',
))

contract_view_role = (whitelist(
'id', 'awardID', 'contractID', 'dateModified', 'contractNumber', 'title',
'title_en', 'title_ru', 'description', 'description_en', 'description_ru',
'status', 'period', 'value', 'dateSigned', 'documents', 'items',
'suppliers', 'procuringEntity', 'owner', 'mode', 'tender_id', 'changes',
'amountPaid', 'terminationDetails'
'amountPaid', 'terminationDetails', 'contract_amountPaid',
))

contract_administrator_role = (Administrator_role + whitelist('suppliers',))
Expand Down Expand Up @@ -197,6 +197,13 @@ def doc_id(self):
"""A property that is serialized by schematics exports."""
return self._id

@serializable(serialized_name='amountPaid', serialize_when_none=False, type=ModelType(Value))
def contract_amountPaid(self):
if self.amountPaid:
return Value(dict(amount=self.amountPaid.amount,
currency=self.value.currency,
valueAddedTaxIncluded=self.value.valueAddedTaxIncluded))

def validate_awardID(self, data, awardID):
# awardID is not validatable without tender data
pass
Expand Down
7 changes: 7 additions & 0 deletions openprocurement/contracting/api/tests/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,13 @@ def test_patch_tender_contract(self):
# response = self.app.patch_json('/contracts/{}?acc_token={}'.format(contract['id'], token),
# {"data": {"value": {"valueAddedTaxIncluded": False}}})

response = self.app.patch_json('/contracts/{}?acc_token={}'.format(self.contract['id'], token),
{"data": {"amountPaid": {"amount": 900, "currency": "USD", "valueAddedTaxIncluded": False}}})
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.json['data']['amountPaid']['amount'], 900)
self.assertEqual(response.json['data']['amountPaid']['currency'], "UAH")
self.assertEqual(response.json['data']['amountPaid']['valueAddedTaxIncluded'], True)

response = self.app.patch_json('/contracts/{}?acc_token={}'.format(self.contract['id'], token),
{"data": {"value": {"amount": 235}}})
self.assertEqual(response.status, '200 OK')
Expand Down

0 comments on commit dd8a9e3

Please sign in to comment.