{"action":"created","issue":{"url":"https://api.github.com/repos/stripe/stripe-ruby/issues/659","repository_url":"https://api.github.com/repos/stripe/stripe-ruby","labels_url":"https://api.github.com/repos/stripe/stripe-ruby/issues/659/labels{/name}","comments_url":"https://api.github.com/repos/stripe/stripe-ruby/issues/659/comments","events_url":"https://api.github.com/repos/stripe/stripe-ruby/issues/659/events","html_url":"https://github.com/stripe/stripe-ruby/issues/659","id":337155565,"node_id":"MDU6SXNzdWUzMzcxNTU1NjU=","number":659,"title":"InvoiceLineItem can't be deleted, only InvoiceItem can be deleted","user":{"login":"jmanian","id":6848109,"node_id":"MDQ6VXNlcjY4NDgxMDk=","avatar_url":"https://avatars0.githubusercontent.com/u/6848109?v=4","gravatar_id":"","url":"https://api.github.com/users/jmanian","html_url":"https://github.com/jmanian","followers_url":"https://api.github.com/users/jmanian/followers","following_url":"https://api.github.com/users/jmanian/following{/other_user}","gists_url":"https://api.github.com/users/jmanian/gists{/gist_id}","starred_url":"https://api.github.com/users/jmanian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmanian/subscriptions","organizations_url":"https://api.github.com/users/jmanian/orgs","repos_url":"https://api.github.com/users/jmanian/repos","events_url":"https://api.github.com/users/jmanian/events{/privacy}","received_events_url":"https://api.github.com/users/jmanian/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-29T22:32:09Z","updated_at":"2018-06-30T12:44:17Z","closed_at":"2018-06-30T12:44:17Z","author_association":"NONE","body":"I just had a scenario where I wanted to delete some invoice items from an upcoming invoice. We made a change to a subscription's plan, and we inadvertently allowed it to prorate the change. This generated some invoice items for the proration, so I wanted to delete those.\r\n\r\nThe first thing I tried was this:\r\n```ruby\r\ninvoice = Stripe::Invoice.upcoming(customer: 'cus_id')\r\ninvoice.lines.data.each do |line|\r\n  line.delete if line.proration\r\nend\r\n```\r\nThis didn't work:\r\n```ruby\r\nNoMethodError: undefined method `delete' for #<Stripe::InvoiceLineItem:0x00007fee96da9490>\r\n```\r\n\r\nSo I came up with this workaround, which works:\r\n```ruby\r\ninvoice = Stripe::Invoice.upcoming(customer: 'cus_id')\r\ninvoice.lines.data.each do |line|\r\n  Stripe::InvoiceItem.construct_from(id: line.id).delete if line.proration\r\nend\r\n```\r\n\r\nIt seems strange that the `InvoiceLineItem`s that come along with the upcoming `Invoice` can't be deleted directly. Maybe there's good reason for this, but I wanted to flag it since it seemed weird.\r\n\r\nAlso I'm unclear as to why `InvoiceLineItem` and `InvoiceItem` are separate classes, since they seem to represent the same underlying objects. Is there a reason for that?"},"comment":{"url":"https://api.github.com/repos/stripe/stripe-ruby/issues/comments/401538953","html_url":"https://github.com/stripe/stripe-ruby/issues/659#issuecomment-401538953","issue_url":"https://api.github.com/repos/stripe/stripe-ruby/issues/659","id":401538953,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMTUzODk1Mw==","user":{"login":"remi-stripe","id":9683352,"node_id":"MDQ6VXNlcjk2ODMzNTI=","avatar_url":"https://avatars0.githubusercontent.com/u/9683352?v=4","gravatar_id":"","url":"https://api.github.com/users/remi-stripe","html_url":"https://github.com/remi-stripe","followers_url":"https://api.github.com/users/remi-stripe/followers","following_url":"https://api.github.com/users/remi-stripe/following{/other_user}","gists_url":"https://api.github.com/users/remi-stripe/gists{/gist_id}","starred_url":"https://api.github.com/users/remi-stripe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/remi-stripe/subscriptions","organizations_url":"https://api.github.com/users/remi-stripe/orgs","repos_url":"https://api.github.com/users/remi-stripe/repos","events_url":"https://api.github.com/users/remi-stripe/events{/privacy}","received_events_url":"https://api.github.com/users/remi-stripe/received_events","type":"User","site_admin":false},"created_at":"2018-06-30T12:44:17Z","updated_at":"2018-06-30T12:44:17Z","author_association":"CONTRIBUTOR","body":"@jmanian `InvoiceLineItem` corresponds to the [Invoice Line Item object](https://stripe.com/docs/api#invoice_line_item_object) in our API. This represents one of the line items on a given object. It's seen as a read-only object which is why you can't delete it.\r\n\r\n`InvoiceItem` corresponds to the [Invoice Item object](https://stripe.com/docs/api#invoiceitem_object) in our API. This one can be [created](https://stripe.com/docs/api#create_invoiceitem), [updated](https://stripe.com/docs/api#update_invoiceitem) or even [deleted](https://stripe.com/docs/api#delete_invoiceitem). Those live on the customer and are seen as \"pending\". They get pulled into the next invoice and at that point turn into an Invoice Line Item instead.\r\n\r\nIf you want to delete one of those, you should not do this through the invoice. Instead, you would do this by listing them using [this API](https://stripe.com/docs/api#list_invoiceitems) and then deleting each one with this [API](https://stripe.com/docs/api#delete_invoiceitem)."}}
{"actor":{"display_login":"remi-stripe"}}