class XeroRuby::PayrollUk::Payslip
Constants
- CHEQUE
- ELECTRONICALLY
- MANUAL
Attributes
BACS Service User Number
The Xero identifier for payroll employee
Employee
first name
Total earnings before any deductions. Same as total earnings for UK.
The date payslip was last updated
Employee
last name
The Xero identifier for the associated payrun
The Xero identifier for a Payslip
The payment method code
Benefits
(also called fringe benefits, perquisites or perks) are various non-earnings compensations provided to employees in addition to their normal earnings or salaries
Total amounts required by law to subtract from the employee's earnings
Total amount subtracted from an employee's earnings to reach total pay
Total earnings before any deductions. Same as gross earnings for UK.
The part of an employee's earnings that is deducted for tax purposes
The employer's tax obligation
The employee net pay
Total reimbursements are nontaxable payments to an employee used to repay out-of-pocket expenses when the person incurs those expenses through employment
Public Class Methods
Attribute mapping from ruby-style variable name to JSON key.
# File lib/xero-ruby/models/payroll_uk/payslip.rb, line 129 def self.attribute_map { :'pay_slip_id' => :'paySlipID', :'employee_id' => :'employeeID', :'pay_run_id' => :'payRunID', :'last_edited' => :'lastEdited', :'first_name' => :'firstName', :'last_name' => :'lastName', :'total_earnings' => :'totalEarnings', :'gross_earnings' => :'grossEarnings', :'total_pay' => :'totalPay', :'total_employer_taxes' => :'totalEmployerTaxes', :'total_employee_taxes' => :'totalEmployeeTaxes', :'total_deductions' => :'totalDeductions', :'total_reimbursements' => :'totalReimbursements', :'total_court_orders' => :'totalCourtOrders', :'total_benefits' => :'totalBenefits', :'bacs_hash' => :'bacsHash', :'payment_method' => :'paymentMethod', :'earnings_lines' => :'earningsLines', :'leave_earnings_lines' => :'leaveEarningsLines', :'timesheet_earnings_lines' => :'timesheetEarningsLines', :'deduction_lines' => :'deductionLines', :'reimbursement_lines' => :'reimbursementLines', :'leave_accrual_lines' => :'leaveAccrualLines', :'benefit_lines' => :'benefitLines', :'payment_lines' => :'paymentLines', :'employee_tax_lines' => :'employeeTaxLines', :'employer_tax_lines' => :'employerTaxLines', :'court_order_lines' => :'courtOrderLines' } end
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/xero-ruby/models/payroll_uk/payslip.rb, line 421 def self.build_from_hash(attributes) new.build_from_hash(attributes) end
Initializes the object @param [Hash] attributes Model attributes in the form of hash
# File lib/xero-ruby/models/payroll_uk/payslip.rb, line 198 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::PayrollUk::Payslip` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::PayrollUk::Payslip`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'pay_slip_id') self.pay_slip_id = attributes[:'pay_slip_id'] end if attributes.key?(:'employee_id') self.employee_id = attributes[:'employee_id'] end if attributes.key?(:'pay_run_id') self.pay_run_id = attributes[:'pay_run_id'] end if attributes.key?(:'last_edited') self.last_edited = attributes[:'last_edited'] end if attributes.key?(:'first_name') self.first_name = attributes[:'first_name'] end if attributes.key?(:'last_name') self.last_name = attributes[:'last_name'] end if attributes.key?(:'total_earnings') self.total_earnings = attributes[:'total_earnings'] end if attributes.key?(:'gross_earnings') self.gross_earnings = attributes[:'gross_earnings'] end if attributes.key?(:'total_pay') self.total_pay = attributes[:'total_pay'] end if attributes.key?(:'total_employer_taxes') self.total_employer_taxes = attributes[:'total_employer_taxes'] end if attributes.key?(:'total_employee_taxes') self.total_employee_taxes = attributes[:'total_employee_taxes'] end if attributes.key?(:'total_deductions') self.total_deductions = attributes[:'total_deductions'] end if attributes.key?(:'total_reimbursements') self.total_reimbursements = attributes[:'total_reimbursements'] end if attributes.key?(:'total_court_orders') self.total_court_orders = attributes[:'total_court_orders'] end if attributes.key?(:'total_benefits') self.total_benefits = attributes[:'total_benefits'] end if attributes.key?(:'bacs_hash') self.bacs_hash = attributes[:'bacs_hash'] end if attributes.key?(:'payment_method') self.payment_method = attributes[:'payment_method'] end if attributes.key?(:'earnings_lines') if (value = attributes[:'earnings_lines']).is_a?(Array) self.earnings_lines = value end end if attributes.key?(:'leave_earnings_lines') if (value = attributes[:'leave_earnings_lines']).is_a?(Array) self.leave_earnings_lines = value end end if attributes.key?(:'timesheet_earnings_lines') if (value = attributes[:'timesheet_earnings_lines']).is_a?(Array) self.timesheet_earnings_lines = value end end if attributes.key?(:'deduction_lines') if (value = attributes[:'deduction_lines']).is_a?(Array) self.deduction_lines = value end end if attributes.key?(:'reimbursement_lines') if (value = attributes[:'reimbursement_lines']).is_a?(Array) self.reimbursement_lines = value end end if attributes.key?(:'leave_accrual_lines') if (value = attributes[:'leave_accrual_lines']).is_a?(Array) self.leave_accrual_lines = value end end if attributes.key?(:'benefit_lines') if (value = attributes[:'benefit_lines']).is_a?(Array) self.benefit_lines = value end end if attributes.key?(:'payment_lines') if (value = attributes[:'payment_lines']).is_a?(Array) self.payment_lines = value end end if attributes.key?(:'employee_tax_lines') if (value = attributes[:'employee_tax_lines']).is_a?(Array) self.employee_tax_lines = value end end if attributes.key?(:'employer_tax_lines') if (value = attributes[:'employer_tax_lines']).is_a?(Array) self.employer_tax_lines = value end end if attributes.key?(:'court_order_lines') if (value = attributes[:'court_order_lines']).is_a?(Array) self.court_order_lines = value end end end
Attribute type mapping.
# File lib/xero-ruby/models/payroll_uk/payslip.rb, line 163 def self.openapi_types { :'pay_slip_id' => :'String', :'employee_id' => :'String', :'pay_run_id' => :'String', :'last_edited' => :'Date', :'first_name' => :'String', :'last_name' => :'String', :'total_earnings' => :'Float', :'gross_earnings' => :'Float', :'total_pay' => :'Float', :'total_employer_taxes' => :'Float', :'total_employee_taxes' => :'Float', :'total_deductions' => :'Float', :'total_reimbursements' => :'Float', :'total_court_orders' => :'Float', :'total_benefits' => :'Float', :'bacs_hash' => :'String', :'payment_method' => :'String', :'earnings_lines' => :'Array<EarningsLine>', :'leave_earnings_lines' => :'Array<LeaveEarningsLine>', :'timesheet_earnings_lines' => :'Array<TimesheetEarningsLine>', :'deduction_lines' => :'Array<DeductionLine>', :'reimbursement_lines' => :'Array<ReimbursementLine>', :'leave_accrual_lines' => :'Array<LeaveAccrualLine>', :'benefit_lines' => :'Array<BenefitLine>', :'payment_lines' => :'Array<PaymentLine>', :'employee_tax_lines' => :'Array<TaxLine>', :'employer_tax_lines' => :'Array<TaxLine>', :'court_order_lines' => :'Array<CourtOrderLine>' } end
Public Instance Methods
Checks equality by comparing each attribute. @param [Object] Object to be compared
# File lib/xero-ruby/models/payroll_uk/payslip.rb, line 373 def ==(o) return true if self.equal?(o) self.class == o.class && pay_slip_id == o.pay_slip_id && employee_id == o.employee_id && pay_run_id == o.pay_run_id && last_edited == o.last_edited && first_name == o.first_name && last_name == o.last_name && total_earnings == o.total_earnings && gross_earnings == o.gross_earnings && total_pay == o.total_pay && total_employer_taxes == o.total_employer_taxes && total_employee_taxes == o.total_employee_taxes && total_deductions == o.total_deductions && total_reimbursements == o.total_reimbursements && total_court_orders == o.total_court_orders && total_benefits == o.total_benefits && bacs_hash == o.bacs_hash && payment_method == o.payment_method && earnings_lines == o.earnings_lines && leave_earnings_lines == o.leave_earnings_lines && timesheet_earnings_lines == o.timesheet_earnings_lines && deduction_lines == o.deduction_lines && reimbursement_lines == o.reimbursement_lines && leave_accrual_lines == o.leave_accrual_lines && benefit_lines == o.benefit_lines && payment_lines == o.payment_lines && employee_tax_lines == o.employee_tax_lines && employer_tax_lines == o.employer_tax_lines && court_order_lines == o.court_order_lines end
Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data
# File lib/xero-ruby/models/payroll_uk/payslip.rb, line 449 def _deserialize(type, value) case type.to_sym when :DateTime DateTime.parse(parse_date(value)) when :Date Date.parse(parse_date(value)) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :BigDecimal BigDecimal(value.to_s) when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model XeroRuby::PayrollUk.const_get(type).build_from_hash(value) end end
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash
# File lib/xero-ruby/models/payroll_uk/payslip.rb, line 522 def _to_hash(value, downcase: false) if value.is_a?(Array) value.map do |v| v.to_hash(downcase: downcase) end elsif value.is_a?(Hash) {}.tap do |hash| value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash value.to_hash(downcase: downcase) else value end end
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/xero-ruby/models/payroll_uk/payslip.rb, line 428 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end
@see the `==` method @param [Object] Object to be compared
# File lib/xero-ruby/models/payroll_uk/payslip.rb, line 408 def eql?(o) self == o end
Calculates hash code according to all attributes. @return [Integer] Hash code
# File lib/xero-ruby/models/payroll_uk/payslip.rb, line 414 def hash [pay_slip_id, employee_id, pay_run_id, last_edited, first_name, last_name, total_earnings, gross_earnings, total_pay, total_employer_taxes, total_employee_taxes, total_deductions, total_reimbursements, total_court_orders, total_benefits, bacs_hash, payment_method, earnings_lines, leave_earnings_lines, timesheet_earnings_lines, deduction_lines, reimbursement_lines, leave_accrual_lines, benefit_lines, payment_lines, employee_tax_lines, employer_tax_lines, court_order_lines].hash end
Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons
# File lib/xero-ruby/models/payroll_uk/payslip.rb, line 348 def list_invalid_properties invalid_properties = Array.new invalid_properties end
# File lib/xero-ruby/models/payroll_uk/payslip.rb, line 538 def parse_date(datestring) if datestring.include?('Date') date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// original, date, timezone = *date_pattern.match(datestring) date = (date.to_i / 1000) Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end end
Custom attribute writer method checking allowed values (enum). @param [Object] payment_method
Object to be assigned
# File lib/xero-ruby/models/payroll_uk/payslip.rb, line 363 def payment_method=(payment_method) validator = EnumAttributeValidator.new('String', ["Cheque", "Electronically", "Manual"]) unless validator.valid?(payment_method) fail ArgumentError, "invalid value for \"payment_method\", must be one of #{validator.allowable_values}." end @payment_method = payment_method end
Returns the object in the form of hash with snake_case
# File lib/xero-ruby/models/payroll_uk/payslip.rb, line 514 def to_attributes to_hash(downcase: true) end
Returns the object in the form of hash @return [Hash] Returns the object in the form of hash
# File lib/xero-ruby/models/payroll_uk/payslip.rb, line 502 def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? key = downcase ? attr : param hash[key] = _to_hash(value, downcase: downcase) end hash end
Returns the string representation of the object @return [String] String presentation of the object
# File lib/xero-ruby/models/payroll_uk/payslip.rb, line 490 def to_s to_hash.to_s end
Check to see if the all the properties in the model are valid @return true if the model is valid
# File lib/xero-ruby/models/payroll_uk/payslip.rb, line 355 def valid? payment_method_validator = EnumAttributeValidator.new('String', ["Cheque", "Electronically", "Manual"]) return false unless payment_method_validator.valid?(@payment_method) true end