all the refactor
This commit is contained in:
+19
-14
@@ -1,30 +1,35 @@
|
||||
package order
|
||||
|
||||
import "git.k6n.net/mats/go-cart-actor/pkg/cart"
|
||||
import (
|
||||
"git.k6n.net/mats/platform/money"
|
||||
"git.k6n.net/mats/platform/tax"
|
||||
)
|
||||
|
||||
// TaxProvider computes taxes for orders and line items.
|
||||
// The canonical definition is in pkg/cart; this is a re-export for
|
||||
// backward compatibility.
|
||||
type TaxProvider = cart.TaxProvider
|
||||
// The canonical definition is in platform/tax; this is a type alias
|
||||
// for backward compatibility.
|
||||
type TaxProvider = tax.Provider
|
||||
|
||||
// ComputeTax is the shared tax formula: tax = total x rate / (100 + rate).
|
||||
// Re-exported from pkg/cart for backward compatibility.
|
||||
func ComputeTax(total int64, taxRate int) int64 {
|
||||
return cart.ComputeTax(total, taxRate)
|
||||
// ComputeTax is the shared ex-VAT-first tax formula. rateBp is basis points
|
||||
// (2500 = 25%). Re-exported from platform/tax for backward compatibility.
|
||||
func ComputeTax(total money.Cents, rateBp int) money.Cents {
|
||||
return money.Cents(tax.Compute(total.Int64(), rateBp))
|
||||
}
|
||||
|
||||
// NordicTaxProvider implements TaxProvider for the Nordic countries.
|
||||
// Re-exported from pkg/cart for backward compatibility.
|
||||
type NordicTaxProvider = cart.NordicTaxProvider
|
||||
// Re-exported from platform/tax for backward compatibility.
|
||||
type NordicTaxProvider = tax.Nordic
|
||||
|
||||
// NewNordicTaxProvider returns a new NordicTaxProvider.
|
||||
func NewNordicTaxProvider(defaultCountry string) *NordicTaxProvider {
|
||||
return cart.NewNordicTaxProvider(defaultCountry)
|
||||
return tax.NewNordic(defaultCountry)
|
||||
}
|
||||
|
||||
// StaticTaxProvider is a stateless TaxProvider with no country awareness.
|
||||
// Re-exported from pkg/cart for backward compatibility.
|
||||
type StaticTaxProvider = cart.StaticTaxProvider
|
||||
// Re-exported from platform/tax for backward compatibility.
|
||||
type StaticTaxProvider = tax.Static
|
||||
|
||||
// NewStaticTaxProvider returns a new StaticTaxProvider.
|
||||
func NewStaticTaxProvider() *StaticTaxProvider {
|
||||
return cart.NewStaticTaxProvider()
|
||||
return tax.NewStatic()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user