-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2dcbe04
commit ea8087d
Showing
7 changed files
with
131 additions
and
6 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
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,34 @@ | ||
.summary-container { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: flex-start; | ||
margin-bottom: 1.2rem; | ||
|
||
h2 { | ||
margin: 0 0 0.5rem 0; | ||
padding: 0; | ||
font-size: 1rem; | ||
font-weight: 500; | ||
color: #000; | ||
} | ||
|
||
.summary-list { | ||
display: flex; | ||
gap: 1rem; | ||
flex-wrap: wrap; | ||
justify-content: flex-start; | ||
align-items: flex-start; | ||
|
||
p { | ||
margin: 0; | ||
padding: 0; | ||
font-size: 1rem; | ||
font-weight: 400; | ||
color: #000; | ||
|
||
span { | ||
font-weight: 501; | ||
} | ||
} | ||
} | ||
} |
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(); | ||
}); | ||
}); |
63 changes: 63 additions & 0 deletions
63
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,63 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'budget-summary', | ||
template: ` | ||
<div class="summary-container"> | ||
<h2>Budget Summary</h2> | ||
<div class="summary-list"> | ||
<p matTooltip="Total Family Labour Hours"> | ||
TFLH: <span>{{ totalFamilyLabourHours }}</span> | ||
</p> | ||
<p matTooltip="Total Inputs Value"> | ||
TIV: <span>{{ totalInputsValue }}</span> | ||
</p> | ||
<p matTooltip="Total Outputs Value"> | ||
TOV: <span>{{ totalOutputsValue }}</span> | ||
</p> | ||
<p matTooltip="Total Produce Consumed"> | ||
TPC: <span>{{ totalProduceConsumed }}</span> | ||
</p> | ||
<p matTooltip="Final Cash Balance"> | ||
FCB: <span>{{ finalCashBalance }}</span> | ||
</p> | ||
</div> | ||
</div> | ||
`, | ||
styleUrls: ['./budget-summary.component.scss'], | ||
}) | ||
export class BudgetSummaryComponent implements OnInit { | ||
@Input() budgetData: any; | ||
|
||
totalFamilyLabourHours: number = 0; | ||
totalInputsValue: number = 0; | ||
totalOutputsValue: number = 0; | ||
totalProduceConsumed: number = 0; | ||
finalCashBalance: number = 0; | ||
|
||
ngOnInit(): void { | ||
this.calculateSummary(); | ||
} | ||
|
||
calculateSummary() { | ||
this.budgetData.data.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.totalProduceConsumed += consumed.values.quantity; | ||
}); | ||
}); | ||
|
||
this.finalCashBalance = this.totalOutputsValue - this.totalInputsValue; | ||
} | ||
} |
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
7 changes: 5 additions & 2 deletions
7
apps/picsa-tools/budget-tool/src/app/components/list-item/budget-list-item.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
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