Allow entering transactions with mixed commodities of equal cost
This commit is contained in:
parent
f97420b055
commit
1fe1aec828
@ -339,7 +339,7 @@
|
||||
|
||||
async function onAmountChange(posting: EditingPosting) {
|
||||
// Synchronise the amounts if only two postings
|
||||
if (transaction.postings.length == 2) {
|
||||
if (transaction.postings.length === 2 && posting === transaction.postings[0]) {
|
||||
for (const otherPosting of transaction.postings) {
|
||||
if (otherPosting !== posting) {
|
||||
otherPosting.amount_abs = posting.amount_abs;
|
||||
|
@ -23,7 +23,7 @@ import { readTextFile } from '@tauri-apps/plugin-fs';
|
||||
import Database from '@tauri-apps/plugin-sql';
|
||||
import { reactive } from 'vue';
|
||||
|
||||
import { Balance } from './amounts.ts';
|
||||
import { asCost } from './amounts.ts';
|
||||
import { ExtendedDatabase } from './dbutil.ts';
|
||||
import { CriticalError } from './error.ts';
|
||||
|
||||
@ -274,12 +274,11 @@ export class Transaction {
|
||||
) {}
|
||||
|
||||
doesBalance(): boolean {
|
||||
const balance = new Balance();
|
||||
let total = 0;
|
||||
for (const posting of this.postings) {
|
||||
balance.add(posting.quantity, posting.commodity);
|
||||
total += asCost(posting.quantity, posting.commodity);
|
||||
}
|
||||
balance.clean();
|
||||
return balance.amounts.length === 0;
|
||||
return total === 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user