Module: UU::Finman::Account

Extended by:
Account
Included in:
Account
Defined in:
lib/uu/finman/account.rb,
lib/uu/finman/account/account_type.rb,
lib/uu/finman/account/account_state.rb,
lib/uu/finman/account/account_create.rb,
lib/uu/finman/account/account_set_state.rb,
lib/uu/finman/account/account_attributes.rb,
lib/uu/finman/account/account_set_attributes.rb

Overview

Module of Account

Defined Under Namespace

Classes: AccountAttributes, AccountCreate, AccountSetAttributes, AccountSetState, AccountState, AccountType

Constant Summary

PATH =

Service path

'uu/finman/account/Account'

Instance Method Summary (collapse)

Instance Method Details

- (UU::OS::UESURI) create(location_uri, account)

Creates a new Account. The command creates a new Account in a specified location with passed DTO parameters.

Required attributes:

account_type, name, company_uri, location_uri, bank_account_number, account_currency_code (since version FINMAN3-15-8)

Examples:

# Prepare folder of Organization Unit URI, where we want to create Account.
location_uri = UU::OS::UESURI.new('ues:TERRITORY:FOLDER');

# Create Account
UU::Finman::Account.create(location_uri,
  :name => "Name",
  :account_type => "BANK",
  :account_currency_code => "CZK",
  :bank_account_number => "12345",
  :company_uri => "ues:TERRITORY:COMPANY");

# Create Cash Account
UU::Finman::Account.create(location_uri,
  :name => "Name",
  :account_type => "CASH",
  :account_currency_code => "CZK",
  :bank_account_number => "12345",
  :company_uri => "ues:TERRITORY:COMPANY");

Parameters:

  • location_uri (UU::OS::UESURI)

    UESURI of the folder or organizational unit where Account will be created.

  • account (UU::Finman::Account::AccountCreate)

    DTO containing attributes of the new Account

Returns:

  • (UU::OS::UESURI)

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



47
48
49
50
51
52
53
54
55
56
# File 'lib/uu/finman/account.rb', line 47

def create(location_uri, )
  svc = UU::OS::REST::RemoteClient.new(Account)
   = UU::Finman::Account::AccountCreate.new()
  transaction = ().to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.post('create', location_uri, transaction)
    return UU::OS::UESURI.new(res)
  end
end

- (UU::Finman::Account::AccountAttributes) get_attributes(account_uri)

Obtains Account attributes from REST service and returns them

Examples:

# Prepare Account URI, where we want to get attributes.
 = UU::OS::UESURI.new('ues:TERRITORY:ACCOUNT');

# Get Account attributes
UU::Finman::Account.get_attributes();

Parameters:

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

    UESURI of Account.

Returns:



71
72
73
74
75
76
77
78
79
# File 'lib/uu/finman/account.rb', line 71

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

- (UU::OS::UESURI) set_attributes(account_uri, account_set_attributes)

Sets attributes of Account.

Examples:

# Prepare Account URI, where we want to set attributes.
 = UU::OS::UESURI.new('ues:TERRITORY:FOLDER');

# Set Account attributes.
UU::Finman::Account.set_attributes(,
  :name => "Name");

Parameters:

Returns:

  • (UU::OS::UESURI)

    UESURI of modified Account



96
97
98
99
100
101
102
103
104
105
# File 'lib/uu/finman/account.rb', line 96

def set_attributes(, )
  svc = UU::OS::REST::RemoteClient.new(Account)
  a_attrs = UU::Finman::Account::AccountSetAttributes.new()
  transaction = (a_attrs).to_json

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

- (Object) set_state(account_uri, state)

Sets state of Account.

Examples:

# Prepare Account URI, where we want to set state.
 = UU::OS::UESURI.new('ues:TERRITORY:ACCOUNT');

# Set state of Account.
UU::Finman::Account.set_state(, :account_state => "ACTIVE" ,:comment=>"Some sample comment");

Parameters:



119
120
121
122
123
124
125
126
# File 'lib/uu/finman/account.rb', line 119

def set_state(, state)
  svc = UU::OS::REST::RemoteClient.new(Account)
  payload = UU::Finman::Account::AccountSetState.new(state).to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.post('setState', , payload)
  end
end