Sha256: 0ad2919768feb4fcc7aa6bbd0cc3bea60517ff180adb70868af61e7e1026a247

Contents?: true

Size: 936 Bytes

Versions: 9

Compression:

Stored size: 936 Bytes

Contents

# frozen_string_literal: true

require 'date'
require 'codat/base_model'
require 'codat/models/report_item'

module Codat
  module Models
    class ProfitAndLossReport < BaseModel
      attributes :from_date, :to_date, :gross_profit, :net_other_income, :net_profit
      attributes :net_operating_profit

      attr_accessor :income, :cost_of_sales, :expenses, :other_expenses, :other_income

      def initialize(json: {})
        super

        @from_date = Date.parse(json.fetch(:fromDate))
        @to_date = Date.parse(json.fetch(:toDate))

        @income = ReportItem.new(json: json.fetch(:income, {}))
        @cost_of_sales = ReportItem.new(json: json.fetch(:costOfSales, {}))
        @expenses = ReportItem.new(json: json.fetch(:expenses, {}))
        @other_expenses = ReportItem.new(json: json.fetch(:otherExpenses, {}))
        @other_income = ReportItem.new(json: json.fetch(:otherIncome, {}))
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
codat-0.1.6.2 lib/codat/models/profit_and_loss_report.rb
codat-0.1.6.1 lib/codat/models/profit_and_loss_report.rb
codat-0.1.8 lib/codat/models/profit_and_loss_report.rb
codat-0.1.7 lib/codat/models/profit_and_loss_report.rb
codat-0.1.6 lib/codat/models/profit_and_loss_report.rb
codat-0.1.5 lib/codat/models/profit_and_loss_report.rb
codat-0.1.4 lib/codat/models/profit_and_loss_report.rb
codat-0.1.3 lib/codat/models/profit_and_loss_report.rb
codat-0.1.2 lib/codat/models/profit_and_loss_report.rb