Skip to content

Instantly share code, notes, and snippets.

View ghalimi's full-sized avatar

Ismael Ghalimi ghalimi

View GitHub Profile
@ghalimi
ghalimi / IRR.js
Created January 22, 2013 01:45
IRR Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
// Some algorithms have been ported from Apache OpenOffice:
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
@ghalimi
ghalimi / IPMT.js
Created January 22, 2013 00:35
IPMT Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
// Some algorithms have been ported from Apache OpenOffice:
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
@ghalimi
ghalimi / FVSCHEDULE.js
Last active December 11, 2015 10:58
FVSCHEDULE Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
function FVSCHEDULE(principal, schedule) {
// Initialize future value
var future = principal;
// Apply all interests in schedule
for (var i = 0; i < schedule.length; i++) {
// Return error if schedule value is not a number
if (isNaN(schedule[i])) return '#VALUE!';
@ghalimi
ghalimi / FV.js
Created January 21, 2013 22:43
FV Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
// Some algorithms have been ported from Apache OpenOffice:
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
@ghalimi
ghalimi / PMT.js
Last active April 27, 2023 16:40
PMT Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
// Some algorithms have been ported from Apache OpenOffice:
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
@ghalimi
ghalimi / EFFECT.js
Created January 21, 2013 22:11
EFFECT Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
function EFFECT(rate, periods) {
// Return error if any of the parameters is not a number
if (isNaN(rate) || isNaN(periods)) return '#VALUE!';
// Return error if rate <=0 or periods < 1
if (rate <=0 || periods < 1) return '#NUM!';
// Truncate periods if it is not an integer
@ghalimi
ghalimi / DOLLARFR.js
Last active December 11, 2015 10:48
DOLLARFR Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
// Some algorithms have been ported from Apache OpenOffice:
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
@ghalimi
ghalimi / DOLLARDE.js
Last active December 11, 2015 10:39
DOLLARDE Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
// Some algorithms have been ported from Apache OpenOffice:
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
@ghalimi
ghalimi / DDB.js
Last active December 11, 2015 10:38
DDB Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
function DDB(cost, salvage, life, period, factor) {
// Initialize factor
var factor = (typeof factor === 'undefined') ? 2 : factor;
// Return error if any of the parameters is not a number
if (isNaN(cost) || isNaN(salvage) || isNaN(life) || isNaN(period) || isNaN(factor)) return '#VALUE!';
// Return error if any of the parameters is negative or if factor is null
@ghalimi
ghalimi / DB.js
Last active December 11, 2015 10:38
DB Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
function DB(cost, salvage, life, period, month) {
// Initialize month
var month = (typeof month === 'undefined') ? 12 : month;
// Return error if any of the parameters is not a number
if (isNaN(cost) || isNaN(salvage) || isNaN(life) || isNaN(period) || isNaN(month)) return '#VALUE!';
// Return error if any of the parameters is negative