Browse Source

Merge branch 'main' into feature/rename-order-to-activities-in-account-database-schema

pull/4577/head
Thomas Kaul 4 months ago
committed by GitHub
parent
commit
7a9bc22ba5
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 6
      CHANGELOG.md
  2. 6
      apps/api/src/app/import/import.service.ts
  3. 11
      apps/api/src/validators/is-currency-code.ts
  4. 5
      apps/client/src/app/pages/portfolio/activities/import-activities-dialog/import-activities-dialog.component.ts

6
CHANGELOG.md

@ -9,8 +9,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Improved the error message of the currency code validation
- Tightened the currency code validation by requiring uppercase letters
- Renamed `Order` to `activities` in the `Account` database schema
### Fixed
- Improved the file selector of the activities import functionality to accept case-insensitive file extensions (`.CSV` and `.JSON`)
## 2.155.0 - 2025-04-23
### Added

6
apps/api/src/app/import/import.service.ts

@ -167,9 +167,9 @@ export class ImportService {
for (const account of accountsDto) {
// Check if there is any existing account with the same ID
const accountWithSameId = existingAccounts.find(
(existingAccount) => existingAccount.id === account.id
);
const accountWithSameId = existingAccounts.find((existingAccount) => {
return existingAccount.id === account.id;
});
// If there is no account or if the account belongs to a different user then create a new account
if (!accountWithSameId || accountWithSameId.userId !== user.id) {

11
apps/api/src/validators/is-currency-code.ts

@ -25,19 +25,24 @@ export class IsExtendedCurrencyConstraint
implements ValidatorConstraintInterface
{
public defaultMessage() {
return '$value must be a valid ISO4217 currency code';
return '$property must be a valid ISO4217 currency code';
}
public validate(currency: any) {
// Return true if currency is a standard ISO 4217 code or a derived currency
return (
isISO4217CurrencyCode(currency) ||
this.isUpperCase(currency) &&
(isISO4217CurrencyCode(currency) ||
[
...DERIVED_CURRENCIES.map((derivedCurrency) => {
return derivedCurrency.currency;
}),
'USX'
].includes(currency)
].includes(currency))
);
}
private isUpperCase(aString: string) {
return aString === aString?.toUpperCase();
}
}

5
apps/client/src/app/pages/portfolio/activities/import-activities-dialog/import-activities-dialog.component.ts

@ -247,9 +247,10 @@ export class ImportActivitiesDialog implements OnDestroy {
reader.onload = async (readerEvent) => {
const fileContent = readerEvent.target.result as string;
const fileExtension = file.name.split('.').pop()?.toLowerCase();
try {
if (file.name.endsWith('.json')) {
if (fileExtension === 'json') {
const content = JSON.parse(fileContent);
this.accounts = content.accounts;
@ -294,7 +295,7 @@ export class ImportActivitiesDialog implements OnDestroy {
}
return;
} else if (file.name.endsWith('.csv')) {
} else if (fileExtension === 'csv') {
const content = fileContent.split('\n').slice(1);
try {

Loading…
Cancel
Save