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)

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.

Examples:

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

# Create Credit note
UU::Finman::FinancialTransaction::CreditNote.create(control_business_case_uri,
  :name => "Credit note",
  :supplier_description => "kreditní popis",
  :client_description => "debetní popis",
  :supplier_account_number => "123456",
  :client_account_number => "987654",
  :supplier_financial_category => UU::OS::UESURI.new("ues:TERRITORY:APPS.UU.FINMAN/CONFIGURATION:SYS.FIN.CONFIG/TX_TYPE/CR.TXWER"),
  :client_financial_category => UU::OS::UESURI.new("ues:TERRITORY:APPS.UU.FINMAN/CONFIGURATION:SYS.FIN.CONFIG/TX_TYPE/DR.TXOTR"),
  :realization_probability => 50,
  :isCreditNoteOutgoing => false,
  :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",
  :for_acceptance_date => "2014-11-02",
  :protocol_date => "2014-11-02",
  :Vat_date => "2014-11-02",
  :due_date => "2014-11-02",
  :expected_pay_date => "2014-11-02",
  :counterparty_business_case_uri =>  UU::OS::UESURI.new("ues:TERRITORY:CP_BC"),
  :client_account_number => "debetní číslo učtu",
  :is_planned => false,
  :is_ready_for_acceptance => true,
  :request_approval_by_manager => true,
  :wait_for_acceptance_by_accountant => true,
  :client_side_currency => "CZK",
  :supplier_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 Credit Note. In case of setting dry_run parameter to true, UU::OS::UESURI::NIL_URI is returned instead.



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

Examples:

# Prepare Credit note location which we want get attributes.
credit_note_uri = UU::OS::UESURI.new('ues:TERRITORY:CREDIT_NOTE');

# Get Credit note
  credit_note_uesuri = UU::Finman::FinancialTransaction::CreditNote.get_attributes(credit_note_uri);

Parameters:

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

    UESURI of the Credit note

Returns:



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.

Examples:

# Prepare Credit note location which we want set attributes.
credit_note_uri = UU::OS::UESURI.new('ues:TERRITORY:CREDIT_NOTE');

# Set Credit note
  credit_note_uesuri = UU::Finman::FinancialTransaction::CreditNote.set_attributes(credit_note_uri,
  :name => "Credit note set");

Parameters:

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

    UESURI of modified Credit note

  • credit_note_set_attributes (CreditNoteSetAttributes)

    DTO containing modified attributes of the Credit note

Returns:

  • (UU::OS::UESURI)

    UESURI of modified 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