Skip to content

Commit

Permalink
Fix issue #21
Browse files Browse the repository at this point in the history
  • Loading branch information
angelodlfrtr committed Jan 6, 2023
1 parent 836cb19 commit 3498a76
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func (doc *Document) appendTotal() {
descString.WriteString(doc.ac.FormatMoneyDecimal(discountAmount))
descString.WriteString(" / -")
descString.WriteString(
discountAmount.Mul(decimal.NewFromFloat(100)).Div(doc.TotalWithoutTax()).StringFixed(2),
discountAmount.Mul(decimal.NewFromFloat(100)).Div(doc.TotalWithoutTaxAndWithoutDocumentDiscount()).StringFixed(2),
)
descString.WriteString(" %")
}
Expand Down
4 changes: 2 additions & 2 deletions generator_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package generator

import (
"io/ioutil"
"os"
"testing"
)

Expand Down Expand Up @@ -35,7 +35,7 @@ func TestNew(t *testing.T) {
doc.SetDate("02/03/2021")
doc.SetPaymentTerm("02/04/2021")

logoBytes, _ := ioutil.ReadFile("./example_logo.png")
logoBytes, _ := os.ReadFile("./example_logo.png")

doc.SetCompany(&Contact{
Name: "Test Company",
Expand Down
4 changes: 2 additions & 2 deletions totals.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (doc *Document) TotalWithTax() decimal.Decimal {

// Tax return the total tax with document discount
func (doc *Document) Tax() decimal.Decimal {
totalWithoutTax := doc.TotalWithoutTax()
totalWithoutTaxAndWithoutDocDiscount := doc.TotalWithoutTaxAndWithoutDocumentDiscount()
totalTax := decimal.NewFromFloat(0)

if doc.Discount == nil {
Expand All @@ -57,7 +57,7 @@ func (doc *Document) Tax() decimal.Decimal {
discountPercent := discountAmount
if discountType == DiscountTypeAmount {
// Get percent from total discounted
discountPercent = discountAmount.Mul(decimal.NewFromFloat(100)).Div(totalWithoutTax)
discountPercent = discountAmount.Mul(decimal.NewFromFloat(100)).Div(totalWithoutTaxAndWithoutDocDiscount)
}

for _, item := range doc.Items {
Expand Down

0 comments on commit 3498a76

Please sign in to comment.