-
Notifications
You must be signed in to change notification settings - Fork 2
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(budget): list page budget summaries #215
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ea8087d
budget summary
OchiengPaul442 3191518
changed value tag
OchiengPaul442 47e1ded
Merge branch 'main' of https://github.com/e-picsa/picsa-apps into ft-…
OchiengPaul442 d8c487d
worked on issues raised in the feedback
OchiengPaul442 409a137
html tag change
OchiengPaul442 0f6a5d5
worked on PR feedback
OchiengPaul442 63ced18
Merge branch 'main' into ft-budget-detailed-summary
OchiengPaul442 4e9d88c
ui adjustments
OchiengPaul442 bd3d26e
Merge branch 'main' of https://github.com/e-picsa/picsa-apps into ft-…
chrismclarke 6dde64e
chore: update mat icons
chrismclarke 8f81791
chore: change ts to html template
chrismclarke 025c695
chore: remove inline template
chrismclarke 700e144
chore: improve type defs
chrismclarke dcfbbf2
refactor: custom icons
chrismclarke 3183960
chore: code tidying
chrismclarke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
apps/picsa-tools/budget-tool/src/app/components/budget-summary/budget-summary.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<div class="summary-container"> | ||
<section matTooltip="Total Family Labour Hours"> | ||
<mat-icon svgIcon="picsa_budget_family-labour" class="summary-icon"></mat-icon> | ||
<span class="summary-value">{{ totalFamilyLabourHours }} {{ 'hours' | translate }}</span> | ||
</section> | ||
<!-- TODO - confirm with UoR if inputs/outputs preferred alongside net cash balance --> | ||
<!-- <p matTooltip="Total Inputs Value"> | ||
<img [src]="getImagePath('inputs', 'svg')" alt="Receipt Icon" class="icon" /> : <b>{{ totalInputsValue }}</b> | ||
</p> | ||
<p matTooltip="Total Outputs Value"> | ||
<img [src]="getImagePath('outputs', 'svg')" alt="Monetization Icon" class="icon" />: | ||
<b>{{ totalOutputsValue }}</b> | ||
</p> --> | ||
@for (produce of totalProduceSummary; track produce.id) { | ||
<section [matTooltip]="'Total ' + produce.label + ' consumed'"> | ||
<img [src]="produce.imgPath" [alt]="produce.label + ' Icon'" class="summary-icon" /> | ||
<span class="summary-value">{{ produce.total }} {{ 'consumed' | translate }}</span> | ||
</section> | ||
} | ||
|
||
<section matTooltip="Final Cash Balance"> | ||
<mat-icon svgIcon="picsa_budget_cash_balance" alt="Wallet Icon" class="summary-icon" /> | ||
<span class="summary-value">{{ finalCashBalance }} {{ 'balance' | translate }}</span> | ||
</section> | ||
</div> |
20 changes: 20 additions & 0 deletions
20
apps/picsa-tools/budget-tool/src/app/components/budget-summary/budget-summary.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
:host { | ||
display: block; | ||
} | ||
.summary-container { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 8px; | ||
} | ||
section { | ||
display: flex; | ||
align-items: center; | ||
} | ||
.summary-icon { | ||
width: 24px; | ||
height: 24px; | ||
font-size: 24px; | ||
} | ||
.summary-value { | ||
margin-left: 8px; | ||
} |
21 changes: 21 additions & 0 deletions
21
...icsa-tools/budget-tool/src/app/components/budget-summary/budget-summary.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { BudgetSummaryComponent } from './budget-summary.component'; | ||
|
||
describe('BudgetSummaryComponent', () => { | ||
let component: BudgetSummaryComponent; | ||
let fixture: ComponentFixture<BudgetSummaryComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [BudgetSummaryComponent], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(BudgetSummaryComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
71 changes: 71 additions & 0 deletions
71
apps/picsa-tools/budget-tool/src/app/components/budget-summary/budget-summary.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
|
||
import { IBudget } from '../../models/budget-tool.models'; | ||
import { IBudgetCardWithValues } from '../../schema'; | ||
|
||
interface ISummaryEntry { | ||
label: string; | ||
total: number; | ||
id: string; | ||
imgPath: string; | ||
} | ||
|
||
@Component({ | ||
selector: 'budget-summary', | ||
templateUrl: './budget-summary.component.html', | ||
styleUrls: ['./budget-summary.component.scss'], | ||
}) | ||
export class BudgetSummaryComponent implements OnInit { | ||
@Input() budgetData: IBudget['data']; | ||
|
||
totalFamilyLabourHours: number = 0; | ||
totalInputsValue: number = 0; | ||
totalOutputsValue: number = 0; | ||
totalProduceSummary: ISummaryEntry[] = []; | ||
finalCashBalance: number = 0; | ||
|
||
ngOnInit(): void { | ||
this.calculateSummary(); | ||
} | ||
|
||
calculateSummary() { | ||
this.budgetData.forEach((item) => { | ||
item.familyLabour.forEach((member) => { | ||
this.totalFamilyLabourHours += member.values.quantity; | ||
}); | ||
|
||
item.inputs.forEach((input) => { | ||
this.totalInputsValue += input.values.total; | ||
}); | ||
|
||
item.outputs.forEach((output) => { | ||
this.totalOutputsValue += output.values.total; | ||
}); | ||
|
||
item.produceConsumed.forEach((consumed) => { | ||
this.updateProduceSummary(consumed); | ||
}); | ||
}); | ||
|
||
this.finalCashBalance = this.totalOutputsValue - this.totalInputsValue; | ||
} | ||
|
||
updateProduceSummary(consumed: IBudgetCardWithValues) { | ||
const existingProduce = this.totalProduceSummary.find((p) => p.label === consumed.label); | ||
|
||
if (existingProduce) { | ||
existingProduce.total += consumed.values.quantity; | ||
} else { | ||
this.totalProduceSummary.push({ | ||
label: consumed.label, | ||
total: consumed.values.quantity, | ||
id: consumed.id, | ||
imgPath: this.getImagePath(consumed.id, consumed.imgType), | ||
}); | ||
} | ||
} | ||
|
||
getImagePath(imageId: string, extension: 'png' | 'svg'): string { | ||
return `assets/budget-cards/${imageId}.${extension}`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,8 @@ mat-card-content { | |
padding: 0; | ||
margin-bottom: 0.5rem; | ||
} | ||
|
||
.date { | ||
display: flex; | ||
justify-content: flex-end; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
apps/picsa-tools/budget-tool/src/assets/budget-cards/cash-balance.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions
20
apps/picsa-tools/budget-tool/src/assets/svgs/cash_balance.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(+) Nice concise methods to calculate the totals