<commit_before>module XeroGateway::Payroll
  class NoGatewayError < StandardError; end
  class TimesheetEarningsLine < EarningsRate; end
  class LeaveEarningsLine < EarningsRate; end

  class Payslip
    GUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/ unless defined?(GUID_REGEX)

    attr_accessor :gateway

    # Any errors that occurred when the #valid? method called.
    attr_reader :errors

    attr_accessor :employee_id, :payslip_id, :earnings_lines, :timesheet_earnings_lines, :deduction_lines,
                  :leave_accrual_lines, :reimbursement_lines, :superannuation_lines, :tax_lines, :first_name,
                  :last_name, :employee_group, :last_edited, :wages, :deductions, :net_pay, :tax, :super,
                  :reimbursements, :leave_earnings_lines

    def initialize(params = {})
      @errors ||= []

      params = {}.merge(params)
      params.each do |k,v|
        self.send("#{k}=", v)
      end

      @earnings_lines ||= []
      @timesheet_earnings_lines ||= []
      @deduction_lines ||= []
      @leave_accrual_lines ||= []
      @reimbursement_lines ||= []
      @superannuation_lines ||= []
      @tax_lines ||= []
      @leave_earnings_lines ||= []
    end

    def total_help_component_tax
      help_component_tax = tax_lines.select {|obj| obj[:tax_type_name] == "HELP Component" }
      help_component_tax.sum {|a| a.amount }
    end

    def to_xml(b = Builder::XmlMarkup.new)
      b.Payslip{
        b.EmployeeID self.employee_id if self.employee_id
        b.PayslipID self.payslip_id if self.payslip_id
        b.EarningsLines{
          self.earnings_lines.each do |earnings_line|
            earnings_line.to_xml(b)
          end
        } unless self.earnings_lines.blank?
        b.TimesheetEarningsLines{
          self.timesheet_earnings_lines.each do |timesheet_earnings_line|<commit_msg>Fix TaxLine total help component<commit_after>module XeroGateway::Payroll
  class NoGatewayError < StandardError; end
  class TimesheetEarningsLine < EarningsRate; end
  class LeaveEarningsLine < EarningsRate; end

  class Payslip
    GUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/ unless defined?(GUID_REGEX)

    attr_accessor :gateway

    # Any errors that occurred when the #valid? method called.
    attr_reader :errors

    attr_accessor :employee_id, :payslip_id, :earnings_lines, :timesheet_earnings_lines, :deduction_lines,
                  :leave_accrual_lines, :reimbursement_lines, :superannuation_lines, :tax_lines, :first_name,
                  :last_name, :employee_group, :last_edited, :wages, :deductions, :net_pay, :tax, :super,
                  :reimbursements, :leave_earnings_lines

    def initialize(params = {})
      @errors ||= []

      params = {}.merge(params)
      params.each do |k,v|
        self.send("#{k}=", v)
      end

      @earnings_lines ||= []
      @timesheet_earnings_lines ||= []
      @deduction_lines ||= []
      @leave_accrual_lines ||= []
      @reimbursement_lines ||= []
      @superannuation_lines ||= []
      @tax_lines ||= []
      @leave_earnings_lines ||= []
    end

    def total_help_component_tax
      help_component_tax = tax_lines.select {|obj| obj.tax_type_name == "HELP Component" }
      help_component_tax.sum {|a| a.amount.to_f }
    end

    def to_xml(b = Builder::XmlMarkup.new)
      b.Payslip{
        b.EmployeeID self.employee_id if self.employee_id
        b.PayslipID self.payslip_id if self.payslip_id
        b.EarningsLines{
          self.earnings_lines.each do |earnings_line|
            earnings_line.to_xml(b)
          end
        } unless self.earnings_lines.blank?
        b.TimesheetEarningsLines{
          self.timesheet_earnings_lines.each do |timesheet_earnings_line|
{'fraction_non_alphanumeric': 0.12109167991520933, 'fraction_numerical': 0.008479067302596715, 'mean_word_length': 2.9695057833859098, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4105428', 'n_tokens_mistral': 1361, 'n_tokens_neox': 1305, 'n_words': 223}