#7936 improve InvoiceIn #1004
|
@ -177,6 +177,7 @@ function normalize(text) {
|
|||
class="full-width"
|
||||
filled
|
||||
dense
|
||||
autofocus
|
||||
/>
|
||||
</QItem>
|
||||
<QSeparator />
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
import { describe, expect, it, vi } from 'vitest';
|
||||
import axios from 'axios';
|
||||
import { getExchange } from 'src/composables/getExchange';
|
||||
|
||||
vi.mock('axios');
|
||||
|
||||
describe('getExchange()', () => {
|
||||
it('should return the correct exchange rate', async () => {
|
||||
axios.get.mockResolvedValue({
|
||||
data: { value: 1.2 },
|
||||
});
|
||||
|
||||
const amount = 100;
|
||||
const currencyFk = 1;
|
||||
const dated = '2023-01-01';
|
||||
const result = await getExchange(amount, currencyFk, dated);
|
||||
|
||||
expect(result).toBe('83.33');
|
||||
});
|
||||
|
||||
it('should return the correct exchange rate with custom decimal places', async () => {
|
||||
axios.get.mockResolvedValue({
|
||||
data: { value: 1.2 },
|
||||
});
|
||||
|
||||
const amount = 100;
|
||||
const currencyFk = 1;
|
||||
const dated = '2023-01-01';
|
||||
const decimalPlaces = 3;
|
||||
const result = await getExchange(amount, currencyFk, dated, decimalPlaces);
|
||||
|
||||
expect(result).toBe('83.333');
|
||||
});
|
||||
|
||||
it('should return null if the API call fails', async () => {
|
||||
axios.get.mockRejectedValue(new Error('Network error'));
|
||||
|
||||
const amount = 100;
|
||||
const currencyFk = 1;
|
||||
const dated = '2023-01-01';
|
||||
const result = await getExchange(amount, currencyFk, dated);
|
||||
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,9 @@
|
|||
import { describe, expect, it } from 'vitest';
|
||||
import { useAccountShortToStandard } from 'src/composables/useAccountShortToStandard';
|
||||
|
||||
describe('useAccountShortToStandard()', () => {
|
||||
it('should pad the decimal part with zeros for short numbers', () => {
|
||||
expect(useAccountShortToStandard('123.45')).toBe('1230000045');
|
||||
expect(useAccountShortToStandard('123.')).toBe('1230000000');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue