Specify CGT cost base adjustment as signed numbers
This commit is contained in:
parent
4d9741525b
commit
5cd25cb76f
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
DrCr: Web-based double-entry bookkeeping framework
|
DrCr: Double-entry bookkeeping framework
|
||||||
Copyright (C) 2022-2025 Lee Yingtong Li (RunasSudo)
|
Copyright (C) 2022-2025 Lee Yingtong Li (RunasSudo)
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
@ -46,13 +46,7 @@
|
|||||||
<div class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">
|
<div class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">
|
||||||
<span class="text-gray-500">{{ db.metadata.reporting_commodity }}</span>
|
<span class="text-gray-500">{{ db.metadata.reporting_commodity }}</span>
|
||||||
</div>
|
</div>
|
||||||
<input type="number" class="bordered-field pl-7 pr-16" step="0.01" v-model="adjustment.cost_adjustment_abs" placeholder="0.00">
|
<input type="number" class="bordered-field pl-7" step="0.01" v-model="adjustment.cost_adjustment" placeholder="0.00">
|
||||||
<div class="absolute inset-y-0 right-0 flex items-center">
|
|
||||||
<select class="h-full border-0 bg-transparent py-0 pl-2 pr-8 text-gray-900 focus:ring-2 focus:ring-inset focus:ring-indigo-600" v-model="adjustment.sign">
|
|
||||||
<option value="dr">Dr</option>
|
|
||||||
<option value="cr">Cr</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -90,8 +84,7 @@
|
|||||||
acquisition_dt: string,
|
acquisition_dt: string,
|
||||||
dt: string,
|
dt: string,
|
||||||
description: string,
|
description: string,
|
||||||
sign: string,
|
cost_adjustment: string,
|
||||||
cost_adjustment_abs: string,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { adjustment } = defineProps<{ adjustment: EditingCGTAdjustment }>();
|
const { adjustment } = defineProps<{ adjustment: EditingCGTAdjustment }>();
|
||||||
@ -114,9 +107,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let cost_adjustment_abs;
|
let cost_adjustment;
|
||||||
try {
|
try {
|
||||||
cost_adjustment_abs = deserialiseAmount('' + adjustment.cost_adjustment_abs);
|
cost_adjustment = deserialiseAmount('' + adjustment.cost_adjustment).quantity;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err instanceof DeserialiseAmountError) {
|
if (err instanceof DeserialiseAmountError) {
|
||||||
error.value = err.message;
|
error.value = err.message;
|
||||||
@ -126,8 +119,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const cost_adjustment = adjustment.sign === 'dr' ? cost_adjustment_abs.quantity : -cost_adjustment_abs.quantity;
|
|
||||||
|
|
||||||
const session = await db.load();
|
const session = await db.load();
|
||||||
|
|
||||||
if (adjustment.id === null) {
|
if (adjustment.id === null) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
DrCr: Web-based double-entry bookkeeping framework
|
DrCr: Double-entry bookkeeping framework
|
||||||
Copyright (C) 2022-2025 Lee Yingtong Li (RunasSudo)
|
Copyright (C) 2022-2025 Lee Yingtong Li (RunasSudo)
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
@ -41,8 +41,7 @@
|
|||||||
acquisition_dt: null!,
|
acquisition_dt: null!,
|
||||||
dt: null!,
|
dt: null!,
|
||||||
description: null!,
|
description: null!,
|
||||||
sign: null!,
|
cost_adjustment: null!,
|
||||||
cost_adjustment_abs: null!,
|
|
||||||
} as EditingCGTAdjustment);
|
} as EditingCGTAdjustment);
|
||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
@ -60,8 +59,7 @@
|
|||||||
rawAdjustment.asset = serialiseAmount(rawAdjustment.quantity, rawAdjustment.commodity);
|
rawAdjustment.asset = serialiseAmount(rawAdjustment.quantity, rawAdjustment.commodity);
|
||||||
rawAdjustment.acquisition_dt = dayjs(rawAdjustment.acquisition_dt).format('YYYY-MM-DD');
|
rawAdjustment.acquisition_dt = dayjs(rawAdjustment.acquisition_dt).format('YYYY-MM-DD');
|
||||||
rawAdjustment.dt = dayjs(rawAdjustment.dt).format('YYYY-MM-DD');
|
rawAdjustment.dt = dayjs(rawAdjustment.dt).format('YYYY-MM-DD');
|
||||||
rawAdjustment.sign = rawAdjustment.cost_adjustment >= 0 ? 'dr' : 'cr';
|
rawAdjustment.cost_adjustment = serialiseAmount(rawAdjustment.cost_adjustment, db.metadata.reporting_commodity);
|
||||||
rawAdjustment.cost_adjustment_abs = serialiseAmount(Math.abs(rawAdjustment.cost_adjustment), db.metadata.reporting_commodity);
|
|
||||||
|
|
||||||
adjustment.value = rawAdjustment as EditingCGTAdjustment;
|
adjustment.value = rawAdjustment as EditingCGTAdjustment;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
DrCr: Web-based double-entry bookkeeping framework
|
DrCr: Double-entry bookkeeping framework
|
||||||
Copyright (C) 2022-2025 Lee Yingtong Li (RunasSudo)
|
Copyright (C) 2022-2025 Lee Yingtong Li (RunasSudo)
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
@ -57,13 +57,7 @@
|
|||||||
<div class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">
|
<div class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">
|
||||||
<span class="text-gray-500">{{ db.metadata.reporting_commodity }}</span>
|
<span class="text-gray-500">{{ db.metadata.reporting_commodity }}</span>
|
||||||
</div>
|
</div>
|
||||||
<input type="number" class="bordered-field pl-7 pr-16" step="0.01" v-model="cost_adjustment_abs" placeholder="0.00">
|
<input type="number" class="bordered-field pl-7" step="0.01" v-model="cost_adjustment" placeholder="0.00">
|
||||||
<div class="absolute inset-y-0 right-0 flex items-center">
|
|
||||||
<select class="h-full border-0 bg-transparent py-0 pl-2 pr-8 text-gray-900 focus:ring-2 focus:ring-inset focus:ring-indigo-600" v-model="sign">
|
|
||||||
<option value="dr">Dr</option>
|
|
||||||
<option value="cr">Cr</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -101,8 +95,7 @@
|
|||||||
const commodity = ref('');
|
const commodity = ref('');
|
||||||
const dt = ref(dayjs().format('YYYY-MM-DD'));
|
const dt = ref(dayjs().format('YYYY-MM-DD'));
|
||||||
const description = ref('');
|
const description = ref('');
|
||||||
const cost_adjustment_abs = ref(null! as number);
|
const cost_adjustment = ref(null! as number);
|
||||||
const sign = ref('dr');
|
|
||||||
|
|
||||||
const error = ref(null as string | null);
|
const error = ref(null as string | null);
|
||||||
|
|
||||||
@ -111,9 +104,9 @@
|
|||||||
|
|
||||||
error.value = null;
|
error.value = null;
|
||||||
|
|
||||||
let totalAdjustmentAbs;
|
let totalAdjustment;
|
||||||
try {
|
try {
|
||||||
totalAdjustmentAbs = deserialiseAmount('' + cost_adjustment_abs.value);
|
totalAdjustment = deserialiseAmount('' + cost_adjustment.value).quantity;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err instanceof DeserialiseAmountError) {
|
if (err instanceof DeserialiseAmountError) {
|
||||||
error.value = err.message;
|
error.value = err.message;
|
||||||
@ -123,8 +116,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const totalAdjustment = sign.value === 'dr' ? totalAdjustmentAbs.quantity : -totalAdjustmentAbs.quantity;
|
|
||||||
|
|
||||||
// Get all postings to the CGT asset account
|
// Get all postings to the CGT asset account
|
||||||
const session = await db.load();
|
const session = await db.load();
|
||||||
const cgtPostings = await session.select(
|
const cgtPostings = await session.select(
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
DrCr: Web-based double-entry bookkeeping framework
|
DrCr: Double-entry bookkeeping framework
|
||||||
Copyright (C) 2022-2025 Lee Yingtong Li (RunasSudo)
|
Copyright (C) 2022-2025 Lee Yingtong Li (RunasSudo)
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
@ -37,7 +37,6 @@
|
|||||||
acquisition_dt: dayjs().format('YYYY-MM-DD'),
|
acquisition_dt: dayjs().format('YYYY-MM-DD'),
|
||||||
dt: dayjs().format('YYYY-MM-DD'),
|
dt: dayjs().format('YYYY-MM-DD'),
|
||||||
description: '',
|
description: '',
|
||||||
sign: 'dr',
|
cost_adjustment: '',
|
||||||
cost_adjustment_abs: '',
|
|
||||||
} as EditingCGTAdjustment);
|
} as EditingCGTAdjustment);
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user