missing updates #5
@@ -25,7 +25,7 @@ func NewPrice() *Price {
|
|||||||
func NewPriceFromIncVat(incVat int64, taxRate float32) *Price {
|
func NewPriceFromIncVat(incVat int64, taxRate float32) *Price {
|
||||||
tax := GetTaxAmount(incVat, int(taxRate*100))
|
tax := GetTaxAmount(incVat, int(taxRate*100))
|
||||||
return &Price{
|
return &Price{
|
||||||
IncVat: incVat - tax,
|
IncVat: incVat,
|
||||||
VatRates: map[float32]int64{
|
VatRates: map[float32]int64{
|
||||||
taxRate: tax,
|
taxRate: tax,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -32,6 +32,19 @@ func TestPriceMarshalJSON(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewPriceFromIncVat(t *testing.T) {
|
||||||
|
p := NewPriceFromIncVat(1000, 0.25)
|
||||||
|
if p.IncVat != 1000 {
|
||||||
|
t.Fatalf("expected IncVat %d got %d", 1000, p.IncVat)
|
||||||
|
}
|
||||||
|
if p.VatRates[25] != 250 {
|
||||||
|
t.Fatalf("expected VAT 25 rate %d got %d", 250, p.VatRates[25])
|
||||||
|
}
|
||||||
|
if p.ValueExVat() != 750 {
|
||||||
|
t.Fatalf("expected exVat %d got %d", 750, p.ValueExVat())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestSumPrices(t *testing.T) {
|
func TestSumPrices(t *testing.T) {
|
||||||
// We'll construct prices via raw struct since constructor expects tax math.
|
// We'll construct prices via raw struct since constructor expects tax math.
|
||||||
// IncVat already includes vat portions.
|
// IncVat already includes vat portions.
|
||||||
|
|||||||
Reference in New Issue
Block a user