Class: XeroRuby::PayrollUk::Deduction
- Inherits:
-
Object
- Object
- XeroRuby::PayrollUk::Deduction
- Defined in:
- lib/xero-ruby/models/payroll_uk/deduction.rb
Defined Under Namespace
Classes: EnumAttributeValidator
Constant Summary collapse
- CAPITAL_CONTRIBUTIONS =
"CapitalContributions".freeze
- CHILD_CARE_VOUCHER =
"ChildCareVoucher".freeze
- MAKING_GOOD =
"MakingGood".freeze
- POSTGRADUATE_LOAN_DEDUCTIONS =
"PostgraduateLoanDeductions".freeze
- PRIVATE_USE_PAYMENTS =
"PrivateUsePayments".freeze
- SALARY_SACRIFICE =
"SalarySacrifice".freeze
- STAKEHOLDER_PENSION =
"StakeholderPension".freeze
- STAKEHOLDER_PENSION_POST_TAX =
"StakeholderPensionPostTax".freeze
- STUDENT_LOAN_DEDUCTIONS =
"StudentLoanDeductions".freeze
- UK_OTHER =
"UkOther".freeze
- FIXED_AMOUNT =
"FixedAmount".freeze
- PERCENTAGE_OF_GROSS =
"PercentageOfGross".freeze
Instance Attribute Summary collapse
-
#apply_to_pension_calculations ⇒ Object
Identifier for apply to pension calculations.
-
#calculation_type ⇒ Object
determine the calculation type whether fixed amount or percentage of gross.
-
#current_record ⇒ Object
Identifier of a record is active or not.
-
#deduction_category ⇒ Object
Deduction Category type.
-
#deduction_id ⇒ Object
The Xero identifier for Deduction.
-
#deduction_name ⇒ Object
Name of the deduction.
-
#is_calculating_on_qualifying_earnings ⇒ Object
Identifier of calculating on qualifying earnings.
-
#is_pension ⇒ Object
Identifier of applicable for pension or not.
-
#is_reduced_by_basic_rate ⇒ Object
Identifier of reduced by basic rate applicable or not.
-
#liability_account_id ⇒ Object
Xero identifier for Liability Account.
-
#percentage ⇒ Object
Percentage of gross.
-
#reduces_super_liability ⇒ Object
Identifier of reduces super liability.
-
#reduces_tax_liability ⇒ Object
Identifier of reduces tax liability.
-
#standard_amount ⇒ Object
Standard amount of the deduction.
-
#subject_to_nic ⇒ Object
Identifier of subject To NIC.
-
#subject_to_tax ⇒ Object
Identifier of subject To Tax.
Class Method Summary collapse
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
-
#build_from_hash(attributes) ⇒ Object
Builds the object from hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ Deduction
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#parse_date(datestring) ⇒ Object
customized data_parser.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ Deduction
Initializes the object
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 148 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::PayrollUk::Deduction` 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::Deduction`. 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?(:'deduction_id') self.deduction_id = attributes[:'deduction_id'] end if attributes.key?(:'deduction_name') self.deduction_name = attributes[:'deduction_name'] end if attributes.key?(:'deduction_category') self.deduction_category = attributes[:'deduction_category'] end if attributes.key?(:'liability_account_id') self.liability_account_id = attributes[:'liability_account_id'] end if attributes.key?(:'current_record') self.current_record = attributes[:'current_record'] end if attributes.key?(:'standard_amount') self.standard_amount = attributes[:'standard_amount'] end if attributes.key?(:'reduces_super_liability') self.reduces_super_liability = attributes[:'reduces_super_liability'] end if attributes.key?(:'reduces_tax_liability') self.reduces_tax_liability = attributes[:'reduces_tax_liability'] end if attributes.key?(:'calculation_type') self.calculation_type = attributes[:'calculation_type'] end if attributes.key?(:'percentage') self.percentage = attributes[:'percentage'] end if attributes.key?(:'subject_to_nic') self.subject_to_nic = attributes[:'subject_to_nic'] end if attributes.key?(:'subject_to_tax') self.subject_to_tax = attributes[:'subject_to_tax'] end if attributes.key?(:'is_reduced_by_basic_rate') self.is_reduced_by_basic_rate = attributes[:'is_reduced_by_basic_rate'] end if attributes.key?(:'apply_to_pension_calculations') self.apply_to_pension_calculations = attributes[:'apply_to_pension_calculations'] end if attributes.key?(:'is_calculating_on_qualifying_earnings') self. = attributes[:'is_calculating_on_qualifying_earnings'] end if attributes.key?(:'is_pension') self.is_pension = attributes[:'is_pension'] end end |
Instance Attribute Details
#apply_to_pension_calculations ⇒ Object
Identifier for apply to pension calculations
72 73 74 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 72 def apply_to_pension_calculations @apply_to_pension_calculations end |
#calculation_type ⇒ Object
determine the calculation type whether fixed amount or percentage of gross
55 56 57 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 55 def calculation_type @calculation_type end |
#current_record ⇒ Object
Identifier of a record is active or not.
43 44 45 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 43 def current_record @current_record end |
#deduction_category ⇒ Object
Deduction Category type
27 28 29 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 27 def deduction_category @deduction_category end |
#deduction_id ⇒ Object
The Xero identifier for Deduction
21 22 23 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 21 def deduction_id @deduction_id end |
#deduction_name ⇒ Object
Name of the deduction
24 25 26 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 24 def deduction_name @deduction_name end |
#is_calculating_on_qualifying_earnings ⇒ Object
Identifier of calculating on qualifying earnings
75 76 77 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 75 def end |
#is_pension ⇒ Object
Identifier of applicable for pension or not
78 79 80 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 78 def is_pension @is_pension end |
#is_reduced_by_basic_rate ⇒ Object
Identifier of reduced by basic rate applicable or not
69 70 71 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 69 def is_reduced_by_basic_rate @is_reduced_by_basic_rate end |
#liability_account_id ⇒ Object
Xero identifier for Liability Account
40 41 42 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 40 def liability_account_id @liability_account_id end |
#percentage ⇒ Object
Percentage of gross
60 61 62 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 60 def percentage @percentage end |
#reduces_super_liability ⇒ Object
Identifier of reduces super liability
49 50 51 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 49 def reduces_super_liability @reduces_super_liability end |
#reduces_tax_liability ⇒ Object
Identifier of reduces tax liability
52 53 54 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 52 def reduces_tax_liability @reduces_tax_liability end |
#standard_amount ⇒ Object
Standard amount of the deduction
46 47 48 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 46 def standard_amount @standard_amount end |
#subject_to_nic ⇒ Object
Identifier of subject To NIC
63 64 65 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 63 def subject_to_nic @subject_to_nic end |
#subject_to_tax ⇒ Object
Identifier of subject To Tax
66 67 68 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 66 def subject_to_tax @subject_to_tax end |
Class Method Details
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 103 def self.attribute_map { :'deduction_id' => :'deductionId', :'deduction_name' => :'deductionName', :'deduction_category' => :'deductionCategory', :'liability_account_id' => :'liabilityAccountId', :'current_record' => :'currentRecord', :'standard_amount' => :'standardAmount', :'reduces_super_liability' => :'reducesSuperLiability', :'reduces_tax_liability' => :'reducesTaxLiability', :'calculation_type' => :'calculationType', :'percentage' => :'percentage', :'subject_to_nic' => :'subjectToNIC', :'subject_to_tax' => :'subjectToTax', :'is_reduced_by_basic_rate' => :'isReducedByBasicRate', :'apply_to_pension_calculations' => :'applyToPensionCalculations', :'is_calculating_on_qualifying_earnings' => :'isCalculatingOnQualifyingEarnings', :'is_pension' => :'isPension' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
311 312 313 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 311 def self.build_from_hash(attributes) new.build_from_hash(attributes) end |
.openapi_types ⇒ Object
Attribute type mapping.
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 125 def self.openapi_types { :'deduction_id' => :'String', :'deduction_name' => :'String', :'deduction_category' => :'String', :'liability_account_id' => :'String', :'current_record' => :'Boolean', :'standard_amount' => :'BigDecimal', :'reduces_super_liability' => :'Boolean', :'reduces_tax_liability' => :'Boolean', :'calculation_type' => :'String', :'percentage' => :'BigDecimal', :'subject_to_nic' => :'Boolean', :'subject_to_tax' => :'Boolean', :'is_reduced_by_basic_rate' => :'Boolean', :'apply_to_pension_calculations' => :'Boolean', :'is_calculating_on_qualifying_earnings' => :'Boolean', :'is_pension' => :'Boolean' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 275 def ==(o) return true if self.equal?(o) self.class == o.class && deduction_id == o.deduction_id && deduction_name == o.deduction_name && deduction_category == o.deduction_category && liability_account_id == o.liability_account_id && current_record == o.current_record && standard_amount == o.standard_amount && reduces_super_liability == o.reduces_super_liability && reduces_tax_liability == o.reduces_tax_liability && calculation_type == o.calculation_type && percentage == o.percentage && subject_to_nic == o.subject_to_nic && subject_to_tax == o.subject_to_tax && is_reduced_by_basic_rate == o.is_reduced_by_basic_rate && apply_to_pension_calculations == o.apply_to_pension_calculations && == o. && is_pension == o.is_pension end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 339 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 |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
406 407 408 409 410 411 412 413 414 415 416 417 418 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 406 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end |
#build_from_hash(attributes) ⇒ Object
Builds the object from hash
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 318 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 |
#eql?(o) ⇒ Boolean
298 299 300 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 298 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
304 305 306 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 304 def hash [deduction_id, deduction_name, deduction_category, liability_account_id, current_record, standard_amount, reduces_super_liability, reduces_tax_liability, calculation_type, percentage, subject_to_nic, subject_to_tax, is_reduced_by_basic_rate, apply_to_pension_calculations, , is_pension].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 228 def list_invalid_properties invalid_properties = Array.new if @deduction_name.nil? invalid_properties.push('invalid value for "deduction_name", deduction_name cannot be nil.') end if @liability_account_id.nil? invalid_properties.push('invalid value for "liability_account_id", liability_account_id cannot be nil.') end invalid_properties end |
#parse_date(datestring) ⇒ Object
customized data_parser
421 422 423 424 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 421 def parse_date(datestring) seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 return Time.at(seconds_since_epoch).strftime('%Y-%m-%dT%l:%M:%S%z').to_s end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
386 387 388 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 386 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
392 393 394 395 396 397 398 399 400 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 392 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end hash end |
#to_s ⇒ String
Returns the string representation of the object
380 381 382 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 380 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
243 244 245 246 247 248 249 250 251 |
# File 'lib/xero-ruby/models/payroll_uk/deduction.rb', line 243 def valid? return false if @deduction_name.nil? deduction_category_validator = EnumAttributeValidator.new('String', ["CapitalContributions", "ChildCareVoucher", "MakingGood", "PostgraduateLoanDeductions", "PrivateUsePayments", "SalarySacrifice", "StakeholderPension", "StakeholderPensionPostTax", "StudentLoanDeductions", "UkOther"]) return false unless deduction_category_validator.valid?(@deduction_category) return false if @liability_account_id.nil? calculation_type_validator = EnumAttributeValidator.new('String', ["FixedAmount", "PercentageOfGross"]) return false unless calculation_type_validator.valid?(@calculation_type) true end |