Browse Source

Only update if amount

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

6
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,7 +201,8 @@ export class AccountService {
date date
); );
return this.prismaService.account.update({ if (amountInCurrencyOfAccount) {
await this.prismaService.account.update({
data: { data: {
balance: new Big(balance).plus(amountInCurrencyOfAccount).toNumber() balance: new Big(balance).plus(amountInCurrencyOfAccount).toNumber()
}, },
@ -213,4 +214,5 @@ export class AccountService {
} }
}); });
} }
}
} }

Loading…
Cancel
Save