Browse Source

Only update if amount

pull/1926/head
Thomas 2 years ago
parent
commit
1e7db9488a
  1. 24
      apps/api/src/app/account/account.service.ts

24
apps/api/src/app/account/account.service.ts

@ -185,7 +185,7 @@ export class AccountService {
currency: string; currency: string;
date: Date; date: Date;
userId: string; userId: string;
}): Promise<Account> { }) {
const { balance, currency: currencyOfAccount } = await this.account({ const { balance, currency: currencyOfAccount } = await this.account({
id_userId: { id_userId: {
userId, userId,
@ -201,16 +201,18 @@ export class AccountService {
date date
); );
return this.prismaService.account.update({ if (amountInCurrencyOfAccount) {
data: { await this.prismaService.account.update({
balance: new Big(balance).plus(amountInCurrencyOfAccount).toNumber() data: {
}, balance: new Big(balance).plus(amountInCurrencyOfAccount).toNumber()
where: { },
id_userId: { where: {
userId, id_userId: {
id: accountId userId,
id: accountId
}
} }
} });
}); }
} }
} }

Loading…
Cancel
Save