-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from kimthu09/mai
Fix create invoice
- Loading branch information
Showing
10 changed files
with
268 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
package common | ||
|
||
import "math" | ||
import ( | ||
"math" | ||
) | ||
|
||
const maxDecimalNumber = 2 | ||
const maxDecimalNumber = 3 | ||
|
||
func roundToDecimal(num float32, decimalPlaces int) float32 { | ||
func RoundToDecimal(num float32, decimalPlaces int) float32 { | ||
shift := math.Pow10(decimalPlaces) | ||
return float32(math.Round(float64(num)*shift)) / float32(shift) | ||
} | ||
|
||
func CustomRound(num *float32) { | ||
roundedNum := roundToDecimal(*num, maxDecimalNumber) | ||
*num = roundedNum | ||
func RoundToInt(num float32) int { | ||
return int(RoundToDecimal(num, 0)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.