Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Payroll API Branch #76

Open
waynerobinson opened this issue Apr 10, 2013 · 18 comments · May be fixed by #492
Open

Payroll API Branch #76

waynerobinson opened this issue Apr 10, 2013 · 18 comments · May be fixed by #492
Assignees
Milestone

Comments

@waynerobinson
Copy link
Owner

I have started a branch (called payroll) for implementing the upcoming Xero Payroll API into Xeroizer.

This is created under a completely separate endpoint and will require some significant refactoring to implement given some of the new complex data structures and the addition of response paging.

@ghost ghost assigned waynerobinson Apr 10, 2013
@ghiculescu
Copy link

fyi, the PHP and .NET APIs have been updated - https://community.xero.com/developer/discussion/1636240

Can I help with anything on the implementation of this? I'm keen to see it up and running as soon as possible!

@waynerobinson
Copy link
Owner Author

Happy to have some help on this as I have been swamped with other things.

You can look in the payroll branch.

Ultimately, because they've changed the API endpoint and there are some clashes in the namespaces, payroll has had to be implemented almost as a separate API.

I have done this via extending the existing record base classes to be payroll-specific and created a way to return a payroll endpint from an existing Xero one.

For example:

require "pp"
require "logger"
require File.dirname(__FILE__) + "/../lib/xeroizer"

xero = Xeroizer::PrivateApplication.new(
          XERO_AUTH,
          XERO_KEY,
          XERO_PK_FILE
       )
xero.logger = Logger.new(STDOUT)

payroll = xero.payroll
employees = payroll.Employee.all

I have created Employee, BankAccount and HomeAddress models so far (the easy ones), but there are a lot of object types in the new API that are mixed together that may also require underlying changes to the way the associations work, although maybe I was reading into this too much when I first read through the API at http://developer.xero.com/payroll-api

@ghiculescu
Copy link

You were right, there are a few schema changes. I started with Timesheets since that's the model I need most. The timesheet model has many "timesheet lines" (http://developer.xero.com/payroll-api/Timesheets/#TimesheetLines), each of which seems to have one "number of units". This is then made up of several "NumberOfUnit" elements.

I ended up adding another association type - has_array - to go with has_many and belongs_to. That's because I couldn't figure out any way of representing this association using existing associations. My changes and tests are committed at https://github.com/ghiculescu/xeroizer/commit/779d014c3388c320d18110a1d39919726afd38d2 - can you please take a look and let me know what you think.

Annoyingly, the only official Xero library - the .NET one - has the tests for new timesheets incomplete and commented out (see https://github.com/XeroAPI/XeroAPI.Net/blob/payroll/source/XeroApi.ConsoleTests/Payroll/PayrollApiWrite.cs#L17). So I didn't have much to go by. I'm going to email them and ask if there will be more examples.

@ghiculescu
Copy link

I've added PayItems (and LeaveApplications, though that's still a work in progress): https://github.com/ghiculescu/xeroizer/commit/27af99ff82bf31a4a45d5dd6ef978ef10ee0b283 I added a new class_inheritable_attributes - all_children_are_subtypes - to handle the PayItems schema. See comments on line 70 of base_model.rb for more info. As usual, any feedback is very welcome.

One thing I wanted to ask you; there are quite a few tests that fail on code that says:

parent.mark_dirty(self) if parent

With error:

