Module: UU::Finman::FinancialTransaction::Transfer

Extended by:
Transfer
Included in:
Transfer
Defined in:
lib/uu/finman/transfer.rb

Overview

Module of Transfer

Constant Summary

PATH =

Service path

'uu/finman/financialtransaction/FinancialTransaction'

Instance Method Summary (collapse)

Instance Method Details

- (UU::OS::UESURI) create(control_business_case_uri, transfer)

Creates a new Transfer. The command creates a new Transfer for specified business case

Required attributes:

control_business_case_uri, counterparty_business_case_uri, name, amount_without_vat, vat_rate or amount_with_vat, financial_transaction_type,
is_transaction_credit, realization_probability, expected_pay_date, transaction_currency, (credit_account_number and credit_side_currrency) or credit_account_uri,
(debit_account_number and debit_side_currency) or debit_account_uri

Exactly one of attributes credit_account_number and credit_account_uri has to be set.
Exactly one of attributes debit_account_number and debit_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 credit_side_currency and debit_side_currency must be set if respective account is set by number. Attribute transaction_currency must be set and must be one from credit_side_currency and debit_side_currency, with exception if both credit_side_currency and debit_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.

Examples:

# Prepare Business Case URI, which we want to use to create Transfer.
control_business_case_uri = UU::OS::UESURI.new('ues:TERRITORY:BUSINESS_CASE');

# Create Transfer
  transfer_uri = UU::Finman::FinancialTransaction::Transfer.create(control_business_case_uri,
  :name => "Transfer",
  :credit_description => "kreditní popis",
  :debit_description => "debetní popis",
  :credit_financial_category => UU::OS::UESURI.new("ues:TERRITORY:APPS.UU.FINMAN/CONFIGURATION:SYS.FIN.CONFIG/TX_TYPE/CR.TXWER"),
  :debit_financial_category =>  UU::OS::UESURI.new("ues:TERRITORY:APPS.UU.FINMAN/CONFIGURATION:SYS.FIN.CONFIG/TX_TYPE/DR.TXOTR"),
  :realization_probability => "50",
  :is_transaction_credit => true,
  :financial_transaction_type => "NONCASH",
  :vat_rate => "10",
  :original_currency => "USD",
  :Vat_date => "2014-11-03",
  :expected_pay_date => "2014-11-06",
  :counterparty_business_case_uri => UU::OS::UESURI.new("ues:TERRITORY:CP_BC"),
  :credit_account_number => "kreditní číslo učtu",
  :debit_account_number => "debetní číslo učtu",
  :contract_uri => UU::OS::UESURI.new("ues:TERRITORY:CONTRACT"),
  :is_ready_to_be_paid => true,
  :credit_side_currency => "CZK",
  :debit_side_currency => "EUR",
  :transaction_currency => "EUR",
  :related_links => "[["ues:[TERRITORY_OID]:[FIN_TR_OID]:","label 1"],["ues:[TERRITORY_OID]:[FIN_TR_OID]:","label 2"]]"
 )

Parameters:

Returns:

  • (UU::OS::UESURI)

    UESURI of the new Transfer. In case of setting dry_run parameter to true, UU::OS::UESURI::NIL_URI is returned instead.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/uu/finman/transfer.rb', line 68

def create(control_business_case_uri, transfer)
  svc = UU::OS::REST::RemoteClient.new(Transfer)
  transfer_dto = UU::Finman::FinancialTransaction::TransferCreate.new(transfer)
  # adjust given transfer dto to match expected format of financial transaction command
  transaction = transform_transfer_create_to_transaction_dto(transfer_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

- (TransferAttributes) get_attributes(transfer_uri)

Obtains Transfer attributes from service and returns them

Examples:

# Prepare Transfer location which we want get attributes.
transfer_uri = UU::OS::UESURI.new('ues:TERRITORY:TRANSFER');

# Get Transfer
UU::Finman::FinancialTransaction::Transfer.get_attributes(transfer_uri);

Parameters:

  • transfer_uri (String, UU::OS::UESURI)

    UESURI of the Transfer

Returns:



98
99
100
101
102
103
104
105
106
# File 'lib/uu/finman/transfer.rb', line 98

def get_attributes(transfer_uri)
  svc = UU::OS::REST::RemoteClient.new(Transfer)
  UU::OS::QoS::QoSHandler.auto_retry do
    attrs_string = svc.get('getAttributes', transfer_uri)
    attrs = JSON.parse(attrs_string, :symbolize_names => true)
    attrs = remove_invalid_keys(attrs)
    return UU::Finman::FinancialTransaction::TransferAttributes.new(attrs)
  end
end

- (UU::OS::UESURI) set_attributes(transfer_uri, transfer_set_attributes)

Sets attributes of Financial transfer.

Examples:

# Prepare Transfer location which we want set attributes.
transfer_uri = UU::OS::UESURI.new('ues:TERRITORY:TRANSFER');

# Set Transfer attributes
UU::Finman::FinancialTransaction::Transfer.set_attributes(transfer_uri,
  :name => "Transfer set");

Parameters:

  • transfer_uri (String, UU::OS::UESURI)

    UESURI of modified Financial transfer

  • transfer_set_attributes (TransferSetAttributes)

    DTO containing modified attributes of the Financial transfer

Returns:

  • (UU::OS::UESURI)

    UESURI of modified transfer



122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/uu/finman/transfer.rb', line 122

def set_attributes(transfer_uri, transfer_set_attributes)
  svc = UU::OS::REST::RemoteClient.new(Transfer)
  transfer_dto = UU::Finman::FinancialTransaction::TransferSetAttributes.new(transfer_set_attributes)
  # adjust given transfer dto to match expected format of financial transaction command
  transaction = transform_modify_transfer_to_transaction_dto(transfer_dto)
  financial_transaction_dto = transaction.to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.post('setAttributes', transfer_uri, financial_transaction_dto)
    return UU::OS::UESURI.new(res)
  end
end