xero-ruby 9.0.0 → 9.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/lib/xero-ruby/api/payroll_nz_api.rb +330 -7
  3. data/lib/xero-ruby/models/accounting/bank_transactions.rb +13 -1
  4. data/lib/xero-ruby/models/accounting/contacts.rb +13 -1
  5. data/lib/xero-ruby/models/accounting/credit_notes.rb +13 -1
  6. data/lib/xero-ruby/models/accounting/invoices.rb +13 -1
  7. data/lib/xero-ruby/models/accounting/journals.rb +13 -1
  8. data/lib/xero-ruby/models/accounting/manual_journals.rb +13 -1
  9. data/lib/xero-ruby/models/accounting/overpayments.rb +13 -1
  10. data/lib/xero-ruby/models/accounting/payments.rb +13 -1
  11. data/lib/xero-ruby/models/accounting/prepayments.rb +13 -1
  12. data/lib/xero-ruby/models/accounting/purchase_orders.rb +13 -1
  13. data/lib/xero-ruby/models/payroll_nz/employee.rb +24 -4
  14. data/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb +24 -4
  15. data/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb +14 -4
  16. data/lib/xero-ruby/models/payroll_nz/employee_working_pattern.rb +242 -0
  17. data/lib/xero-ruby/models/payroll_nz/employee_working_pattern_with_working_weeks.rb +254 -0
  18. data/lib/xero-ruby/models/payroll_nz/employee_working_pattern_with_working_weeks_object.rb +242 -0
  19. data/lib/xero-ruby/models/payroll_nz/employee_working_pattern_with_working_weeks_request.rb +244 -0
  20. data/lib/xero-ruby/models/payroll_nz/employee_working_patterns_object.rb +244 -0
  21. data/lib/xero-ruby/models/payroll_nz/employment.rb +24 -4
  22. data/lib/xero-ruby/models/payroll_nz/salary_and_wage.rb +28 -4
  23. data/lib/xero-ruby/models/payroll_nz/working_week.rb +317 -0
  24. data/lib/xero-ruby/version.rb +2 -2
  25. data/lib/xero-ruby.rb +6 -0
  26. metadata +8 -2