NoMethodError: undefined method `mark_dirty' for #<Xeroizer::PublicApplication:0x007ffe82b60750>

These tests fail on the master branch too. I haven't attempted to fix them yet; just wanted to know if you were aware of this?

@ghiculescu
Copy link

Hi @waynerobinson - just wondering if you had a chance to take a look at this?

@layby42
Copy link
Contributor

layby42 commented Sep 4, 2013

Hi @waynerobinson, I've tried the payroll branch, read of Employee, BankAccount and HomeAddress works, attempt to write crashes. Do you plan to continue Xero Payroll API implementation?

@ghiculescu
Copy link

Hi @layby42, I wasn't aware of a crash on writes. Can you please give some example code and I will look into it. I've been using the payroll branch in production but currently we only write Timesheets (which explains why the wrapper isn't complete - I would like to see it done one day!)

@layby42
Copy link
Contributor

layby42 commented Sep 4, 2013

yes, here it is (the data is valid employee from Demo Company):

  1. payroll = xero.payroll
  2. xero_employee = payroll.Employee.find('9fc6fabc-d9b2-4ee6-96c7-b417f101e2e7')
  3. xero_employee.first_name = 'AAA'
  4. xero_employee.save <-- Net::HTTPBadRequest 400 Bad Request readbody=true

here is the trace:
method - post
endpoint - "/payroll.xro/1.0/Employees"
data:
"\n 9fc6fabc-d9b2-4ee6-96c7-b417f101e2e7\n Oliver\n Gray\n ACTIVE\n [email protected]\n 1966-05-28\n M\n \n Melbourne\n VIC\n 3000\n AUSTRALIA\n \n 0401 123 456\n 2012-12-02\n 893b9b0d-9352-4580-9ec8-09607ba72dc1\n 1de0197b-68cf-4ca2-bc30-2bd65eab13dc\n false\n \n \n Salary \n O Gray\n 234567\n 123451222\n true\n \n \n\n"

@layby42
Copy link
Contributor

layby42 commented Sep 4, 2013

Create employee seem to be OK (first & last name); trying to find out how to add HomeAddress and BankAccount

update: BankAccount: add_bank_account (just like add_line_item to invoice); create with BankAccount results into Net::HTTPBadRequest 400 Bad Request readbody=true

so the problem is with posting employee with nested elements like bank account(s) or home address

@waynerobinson
Copy link
Owner Author

This branch is an extremely early version of payroll support and no where
near ready for use.

I will definitely be supporting Payroll in the future, but I've not had any
time in the past few months to do so. Xeroizer is something I volunteer my
time for.

I'm always happy to review and merge pull requests. The best people to
write implementations are those making active use of the features.

On Thursday, September 5, 2013, Oxana Goutnik wrote:

Hi @waynerobinson https://github.com/waynerobinson, I've tried the
payroll branch, read of Employee, BankAccount and HomeAddress works,
attempt to write crashes. Do you plan to continue Xero Payroll API
implementation?


Reply to this email directly or view it on GitHubhttps://github.com//issues/76#issuecomment-23811611
.

@layby42
Copy link
Contributor

layby42 commented Sep 5, 2013

Hi @waynerobinson, I'm working on update for payroll branch.

@waynerobinson
Copy link
Owner Author

Cool.

On 5 September 2013 10:39, Oxana Goutnik [email protected] wrote:

Hi @waynerobinson https://github.com/waynerobinson, I'm working on
update for payroll branch.


Reply to this email directly or view it on GitHubhttps://github.com//issues/76#issuecomment-23836696
.

@ghiculescu
Copy link

Hi @layby42, had any luck? I was going to have a look into it otherwise. It looks like the issue is only coming when loading belongs_to associations from the API, but I didn't quite figure out why last time I looked.

@layby42
Copy link
Contributor

layby42 commented Sep 8, 2013

yes, there were 3 issues:

  • Bsb to BSB in xml ; this is the easiest part;
  • belongs_to.. I've changed it to has_one for home address, which looks more appropriate (belongs_to generated wrong parent note when submitting xml), and implemented handlers for has_one; and set_home_address for has_one instead of add_home_address, since we want to have only one home address;
  • address_line_1 & String.underscore: better name address_line1, address_line2, etc. to use underscore

current status: create & update data works; everything goes to Xero without issues; have to finish with reading has_one (home_address) from Xero API properly and implement tests.

If you'd like to look into it yourself as well, please do -)

@layby42
Copy link
Contributor

layby42 commented Oct 23, 2013

https://github.com/syreclabs/xeroizer, payroll branch is relatively OK, we are using it on production. Fixed several bugs in my last pull request that was committed to waynerobinson/xeroizer payroll, has bank_account, tax_declaration, super funds, superannuation memberships. Also rebased on current waynerobinson/xeroizer master.
Pay templates are in progress in https://github.com/syreclabs/xeroizer.

@waynerobinson
Copy link
Owner Author

Feel free to submit these back to here if you like.

@rept
Copy link

rept commented Oct 2, 2019

What's the status on the payroll branch? Could I use that branch and support both Accounting and Payroll ?

@CloCkWeRX CloCkWeRX linked a pull request Oct 17, 2019 that will close this issue
@CloCkWeRX
Copy link
Collaborator

So, I tentatively merged some of the payroll work to master; stuck a 3.0.0-beta on the version and prepped a PR (wildly untested) in #492.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants