Skip to content

Commit

Permalink
fix: visaCal - add missing credit transactions and fix the amount fie…
Browse files Browse the repository at this point in the history
…ld for credits (#808)

👍
  • Loading branch information
itamarco authored Dec 17, 2023
1 parent fe263a8 commit 9cbceaa
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/scrapers/visa-cal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,15 @@ function createLoginFields(credentials: ScraperSpecificCredentials) {
}

function convertParsedDataToTransactions(parsedData: CardTransactionDetails[]): Transaction[] {
return parsedData
const bankAccounts = parsedData
.flatMap((monthData) => monthData.result.bankAccounts)

Check failure on line 180 in src/scrapers/visa-cal.ts

View workflow job for this annotation

GitHub Actions / Release

Missing semicolon

const regularDebitDays = bankAccounts
.flatMap((accounts) => accounts.debitDates)

Check failure on line 183 in src/scrapers/visa-cal.ts

View workflow job for this annotation

GitHub Actions / Release

Missing semicolon
const immediateDebitDays = bankAccounts
.flatMap((accounts) => accounts.immidiateDebits.debitDays)

Check failure on line 185 in src/scrapers/visa-cal.ts

View workflow job for this annotation

GitHub Actions / Release

Multiple spaces found before 'accounts'

Check failure on line 185 in src/scrapers/visa-cal.ts

View workflow job for this annotation

GitHub Actions / Release

Missing semicolon

return [...regularDebitDays, ...immediateDebitDays]
.flatMap((debitDate) => debitDate.transactions)
.map((transaction) => {
const installments = (transaction.curPaymentNum && transaction.numOfPayments &&
Expand All @@ -193,11 +199,6 @@ function convertParsedDataToTransactions(parsedData: CardTransactionDetails[]):
let chargedAmount = transaction.amtBeforeConvAndIndex * (-1);

Check failure on line 199 in src/scrapers/visa-cal.ts

View workflow job for this annotation

GitHub Actions / Release

'chargedAmount' is never reassigned. Use 'const' instead
let originalAmount = transaction.trnAmt * (-1);

Check failure on line 200 in src/scrapers/visa-cal.ts

View workflow job for this annotation

GitHub Actions / Release

'originalAmount' is never reassigned. Use 'const' instead

if (transaction.trnTypeCode === trnTypeCode.credit) {
chargedAmount = transaction.amtBeforeConvAndIndex;
originalAmount = transaction.trnAmt;
}

const result: Transaction = {
identifier: transaction.trnIntId,
type: [trnTypeCode.regular, trnTypeCode.standingOrder].includes(transaction.trnTypeCode) ?
Expand Down

0 comments on commit 9cbceaa

Please sign in to comment.