-
Notifications
You must be signed in to change notification settings - Fork 36
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
Calculated properties question #28
Comments
First of all, I would encourage avoiding Note that you can compute multiple extra properties as an object: L.augment({extra: ({a, b}) => {
const c = a + b
const d = c + 2
return {c, d}
}}) The current implementation of |
Appreciate the feedback and sorry about the fever - speedy recovery! Here is my example that uses car lease calculations, I'm all for avoiding augments :), but what you suggest fits better for this design: export const SUM = {
augment: L.augment({extra:({CarPrice, Downpayment, CostAddedtoLease, Term, HST, InterestRate, ResidualValuePercent}) =>{
const CapCost = CarPrice - Downpayment + CostAddedtoLease
const ResidualValueDollar = CarPrice * ResidualValuePercent / 100
const Depreciation = (CapCost - ResidualValueDollar) / Term
const Finance = (CapCost + ResidualValueDollar) * (InterestRate/2400)
const MonthlyPayment = Depreciation + Finance
const TotalMonthlyPayment = MonthlyPayment + (MonthlyPayment * (HST/100))
return {CapCost, ResidualValueDollar, Depreciation, Finance, MonthlyPayment, TotalMonthlyPayment}
}}),
CarPrice: "CarPrice",
ScenarioName: "ScenarioName",
id: "id",
Downpayment: "Downpayment",
CostAddedtoLease: "CostAddedtoLease",
ResidualValuePercent: "ResidualValuePercent",
Term: "Term",
HST: "HST",
InterestRate: "InterestRate",
CapCost: R.prop("CapCost"),
Depreciation: R.prop("Depreciation"),
Finance: R.prop("Finance"),
MonthlyPayment: R.prop("MonthlyPayment"),
ResidualValueDollar: R.prop("ResidualValueDollar"),
TotalMonthlyPayment: R.prop("TotalMonthlyPayment"),
CreateDate: "CreateDate",
ChangeDate: "ChangeDate"
} Also how the Really appreciate the framework and your help! |
Quick question, is it possible to calculate new properties based on new properties - what would be the approach, in the example below the
c
doesn't get passed in as a context tod
The text was updated successfully, but these errors were encountered: