Comparing version 0.0.13 to 0.0.14
@@ -5,4 +5,11 @@ 'use strict'; | ||
/** | ||
* When payments are due | ||
*/ | ||
(function (PaymentDueTime) { | ||
/** Payments due at the beginning of a period */ | ||
PaymentDueTime["Begin"] = "begin"; | ||
/** Payments are due at the end of a period */ | ||
PaymentDueTime["End"] = "end"; // 0 | ||
@@ -304,2 +311,27 @@ })(exports.PaymentDueTime || (exports.PaymentDueTime = {})); | ||
/** | ||
* Compute the payment against loan principal. | ||
* | ||
* @param rate - Rate of interest (per period) | ||
* @param per - Amount paid against the loan changes. The `per` is the period of interest. | ||
* @param nper - Number of compounding periods | ||
* @param pv - Present value | ||
* @param fv - Future value | ||
* @param when - When payments are due | ||
* | ||
* @returns the payment against loan principal | ||
*/ | ||
function ppmt(rate, per, nper, pv, fv, when) { | ||
if (fv === void 0) { | ||
fv = 0; | ||
} | ||
if (when === void 0) { | ||
when = exports.PaymentDueTime.End; | ||
} | ||
var total = pmt(rate, nper, pv, fv, when); | ||
return total - ipmt(rate, per, nper, pv, fv, when); | ||
} | ||
/** | ||
* This function is here to simply have a different name for the 'fv' | ||
@@ -321,2 +353,3 @@ * function to not interfere with the 'fv' keyword argument within the 'ipmt' | ||
exports.pmt = pmt; | ||
exports.ppmt = ppmt; | ||
//# sourceMappingURL=financial.cjs.development.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var e;function t(e,t,n,r,i){if(void 0===i&&(i=exports.PaymentDueTime.End),0===e)return-(r+n*t);var o=Math.pow(1+e,t);return-r*o-n*(1+e*(i===exports.PaymentDueTime.Begin?1:0))/e*(o-1)}function n(e,t,n,r,i){void 0===r&&(r=0),void 0===i&&(i=exports.PaymentDueTime.End);var o=0===e,u=Math.pow(1+e,t),m=i===exports.PaymentDueTime.Begin?1:0,a=o?1:e;return-(r+n*u)/(o?t:(1+a*m)*(u-1)/a)}function r(e,n,r,i,o){return t(e,n-1,r,i,o)}Object.defineProperty(exports,"__esModule",{value:!0}),(e=exports.PaymentDueTime||(exports.PaymentDueTime={})).Begin="begin",e.End="end",exports.fv=t,exports.ipmt=function(e,t,i,o,u,m){if(void 0===u&&(u=0),void 0===m&&(m=exports.PaymentDueTime.End),t<1)return Number.NaN;if(m===exports.PaymentDueTime.Begin&&1===t)return 0;var a=r(e,t,n(e,i,o,u,m),o,m)*e;return m===exports.PaymentDueTime.Begin&&t>1&&(a/=1+e),a},exports.nper=function(e,t,n,r,i){if(void 0===r&&(r=0),void 0===i&&(i=exports.PaymentDueTime.End),0===e)return-(r+n)/t;var o=t*(1+e*(i===exports.PaymentDueTime.Begin?1:0))/e;return Math.log((-r+o)/(n+o))/Math.log(1+e)},exports.pmt=n; | ||
"use strict";var e;function t(e,t,n,r,i){if(void 0===i&&(i=exports.PaymentDueTime.End),0===e)return-(r+n*t);var o=Math.pow(1+e,t);return-r*o-n*(1+e*(i===exports.PaymentDueTime.Begin?1:0))/e*(o-1)}function n(e,t,n,r,i){void 0===r&&(r=0),void 0===i&&(i=exports.PaymentDueTime.End);var o=0===e,u=Math.pow(1+e,t),m=i===exports.PaymentDueTime.Begin?1:0,p=o?1:e;return-(r+n*u)/(o?t:(1+p*m)*(u-1)/p)}function r(e,t,r,o,u,m){if(void 0===u&&(u=0),void 0===m&&(m=exports.PaymentDueTime.End),t<1)return Number.NaN;if(m===exports.PaymentDueTime.Begin&&1===t)return 0;var p=i(e,t,n(e,r,o,u,m),o,m)*e;return m===exports.PaymentDueTime.Begin&&t>1&&(p/=1+e),p}function i(e,n,r,i,o){return t(e,n-1,r,i,o)}Object.defineProperty(exports,"__esModule",{value:!0}),(e=exports.PaymentDueTime||(exports.PaymentDueTime={})).Begin="begin",e.End="end",exports.fv=t,exports.ipmt=r,exports.nper=function(e,t,n,r,i){if(void 0===r&&(r=0),void 0===i&&(i=exports.PaymentDueTime.End),0===e)return-(r+n)/t;var o=t*(1+e*(i===exports.PaymentDueTime.Begin?1:0))/e;return Math.log((-r+o)/(n+o))/Math.log(1+e)},exports.pmt=n,exports.ppmt=function(e,t,i,o,u,m){return void 0===u&&(u=0),void 0===m&&(m=exports.PaymentDueTime.End),n(e,i,o,u,m)-r(e,t,i,o,u,m)}; | ||
//# sourceMappingURL=financial.cjs.production.min.js.map |
@@ -0,3 +1,8 @@ | ||
/** | ||
* When payments are due | ||
*/ | ||
export declare enum PaymentDueTime { | ||
/** Payments due at the beginning of a period */ | ||
Begin = "begin", | ||
/** Payments are due at the end of a period */ | ||
End = "end" | ||
@@ -195,1 +200,14 @@ } | ||
export declare function ipmt(rate: number, per: number, nper: number, pv: number, fv?: number, when?: PaymentDueTime): number; | ||
/** | ||
* Compute the payment against loan principal. | ||
* | ||
* @param rate - Rate of interest (per period) | ||
* @param per - Amount paid against the loan changes. The `per` is the period of interest. | ||
* @param nper - Number of compounding periods | ||
* @param pv - Present value | ||
* @param fv - Future value | ||
* @param when - When payments are due | ||
* | ||
* @returns the payment against loan principal | ||
*/ | ||
export declare function ppmt(rate: number, per: number, nper: number, pv: number, fv?: number, when?: PaymentDueTime): number; |
@@ -0,5 +1,11 @@ | ||
/** | ||
* When payments are due | ||
*/ | ||
var PaymentDueTime; | ||
(function (PaymentDueTime) { | ||
/** Payments due at the beginning of a period */ | ||
PaymentDueTime["Begin"] = "begin"; | ||
/** Payments are due at the end of a period */ | ||
PaymentDueTime["End"] = "end"; // 0 | ||
@@ -301,2 +307,27 @@ })(PaymentDueTime || (PaymentDueTime = {})); | ||
/** | ||
* Compute the payment against loan principal. | ||
* | ||
* @param rate - Rate of interest (per period) | ||
* @param per - Amount paid against the loan changes. The `per` is the period of interest. | ||
* @param nper - Number of compounding periods | ||
* @param pv - Present value | ||
* @param fv - Future value | ||
* @param when - When payments are due | ||
* | ||
* @returns the payment against loan principal | ||
*/ | ||
function ppmt(rate, per, nper, pv, fv, when) { | ||
if (fv === void 0) { | ||
fv = 0; | ||
} | ||
if (when === void 0) { | ||
when = PaymentDueTime.End; | ||
} | ||
var total = pmt(rate, nper, pv, fv, when); | ||
return total - ipmt(rate, per, nper, pv, fv, when); | ||
} | ||
/** | ||
* This function is here to simply have a different name for the 'fv' | ||
@@ -314,3 +345,3 @@ * function to not interfere with the 'fv' keyword argument within the 'ipmt' | ||
export { PaymentDueTime, fv, ipmt, nper, pmt }; | ||
export { PaymentDueTime, fv, ipmt, nper, pmt, ppmt }; | ||
//# sourceMappingURL=financial.esm.js.map |
@@ -5,3 +5,3 @@ { | ||
"author": "Luciano Mammino <no@spam.com> (https://loige.co)", | ||
"version": "0.0.13", | ||
"version": "0.0.14", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
@@ -88,3 +88,3 @@ # Financial | ||
- [X] `ipmt` | ||
- [ ] `ppmt` | ||
- [X] `ppmt` | ||
- [ ] `pv` | ||
@@ -91,0 +91,0 @@ - [ ] `rate` |
@@ -0,3 +1,8 @@ | ||
/** | ||
* When payments are due | ||
*/ | ||
export enum PaymentDueTime { | ||
/** Payments due at the beginning of a period */ | ||
Begin = 'begin', // 1 | ||
/** Payments are due at the end of a period */ | ||
End = 'end' // 0 | ||
@@ -278,2 +283,19 @@ } | ||
/** | ||
* Compute the payment against loan principal. | ||
* | ||
* @param rate - Rate of interest (per period) | ||
* @param per - Amount paid against the loan changes. The `per` is the period of interest. | ||
* @param nper - Number of compounding periods | ||
* @param pv - Present value | ||
* @param fv - Future value | ||
* @param when - When payments are due | ||
* | ||
* @returns the payment against loan principal | ||
*/ | ||
export function ppmt (rate: number, per: number, nper: number, pv: number, fv = 0, when = PaymentDueTime.End) : number { | ||
const total = pmt(rate, nper, pv, fv, when) | ||
return total - ipmt(rate, per, nper, pv, fv, when) | ||
} | ||
/** | ||
* This function is here to simply have a different name for the 'fv' | ||
@@ -280,0 +302,0 @@ * function to not interfere with the 'fv' keyword argument within the 'ipmt' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
82591
1156