Changed money to use "cents" so it's consistent with ruby-money Money object
This commit is contained in:
parent
914b06dc84
commit
01e1a67b9e
23 changed files with 83 additions and 84 deletions
|
@ -1,6 +1,6 @@
|
||||||
// License: LGPL-3.0-or-later
|
// License: LGPL-3.0-or-later
|
||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
import { Money, Operand, RoundingMode } from './money';
|
import { Money, MoneyAsJson, Operand, RoundingMode } from './money';
|
||||||
|
|
||||||
describe("Money", () => {
|
describe("Money", () => {
|
||||||
describe('Money.fromCents', () => {
|
describe('Money.fromCents', () => {
|
||||||
|
@ -15,7 +15,7 @@ describe("Money", () => {
|
||||||
});
|
});
|
||||||
it('succeeds from a json', () => {
|
it('succeeds from a json', () => {
|
||||||
expect.hasAssertions();
|
expect.hasAssertions();
|
||||||
const old = { amount: 333, currency: 'eur' };
|
const old:MoneyAsJson = { cents: 333, currency: 'eur' };
|
||||||
|
|
||||||
const result = Money.fromCents(old);
|
const result = Money.fromCents(old);
|
||||||
// eslint-disable-next-line jest/prefer-strict-equal
|
// eslint-disable-next-line jest/prefer-strict-equal
|
||||||
|
@ -28,7 +28,7 @@ describe("Money", () => {
|
||||||
expect.hasAssertions();
|
expect.hasAssertions();
|
||||||
const old = Money.fromCents(333, 'eur');
|
const old = Money.fromCents(333, 'eur');
|
||||||
|
|
||||||
const result = Money.fromCents({ amount: '333', currency: 'eur' });
|
const result = Money.fromCents({ cents: '333', currency: 'eur' });
|
||||||
// eslint-disable-next-line jest/prefer-strict-equal
|
// eslint-disable-next-line jest/prefer-strict-equal
|
||||||
expect(result).toEqual(old);
|
expect(result).toEqual(old);
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ describe("Money", () => {
|
||||||
expect.hasAssertions();
|
expect.hasAssertions();
|
||||||
const result = Money.fromCents(333, 'eur');
|
const result = Money.fromCents(333, 'eur');
|
||||||
// eslint-disable-next-line jest/prefer-strict-equal
|
// eslint-disable-next-line jest/prefer-strict-equal
|
||||||
expect(result).toEqual({ amount: 333, currency: 'eur' });
|
expect(result).toEqual({ cents: 333, currency: 'eur' });
|
||||||
|
|
||||||
expect(result).toBeInstanceOf(Money);
|
expect(result).toBeInstanceOf(Money);
|
||||||
});
|
});
|
||||||
|
@ -48,7 +48,7 @@ describe("Money", () => {
|
||||||
expect.hasAssertions();
|
expect.hasAssertions();
|
||||||
const result = Money.fromCents(new BigNumber(333), 'eur');
|
const result = Money.fromCents(new BigNumber(333), 'eur');
|
||||||
// eslint-disable-next-line jest/prefer-strict-equal
|
// eslint-disable-next-line jest/prefer-strict-equal
|
||||||
expect(result).toEqual({ amount: 333, currency: 'eur' });
|
expect(result).toEqual({ cents: 333, currency: 'eur' });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rejects if string is not an integer', () => {
|
it('rejects if string is not an integer', () => {
|
||||||
|
@ -170,7 +170,7 @@ describe("Money", () => {
|
||||||
describe('.divide', () => {
|
describe('.divide', () => {
|
||||||
it('divides 36 into 9', () => {
|
it('divides 36 into 9', () => {
|
||||||
expect.assertions(1);
|
expect.assertions(1);
|
||||||
expect(Money.fromCents(36, 'usd').divide(9).toJSON()).toStrictEqual({amount: 4, currency: 'usd'});
|
expect(Money.fromCents(36, 'usd').divide(9).toJSON()).toStrictEqual({cents: 4, currency: 'usd'});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws if the currencies do not match', () => {
|
it('throws if the currencies do not match', () => {
|
||||||
|
@ -180,27 +180,27 @@ describe("Money", () => {
|
||||||
|
|
||||||
it('defaults to rounding to HalfUp', () => {
|
it('defaults to rounding to HalfUp', () => {
|
||||||
expect.assertions(3);
|
expect.assertions(3);
|
||||||
expect(Money.fromCents(40, 'usd').divide(Money.fromCents(9, 'usd')).toJSON()).toStrictEqual({amount: 4, currency: 'usd'});
|
expect(Money.fromCents(40, 'usd').divide(Money.fromCents(9, 'usd')).toJSON()).toStrictEqual({cents: 4, currency: 'usd'});
|
||||||
|
|
||||||
expect(Money.fromCents(41, 'usd').divide(Money.fromCents(9, 'usd')).toJSON()).toStrictEqual({amount: 5, currency: 'usd'});
|
expect(Money.fromCents(41, 'usd').divide(Money.fromCents(9, 'usd')).toJSON()).toStrictEqual({cents: 5, currency: 'usd'});
|
||||||
|
|
||||||
expect(Money.fromCents(7, 'usd').divide(Money.fromCents(2, 'usd')).toJSON()).toStrictEqual({amount: 4, currency: 'usd'});
|
expect(Money.fromCents(7, 'usd').divide(Money.fromCents(2, 'usd')).toJSON()).toStrictEqual({cents: 4, currency: 'usd'});
|
||||||
});
|
});
|
||||||
it('rounds to floor if requested', () => {
|
it('rounds to floor if requested', () => {
|
||||||
expect.assertions(1);
|
expect.assertions(1);
|
||||||
expect(Money.fromCents(41, 'usd').divide(Money.fromCents(9, 'usd'), RoundingMode.Floor).toJSON()).toStrictEqual({amount: 4, currency: 'usd'});
|
expect(Money.fromCents(41, 'usd').divide(Money.fromCents(9, 'usd'), RoundingMode.Floor).toJSON()).toStrictEqual({cents: 4, currency: 'usd'});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rounds to ceil if requested', () => {
|
it('rounds to ceil if requested', () => {
|
||||||
expect.assertions(1);
|
expect.assertions(1);
|
||||||
expect(Money.fromCents(40, 'usd').divide(Money.fromCents(9, 'usd'), RoundingMode.Ceil).toJSON()).toStrictEqual({amount: 5, currency: 'usd'});
|
expect(Money.fromCents(40, 'usd').divide(Money.fromCents(9, 'usd'), RoundingMode.Ceil).toJSON()).toStrictEqual({cents: 5, currency: 'usd'});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.multiply', () => {
|
describe('.multiply', () => {
|
||||||
it('multiply 9 x 4', () => {
|
it('multiply 9 x 4', () => {
|
||||||
expect.assertions(1);
|
expect.assertions(1);
|
||||||
expect(Money.fromCents(9, 'usd').multiply(4).toJSON()).toStrictEqual({amount: 36, currency: 'usd'});
|
expect(Money.fromCents(9, 'usd').multiply(4).toJSON()).toStrictEqual({cents: 36, currency: 'usd'});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws if the currencies do not match', () => {
|
it('throws if the currencies do not match', () => {
|
||||||
|
@ -210,22 +210,22 @@ describe("Money", () => {
|
||||||
|
|
||||||
it('handles multiplying by a decimal properly', () => {
|
it('handles multiplying by a decimal properly', () => {
|
||||||
expect.assertions(1);
|
expect.assertions(1);
|
||||||
expect(Money.fromCents('3', 'usd').multiply(new BigNumber('1.263')).toJSON()).toStrictEqual({amount: 4, currency: 'usd'});
|
expect(Money.fromCents('3', 'usd').multiply(new BigNumber('1.263')).toJSON()).toStrictEqual({cents: 4, currency: 'usd'});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('defaults to rounding to HalfUp', () => {
|
it('defaults to rounding to HalfUp', () => {
|
||||||
expect.assertions(1);
|
expect.assertions(1);
|
||||||
expect(Money.fromCents(7, 'usd').multiply(new BigNumber('.5')).toJSON()).toStrictEqual({amount: 4, currency: 'usd'});
|
expect(Money.fromCents(7, 'usd').multiply(new BigNumber('.5')).toJSON()).toStrictEqual({cents: 4, currency: 'usd'});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rounds to floor if requested', () => {
|
it('rounds to floor if requested', () => {
|
||||||
expect.assertions(1);
|
expect.assertions(1);
|
||||||
expect(Money.fromCents('3', 'usd').multiply('1.263', RoundingMode.Floor).toJSON()).toStrictEqual({amount: 3, currency: 'usd'});
|
expect(Money.fromCents('3', 'usd').multiply('1.263', RoundingMode.Floor).toJSON()).toStrictEqual({cents: 3, currency: 'usd'});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rounds to ceil if requested', () => {
|
it('rounds to ceil if requested', () => {
|
||||||
expect.assertions(1);
|
expect.assertions(1);
|
||||||
expect(Money.fromCents('3', 'usd').multiply('1.263', RoundingMode.Ceil).toJSON()).toStrictEqual({amount: 4, currency: 'usd'});
|
expect(Money.fromCents('3', 'usd').multiply('1.263', RoundingMode.Ceil).toJSON()).toStrictEqual({cents: 4, currency: 'usd'});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ function coerceToBigNumber(operand:unknown, mustBeInteger=false): BigNumber {
|
||||||
}
|
}
|
||||||
else if (typeof operand === 'object') {
|
else if (typeof operand === 'object') {
|
||||||
//it's MoneyAsJson
|
//it's MoneyAsJson
|
||||||
bigNumber = new BigNumber((operand as MoneyAsJson).amount);
|
bigNumber = new BigNumber((operand as MoneyAsJson).cents);
|
||||||
}
|
}
|
||||||
else if(typeof operand === 'string') {
|
else if(typeof operand === 'string') {
|
||||||
bigNumberDebug(() => {
|
bigNumberDebug(() => {
|
||||||
|
@ -54,8 +54,8 @@ function coerceToBigNumber(operand:unknown, mustBeInteger=false): BigNumber {
|
||||||
return bigNumber;
|
return bigNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MoneyAsJson = { amount: number, currency: string };
|
export type MoneyAsJson = { cents: number, currency: string };
|
||||||
type StringyMoneyAsJson = {amount:string, currency: string};
|
type StringyMoneyAsJson = { cents:string, currency: string };
|
||||||
|
|
||||||
export type Operand = number | Money | BigNumber | string;
|
export type Operand = number | Money | BigNumber | string;
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ export class Money {
|
||||||
*/
|
*/
|
||||||
readonly currency: string;
|
readonly currency: string;
|
||||||
|
|
||||||
protected constructor(readonly amount: number, currency: string) {
|
protected constructor(readonly cents: number, currency: string) {
|
||||||
this.currency = currency.toLowerCase();
|
this.currency = currency.toLowerCase();
|
||||||
const methodsToBind = [this.equals, this.add, this.subtract, this.multiply, this.divide,
|
const methodsToBind = [this.equals, this.add, this.subtract, this.multiply, this.divide,
|
||||||
this.compare, this.greaterThan, this.greaterThanOrEqual, this.lessThan,
|
this.compare, this.greaterThan, this.greaterThanOrEqual, this.lessThan,
|
||||||
|
@ -326,7 +326,7 @@ export class Money {
|
||||||
* Get the amount of the Money instance as a `BigNumber`.
|
* Get the amount of the Money instance as a `BigNumber`.
|
||||||
*/
|
*/
|
||||||
toBigNumber() : BigNumber {
|
toBigNumber() : BigNumber {
|
||||||
return new BigNumber(this.amount);
|
return new BigNumber(this.cents);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -336,7 +336,7 @@ export class Money {
|
||||||
*/
|
*/
|
||||||
toJSON(): MoneyAsJson {
|
toJSON(): MoneyAsJson {
|
||||||
return {
|
return {
|
||||||
amount: this.amount,
|
cents: this.cents,
|
||||||
currency: this.currency,
|
currency: this.currency,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ function FormikInner(props: { onChange:(args:{value:Money})=> void}) {
|
||||||
onChange({value});
|
onChange({value});
|
||||||
}, [value, onChange]);
|
}, [value, onChange]);
|
||||||
|
|
||||||
return <><div><span aria-label="amount">{value.amount}</span><span aria-label="currency">{value.currency}</span></div>
|
return <><div><span aria-label="amount">{value.cents}</span><span aria-label="currency">{value.currency}</span></div>
|
||||||
<Field component={MoneyTextField} name="value" aria-label="field"/></>;
|
<Field component={MoneyTextField} name="value" aria-label="field"/></>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ FormikHandler.defaultProps = {
|
||||||
describe('MoneyTextField', () => {
|
describe('MoneyTextField', () => {
|
||||||
it('displays the $8.00 when Money of {800, usd} is passed in', async () => {
|
it('displays the $8.00 when Money of {800, usd} is passed in', async () => {
|
||||||
expect.hasAssertions();
|
expect.hasAssertions();
|
||||||
const result = render(<FormikHandler value={Money.fromCents({ amount: 800, currency: 'usd' })} />);
|
const result = render(<FormikHandler value={Money.fromCents({ cents: 800, currency: 'usd' })} />);
|
||||||
const field = result.container.querySelector("input[name=value]");
|
const field = result.container.querySelector("input[name=value]");
|
||||||
expect(field).toHaveValue("$8.00");
|
expect(field).toHaveValue("$8.00");
|
||||||
const amount = await result.findByLabelText('amount');
|
const amount = await result.findByLabelText('amount');
|
||||||
|
@ -54,7 +54,7 @@ describe('MoneyTextField', () => {
|
||||||
|
|
||||||
it('displays the 8.00 € when Money of {800, eur} is passed in', async () => {
|
it('displays the 8.00 € when Money of {800, eur} is passed in', async () => {
|
||||||
expect.hasAssertions();
|
expect.hasAssertions();
|
||||||
const result = render(<FormikHandler value={Money.fromCents({ amount: 800, currency: 'eur' })} />);
|
const result = render(<FormikHandler value={Money.fromCents({ cents: 800, currency: 'eur' })} />);
|
||||||
const field = result.container.querySelector("input[name=value]");
|
const field = result.container.querySelector("input[name=value]");
|
||||||
expect(field).toHaveValue("€8.00");
|
expect(field).toHaveValue("€8.00");
|
||||||
const amount = await result.findByLabelText('amount');
|
const amount = await result.findByLabelText('amount');
|
||||||
|
@ -66,7 +66,7 @@ describe('MoneyTextField', () => {
|
||||||
|
|
||||||
it('displays the ¥800 when Money of {800, jpy} is passed in', async () => {
|
it('displays the ¥800 when Money of {800, jpy} is passed in', async () => {
|
||||||
expect.hasAssertions();
|
expect.hasAssertions();
|
||||||
const result = render(<FormikHandler value={Money.fromCents({ amount: 800, currency: 'jpy' })} />);
|
const result = render(<FormikHandler value={Money.fromCents({ cents: 800, currency: 'jpy' })} />);
|
||||||
const field = result.container.querySelector("input[name=value]");
|
const field = result.container.querySelector("input[name=value]");
|
||||||
expect(field).toHaveValue("¥800");
|
expect(field).toHaveValue("¥800");
|
||||||
const amount = await result.findByLabelText('amount');
|
const amount = await result.findByLabelText('amount');
|
||||||
|
@ -79,7 +79,7 @@ describe('MoneyTextField', () => {
|
||||||
|
|
||||||
it('displays the $8.00 when Money of {100, usd} is passed in and then the amount changes to 8.00', async () => {
|
it('displays the $8.00 when Money of {100, usd} is passed in and then the amount changes to 8.00', async () => {
|
||||||
expect.hasAssertions();
|
expect.hasAssertions();
|
||||||
const result = render(<FormikHandler value={Money.fromCents({ amount: 100, currency: 'usd' })} />);
|
const result = render(<FormikHandler value={Money.fromCents({ cents: 100, currency: 'usd' })} />);
|
||||||
const field = result.container.querySelector("input[name=value]");
|
const field = result.container.querySelector("input[name=value]");
|
||||||
expect(field).toHaveValue("$1.00");
|
expect(field).toHaveValue("$1.00");
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ describe('MoneyTextField', () => {
|
||||||
|
|
||||||
it('displays the $80.00 when Money of {800, usd} is passed in and then the amount changes to 8.000', async () => {
|
it('displays the $80.00 when Money of {800, usd} is passed in and then the amount changes to 8.000', async () => {
|
||||||
expect.hasAssertions();
|
expect.hasAssertions();
|
||||||
const result = render(<FormikHandler value={Money.fromCents({ amount: 800, currency: 'usd' })} />);
|
const result = render(<FormikHandler value={Money.fromCents({ cents: 800, currency: 'usd' })} />);
|
||||||
const field = result.container.querySelector("input[name=value]");
|
const field = result.container.querySelector("input[name=value]");
|
||||||
expect(field).toHaveValue("$8.00");
|
expect(field).toHaveValue("$8.00");
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ describe('MoneyTextField', () => {
|
||||||
|
|
||||||
it('displays the $80.00 when Money of {800, usd} is passed in and then {8000, usd} is passed in', async () => {
|
it('displays the $80.00 when Money of {800, usd} is passed in and then {8000, usd} is passed in', async () => {
|
||||||
expect.hasAssertions();
|
expect.hasAssertions();
|
||||||
const {container, findByLabelText, rerender} = render(<FormikHandler value={Money.fromCents({ amount:800, currency: 'usd' })} />, );
|
const {container, findByLabelText, rerender} = render(<FormikHandler value={Money.fromCents({ cents:800, currency: 'usd' })} />, );
|
||||||
const field = container.querySelector("input[name=value]");
|
const field = container.querySelector("input[name=value]");
|
||||||
expect(field).toHaveValue("$8.00");
|
expect(field).toHaveValue("$8.00");
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ describe('MoneyTextField', () => {
|
||||||
expect(currency).toHaveTextContent("usd");
|
expect(currency).toHaveTextContent("usd");
|
||||||
|
|
||||||
|
|
||||||
rerender(<FormikHandler value={Money.fromCents({ amount:8000, currency: 'usd' })} />);
|
rerender(<FormikHandler value={Money.fromCents({ cents:8000, currency: 'usd' })} />);
|
||||||
expect(amount).toHaveTextContent("8000");
|
expect(amount).toHaveTextContent("8000");
|
||||||
expect(currency).toHaveTextContent("usd");
|
expect(currency).toHaveTextContent("usd");
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ function FormikInner(props: { onChange:(args:{value:Money})=> void}) {
|
||||||
onChange({value});
|
onChange({value});
|
||||||
}, [value, onChange]);
|
}, [value, onChange]);
|
||||||
|
|
||||||
return <><div><span aria-label="amount">{value.amount}</span><span aria-label="currency">{value.currency}</span></div>
|
return <><div><span aria-label="cents">{value.cents}</span><span aria-label="currency">{value.currency}</span></div>
|
||||||
<Field component={MoneyTextField} name="value" aria-label="field" /></>;
|
<Field component={MoneyTextField} name="value" aria-label="field" /></>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,11 +31,11 @@ export function useSerializeMoney(props:UseSerializeMoneyProps) : ReturnType<typ
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const {locale} = intl;
|
const {locale} = intl;
|
||||||
const {value, ...other} = props;
|
const {value, ...other} = props;
|
||||||
const {amount, currency} = value;
|
const {cents, currency} = value;
|
||||||
|
|
||||||
const i18n = useI18nCurrencyInput({...other, locale,
|
const i18n = useI18nCurrencyInput({...other, locale,
|
||||||
currency,
|
currency,
|
||||||
value:amount,
|
value:cents,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ class CampaignGiftOption < ApplicationRecord
|
||||||
if amount_one_time
|
if amount_one_time
|
||||||
gift_option_amount.push({
|
gift_option_amount.push({
|
||||||
amount:{
|
amount:{
|
||||||
amount: amount_one_time,
|
cents: amount_one_time,
|
||||||
currency: campaign.nonprofit.currency
|
currency: campaign.nonprofit.currency
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -60,7 +60,7 @@ class CampaignGiftOption < ApplicationRecord
|
||||||
if amount_recurring
|
if amount_recurring
|
||||||
gift_option_amount.push({
|
gift_option_amount.push({
|
||||||
amount:{
|
amount:{
|
||||||
amount: amount_recurring,
|
cents: amount_recurring,
|
||||||
currency: campaign.nonprofit.currency
|
currency: campaign.nonprofit.currency
|
||||||
},
|
},
|
||||||
recurrence: {
|
recurrence: {
|
||||||
|
@ -83,7 +83,7 @@ class CampaignGiftOption < ApplicationRecord
|
||||||
json.gift_option_amount gift_option_amount do |desc|
|
json.gift_option_amount gift_option_amount do |desc|
|
||||||
json.amount do
|
json.amount do
|
||||||
json.currency desc[:amount][:currency]
|
json.currency desc[:amount][:currency]
|
||||||
json.amount desc[:amount][:amount]
|
json.cents desc[:amount][:cents]
|
||||||
end
|
end
|
||||||
json.recurrence do
|
json.recurrence do
|
||||||
json.interval desc[:recurrence][:interval]
|
json.interval desc[:recurrence][:interval]
|
||||||
|
|
|
@ -33,7 +33,7 @@ class CampaignGiftPurchase < ApplicationRecord
|
||||||
json.(self, :deleted)
|
json.(self, :deleted)
|
||||||
|
|
||||||
json.amount do
|
json.amount do
|
||||||
json.amount amount
|
json.cents amount
|
||||||
json.currency nonprofit.currency
|
json.currency nonprofit.currency
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ class ModernCampaignGift < ApplicationRecord
|
||||||
json.(self, :deleted)
|
json.(self, :deleted)
|
||||||
json.object 'campaign_gift'
|
json.object 'campaign_gift'
|
||||||
json.amount do
|
json.amount do
|
||||||
json.amount amount
|
json.cents amount
|
||||||
json.currency nonprofit.currency
|
json.currency nonprofit.currency
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,7 +29,7 @@ class ModernDonation < ApplicationRecord
|
||||||
# TODO the line above is a hacky solution
|
# TODO the line above is a hacky solution
|
||||||
|
|
||||||
json.amount do
|
json.amount do
|
||||||
json.amount amount
|
json.cents amount
|
||||||
json.currency nonprofit.currency
|
json.currency nonprofit.currency
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -62,7 +62,7 @@ class TicketLevel < ApplicationRecord
|
||||||
init_builder(*expand) do |json|
|
init_builder(*expand) do |json|
|
||||||
json.(self, :name, :deleted, :order, :limit, :description)
|
json.(self, :name, :deleted, :order, :limit, :description)
|
||||||
json.amount do
|
json.amount do
|
||||||
json.amount amount || 0
|
json.cents amount || 0
|
||||||
json.currency event.nonprofit.currency
|
json.currency event.nonprofit.currency
|
||||||
end
|
end
|
||||||
json.available_to admin_only ? 'admins' : 'everyone'
|
json.available_to admin_only ? 'admins' : 'everyone'
|
||||||
|
|
|
@ -28,7 +28,7 @@ class TicketPurchase < ApplicationRecord
|
||||||
end if original_discount
|
end if original_discount
|
||||||
|
|
||||||
json.amount do
|
json.amount do
|
||||||
json.amount amount
|
json.cents amount
|
||||||
json.currency nonprofit.currency
|
json.currency nonprofit.currency
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ class TicketToLegacyTicket < ApplicationRecord
|
||||||
json.object "ticket"
|
json.object "ticket"
|
||||||
|
|
||||||
json.amount do
|
json.amount do
|
||||||
json.amount amount
|
json.cents amount
|
||||||
json.currency nonprofit.currency
|
json.currency nonprofit.currency
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Transaction < ApplicationRecord
|
||||||
def to_builder(*expand)
|
def to_builder(*expand)
|
||||||
init_builder(*expand) do |json|
|
init_builder(*expand) do |json|
|
||||||
json.amount do
|
json.amount do
|
||||||
json.amount amount || 0
|
json.cents amount || 0
|
||||||
json.currency nonprofit.currency
|
json.currency nonprofit.currency
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// License: LGPL-3.0-or-later
|
// License: LGPL-3.0-or-later
|
||||||
import { MoneyAsJson } from "../../app/javascript/common/money";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the main identifier for HoudiniObjects which is unique between all other HoudiniObjects with the same object value.
|
* the main identifier for HoudiniObjects which is unique between all other HoudiniObjects with the same object value.
|
||||||
|
@ -16,7 +15,7 @@ export type HouID = string;
|
||||||
* Describes a monetary value in the minimum unit for this current. Corresponds to Money class in
|
* Describes a monetary value in the minimum unit for this current. Corresponds to Money class in
|
||||||
* Ruby and Typescript
|
* Ruby and Typescript
|
||||||
*/
|
*/
|
||||||
export type Amount = MoneyAsJson;
|
export type Amount = { cents: string, currency: string };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A more flexible version of Amount. In cases where we can assume what the currency is,
|
* A more flexible version of Amount. In cases where we can assume what the currency is,
|
||||||
|
|
|
@ -57,9 +57,9 @@ RSpec.describe CampaignGiftOption, 'type' => :model do
|
||||||
'deleted' => false,
|
'deleted' => false,
|
||||||
'description' => description,
|
'description' => description,
|
||||||
'gift_option_amount' => [
|
'gift_option_amount' => [
|
||||||
{'amount' => {'amount'=> amount_one_time, 'currency' => nonprofit.currency}},
|
{'amount' => {'cents'=> amount_one_time, 'currency' => nonprofit.currency}},
|
||||||
{
|
{
|
||||||
'amount' => {'amount' => amount_recurring, 'currency' => nonprofit.currency},
|
'amount' => {'cents' => amount_recurring, 'currency' => nonprofit.currency},
|
||||||
'recurrence' => { 'interval' => 1, 'type' => 'monthly'}
|
'recurrence' => { 'interval' => 1, 'type' => 'monthly'}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -98,9 +98,9 @@ RSpec.describe CampaignGiftOption, 'type' => :model do
|
||||||
'deleted' => false,
|
'deleted' => false,
|
||||||
'description' => description,
|
'description' => description,
|
||||||
'gift_option_amount' => [
|
'gift_option_amount' => [
|
||||||
{'amount' => {'amount' => amount_one_time, 'currency' => nonprofit.currency}},
|
{'amount' => {'cents' => amount_one_time, 'currency' => nonprofit.currency}},
|
||||||
{
|
{
|
||||||
'amount' => {'amount' => amount_recurring, 'currency' => nonprofit.currency},
|
'amount' => {'cents' => amount_recurring, 'currency' => nonprofit.currency},
|
||||||
'recurrence' => { 'interval' => 1, 'type' => 'monthly'}
|
'recurrence' => { 'interval' => 1, 'type' => 'monthly'}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -161,7 +161,7 @@ RSpec.describe CampaignGiftOption, 'type' => :model do
|
||||||
'description' => description,
|
'description' => description,
|
||||||
'gift_option_amount' => [
|
'gift_option_amount' => [
|
||||||
{
|
{
|
||||||
'amount' => {'amount' => amount_recurring, 'currency' => nonprofit.currency},
|
'amount' => {'cents' => amount_recurring, 'currency' => nonprofit.currency},
|
||||||
'recurrence' => { 'interval' => 1, 'type' => 'monthly'}
|
'recurrence' => { 'interval' => 1, 'type' => 'monthly'}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -205,7 +205,7 @@ RSpec.describe CampaignGiftOption, 'type' => :model do
|
||||||
'deleted' => false,
|
'deleted' => false,
|
||||||
'description' => description,
|
'description' => description,
|
||||||
'gift_option_amount' => [
|
'gift_option_amount' => [
|
||||||
{'amount' => {'amount' => amount_one_time, 'currency' => nonprofit.currency}},
|
{'amount' => {'cents' => amount_one_time, 'currency' => nonprofit.currency}},
|
||||||
],
|
],
|
||||||
'id'=> kind_of(Numeric),
|
'id'=> kind_of(Numeric),
|
||||||
'hide_contributions' => false,
|
'hide_contributions' => false,
|
||||||
|
@ -252,9 +252,9 @@ RSpec.describe CampaignGiftOption, 'type' => :model do
|
||||||
'deleted' => true,
|
'deleted' => true,
|
||||||
'description' => description,
|
'description' => description,
|
||||||
'gift_option_amount' => [
|
'gift_option_amount' => [
|
||||||
{'amount' => {'amount' => amount_one_time, 'currency' => nonprofit.currency}},
|
{'amount' => {'cents' => amount_one_time, 'currency' => nonprofit.currency}},
|
||||||
{
|
{
|
||||||
'amount' => {'amount' => amount_recurring, 'currency' => nonprofit.currency},
|
'amount' => {'cents' => amount_recurring, 'currency' => nonprofit.currency},
|
||||||
'recurrence' => { 'interval' => 1, 'type' => 'monthly'}
|
'recurrence' => { 'interval' => 1, 'type' => 'monthly'}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -299,9 +299,9 @@ RSpec.describe CampaignGiftOption, 'type' => :model do
|
||||||
'deleted' => true,
|
'deleted' => true,
|
||||||
'description' => description,
|
'description' => description,
|
||||||
'gift_option_amount' => [
|
'gift_option_amount' => [
|
||||||
{'amount' => {'amount' => amount_one_time, 'currency' => nonprofit.currency}},
|
{'amount' => {'cents' => amount_one_time, 'currency' => nonprofit.currency}},
|
||||||
{
|
{
|
||||||
'amount' => {'amount' => amount_recurring, 'currency' => nonprofit.currency},
|
'amount' => {'cents' => amount_recurring, 'currency' => nonprofit.currency},
|
||||||
'recurrence' => { 'interval' => 1, 'type' => 'monthly'}
|
'recurrence' => { 'interval' => 1, 'type' => 'monthly'}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -40,7 +40,7 @@ RSpec.describe CampaignGiftPurchase, type: :model do
|
||||||
'deleted' => false,
|
'deleted' => false,
|
||||||
'gift_option_amount' => [{
|
'gift_option_amount' => [{
|
||||||
'amount' => {
|
'amount' => {
|
||||||
'amount' => 400,
|
'cents' => 400,
|
||||||
'currency' => 'usd'
|
'currency' => 'usd'
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
|
@ -66,7 +66,7 @@ RSpec.describe CampaignGiftPurchase, type: :model do
|
||||||
'id' => match_houid('trx'),
|
'id' => match_houid('trx'),
|
||||||
'object' => 'transaction',
|
'object' => 'transaction',
|
||||||
'amount' => {
|
'amount' => {
|
||||||
'amount' => trx.amount,
|
'cents' => trx.amount,
|
||||||
'currency' => 'usd'
|
'currency' => 'usd'
|
||||||
},
|
},
|
||||||
'supporter' => kind_of(Numeric),
|
'supporter' => kind_of(Numeric),
|
||||||
|
@ -81,7 +81,7 @@ RSpec.describe CampaignGiftPurchase, type: :model do
|
||||||
'object' => 'campaign_gift_purchase',
|
'object' => 'campaign_gift_purchase',
|
||||||
'campaign_gifts' => [modern_campaign_gift_builder],
|
'campaign_gifts' => [modern_campaign_gift_builder],
|
||||||
'amount' => {
|
'amount' => {
|
||||||
'amount' => trx.amount,
|
'cents' => trx.amount,
|
||||||
'currency' => 'usd'
|
'currency' => 'usd'
|
||||||
},
|
},
|
||||||
'supporter' => supporter_builder_expanded,
|
'supporter' => supporter_builder_expanded,
|
||||||
|
@ -94,7 +94,7 @@ RSpec.describe CampaignGiftPurchase, type: :model do
|
||||||
let(:modern_campaign_gift_builder) {
|
let(:modern_campaign_gift_builder) {
|
||||||
{
|
{
|
||||||
'amount' => {
|
'amount' => {
|
||||||
'amount' => 400,
|
'cents' => 400,
|
||||||
'currency' => 'usd'
|
'currency' => 'usd'
|
||||||
},
|
},
|
||||||
'campaign' => kind_of(Numeric),
|
'campaign' => kind_of(Numeric),
|
||||||
|
@ -125,7 +125,7 @@ RSpec.describe CampaignGiftPurchase, type: :model do
|
||||||
'object' => 'campaign_gift_purchase',
|
'object' => 'campaign_gift_purchase',
|
||||||
'campaign_gifts' => [modern_campaign_gift_builder],
|
'campaign_gifts' => [modern_campaign_gift_builder],
|
||||||
'amount' => {
|
'amount' => {
|
||||||
'amount' => trx.amount,
|
'cents' => trx.amount,
|
||||||
'currency' => 'usd'
|
'currency' => 'usd'
|
||||||
},
|
},
|
||||||
'supporter' => supporter_builder_expanded,
|
'supporter' => supporter_builder_expanded,
|
||||||
|
@ -152,7 +152,7 @@ RSpec.describe CampaignGiftPurchase, type: :model do
|
||||||
'object' => 'campaign_gift_purchase',
|
'object' => 'campaign_gift_purchase',
|
||||||
'campaign_gifts' => [modern_campaign_gift_builder],
|
'campaign_gifts' => [modern_campaign_gift_builder],
|
||||||
'amount' => {
|
'amount' => {
|
||||||
'amount' => trx.amount,
|
'cents' => trx.amount,
|
||||||
'currency' => 'usd'
|
'currency' => 'usd'
|
||||||
},
|
},
|
||||||
'supporter' => supporter_builder_expanded,
|
'supporter' => supporter_builder_expanded,
|
||||||
|
@ -179,7 +179,7 @@ RSpec.describe CampaignGiftPurchase, type: :model do
|
||||||
'object' => 'campaign_gift_purchase',
|
'object' => 'campaign_gift_purchase',
|
||||||
'campaign_gifts' => [modern_campaign_gift_builder],
|
'campaign_gifts' => [modern_campaign_gift_builder],
|
||||||
'amount' => {
|
'amount' => {
|
||||||
'amount' => trx.amount,
|
'cents' => trx.amount,
|
||||||
'currency' => 'usd'
|
'currency' => 'usd'
|
||||||
},
|
},
|
||||||
'supporter' => supporter_builder_expanded,
|
'supporter' => supporter_builder_expanded,
|
||||||
|
|
|
@ -88,7 +88,7 @@ RSpec.describe EventDiscount, type: :model do
|
||||||
'object' => 'ticket_level',
|
'object' => 'ticket_level',
|
||||||
'description' => ticket_level.description,
|
'description' => ticket_level.description,
|
||||||
'amount' => {
|
'amount' => {
|
||||||
'amount' => ticket_level.amount,
|
'cents' => ticket_level.amount,
|
||||||
'currency' => 'usd'
|
'currency' => 'usd'
|
||||||
},
|
},
|
||||||
'available_to' => 'everyone',
|
'available_to' => 'everyone',
|
||||||
|
@ -150,7 +150,7 @@ RSpec.describe EventDiscount, type: :model do
|
||||||
'object' => 'ticket_level',
|
'object' => 'ticket_level',
|
||||||
'description' => ticket_level.description,
|
'description' => ticket_level.description,
|
||||||
'amount' => {
|
'amount' => {
|
||||||
'amount' => ticket_level.amount,
|
'cents' => ticket_level.amount,
|
||||||
'currency' => 'usd'
|
'currency' => 'usd'
|
||||||
},
|
},
|
||||||
'available_to' => 'everyone',
|
'available_to' => 'everyone',
|
||||||
|
@ -213,7 +213,7 @@ RSpec.describe EventDiscount, type: :model do
|
||||||
'object' => 'ticket_level',
|
'object' => 'ticket_level',
|
||||||
'description' => ticket_level.description,
|
'description' => ticket_level.description,
|
||||||
'amount' => {
|
'amount' => {
|
||||||
'amount' => ticket_level.amount,
|
'cents' => ticket_level.amount,
|
||||||
'currency' => 'usd'
|
'currency' => 'usd'
|
||||||
},
|
},
|
||||||
'available_to' => 'everyone',
|
'available_to' => 'everyone',
|
||||||
|
|
|
@ -40,7 +40,7 @@ RSpec.describe ModernCampaignGift, type: :model do
|
||||||
'deleted' => false,
|
'deleted' => false,
|
||||||
'gift_option_amount' => [{
|
'gift_option_amount' => [{
|
||||||
'amount' => {
|
'amount' => {
|
||||||
'amount' => 400,
|
'cents' => 400,
|
||||||
'currency' => 'usd'
|
'currency' => 'usd'
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
|
@ -66,7 +66,7 @@ RSpec.describe ModernCampaignGift, type: :model do
|
||||||
'id' => match_houid('trx'),
|
'id' => match_houid('trx'),
|
||||||
'object' => 'transaction',
|
'object' => 'transaction',
|
||||||
'amount' => {
|
'amount' => {
|
||||||
'amount' => trx.amount,
|
'cents' => trx.amount,
|
||||||
'currency' => 'usd'
|
'currency' => 'usd'
|
||||||
},
|
},
|
||||||
'supporter' => kind_of(Numeric),
|
'supporter' => kind_of(Numeric),
|
||||||
|
@ -81,7 +81,7 @@ RSpec.describe ModernCampaignGift, type: :model do
|
||||||
'object' => 'campaign_gift_purchase',
|
'object' => 'campaign_gift_purchase',
|
||||||
'campaign_gifts' => [match_houid('cgift')],
|
'campaign_gifts' => [match_houid('cgift')],
|
||||||
'amount' => {
|
'amount' => {
|
||||||
'amount' => trx.amount,
|
'cents' => trx.amount,
|
||||||
'currency' => 'usd'
|
'currency' => 'usd'
|
||||||
},
|
},
|
||||||
'supporter' => kind_of(Numeric),
|
'supporter' => kind_of(Numeric),
|
||||||
|
@ -103,7 +103,7 @@ RSpec.describe ModernCampaignGift, type: :model do
|
||||||
'data' => {
|
'data' => {
|
||||||
'object' => {
|
'object' => {
|
||||||
'amount' => {
|
'amount' => {
|
||||||
'amount' => 400,
|
'cents' => 400,
|
||||||
'currency' => 'usd'
|
'currency' => 'usd'
|
||||||
},
|
},
|
||||||
'campaign' => campaign_builder_expanded,
|
'campaign' => campaign_builder_expanded,
|
||||||
|
@ -131,7 +131,7 @@ RSpec.describe ModernCampaignGift, type: :model do
|
||||||
'data' => {
|
'data' => {
|
||||||
'object' => {
|
'object' => {
|
||||||
'amount' => {
|
'amount' => {
|
||||||
'amount' => 400,
|
'cents' => 400,
|
||||||
'currency' => 'usd'
|
'currency' => 'usd'
|
||||||
},
|
},
|
||||||
'campaign' => campaign_builder_expanded,
|
'campaign' => campaign_builder_expanded,
|
||||||
|
@ -159,7 +159,7 @@ RSpec.describe ModernCampaignGift, type: :model do
|
||||||
'data' => {
|
'data' => {
|
||||||
'object' => {
|
'object' => {
|
||||||
'amount' => {
|
'amount' => {
|
||||||
'amount' => 400,
|
'cents' => 400,
|
||||||
'currency' => 'usd'
|
'currency' => 'usd'
|
||||||
},
|
},
|
||||||
'campaign' => campaign_builder_expanded,
|
'campaign' => campaign_builder_expanded,
|
||||||
|
|
|
@ -24,7 +24,7 @@ RSpec.describe ModernDonation, type: :model do
|
||||||
'object' => 'donation',
|
'object' => 'donation',
|
||||||
'nonprofit' => nonprofit.id,
|
'nonprofit' => nonprofit.id,
|
||||||
'supporter' => supporter.id,
|
'supporter' => supporter.id,
|
||||||
'amount' => {'currency' => 'usd', 'amount' => 1200},
|
'amount' => {'currency' => 'usd', 'cents' => 1200},
|
||||||
'transaction' => trx.id,
|
'transaction' => trx.id,
|
||||||
'designation' => nil
|
'designation' => nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ RSpec.describe TicketLevel, type: :model do
|
||||||
'type' => 'ticket_level.created',
|
'type' => 'ticket_level.created',
|
||||||
'data' => {
|
'data' => {
|
||||||
'object' => {
|
'object' => {
|
||||||
'amount' => {'amount' => 0, 'currency' => 'usd'},
|
'amount' => {'cents' => 0, 'currency' => 'usd'},
|
||||||
'available_to' => 'admins',
|
'available_to' => 'admins',
|
||||||
'deleted' => false,
|
'deleted' => false,
|
||||||
'description' => description,
|
'description' => description,
|
||||||
|
@ -90,7 +90,7 @@ RSpec.describe TicketLevel, type: :model do
|
||||||
'type' => 'ticket_level.created',
|
'type' => 'ticket_level.created',
|
||||||
'data' => {
|
'data' => {
|
||||||
'object' => {
|
'object' => {
|
||||||
'amount' => {'amount' => non_free_amount, 'currency' => 'usd'},
|
'amount' => {'cents' => non_free_amount, 'currency' => 'usd'},
|
||||||
'available_to' => 'everyone',
|
'available_to' => 'everyone',
|
||||||
'deleted' => false,
|
'deleted' => false,
|
||||||
'description' => description,
|
'description' => description,
|
||||||
|
@ -136,7 +136,7 @@ RSpec.describe TicketLevel, type: :model do
|
||||||
'type' => 'ticket_level.updated',
|
'type' => 'ticket_level.updated',
|
||||||
'data' => {
|
'data' => {
|
||||||
'object' => {
|
'object' => {
|
||||||
'amount' => {'amount' => 5000, 'currency' => 'usd'},
|
'amount' => {'cents' => 5000, 'currency' => 'usd'},
|
||||||
'available_to' => 'admins',
|
'available_to' => 'admins',
|
||||||
'deleted' => false,
|
'deleted' => false,
|
||||||
'description' => description,
|
'description' => description,
|
||||||
|
@ -182,7 +182,7 @@ RSpec.describe TicketLevel, type: :model do
|
||||||
'type' => 'ticket_level.updated',
|
'type' => 'ticket_level.updated',
|
||||||
'data' => {
|
'data' => {
|
||||||
'object' => {
|
'object' => {
|
||||||
'amount' => {'amount' => 0, 'currency' => 'usd'},
|
'amount' => {'cents' => 0, 'currency' => 'usd'},
|
||||||
'available_to' => 'everyone',
|
'available_to' => 'everyone',
|
||||||
'deleted' => false,
|
'deleted' => false,
|
||||||
'description' => description,
|
'description' => description,
|
||||||
|
@ -231,7 +231,7 @@ RSpec.describe TicketLevel, type: :model do
|
||||||
'type' => 'ticket_level.deleted',
|
'type' => 'ticket_level.deleted',
|
||||||
'data' => {
|
'data' => {
|
||||||
'object' => {
|
'object' => {
|
||||||
'amount' => {'amount' => 0, 'currency' => 'usd'},
|
'amount' => {'cents' => 0, 'currency' => 'usd'},
|
||||||
'available_to' => 'admins',
|
'available_to' => 'admins',
|
||||||
'deleted' => true,
|
'deleted' => true,
|
||||||
'description' => description,
|
'description' => description,
|
||||||
|
@ -273,7 +273,7 @@ RSpec.describe TicketLevel, type: :model do
|
||||||
'type' => 'ticket_level.deleted',
|
'type' => 'ticket_level.deleted',
|
||||||
'data' => {
|
'data' => {
|
||||||
'object' => {
|
'object' => {
|
||||||
'amount' => {'amount' => non_free_amount, 'currency' => 'usd'},
|
'amount' => {'cents' => non_free_amount, 'currency' => 'usd'},
|
||||||
'available_to' => 'everyone',
|
'available_to' => 'everyone',
|
||||||
'deleted' => true,
|
'deleted' => true,
|
||||||
'description' => description,
|
'description' => description,
|
||||||
|
|
|
@ -54,7 +54,7 @@ RSpec.describe TicketPurchase, type: :model do
|
||||||
'event' => event.id,
|
'event' => event.id,
|
||||||
'supporter' => supporter.id,
|
'supporter' => supporter.id,
|
||||||
'tickets' => match_array(ticket_purchase.ticket_to_legacy_tickets.pluck(:id)),
|
'tickets' => match_array(ticket_purchase.ticket_to_legacy_tickets.pluck(:id)),
|
||||||
'amount' => {'currency' => 'usd', 'amount' => 1200},
|
'amount' => {'currency' => 'usd', 'cents' => 1200},
|
||||||
'original_discount' => { 'percent' => 0},
|
'original_discount' => { 'percent' => 0},
|
||||||
'event_discount' => nil,
|
'event_discount' => nil,
|
||||||
'transaction' => trx.id
|
'transaction' => trx.id
|
||||||
|
|
|
@ -58,14 +58,14 @@ RSpec.describe TicketToLegacyTicket, type: :model do
|
||||||
let(:free_ticket_default) {
|
let(:free_ticket_default) {
|
||||||
ticket_default.merge({
|
ticket_default.merge({
|
||||||
'ticket_level' => legacy_free_tickets.ticket_level.id,
|
'ticket_level' => legacy_free_tickets.ticket_level.id,
|
||||||
'amount' => {'currency' => 'usd', 'amount' => 0}
|
'amount' => {'currency' => 'usd', 'cents' => 0}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let(:nonfree_ticket_default) {
|
let(:nonfree_ticket_default) {
|
||||||
ticket_default.merge({
|
ticket_default.merge({
|
||||||
'ticket_level' => legacy_nonfree_tickets.ticket_level.id,
|
'ticket_level' => legacy_nonfree_tickets.ticket_level.id,
|
||||||
'amount' => {'currency' => 'usd', 'amount' => legacy_nonfree_tickets.ticket_level.amount}
|
'amount' => {'currency' => 'usd', 'cents' => legacy_nonfree_tickets.ticket_level.amount}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,14 +143,14 @@ RSpec.describe TicketToLegacyTicket, type: :model do
|
||||||
let(:free_ticket_default) {
|
let(:free_ticket_default) {
|
||||||
ticket_default.merge({
|
ticket_default.merge({
|
||||||
'ticket_level' => legacy_free_tickets.ticket_level.id,
|
'ticket_level' => legacy_free_tickets.ticket_level.id,
|
||||||
'amount' => {'currency' => 'usd', 'amount' => 0}
|
'amount' => {'currency' => 'usd', 'cents' => 0}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let(:nonfree_ticket_default) {
|
let(:nonfree_ticket_default) {
|
||||||
ticket_default.merge({
|
ticket_default.merge({
|
||||||
'ticket_level' => legacy_nonfree_tickets.ticket_level.id,
|
'ticket_level' => legacy_nonfree_tickets.ticket_level.id,
|
||||||
'amount' => {'currency' => 'usd', 'amount' => 320 }
|
'amount' => {'currency' => 'usd', 'cents' => 320 }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ RSpec.describe Transaction, type: :model do
|
||||||
'supporter' => supporter.id,
|
'supporter' => supporter.id,
|
||||||
'object' => 'transaction',
|
'object' => 'transaction',
|
||||||
'amount' => {
|
'amount' => {
|
||||||
'amount' => 1000,
|
'cents' => 1000,
|
||||||
'currency' => 'usd'
|
'currency' => 'usd'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue