Skip to content

Instantly share code, notes, and snippets.

@Macadoshis
Created October 24, 2018 08:41
Show Gist options
  • Save Macadoshis/ac863e86efe77ac7eb5ca1a8894c20df to your computer and use it in GitHub Desktop.
Save Macadoshis/ac863e86efe77ac7eb5ca1a8894c20df to your computer and use it in GitHub Desktop.
private getTotalPriceWithoutVat(qwis: CWIE[], includeShippingCost: boolean = false): QuotationPrice {
if (!this._serviceFolder.Refused) {
const quotationPrice: QuotationPrice = <QuotationPrice>({ public: 0, sales: 0 });
// Sum all prices of selected work instructions
qwis
.filter((qwi: CWIE) => this.filterWorkInstructionForTotalPrice(qwi))
.forEach((qwie: CWIE) => {
quotationPrice.public += (qwie.PublicPriceWithDiscount || 0);
quotationPrice.sales += (qwie.SalesPriceWithDiscount || 0);
qwie.ChargeSpareParts.forEach((qsp: CSP) => {
const qspe: CSPE = <CSPE><any>(qsp);
quotationPrice.public += (qspe.PublicPriceWithDiscount || 0) * qspe.EstimationSparePart.Quantity;
quotationPrice.sales += (qspe.SalesPriceWithDiscount || 0) * qspe.EstimationSparePart.Quantity;
});
});
if (includeShippingCost) {
// Add shipping costs
quotationPrice.public += this.quotation.ShippingPublic || 0;
quotationPrice.sales += this.quotation.ShippingSales || 0;
}
return quotationPrice;
} else {
<QuotationPrice>({ public: this.quotation.TotalWithVATPublic, sales: this.quotation.TotalWithVATSales });
}
}
@Macadoshis
Copy link
Author

à tester 😝

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment