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>
<td style="width: 10%"> <td style="width: 10%">
<mat-form-field> <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> </mat-form-field>
</td> </td>
</tr> </tr>

View File

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