@@ -0,0 +1,244 @@
1
+ =begin
2
+ #Xero Payroll NZ
3
+
4
+ #This is the Xero Payroll API for orgs in the NZ region.
5
+
6
+ Contact: api@xero.com
7
+ Generated by: https://openapi-generator.tech
8
+ OpenAPI Generator version: 4.3.1
9
+
10
+ =end
11
+
12
+ require 'time'
13
+ require 'date'
14
+
15
+ module XeroRuby::PayrollNz
16
+ require 'bigdecimal'
17
+
18
+ class EmployeeWorkingPatternsObject
19
+
20
+ attr_accessor :pagination
21
+
22
+
23
+ attr_accessor :problem
24
+
25
+
26
+ attr_accessor :payee_working_patterns
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'pagination' => :'pagination',
32
+ :'problem' => :'problem',
33
+ :'payee_working_patterns' => :'payeeWorkingPatterns'
34
+ }
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'pagination' => :'Pagination',
41
+ :'problem' => :'Problem',
42
+ :'payee_working_patterns' => :'Array<EmployeeWorkingPattern>'
43
+ }
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ if (!attributes.is_a?(Hash))
50
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::PayrollNz::EmployeeWorkingPatternsObject` initialize method"
51
+ end
52
+
53
+ # check to see if the attribute exists and convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h|
55
+ if (!self.class.attribute_map.key?(k.to_sym))
56
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::PayrollNz::EmployeeWorkingPatternsObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
57
+ end
58
+ h[k.to_sym] = v
59
+ }
60
+
61
+ if attributes.key?(:'pagination')
62
+ self.pagination = attributes[:'pagination']
63
+ end
64
+
65
+ if attributes.key?(:'problem')
66
+ self.problem = attributes[:'problem']
67
+ end
68
+
69
+ if attributes.key?(:'payee_working_patterns')
70
+ if (value = attributes[:'payee_working_patterns']).is_a?(Array)
71
+ self.payee_working_patterns = value
72
+ end
73
+ end
74
+ end
75
+
76
+ # Show invalid properties with the reasons. Usually used together with valid?
77
+ # @return Array for valid properties with the reasons
78
+ def list_invalid_properties
79
+ invalid_properties = Array.new
80
+ invalid_properties
81
+ end
82
+
83
+ # Check to see if the all the properties in the model are valid
84
+ # @return true if the model is valid
85
+ def valid?
86
+ true
87
+ end
88
+
89
+ # Checks equality by comparing each attribute.
90
+ # @param [Object] Object to be compared
91
+ def ==(o)
92
+ return true if self.equal?(o)
93
+ self.class == o.class &&
94
+ pagination == o.pagination &&
95
+ problem == o.problem &&
96
+ payee_working_patterns == o.payee_working_patterns
97
+ end
98
+
99
+ # @see the `==` method
100
+ # @param [Object] Object to be compared
101
+ def eql?(o)
102
+ self == o
103
+ end
104
+
105
+ # Calculates hash code according to all attributes.
106
+ # @return [Integer] Hash code
107
+ def hash
108
+ [pagination, problem, payee_working_patterns].hash
109
+ end
110
+
111
+ # Builds the object from hash
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ # @return [Object] Returns the model itself
114
+ def self.build_from_hash(attributes)
115
+ new.build_from_hash(attributes)
116
+ end
117
+
118
+ # Builds the object from hash
119
+ # @param [Hash] attributes Model attributes in the form of hash
120
+ # @return [Object] Returns the model itself
121
+ def build_from_hash(attributes)
122
+ return nil unless attributes.is_a?(Hash)
123
+ self.class.openapi_types.each_pair do |key, type|
124
+ if type =~ /\AArray<(.*)>/i
125
+ # check to ensure the input is an array given that the attribute
126
+ # is documented as an array but the input is not
127
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
128
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
129
+ end
130
+ elsif !attributes[self.class.attribute_map[key]].nil?
131
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
132
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
133
+ end
134
+
135
+ self
136
+ end
137
+
138
+ # Deserializes the data based on type
139
+ # @param string type Data type
140
+ # @param string value Value to be deserialized
141
+ # @return [Object] Deserialized data
142
+ def _deserialize(type, value)
143
+ case type.to_sym
144
+ when :DateTime
145
+ DateTime.parse(parse_date(value))
146
+ when :Date
147
+ Date.parse(parse_date(value))
148
+ when :String
149
+ value.to_s
150
+ when :Integer
151
+ value.to_i
152
+ when :Float
153
+ value.to_f
154
+ when :BigDecimal
155
+ BigDecimal(value.to_s)
156
+ when :Boolean
157
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
158
+ true
159
+ else
160
+ false
161
+ end
162
+ when :Object
163
+ # generic object (usually a Hash), return directly
164
+ value
165
+ when /\AArray<(?<inner_type>.+)>\z/
166
+ inner_type = Regexp.last_match[:inner_type]
167
+ value.map { |v| _deserialize(inner_type, v) }
168
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
169
+ k_type = Regexp.last_match[:k_type]
170
+ v_type = Regexp.last_match[:v_type]
171
+ {}.tap do |hash|
172
+ value.each do |k, v|
173
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
174
+ end
175
+ end
176
+ else # model
177
+ XeroRuby::PayrollNz.const_get(type).build_from_hash(value)
178
+ end
179
+ end
180
+
181
+ # Returns the string representation of the object
182
+ # @return [String] String presentation of the object
183
+ def to_s
184
+ to_hash.to_s
185
+ end
186
+
187
+ # to_body is an alias to to_hash (backward compatibility)
188
+ # @return [Hash] Returns the object in the form of hash
189
+ def to_body
190
+ to_hash
191
+ end
192
+
193
+ # Returns the object in the form of hash
194
+ # @return [Hash] Returns the object in the form of hash
195
+ def to_hash(downcase: false)
196
+ hash = {}
197
+ self.class.attribute_map.each_pair do |attr, param|
198
+ value = self.send(attr)
199
+ next if value.nil?
200
+ key = downcase ? attr : param
201
+ hash[key] = _to_hash(value, downcase: downcase)
202
+ end
203
+ hash
204
+ end
205
+
206
+ # Returns the object in the form of hash with snake_case
207
+ def to_attributes
208
+ to_hash(downcase: true)
209
+ end
210
+
211
+ # Outputs non-array value in the form of hash
212
+ # For object, use to_hash. Otherwise, just return the value
213
+ # @param [Object] value Any valid value
214
+ # @return [Hash] Returns the value in the form of hash
215
+ def _to_hash(value, downcase: false)
216
+ if value.is_a?(Array)
217
+ value.map do |v|
218
+ v.to_hash(downcase: downcase)
219
+ end
220
+ elsif value.is_a?(Hash)
221
+ {}.tap do |hash|
222
+ value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
223
+ end
224
+ elsif value.respond_to? :to_hash
225
+ value.to_hash(downcase: downcase)
226
+ else
227
+ value
228
+ end
229
+ end
230
+
231
+ def parse_date(datestring)
232
+ if datestring.include?('Date')
233
+ date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
234
+ original, date, timezone = *date_pattern.match(datestring)
235
+ date = (date.to_i / 1000)
236
+ Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
237
+ elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
238
+ Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
239
+ else # handle date 'types' for small subset of payroll API's
240
+ Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
241
+ end
242
+ end
243
+ end
244
+ end
@@ -25,12 +25,20 @@ module XeroRuby::PayrollNz
25
25
  # Start date of the employment (YYYY-MM-DD)
26
26
  attr_accessor :start_date
27
27
 
28
+ # Engagement type of the employee
29
+ attr_accessor :engagement_type
30
+
31
+ # End date for an employee with a fixed-term engagement type
32
+ attr_accessor :fixed_term_end_date
33
+
28
34
  # Attribute mapping from ruby-style variable name to JSON key.
29
35
  def self.attribute_map
30
36
  {
31
37
  :'payroll_calendar_id' => :'payrollCalendarID',
32
38
  :'pay_run_calendar_id' => :'payRunCalendarID',
33
- :'start_date' => :'startDate'
39
+ :'start_date' => :'startDate',
40
+ :'engagement_type' => :'engagementType',
41
+ :'fixed_term_end_date' => :'fixedTermEndDate'
34
42
  }
35
43
  end
36
44
 
@@ -39,7 +47,9 @@ module XeroRuby::PayrollNz
39
47
  {
40
48
  :'payroll_calendar_id' => :'String',
41
49
  :'pay_run_calendar_id' => :'String',
42
- :'start_date' => :'Date'
50
+ :'start_date' => :'Date',
51
+ :'engagement_type' => :'String',
52
+ :'fixed_term_end_date' => :'Date'
43
53
  }
44
54
  end
45
55
 
@@ -69,6 +79,14 @@ module XeroRuby::PayrollNz
69
79
  if attributes.key?(:'start_date')
70
80
  self.start_date = attributes[:'start_date']
71
81
  end
82
+
83
+ if attributes.key?(:'engagement_type')
84
+ self.engagement_type = attributes[:'engagement_type']
85
+ end
86
+
87
+ if attributes.key?(:'fixed_term_end_date')
88
+ self.fixed_term_end_date = attributes[:'fixed_term_end_date']
89
+ end
72
90
  end
73
91
 
74
92
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -91,7 +109,9 @@ module XeroRuby::PayrollNz
91
109
  self.class == o.class &&
92
110
  payroll_calendar_id == o.payroll_calendar_id &&
93
111
  pay_run_calendar_id == o.pay_run_calendar_id &&
94
- start_date == o.start_date
112
+ start_date == o.start_date &&
113
+ engagement_type == o.engagement_type &&
114
+ fixed_term_end_date == o.fixed_term_end_date
95
115
  end
96
116
 
97
117
  # @see the `==` method
@@ -103,7 +123,7 @@ module XeroRuby::PayrollNz
103
123
  # Calculates hash code according to all attributes.
104
124
  # @return [Integer] Hash code
105
125
  def hash
106
- [payroll_calendar_id, pay_run_calendar_id, start_date].hash
126
+ [payroll_calendar_id, pay_run_calendar_id, start_date, engagement_type, fixed_term_end_date].hash
107
127
  end
108
128
 
109
129
  # Builds the object from hash
@@ -51,6 +51,11 @@ module XeroRuby::PayrollNz
51
51
  SALARY ||= "Salary".freeze
52
52
  HOURLY ||= "Hourly".freeze
53
53
 
54
+ # The type of the Working Pattern of the corresponding salary and wages
55
+ attr_accessor :work_pattern_type
56
+ DAYS_AND_HOURS ||= "DaysAndHours".freeze
57
+ REGULAR_WEEK ||= "RegularWeek".freeze
58
+
54
59
  class EnumAttributeValidator
55
60
  attr_reader :datatype
56
61
  attr_reader :allowable_values
@@ -85,7 +90,8 @@ module XeroRuby::PayrollNz
85
90
  :'effective_from' => :'effectiveFrom',
86
91
  :'annual_salary' => :'annualSalary',
87
92
  :'status' => :'status',
88
- :'payment_type' => :'paymentType'
93
+ :'payment_type' => :'paymentType',
94
+ :'work_pattern_type' => :'workPatternType'
89
95
  }
90
96
  end
91
97
 
@@ -101,7 +107,8 @@ module XeroRuby::PayrollNz
101
107
  :'effective_from' => :'Date',
102
108
  :'annual_salary' => :'BigDecimal',
103
109
  :'status' => :'String',
104
- :'payment_type' => :'String'
110
+ :'payment_type' => :'String',
111
+ :'work_pattern_type' => :'String'
105
112
  }
106
113
  end
107
114
 
@@ -159,6 +166,10 @@ module XeroRuby::PayrollNz
159
166
  if attributes.key?(:'payment_type')
160
167
  self.payment_type = attributes[:'payment_type']
161
168
  end
169
+
170
+ if attributes.key?(:'work_pattern_type')
171
+ self.work_pattern_type = attributes[:'work_pattern_type']
172
+ end
162
173
  end
163
174
 
164
175
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -210,6 +221,8 @@ module XeroRuby::PayrollNz
210
221
  return false if @payment_type.nil?
211
222
  payment_type_validator = EnumAttributeValidator.new('String', ["Salary", "Hourly"])
212
223
  return false unless payment_type_validator.valid?(@payment_type)
224
+ work_pattern_type_validator = EnumAttributeValidator.new('String', ["DaysAndHours", "RegularWeek"])
225
+ return false unless work_pattern_type_validator.valid?(@work_pattern_type)
213
226
  true
214
227
  end
215
228
 
@@ -233,6 +246,16 @@ module XeroRuby::PayrollNz
233
246
  @payment_type = payment_type
234
247
  end
235
248
 
249
+ # Custom attribute writer method checking allowed values (enum).
250
+ # @param [Object] work_pattern_type Object to be assigned
251
+ def work_pattern_type=(work_pattern_type)
252
+ validator = EnumAttributeValidator.new('String', ["DaysAndHours", "RegularWeek"])
253
+ unless validator.valid?(work_pattern_type)
254
+ fail ArgumentError, "invalid value for \"work_pattern_type\", must be one of #{validator.allowable_values}."
255
+ end
256
+ @work_pattern_type = work_pattern_type
257
+ end
258
+
236
259
  # Checks equality by comparing each attribute.
237
260
  # @param [Object] Object to be compared
238
261
  def ==(o)
@@ -247,7 +270,8 @@ module XeroRuby::PayrollNz
247
270
  effective_from == o.effective_from &&
248
271
  annual_salary == o.annual_salary &&
249
272
  status == o.status &&
250
- payment_type == o.payment_type
273
+ payment_type == o.payment_type &&
274
+ work_pattern_type == o.work_pattern_type
251
275
  end
252
276
 
253
277
  # @see the `==` method
@@ -259,7 +283,7 @@ module XeroRuby::PayrollNz
259
283
  # Calculates hash code according to all attributes.
260
284
  # @return [Integer] Hash code
261
285
  def hash
262
- [salary_and_wages_id, earnings_rate_id, number_of_units_per_week, rate_per_unit, number_of_units_per_day, days_per_week, effective_from, annual_salary, status, payment_type].hash
286
+ [salary_and_wages_id, earnings_rate_id, number_of_units_per_week, rate_per_unit, number_of_units_per_day, days_per_week, effective_from, annual_salary, status, payment_type, work_pattern_type].hash
263
287
  end
264
288
 
265
289
  # Builds the object from hash