Your Help Group

How We Pass Discount in Invoice/Bill Using Quickbooks Api

Hi All
Welcome to the network. i might be glad to stroll you via with including a Discount on an invoice in QuickBooks online using api.you may need to apply a discount line item in case you need to apply a discount to one or greater objects on the invoice. You ought to create a discount object first earlier than making use of it on the invoice/bill.I will share the code today for add discount using the QB api.How we create the discount object into invoice or bill api object.We can either pass discount as percentage or fixed price.Please check code below.

Code Block Example

					    
                            First we create the line item object like below
$itemLine[] =array( 
'Amount'=>$price*$details['quantity'], 
 'DetailType'=>'SalesItemLineDetail', 
"Description"=>$details['title'],   
'SalesItemLineDetail'=>array( 
  "Qty"=> $details['quantity'],  
    "UnitPrice"=> $price,  
'ItemRef'=>array(   
'value'=>$itemId, 
  'name'=>''     
),   
"TaxCodeRef"=>[   
    "value"=> '7'           
        ], 
    ),   
          );  
          Then add discount object into same array$discountamt = 20;   
    $itemLine[]=array(   
  'Amount'=>$discountamt,   
         'DetailType'=>'DiscountLineDetail',     
       "DiscountLineDetail"=>array(     
          'PercentBased'=>false       
                  ),       
            );
Then add option when discount is applied before tax or after tax.
 'ApplyTaxAfterDiscount'=>false