Coder Social home page Coder Social logo

Comments (6)

SylarRuby avatar SylarRuby commented on August 17, 2024 1

@golusin AWESOME! Thanks! While Im here, anyway to get the invoice url from the api? Im stuck with this part.

from xeroizer.

waynerobinson avatar waynerobinson commented on August 17, 2024

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.

mrmason avatar mrmason commented on August 17, 2024

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.

SylarRuby avatar SylarRuby commented on August 17, 2024

@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.

SylarRuby avatar SylarRuby commented on August 17, 2024

@waynerobinson It's 2016, can you mark invoice as paid soon?

from xeroizer.

golusin avatar golusin commented on August 17, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.