Module: UU::Finman::FinancialTransaction::ExpostPayment

Extended by:
ExpostPayment
Included in:
ExpostPayment
Defined in:
lib/uu/finman/expost_payment.rb

Overview

Module of Expost Payment

Constant Summary

PATH =

Service path

'uu/finman/financialtransaction/FinancialTransaction'

Instance Method Summary (collapse)

Instance Method Details

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

Creates a new Expost Payment. The command creates a new Expost Payment 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_transaction_credit,
credit_vat_date, debit_vat_date, 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 Expost payment.
locationUri = UU::OS::UESURI.new('ues:TERRITORY:BUSINESS_CASE');

# Create Expost payment
  UU::Finman::FinancialTransaction::ExpostPayment.create(control_business_case_uri,
  :name => "Ex-post payment ",
  :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"),
  :is_transaction_credit => true,
  :financial_transaction_type => "NONCASH",
  :amount_without_vat => 10000,
  :vat_rate => 10,
  :invoice_number => "Číslo faktury",
  :constant_symbol => "konstantní symbol",
  :variable_symbol => "variabilní symbol",
  :specific_symbol => "specifický symbol",
  :credit_vat_date => "2014-11-03",
  :debit_vat_date => "2014-11-04",
  :pay_date => "2014-10-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",
  :is_planned => false,
  :contract_uri => UU::OS::UESURI.new("ues:TERRITORY:CONTRACT"),
  :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 Expost Payment. In case of setting dry_run parameter to true, UU::OS::UESURI::NIL_URI is returned instead.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/uu/finman/expost_payment.rb', line 73

def create(control_business_case_uri, expost_payment)
  svc = UU::OS::REST::RemoteClient.new(ExpostPayment)
  payment_dto = UU::Finman::FinancialTransaction::ExpostPaymentCreate.new(expost_payment)
  # adjust given Expost Payment dto to match expected format of financial transaction command
  transaction = transform_expost_payment_create_to_transaction_dto(payment_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

- (ExpostPaymentAttributes) get_attributes(expost_payment_uri)

Obtains Ex-post attributes from service and returns them

Examples:

# Prepare Expost payment location which we want get attributes.
expost_payment_uri = UU::OS::UESURI.new('ues:TERRITORY:EXPOST_PAYMENT');

# Get Expost payment
UU::Finman::FinancialTransaction::ExpostPayment.get_attributes(expost_payment_uri);

Parameters:

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

    UESURI of the Expost Payment

Returns:



103
104
105
106
107
108
109
110
111
# File 'lib/uu/finman/expost_payment.rb', line 103

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

- (UU::OS::UESURI) set_attributes(expost_payment_uri, expost_payment_set_attributes)

Sets attributes of Expost Payment.

Examples:

# Prepare Expost payment location which we want set attributes.
expost_payment_uri = UU::OS::UESURI.new('ues:TERRITORY:EXPOST_PAYMENT');

# Create Expost payment
UU::Finman::FinancialTransaction::ExpostPayment.set_attributes(expost_payment_uri,
  :name => "Expost payment set");

Parameters:

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

    UESURI of modified Payment

  • expost_payment_set_attributes (ExpostPaymentSetAttributes)

    DTO containing modified attributes of the Expost Payment

Returns:

  • (UU::OS::UESURI)

    UESURI of modified Payment



128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/uu/finman/expost_payment.rb', line 128

def set_attributes(expost_payment_uri, expost_payment_set_attributes)
  svc = UU::OS::REST::RemoteClient.new(ExpostPayment)
  payment_dto = UU::Finman::FinancialTransaction::ExpostPaymentSetAttributes.new(expost_payment_set_attributes)
  # adjust given payment dto to match expected format of financial transaction command
  transaction = transform_expost_payment_modify_to_transaction_dto(payment_dto)
  financial_transaction_dto = transaction.to_json

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