Module: UU::Finman::FinancialTransaction::CreditNote
- Extended by:
- CreditNote
- Included in:
- CreditNote
- Defined in:
- lib/uu/finman/credit_note.rb
Overview
Module of Credit Note
Constant Summary
- PATH =
Service path
'uu/finman/financialtransaction/FinancialTransaction'
Instance Method Summary (collapse)
-
- (UU::OS::UESURI) create(control_business_case_uri, credit_note)
Creates a new Credit Note.
-
- (CreditNoteAttributes) get_attributes(credit_note_uri)
Obtains Credit note attributes from service and returns them.
-
- (UU::OS::UESURI) set_attributes(credit_note_uri, credit_note_set_attributes)
Sets attributes of Credit note.
Instance Method Details
- (UU::OS::UESURI) create(control_business_case_uri, credit_note)
Creates a new Credit Note. The command creates a new Credit Note for specified business case with passed DTO parameters.
Required attributes:
control_business_case_uri, counterparty_business_case_uri, name, amount_without_vat, vat_rate or amount_with_vat, financial_transaction_type, is_credit_note_outgoing,
realization_probability, expected_pay_date, due_date, protocol_date, transaction_currency, (client_account_number and client_side_currency) or client_account_uri,
(supplier_account_number and supplier_side_currency) or supplier_account_uri, vat_date
Exactly one of attributes supplier_account_number
and
supplier_account_uri
has to be set. Exactly one of attributes
client_account_number
and client_account_uri
has
to be set. Exactly one of attributes vat_rate
and
amount_with_vat
has to be set. Both attributes can be set
simultaneously only if following statement is true :
amount_without_vat
* vat_rate
=
amount_with_rate
. Attribute client_side_currency
and supplier_side_currency
must be set if respective account
is set by number. Attribute transaction_currency
must be set
and must be one from client_side_currency
and
supplier_side_currency
, with exception if both
client_side_currency
and supplier_side_currency
are equal. Attribute related_links
must be valid JSON string
with specific array structure with attributes UESURI of financial
transaction and label. Both attributes are required. See example.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/uu/finman/credit_note.rb', line 84 def create(control_business_case_uri, credit_note) svc = UU::OS::REST::RemoteClient.new(CreditNote) credit_note_dto = UU::Finman::FinancialTransaction::CreditNoteCreate.new(credit_note) # adjust given payment dto to match expected format of financial transaction command transaction = transform_cnote_create_to_transaction_dto(credit_note_dto) financial_transaction_create = transaction.to_json UU::OS::QoS::QoSHandler.auto_retry do res = svc.post('create', control_business_case_uri, financial_transaction_create) if res.nil? return res else return UU::OS::UESURI.new(res) end end end |
- (CreditNoteAttributes) get_attributes(credit_note_uri)
Obtains Credit note attributes from service and returns them
114 115 116 117 118 119 120 121 122 |
# File 'lib/uu/finman/credit_note.rb', line 114 def get_attributes(credit_note_uri) svc = UU::OS::REST::RemoteClient.new(CreditNote) UU::OS::QoS::QoSHandler.auto_retry do attrs_string = svc.get('getAttributes', credit_note_uri) attrs = JSON.parse(attrs_string, :symbolize_names => true) attrs = remove_invalid_keys(attrs) return UU::Finman::FinancialTransaction::CreditNoteAttributes.new(attrs) end end |
- (UU::OS::UESURI) set_attributes(credit_note_uri, credit_note_set_attributes)
Sets attributes of Credit note.
139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/uu/finman/credit_note.rb', line 139 def set_attributes(credit_note_uri, credit_note_set_attributes) svc = UU::OS::REST::RemoteClient.new(CreditNote) credit_note_dto = UU::Finman::FinancialTransaction::CreditNoteSetAttributes.new(credit_note_set_attributes) # adjust given payment dto to match expected format of financial transaction command transaction = transform_cnote_modify_to_transaction_dto(credit_note_dto) financial_transaction_dto = transaction.to_json UU::OS::QoS::QoSHandler.auto_retry do res = svc.post('setAttributes', credit_note_uri, financial_transaction_dto) return UU::OS::UESURI.new(res) end end |