Sha256: 82cd3081f31c1b79f6c8dd75139dce075ab09bc61c6278fdbde1287f96512d59

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

module KashflowApi
    class Line < KashflowApi::SoapObject
        def save
            if @hash["ReceiptID"] != ""
                insert_receipt_line
            elsif @hash["InvoiceID"] != ""
                insert_invoice_line
            end
        end
        
        def to_xml
            xml = []
            id_line = ""
            @hash.keys.each do |key|
                if key == "LineID"
                    id_line = "<#{key}>#{@hash[key]}</#{key}>" unless @hash[key] == "0"
                elsif key != "ReceiptID" && key != "InvoiceID" && @hash[key] != ""
                    xml.push("<#{key}>#{@hash[key]}</#{key}>")
                end
            end
            [id_line, xml.join].join
        end
        
        private
        
        def blank_object_hash
            {"Quantity" => "", "Description" => "", "ChargeType" => "", "VatAmount" => "", "VatRate" => "", "Rate" => "", "ReceiptID" => "", "InvoiceID" => "" }
        end
        
        def insert_receipt_line
            KashflowApi.api.insert_receipt_line(self)
        end
        
        def insert_invoice_line
            KashflowApi.api.insert_invoice_line(self)
        end
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kashflow_api-0.0.1 lib/kashflow_api/models/line.rb
kashflow_api-0.0.1rc1 lib/kashflow_api/models/line.rb
kashflow_api-0.0.1pre lib/kashflow_api/models/line.rb