Comments (6)
@golusin AWESOME! Thanks! While Im here, anyway to get the invoice url from the api? Im stuck with this part.
from xeroizer.
I'm not sure you can create PAID invoices.
Also, you might want to use actual Date or Time objects.
On 10/10/2012, at 4:24 AM, Jared Moody [email protected] wrote:
I'm just getting started with the xero api and this gem, and while trying
to create and save an invoice, I'm getting the above error. Here's my code:
xero = Xeroizer::PrivateApplication.new("MY_CONSUMER_KEY",
"MY_SECRET_KEY", "/path/to/my/privatekey.pem")
build contact
contact = xero.Contact.build(
:name => "company",
:first_name => "john",
:last_name => "smith",
:email_address => "[email protected]",
:contact_number => "123"
)
contact.add_address(
:type => "STREET",
:line1 => "123 Any Street",
:city => "New York",
:region => "NY",
:postal_code => "11111",
:country => "United States"
)
contact.save
=> success!
build the invoiceinvoice = xero.Invoice.build(
:type => "ACCREC",
:contact => contact,
:date => "2010-10-01",
:due_date => "2012-10-01",
:line_amount_types => "NoTax",
:invoice_number => "123",
:status => "PAID"
)
invoice.add_line_item(
:description => "My Product",
:quantity => "1",
:unit_amount => "5.00",
:item_code => "120")
invoice.save
=> Xeroizer::ApiException
Am I doing something wrong here? I'm not sure where to begin debugging this.
Thanks!
—
Reply to this email directly or view it on
GitHubhttps://github.com//issues/38.
from xeroizer.
This error is also being caused by sending quantity, and amounts as strings as well..
invoice.add_line_item(
:description => "My Product",
:quantity => "1",
:unit_amount => "5.00",
:item_code => "120")
should be
invoice.add_line_item(
:description => "My Product",
:quantity => 1,
:unit_amount => 5.00,
:item_code => "120")
from xeroizer.
@mrmason Not really. I can have both string and ints and it works great. The issue, so far, you cannot have a status. Would be great to event have it "AUTHORISED".
# using the OP contact var
invoice = @xero.Invoice.build(
type: "ACCREC",
contact: contact,
sub_total: 99.00,
total_tax: 0.00,
total: 99.00,
currency_code: "GBP",
amount_due: 0.00,
amount_paid: 99.00,
sent_to_contact: false,
date: Time.now,
due_date: 7.days.from_now,
)
invoice.add_line_item(
description: "robot repair service",
unit_amount: "99.00",
line_amount: "99.00",
quantity: "1"
)
invoice.save
from xeroizer.
@waynerobinson It's 2016, can you mark invoice as paid soon?
from xeroizer.
@SylarRuby You can mark invoice as paid. You need to build and save Payment... something like this:
document = {
type: 'ACCREC',
status: 'AUTHORISED',
date: DateTime.now(),
due_date: DateTime.now(),
line_items: [
{
description: 'Product/Service description',
quantity: 1,
unit_amount: 100,
account_code: '200'
}
],
line_amount_types: "Exclusive",
contact: {
name: 'John Doe'
}
}
invoice = @xero.Invoice.build(document)
invoice.save
document_payment = {
invoice: invoice,
account: { :code => '090' },
date: invoice.due_date,
amount: invoice.amount_due,
payment_type: 'ACCRECPAYMENT'
}
payment = @xero.Payment.build(document_payment)
payment.save
For payment you can also pass Xero internal bank account id instead of bank account code. In that case account line should be something like this: account: { account_id: '98C4CEAD-7550-412D-9B72-004E2ABCC1F2C' }
from xeroizer.
Related Issues (20)
- Question: Does Xeroizer support OAuth 2? HOT 2
- `.sent_to_contact` on Invoices is undefined HOT 3
- Update the readme/documentation to include Oauth2Application HOT 2
- Xero Deprecation Notice - OAuth 1.0a HOT 1
- Timeout option not set correctly on OAuth 2 client HOT 3
- invoice.save returns false but invoice.errors is empty HOT 15
- New gem release? HOT 6
- How to get all the Items from Xero account HOT 1
- NameError: uninitialized constant Xeroizer::OAuth2Application HOT 4
- Double raise for expired tokens? HOT 2
- GET ERROR WHE do any object.save HOT 2
- trying to run tests as a developer... HOT 5
- syntax error, unexpected ',' in branding_theme.rb HOT 1
- Line Amount can not explicity be set to 0.00 if there is a discount
- Missing require somewhere: "uninitialized constant ActiveSupport::XmlMini::IsolatedExecutionState" when used outside of Rails HOT 3
- AuthorizationUnsuccessful error HOT 2
- ApiExceptions result in parse error
- Saving Quotes
- BankAccount Model Not Available?
- How to revoke token / delete current_connection HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xeroizer.