Module: UU::Finman::FinancialTransaction::Payment

Extended by:
Payment
Included in:
Payment
Defined in:
lib/uu/finman/payment.rb

Overview

Module of 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, payment)

Creates a new Payment. The command creates a new Payment 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, due_date, protocol_date, vat_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 Payment.
control_business_case_uri = UU::OS::UESURI.new('ues:TERRITORY:BUSINESS_CASE');

# Create Payment
    payment_uri = UU::Finman::FinancialTransaction::Payment.create(control_business_case_uri,
    :name => "Platba ",
    :credit_description => "Kreditní popis",
    :debit_description => "Debetní popis",
    :credit_financial_category_uri => UU::OS::UESURI.new("ues:TERRITORY:APPS.UU.FINMAN/CONFIGURATION:SYS.FIN.CONFIG/TX_TYPE/CR.TXWER"),
    :debit_financial_category_uri => 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",
    :amount_without_vat => 100,
    :amount_with_vat =>  120,
    :vat_rate => 20,
    :is_ready_for_acceptance => true,
    :invoice_number => "Číslo faktury ",
    :constant_symbol => "Konstantní symbol",
    :variable_symbol => "Variabilní symbol",
    :specific_symbol => "Specifický symbol",
    :for_acceptance_date => "2014-11-02",
    :protocol_date => "2014-11-02",
    :vat_date => "2014-11-02",
    :expected_pay_date => "2014-11-02",
    :counterparty_business_case_uri =>  UU::OS::UESURI.new("ues:TERRITORY:CP_BC"),
    :credit_account_uri =>  UU::OS::UESURI.new("ues:TERRITORY:ACCOUNT"),
    :is_planned => false,
    :credit_business_case_from_opposite_territory => UU::OS::UESURI.new("ues:TERRITORY:ITA_BC"),
    :debit_business_case_from_opposite_territory => UU::OS::UESURI.new("ues:TERRITORY:ITA_BC"),
    :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 Payment. In case of setting dry_run parameter to true, UU::OS::UESURI::NIL_URI is returned instead.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/uu/finman/payment.rb', line 76

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

- (PaymentAttributes) get_attributes(payment_uri)

Obtains Payment attributes from service and returns them

Examples:

# Prepare Payment location which we want get attributes.
payment_uri = UU::OS::UESURI.new('ues:TERRITORY:PAYMENT');

# Get Payment
UU::Finman::FinancialTransaction::Payment.get_attributes(payment_uri);

Parameters:

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

    UESURI of the Payment

Returns:



106
107
108
109
110
111
112
113
114
# File 'lib/uu/finman/payment.rb', line 106

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

- (UU::OS::UESURI) set_attributes(payment_uri, payment_set_attributes)

Sets attributes of Payment.

Examples:

# Prepare Payment location which we want set attributes.
payment_uri = UU::OS::UESURI.new('ues:TERRITORY:PAYMENT');

# Set Payment
UU::Finman::FinancialTransaction::Payment.set_attributes(payment_uri,
  :name => "Payment set");

Parameters:

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

    UESURI of modified Payment

  • payment_set_attributes (PaymentSetAttributes)

    DTO containing modified attributes of the Payment

Returns:

  • (UU::OS::UESURI)

    UESURI of modified Payment



131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/uu/finman/payment.rb', line 131

def set_attributes(payment_uri, payment_set_attributes)
  svc = UU::OS::REST::RemoteClient.new(Payment)
  payment_dto = UU::Finman::FinancialTransaction::PaymentSetAttributes.new(payment_set_attributes)
  # adjust given payment dto to match expected format of financial transaction command
  transaction = transform_modify_payment_to_transaction_dto(payment_dto)
  financial_transaction_dto = transaction.to_json

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