class BotEbill::BarcodeText

Attributes

bot_text[RW]
post_office_text[RW]
store_text[RW]

Public Class Methods

new(options) click to toggle source
# File lib/bot_ebill/barcode_text.rb, line 4
def initialize(options)
        raise ArgumentError, 'Missing required argument: collection_no.代收類別' unless options[:collection_no]
        raise ArgumentError, 'Missing required argument: store_no.超商代收項目' unless options[:store_no]
        raise ArgumentError, 'Missing required argument: order_no.自訂編號' unless options[:order_no]
        raise ArgumentError, 'Missing required argument: price.金額' unless options[:price]
        
        @collection_no = options[:collection_no].to_s #代收類別
        @store_no = options[:store_no].to_s #超商代收項目
        @order_no = options[:order_no].to_s #自訂編號
        @price = options[:price] #金額

        bot_check_code = BotEbill::CheckCode.bot(collection_no: @collection_no, order_no: @order_no, price: @price)
        
        @bot_account = "#{@collection_no}#{@order_no}#{bot_check_code}" #台銀帳號
end

Private Instance Methods

post_office_fee() click to toggle source
# File lib/bot_ebill/barcode_text.rb, line 53
 def post_office_fee
         origin_price = @price.to_i
fee = 5 if origin_price.between?(1, 95)
fee = 10 if origin_price.between?(96, 990)
fee = 15 if origin_price >= 991

fee ||= 0
 end