eriksencosta/money
소개
Monetary calculations and allocations made easy
비즈니스 및 금융측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalMoney
Monetary calculations and allocations made easy.
Installation
Add Money to your Gradle build script:
repositories {
mavenCentral()
}
dependencies {
implementation("com.eriksencosta:money:0.2.0")
}
If you're using Maven, add to your POM xml file:
<dependency>
<groupId>com.eriksencosta</groupId>
<artifactId>money</artifactId>
<version>0.2.0</version>
</dependency>
Usage
The library provides a powerful yet simple API that makes monetary calculations easy:
val price = 100 money "USD" // USD 100.00
val shipping = 5 money "USD" // USD 5.00
val subtotal = price + shipping // USD 105.00
val discount = 10.percent() // 10%
val total = subtotal decreaseBy discount // USD 94.50
val ratios = listOf(60.percent(), 40.percent()) // [60%, 40%]
total allocate 2 // [USD 47.25, USD 47.25]
total allocate ratios // [USD 56.70, USD 37.80]
The library supports arithmetic operations with monetary amounts, calculations with percentages, and allocation, making it simple to model use cases like installment payments (e.g., buy now, pay later), foreign exchange, investment yields, and tax collection. Cryptocurrencies are also fully supported out of the box:
val price = 0.01607580 money "BTC" // BTC 0.01607580
val transactionFee = 1.25.percent() // 1.25%
val total = price increaseBy transactionFee // BTC 0.01627675
val installments = total allocate 3 // [BTC 0.00542559, BTC 0.00542558, BTC 0.00542558]
val rate = 62_555.60 money "USD" // USD 62555.60
val totalInUsd = total exchange rate // USD 1005.63
Refer to the documentation for more about how to work with monetary amounts, supported currencies, available operations, rounding, and allocation.
License
관련 프로젝트 살펴보기
불러오는 중…