Make sure our transactions are always positive

Amount cannot be negative
This commit is contained in:
2025-07-09 21:06:23 +02:00
parent 02e91a3951
commit 93037b581c
2 changed files with 9 additions and 5 deletions

View File

@@ -71,7 +71,7 @@ export class DataService {
if (visibleStatuses) {
// Mark these statuses as loaded
visibleStatuses.forEach(status => this.loadedStatuses.add(status));
// Merge with existing jobs, replacing jobs with same IDs
const existingJobIds = new Set(jobs.map(job => job.id));
const otherJobs = this.jobs.filter(job => !existingJobIds.has(job.id));
@@ -83,10 +83,10 @@ export class DataService {
const allStatuses = new Set(jobs.map(job => job.status));
allStatuses.forEach(status => this.loadedStatuses.add(status));
}
// Use setTimeout to defer the notification to prevent immediate re-renders
setTimeout(() => this.notifyListeners(), 0);
return this.getJobs();
}).finally(() => {
this.loadPromise = null;

View File

@@ -55,8 +55,12 @@ export const parseTransactionLine = (line: string): PastedTransaction | null =>
const quantity = parseInt(quantityStr.replace(/,/g, ''));
// Parse prices
const unitPrice = parseISKAmount(unitPriceStr);
const totalPrice = parseISKAmount(totalAmountStr);
let unitPrice = parseISKAmount(unitPriceStr);
let totalPrice = parseISKAmount(totalAmountStr);
if (totalPrice < 0) {
totalPrice = -totalPrice;
}
return {
date: date.toISOString(),