Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update Personal Transaction card to display exact amount #3373

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,35 @@
<ion-skeleton-text class="shimmer--date" animated></ion-skeleton-text>
<div class="shimmer--header">
<ion-skeleton-text class="shimmer--desc" animated></ion-skeleton-text>
<ion-skeleton-text class="shimmer--amount" animated></ion-skeleton-text>
</div>
<ion-skeleton-text class="shimmer--amount" animated></ion-skeleton-text>
<ion-skeleton-text class="shimmer--sub-header" animated></ion-skeleton-text>
<div class="shimmer--header">
<ion-skeleton-text class="shimmer--desc" animated></ion-skeleton-text>
<ion-skeleton-text class="shimmer--amount" animated></ion-skeleton-text>
</div>
<ion-skeleton-text class="shimmer--amount" animated></ion-skeleton-text>
<ion-skeleton-text class="shimmer--sub-header" animated></ion-skeleton-text>
<div class="shimmer--header">
<ion-skeleton-text class="shimmer--desc" animated></ion-skeleton-text>
<ion-skeleton-text class="shimmer--amount" animated></ion-skeleton-text>
</div>
<ion-skeleton-text class="shimmer--amount" animated></ion-skeleton-text>
<ion-skeleton-text class="shimmer--sub-header" animated></ion-skeleton-text>
</div>
<div class="shimmer--section">
<ion-skeleton-text class="shimmer--date" animated></ion-skeleton-text>
<div class="shimmer--header">
<ion-skeleton-text class="shimmer--desc" animated></ion-skeleton-text>
<ion-skeleton-text class="shimmer--amount" animated></ion-skeleton-text>
</div>
<ion-skeleton-text class="shimmer--amount" animated></ion-skeleton-text>
<ion-skeleton-text class="shimmer--sub-header" animated></ion-skeleton-text>
<div class="shimmer--header">
<ion-skeleton-text class="shimmer--desc" animated></ion-skeleton-text>
<ion-skeleton-text class="shimmer--amount" animated></ion-skeleton-text>
</div>
<ion-skeleton-text class="shimmer--sub-header" animated></ion-skeleton-text>
<div class="shimmer--header">
<ion-skeleton-text class="shimmer--desc" animated></ion-skeleton-text>
<ion-skeleton-text class="shimmer--amount" animated></ion-skeleton-text>
</div>
<ion-skeleton-text class="shimmer--amount" animated></ion-skeleton-text>
<ion-skeleton-text class="shimmer--sub-header" animated></ion-skeleton-text>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.shimmer {
&--section {
margin-bottom: 30px;
padding: 12px;
SahilK-027 marked this conversation as resolved.
Show resolved Hide resolved
}

&--date {
Expand All @@ -15,16 +16,18 @@
}

&--desc {
width: 65%;
height: 22px;
width: 100%;
height: 20px;
}

&--amount {
width: 25%;
width: 35%;
height: 22px;
margin-bottom: 8px;
}

&--sub-header {
width: 35%;
width: 45%;
height: 20px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,55 @@
<mat-checkbox class="custom-mat-checkbox expenses-card--checkbox" [checked]="isSelected" disabled> </mat-checkbox>
</div>
<div class="personal-card-transaction--details">
<div class="personal-card-transaction--vendor">
{{ description }}
</div>
<div class="personal-card-transaction--button">
<ng-container *ngIf="status === 'INITIALIZED' || status === 'HIDDEN'"> Create expense </ng-container>
<ng-container *ngIf="status === 'MATCHED'"> View expense </ng-container>
<ion-icon
*ngIf="!isMatchedCountLoading"
[src]="'assets/svg/arrow-right.svg'"
class="personal-card-transaction--icon"
slot="icon-only"
>
</ion-icon>
<ion-spinner *ngIf="isMatchedCountLoading" name="crescent" class="personal-card-transaction--icon"></ion-spinner>
<!-- List Icon -->
<mat-icon class="personal-card-transaction--list-icon" svgIcon="list"></mat-icon>
SahilK-027 marked this conversation as resolved.
Show resolved Hide resolved

<!-- Txn details -->
<div class="personal-card-transaction--vendor-amount-container">
<!-- Vendor -->
<div class="personal-card-transaction--vendor">
{{ description }}
</div>

<!-- Amount -->
<div class="personal-card-transaction--currency-amount-container">
<span
class="personal-card-transaction--currency"
[ngClass]="{ ' personal-card-transaction--green': type === 'credit' }"
>{{ currency }}
</span>
<span
class="personal-card-transaction--amount"
[ngClass]="{ 'personal-card-transaction--green': type === 'credit' }"
>
{{ { value: amount, currencyCode: currency, skipSymbol: true } | exactCurrency }}
</span>
<span
class="personal-card-transaction--type"
[ngClass]="{ ' personal-card-transaction--green': type === 'credit' }"
>
<ng-container *ngIf="type === 'debit'">DR</ng-container>
<ng-container *ngIf="type === 'credit'">CR</ng-container>
</span>
</div>
SahilK-027 marked this conversation as resolved.
Show resolved Hide resolved

<!-- Buttons -->
<div class="personal-card-transaction--button">
<ng-container *ngIf="status === 'INITIALIZED' || status === 'HIDDEN'"> Create expense </ng-container>
<ng-container *ngIf="status === 'MATCHED'"> View expense </ng-container>
<ion-icon
*ngIf="!isMatchedCountLoading"
[src]="'assets/svg/arrow-right.svg'"
class="personal-card-transaction--icon"
slot="icon-only"
>
</ion-icon>
<ion-spinner
*ngIf="isMatchedCountLoading"
name="crescent"
class="personal-card-transaction--icon"
></ion-spinner>
</div>
SahilK-027 marked this conversation as resolved.
Show resolved Hide resolved
</div>
</div>
<div class="personal-card-transaction--currency-amount-container ion-text-right">
<span
class="personal-card-transaction--currency"
[ngClass]="{ ' personal-card-transaction--green': type === 'credit' }"
>{{ currency }}
</span>
<span
class="personal-card-transaction--amount"
[ngClass]="{ 'personal-card-transaction--green': type === 'credit' }"
>{{ amount | currency : currency : '' }}
</span>
<span
class="personal-card-transaction--type"
[ngClass]="{ ' personal-card-transaction--green': type === 'credit' }"
>
<ng-container *ngIf="type === 'debit'">DR</ng-container>
<ng-container *ngIf="type === 'credit'">CR</ng-container>
</span>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@

.personal-card-transaction {
&--date {
color: $grey-light;
color: $black-light;
font-size: 14px;
padding: 14px 0 4px 12px;
padding: 24px 16px 16px 16px;
font-weight: 500;

&__from-reports {
background-color: $pure-white;
}
background-color: $white;
}

&--body {
background-color: $pure-white;
min-height: 99px;
padding: 24px 4px 24px 12px;
padding: 12px;
}

&--deatils-block {
Expand All @@ -41,26 +38,38 @@
}

&--details {
display: flex;
justify-content: flex-start;
gap: 8px;
SahilK-027 marked this conversation as resolved.
Show resolved Hide resolved
flex-grow: 3;
margin: 2px 25px 0px 0px;
overflow: hidden;
}

&--list-icon {
width: 16px;
height: 16px;
padding-top: 2px;
}

&--vendor-amount-container {
max-width: 90%;
}

&--vendor {
color: $black;
font-size: 18px;
font-weight: 500;
font-size: 14px;
font-weight: 400;
line-height: 1.3;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

&--button {
color: $text-button-grey;
color: $brand-primary;
font-size: 14px;
line-height: 18px;
margin-top: 6px;
font-weight: 500;

&__not-filled {
Expand All @@ -71,10 +80,11 @@
&--currency-amount-container {
white-space: nowrap;
flex-grow: 1;
margin: 10px 0;
}

&--currency {
color: $black-light;
color: $black;
font-weight: 500;
font-size: 16px;
line-height: 20px;
Expand All @@ -83,15 +93,15 @@

&--amount {
color: $black;
font-size: 20px;
font-size: 16px;
line-height: 26px;
margin-right: 2px;
font-weight: 500;
}

&--type {
color: $grey-light;
font-size: 12px;
color: $black-light;
font-size: 10px;
line-height: 1.3;
margin-right: 15px;
font-weight: 400;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import { PersonalCardTransactionComponent } from './personal-card-transaction.co
import { IonicModule } from '@ionic/angular';
import { DateFormatPipe } from '../../pipes/date-format.pipe';
import { getElementBySelector, getTextContent } from 'src/app/core/dom-helpers';
import { ExactCurrencyPipe } from '../../pipes/exact-currency.pipe';
import { FyCurrencyPipe } from '../../pipes/fy-currency.pipe';
import { CurrencyPipe } from '@angular/common';
import { MatIconModule } from '@angular/material/icon';
import { MatIconTestingModule } from '@angular/material/icon/testing';

describe('PersonalCardTransactionComponent', () => {
let component: PersonalCardTransactionComponent;
Expand All @@ -12,13 +17,15 @@ describe('PersonalCardTransactionComponent', () => {
beforeEach(waitForAsync(() => {
const dateFormatPipeSpy = jasmine.createSpyObj('DateFormatPipe', ['transform']);
TestBed.configureTestingModule({
declarations: [PersonalCardTransactionComponent, DateFormatPipe],
imports: [IonicModule.forRoot(), IconModule],
declarations: [PersonalCardTransactionComponent, DateFormatPipe, ExactCurrencyPipe, FyCurrencyPipe],
imports: [IonicModule.forRoot(), IconModule, MatIconTestingModule, MatIconModule],
providers: [
{
provide: DateFormatPipe,
useValue: dateFormatPipeSpy,
},
FyCurrencyPipe,
CurrencyPipe,
SahilK-027 marked this conversation as resolved.
Show resolved Hide resolved
],
}).compileComponents();

Expand Down Expand Up @@ -75,12 +82,12 @@ describe('PersonalCardTransactionComponent', () => {
it('should return true when the transaction is selected', () => {
component.selectedElements = ['btxn4xVrxJS1Kz', 'btxnspKO99BGrB'];
component.selectAll = true;
expect(component.isSelected).toBe(true);
expect(component.isSelected).toBeTrue();
});

it('should return false when the transaction is not selected', () => {
component.txnId = 'some-other-txn-id';
expect(component.isSelected).toBe(false);
expect(component.isSelected).toBeFalse();
});
});

Expand Down Expand Up @@ -115,14 +122,14 @@ describe('PersonalCardTransactionComponent', () => {

it('should display the currency, amount, and type', () => {
component.currency = 'USD';
component.amount = 123.45;
component.amount = 123678965.45;
SahilK-027 marked this conversation as resolved.
Show resolved Hide resolved
component.type = 'debit';
fixture.detectChanges();
const currencyElement = getElementBySelector(fixture, '.personal-card-transaction--currency');
expect(getTextContent(currencyElement)).toEqual('USD');

const amountElement = getElementBySelector(fixture, '.personal-card-transaction--amount');
expect(getTextContent(amountElement)).toEqual('123.45');
expect(getTextContent(amountElement)).toEqual('123,678,965.45');

const typeElement = getElementBySelector(fixture, '.personal-card-transaction--type');
expect(getTextContent(typeElement)).toEqual('DR');
Expand Down
Loading