Skip to content

Commit

Permalink
Merge pull request #20 from two-inc/brtknr/t-13933-calculate-tax-amou…
Browse files Browse the repository at this point in the history
…nt-from-net-amount

fix: Calculate tax amount from net amount
  • Loading branch information
brtkwr authored Nov 7, 2023
2 parents 3cfa26f + 32d4b2e commit 1947ac8
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
15 changes: 12 additions & 3 deletions Service/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function getLineItemsOrder(OrderModel $order): array
'net_amount' => $this->roundAmt($this->getNetAmountItem($item)),
'tax_amount' => $this->roundAmt($this->getTaxAmountItem($item)),
'discount_amount' => $this->roundAmt($this->getDiscountAmountItem($item)),
'tax_rate' => $this->roundAmt(($item->getTaxPercent() / 100)),
'tax_rate' => $this->roundAmt($this->getTaxRateItem($item)),
'tax_class_name' => 'VAT ' . $this->roundAmt($item->getTaxPercent()) . '%',
'unit_price' => $this->roundAmt($this->getUnitPriceItem($item), 5),
'quantity' => $item->getQtyOrdered(),
Expand Down Expand Up @@ -257,7 +257,16 @@ public function getNetAmountItem($item): float
*/
public function getUnitPriceItem($item): float
{
return (float)$item->getRowTotalInclTax() / (1 + $item->getTaxPercent() / 100) / $item->getQtyOrdered();
return (float)$item->getRowTotalInclTax() / (1 + $this->getTaxRateItem($item)) / $item->getQtyOrdered();
}

/**
* @param OrderItem|InvoiceItem|CreditmemoItem $item
* @return float
*/
public function getTaxRateItem($item): float
{
return $item->getTaxPercent() / 100;
}

/**
Expand All @@ -266,7 +275,7 @@ public function getUnitPriceItem($item): float
*/
public function getTaxAmountItem($item): float
{
return (float)$item->getTaxAmount();
return $this->getNetAmountItem($item) * $this->getTaxRateItem($item);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion bumpver.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.bumpver]
current_version = "1.3.1"
current_version = "1.3.2"
version_pattern = "MAJOR.MINOR.PATCH[-TAGNUM]"
commit_message = "chore: Bump version {old_version} -> {new_version}"
commit = true
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "two-inc/magento2",
"description": "Two B2B BNPL payments extension",
"type": "magento2-module",
"version": "1.3.1",
"version": "1.3.2",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<payment>
<two_payment>
<active>1</active>
<version>1.3.1</version>
<version>1.3.2</version>
<title>Business invoice in 30 days</title>
<mode>sandbox</mode>
<invoice_type>FUNDED_INVOICE</invoice_type>
Expand Down
29 changes: 15 additions & 14 deletions view/frontend/web/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
--color-gray89: #e3e3e3;
--color-brownie-vanilla: #736963;
--color-white: #fff;
--color-color-blue2: #3043d1;
--color-blue2: #3043d1;
}

#two_gateway_form {
Expand Down Expand Up @@ -34,15 +34,15 @@ input#two_payment:before {

.enter_details_manually {
cursor: pointer;
color: var(--color-color-blue2);
color: var(--color-blue2);
padding: 5px;
}

.search_for_company {
text-align: right;
cursor: pointer;
padding-top: 5px;
color: var(--color-color-blue2);
color: var(--color-blue2);
right: 4px;
}

Expand Down Expand Up @@ -81,7 +81,7 @@ input#two_payment:before {
.what_is_two_popup {
margin: 70px auto;
padding: 20px;
background: #fff;
background: var(--color-white);
border-radius: 10px;
width: 200px;
height: 330px;
Expand All @@ -95,7 +95,12 @@ input#two_payment:before {
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: #333;
color: var(--color-gray89);
cursor: pointer;
}

.what_is_two_popup .close:hover {
color: var(--color-blue2);
}

.what_is_two_popup img {
Expand All @@ -105,10 +110,6 @@ input#two_payment:before {
width: 40%;
}

.what_is_two_popup .close:hover {
color: #06D85F;
}

.what_is_two_popup .content {
height: 100%;
overflow: none;
Expand All @@ -122,7 +123,7 @@ input#two_payment:before {
padding: 5px 10px;
border-radius: 5px;
border: 1px solid var(--color-gray89);
color: var(--color-color-blue2);
color: var(--color-blue2);
background-color: var(--color-white);
}

Expand Down Expand Up @@ -158,14 +159,14 @@ input#two_payment:before {
}

.mode_selector [data-element="click-element"] {
color: var(--color-color-blue2);
color: var(--color-blue2);
background-color: var(--color-white);
cursor: pointer;
}

.mode_selector [data-element="selected-element"] {
color: var(--color-white);
background-color: var(--color-color-blue2);
background-color: var(--color-blue2);
}

/* Sole trader part */
Expand All @@ -186,7 +187,7 @@ input#two_payment:before {
}

.sole_trader_note [data-element="click-element"] {
color: var(--color-color-blue2);
color: var(--color-blue2);
text-decoration: underline;
text-underline-offset: 2px;
cursor: pointer;
Expand All @@ -197,7 +198,7 @@ input#two_payment:before {
}

.popup_message [data-element="click-element"] {
color: var(--color-color-blue2);
color: var(--color-blue2);
text-decoration: underline;
text-underline-offset: 2px;
cursor: pointer;
Expand Down

0 comments on commit 1947ac8

Please sign in to comment.