Skip to main content

Contract Service

If you need more information on contracts, please, see Contracts.

List of all options:

  • Contracts management
  • Contract's Parties management
  • Party's Signers management
  • Party's Contacts management
  • Appendix management
  • Contract body's file management
  • Appendix file management

Contract Status

  • DRAFT - new contract has been created.
  • SIGNABLE - contract has been finalized.  NB! Even if the allowed action *modifyFinalised *is True, after contract is finalized user can modify only notes.
  • SIGNED - every signer has signed.
  • EXPIRED - contract passes expiration dates.
  • TERMINATED - contract termination conditions are passed
  • ARCHIVED - expired or terminated contract will eventually be archived

Contract Actions

  • Finalize - to finalize contract following conditions should be fulfilled:
    • current user must have read access to contract
    • current user must be owner of contract
    • contract's state must be DRAFT
    • contract must have an owner
    • contract must have at least one party
    • each party must have at least one signer
  • Sign
  • Terminate

Contracts management

from trivoreid.models.contract import Contract, TerminationMode
from trivoreid.utils.criteria import Filter

# Get list of all contracts
page = api.contract_service.get_all()

# Apply filter
filt = Filter(Filter.EQUAL, 'code', 'examplecode')
page = api.contract_service.get_all(filt)

# Add new Contract
contract = Contract()

contract.termOfNoticeDays = 'Example Term of Notice'
contract.terminationMode = TerminationMode.AFTER_ALL_PARTIES_TERMINATE
contract.title = 'Example Title'
contract.version = '1.0.0'
contract.validFrom = '2018-04-26T08:38:02.730Z'
contract.validTo = '2022-04-26T08:38:02.730Z'
contract.code = 'examplecode'
contract.links = ['example1', 'example2']
contract.contractRefs = ['ref1', 'ref2']
contract.notes = 'Example contract notes.'

contract.financialTerms.billingTerms = 'Example Billing Terms.'
contract.financialTerms.paymentTerms = 'Example Payment Terms.'

# This method returns new contract object with the generated ID
contract = api.contract_service.create(contract)
contractId = contract.id

# Get one, Update and Delete
contract.scope = 'Modified scope'
contract.title = 'Modified Title'

api.contract_service.update(contract)

contract = api.contract_service.get(contractId)

api.contract_service.delete(contractId)

# Get all allowed actions, finalise, sign and terminate the contract

# returns dictionary with all actions
actions = api.contract_service.get_allowed_actions(contractId)

contract = api.contract_service.finalise(contractId)

contract = api.contract_service.sign(contractId)

contract = api.contract_service.terminate(contractId, reason='Termination Reason')

Contract's Party management

from trivoreid.models.contract import Party

# Get list of all contract's parties.
# Instead of Page returns list of parties. No pagination or filter can be applied.
parties = api.contract_service.get_all_parties(contractId)

# Add new Party
party = Party()

party.name = 'Example Name'
party.address = 'Example Address'

# This method returns new party object with the generated ID
party = api.contract_service.create_party(contractId, party)
partyId = party.id

# Get one, Update and Delete
party.mobile = '+358401234567'
party.email = '[email protected]'

api.contract_service.update_party(contractId, party)

party = api.contract_service.get_party(contractId, partyId)

api.contract_service.delete_party(contractId, partyId)

Party's Signer management

from trivoreid.models.contract import Signer

# Get list of all contract's signers.
# Instead of Page returns list of signers. No pagination or filter can be applied.
signers = api.contract_service.get_all_party_signers(contractId, partyId)

# Add new Signer
signer = Signer()

signer.name = 'Example Name'
signer.address = 'Example Address'

# This method returns new signer object with the generated ID
signer = api.contract_service.create_party_signer(contractId, partyId, signer)
signerId = signer.id

# Get one, Update and Delete
signer.mobile = '+358401234567'
signer.email = '[email protected]'

api.contract_service.update_party_signer(contractId, partyId, signer)

signer = api.contract_service.get_party_signer(contractId, partyId, signerId)

api.contract_service.delete_party_signer(contractId, partyId, signerId)

Party's Contact management

from trivoreid.models.contract import PartyContact

# Get list of all contract's contacts.
# Instead of Page returns list of contacts. No pagination or filter can be applied.
contacts = api.contract_service.get_all_party_contacts(contractId, partyId)

# Add new Contact
contact = PartyContact()

contact.name = 'Example Name'
contact.address = 'Example Address'

# This method returns new contact object with the generated ID
contact = api.contract_service.create_party_contact(contractId, partyId, contact)
contactId = contact.id

# Get one, Update and Delete
contact.mobile = '+358401234567'
contact.email = '[email protected]'

api.contract_service.update_party_contact(contractId, partyId, contact)

contact = api.contract_service.get_party_contact(contractId, partyId, contactId)

api.contract_service.delete_party_contact(contractId, partyId, contactId)

Contract's Appendix management

from trivoreid.models.contract import Appendix

# Get list of all contract's appendices.
# Instead of Page returns list of appendices. No pagination or filter can be applied.
appendices = api.contract_service.get_all_appendices(contractId)

# Add new Appendix
appendix = Appendix()

appendix.text = 'Example text.'
appendix.title = 'Example Title'

# This method returns new appendix object with the generated ID
appendix = api.contract_service.create_appendix(contractId, appendix)
appendixId = appendix.id

# Get one, Update and Delete
appendix.text = 'Modified appendix text.'

api.contract_service.update_appendix(contractId, appendix)

appendix = api.contract_service.get_appendix(contractId, appendixId)

api.contract_service.delete_appendix(contractId, appendixId)

# Change appendix order
appendices = api.contract_service.get_all_appendices(contractId)
ids = []
for a in appendices:
ids.append(a.id)
# Reversing the order of appendices IDs
ids_reversed = ids[::-1]

api.contract_service.change_appendix_order(contractId, ids_reversed)

Content and appendix file management

# Safe file to the contract body
file = open('example.pdf', 'rb')
file_bytes = file.read()

api.contract_service.upload_body_file(contractId, file_bytes)

# Get the file from the contract body
result = api.contract_service.get_body_file(contractId)

with open('result.pdf', 'wb') as out_file:
out_file.write(result)

# Safe file to appendix
api.contract_service.upload_appendix_file(cId, a.id, file_bytes)

# Get the file from the appendix
result = api.contract_service.get_appendix_file(contractId, appendixId)

with open('result.pdf', 'wb') as out_file:
out_file.write(result)

# Delete
api.contract_service.delete_body_file(contractId)
api.contract_service.delete_appendix_file(contractId, appendixId)

Contract Service Models

Contract

ContractContent

FinancialTerms

Appendix

Party

Signer

PartyContact

AllowedActions