Added total price calculator

This commit is contained in:
Zakary Timson 2018-07-12 17:16:33 -04:00
parent 2055c1f27b
commit 12fa5ade5c
2 changed files with 7 additions and 6 deletions

View File

@ -57,7 +57,7 @@
</td>
<td style="width: 10%">
<mat-form-field>
<input matInput placeholder="Cost" [value]="cost() | currency" [readonly]="true">
<input matInput placeholder="Total Cost" [value]="cost() | currency" [readonly]="true">
</mat-form-field>
</td>
</tr>

View File

@ -49,12 +49,13 @@ export class FormulaManagerComponent {
}
cost() {
console.log(
this.componentCosts.reduce((acc, row) => {
//acc + Number(new RegExp(/\$(\d+\.\d+)/).exec(row.nativeElement.innerHtml)[1])
return acc;
}, 0)
if (!this.formula || this.formula.components.filter(row => typeof row.component.get == 'function').length > 0)
return 0;
let cost = 0;
this.formula.components.forEach(
row => (cost += (((row.quantity / this.formula.total) * this._newTotal) / 1000) * row.component.cost)
);
return cost;
}
prompt() {