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

How to add discount value in quickbooks #216

Closed
zeeshananis opened this issue Feb 4, 2015 · 15 comments
Closed

How to add discount value in quickbooks #216

zeeshananis opened this issue Feb 4, 2015 · 15 comments

Comments

@zeeshananis
Copy link

Hi, i am new to quickbooks-ruby
just going through the code by how we can add percent discount using the below code:

discount_line_item = Quickbooks::Model::InvoiceLineItem.new
discount_line_item.amount = 149
discount_line_item.discount_item! do |detail|
detail.discount_percent = 10
detail.percent_based = true
detail.discount_account_id = 99
end
invoice.line_items << discount_line_item

but how can we add discount value in the transaction other than percent discount?

@bhaity
Copy link
Contributor

bhaity commented Feb 4, 2015

you could add a line item with a negative amount ?

@zeeshananis
Copy link
Author

ok thanks for your reply, but what will i add in item id column, and in this case i will be unable to see it as discount value we can see in quickbooks online like in this given screenshot

untitled

@minimul
Copy link
Collaborator

minimul commented Feb 4, 2015

Like this:

discount_line_item = Quickbooks::Model::InvoiceLineItem.new
discount_line_item.amount = 149
discount_line_item.discount_item! do |detail|
  detail.discount_account_id = 99
end
invoice.line_items << discount_line_item

XML

      <Line>
        <Amount>149.00</Amount>
        <DetailType>DiscountLineDetail</DetailType>
        <DiscountLineDetail>
          <DiscountAccountRef>99</DiscountAccountRef>
        </DiscountLineDetail>
      </Line>

@zeeshananis
Copy link
Author

Thanks minimul for your reply,i have a question here, as discount_account_id is optional as written by ruckus here
#70
so i leave it blank,which gives me below error message:
Required param missing, need to supply the required value for the API:
Required parameter Line.DiscountLineDetail is missing in the request

@minimul
Copy link
Collaborator

minimul commented Feb 4, 2015

Perhaps it is optional for percent-based discounts but not for value based. Try an account reference for discount_account_id. Should be an income account.

@zeeshananis
Copy link
Author

Thanks, currently i am working on sandbox, what can i add here as accountid

@minimul
Copy link
Collaborator

minimul commented Feb 4, 2015

Try 86

@zeeshananis
Copy link
Author

i tried it but no luck, it gives this message
Invalid Customer:
The customer you have specified has been deleted. You cannot create or edit a transaction with a deleted customer.

@ruckus
Copy link
Owner

ruckus commented Feb 4, 2015

Try it with an active Customer ID

On Feb 4, 2015, at 5:40 AM, zeeshananis notifications@github.com wrote:

i tried it but no luck, it gives this message
Invalid Customer:
The customer you have specified has been deleted. You cannot create or edit a transaction with a deleted customer.


Reply to this email directly or view it on GitHub.

@zeeshananis
Copy link
Author

I have tried with an active customer id but without discount line item it worked, but when i add discount line item having discount_account_id with active customer id, it gives me below message:

Invalid Reference Id:
Invalid Reference Id : Something you're trying to use has been deleted. Check the fields with accounts, customers, items, vendors or employees

Here is my invoice object while debugging:

{"line_items":[{"amount":"5.99","description":"Plush Baby Doll","detail_type":"SalesItemLineDetail","sales_line_item_detail":{"unit_price":"5.99","quantity":1,"item_ref":{"value":"36"}}},{"amount":1,"detail_type":"DiscountLineDetail","discount_line_detail":{"discount_account_ref":{"value":95}}}],"customer_ref":{"value":95},"txn_date":"2015-02-04","doc_number":""}

@minimul
Copy link
Collaborator

minimul commented Feb 4, 2015

Try discount_account_id = 86 or go to the API explorer at https://developer.intuit.com and do a

SELECT * FROM Account

to find a valid income account.

@zeeshananis
Copy link
Author

Thanks minimul for guidance, i found an active account by query and assigned to it and it worked

@gurmindersingh42
Copy link

Hi, i am new to quickbooks.
As mentioned above, we are using the the discount_account_id = 86 for the sandbox account. Does this id change when we shift the code on production mode?
Also these ids are different for different quickbook accounts?

@minimul
Copy link
Collaborator

minimul commented May 18, 2016

Yes and Yes.

@faisalsahil
Copy link

discount_account_id is optional. Here is my code with discount value and its working fine.

discount_line_item = Quickbooks::Model::InvoiceLineItem.new
discount_line_item.amount = 70
discount_line_item.discount_item! do |detail|
detail.percent_based = false
# detail.discount_percent = 10. // Its mandatory if percent_based is true
# detail.discount_account_id = 54. // Optional
end

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

No branches or pull requests

6 participants