Class: Cetustek::CreateAllowance

Inherits:
Object
  • Object
show all
Includes:
Soap
Defined in:
lib/cetustek/create_allowance.rb

Overview

2.9 CreateAllowance 開立折讓單. Returns "A0" on success, raises ResultError otherwise.

Constant Summary collapse

SUCCESS_CODE =
'A0'
RESULT_MESSAGES =

Spec AVM-26-03 Table 17.

ResultCode::COMMON.merge(ResultCode::DETAILS).merge(
  'A1' => '上傳失敗',
  'A2' => '所有折讓金額加總不能大於原發票金額',
  'A3' => '發票號碼不存在',
  'A4' => '發票號碼已經被作廢',
  'A5' => '折讓單已經上傳',
  'A6' => '折讓總金額須大於零',
  'A7' => '折讓日期應大於原發票開立日期'
).freeze

Instance Method Summary collapse

Methods included from Soap

#rentid, #soap_call, #soap_client, #soap_return, #source

Constructor Details

#initialize(allowance_data, check_allowance: 0) ⇒ CreateAllowance

check_allowance 只剩 0(已確認的折讓單):規格 §2.9 已刪除 1, 114/01/01 起上傳的折讓單皆為已確認。

Raises:

  • (ArgumentError)


23
24
25
26
27
28
# File 'lib/cetustek/create_allowance.rb', line 23

def initialize(allowance_data, check_allowance: 0)
  raise ArgumentError, 'check_allowance must be 0 (114/01/01 起折讓單皆為已確認)' unless check_allowance.to_i.zero?

  @data = allowance_data
  @check_allowance = 0
end

Instance Method Details

#executeObject



30
31
32
33
# File 'lib/cetustek/create_allowance.rb', line 30

def execute
  response = soap_call(:create_allowance, allowancexml: generate_xml, checkallowance: @check_allowance)
  ResultCode.check!(soap_return(response, :create_allowance), RESULT_MESSAGES, success: SUCCESS_CODE)
end