Good Morning,
I am stuck here with the following problem:
For an invoice-object I need all tax-percentages, tax-amounts and
total without tax that were processed within this invoice
Eg:
20%, 5€, 25€
10%,5€,50€
0%,0€,100€
...
How can I achieve that? is there any documentation about the classes in Magento2?
For the moment it is just trial and error for me
Solved! Go to Solution.
Hello,
Let's example you have invoice item and object name for invoice item is $invoiceItem
echo $invoiceItem->getOrderItem()->getTaxPercent()
By above code you will get Percentage for specific item.
If it will work or help you then mark as solution
Hello,
Hope you have invoice object
let's example your invoice object name is $invoice
echo $invoice->getTaxAmount();
above code for get Tax value from invoice
echo $invoice->getBaseGrandTotal();
above code get base total.
for percentage you will get from all invoice item.
Hope it will work for you.
If it will help you, then mark as solution
Hello,
Let's example you have invoice item and object name for invoice item is $invoiceItem
echo $invoiceItem->getOrderItem()->getTaxPercent()
By above code you will get Percentage for specific item.
If it will work or help you then mark as solution
is that work for you?
@kornblumenapo, you can loop all the items of invoice object and create an array for tax percentage based on product if or sku & then do rest calculation.$taxes
$taxes = []; foreach ($invoice->getAllItems() as $item) { $taxes[$item->getProductId()] = $item->getTaxPercent(); }
Then in $taxes, you will get taxes for each product id.