n8n-nodes-salary-hike-calculator 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
ADDED
|
File without changes
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class SalaryHikeCalculator implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SalaryHikeCalculator = void 0;
|
|
4
|
+
class SalaryHikeCalculator {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.description = {
|
|
7
|
+
displayName: 'Salary Hike Calculator',
|
|
8
|
+
name: 'salaryHikeCalculator',
|
|
9
|
+
icon: 'file:salaryhike.svg',
|
|
10
|
+
group: ['transform'],
|
|
11
|
+
version: 1,
|
|
12
|
+
subtitle: '={{$parameter["operation"]}}',
|
|
13
|
+
description: 'Calculate salary hikes, increments, and percentage changes',
|
|
14
|
+
defaults: {
|
|
15
|
+
name: 'Salary Hike Calculator',
|
|
16
|
+
},
|
|
17
|
+
inputs: ['main'],
|
|
18
|
+
outputs: ['main'],
|
|
19
|
+
properties: [
|
|
20
|
+
{
|
|
21
|
+
displayName: 'Operation',
|
|
22
|
+
name: 'operation',
|
|
23
|
+
type: 'options',
|
|
24
|
+
noDataExpression: true,
|
|
25
|
+
options: [
|
|
26
|
+
{
|
|
27
|
+
name: 'Calculate Hike Percentage',
|
|
28
|
+
value: 'calculateHike',
|
|
29
|
+
description: 'Calculate percentage change between old and new salary',
|
|
30
|
+
action: 'Calculate hike percentage',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'Calculate New Salary',
|
|
34
|
+
value: 'calculateNewSalary',
|
|
35
|
+
description: 'Calculate new salary from percentage increase',
|
|
36
|
+
action: 'Calculate new salary from percentage',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'Open Web Calculator',
|
|
40
|
+
value: 'openCalculator',
|
|
41
|
+
description: 'Get link to interactive web calculator',
|
|
42
|
+
action: 'Open interactive calculator',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
default: 'calculateHike',
|
|
46
|
+
},
|
|
47
|
+
// Calculate Hike Percentage fields
|
|
48
|
+
{
|
|
49
|
+
displayName: 'Old Salary',
|
|
50
|
+
name: 'oldSalary',
|
|
51
|
+
type: 'number',
|
|
52
|
+
displayOptions: {
|
|
53
|
+
show: {
|
|
54
|
+
operation: ['calculateHike'],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
default: 50000,
|
|
58
|
+
description: 'Current/old salary amount',
|
|
59
|
+
required: true,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
displayName: 'New Salary',
|
|
63
|
+
name: 'newSalary',
|
|
64
|
+
type: 'number',
|
|
65
|
+
displayOptions: {
|
|
66
|
+
show: {
|
|
67
|
+
operation: ['calculateHike'],
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
default: 60000,
|
|
71
|
+
description: 'New salary amount after increment',
|
|
72
|
+
required: true,
|
|
73
|
+
},
|
|
74
|
+
// Calculate New Salary fields
|
|
75
|
+
{
|
|
76
|
+
displayName: 'Current Salary',
|
|
77
|
+
name: 'currentSalary',
|
|
78
|
+
type: 'number',
|
|
79
|
+
displayOptions: {
|
|
80
|
+
show: {
|
|
81
|
+
operation: ['calculateNewSalary'],
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
default: 50000,
|
|
85
|
+
description: 'Current salary amount',
|
|
86
|
+
required: true,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
displayName: 'Hike Percentage',
|
|
90
|
+
name: 'hikePercentage',
|
|
91
|
+
type: 'number',
|
|
92
|
+
displayOptions: {
|
|
93
|
+
show: {
|
|
94
|
+
operation: ['calculateNewSalary'],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
default: 10,
|
|
98
|
+
description: 'Percentage increase (e.g., 10 for 10%)',
|
|
99
|
+
required: true,
|
|
100
|
+
},
|
|
101
|
+
// Currency (for all operations)
|
|
102
|
+
{
|
|
103
|
+
displayName: 'Currency',
|
|
104
|
+
name: 'currency',
|
|
105
|
+
type: 'options',
|
|
106
|
+
displayOptions: {
|
|
107
|
+
show: {
|
|
108
|
+
operation: ['calculateHike', 'calculateNewSalary'],
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
options: [
|
|
112
|
+
{ name: 'INR (βΉ)', value: 'INR' },
|
|
113
|
+
{ name: 'USD ($)', value: 'USD' },
|
|
114
|
+
{ name: 'EUR (β¬)', value: 'EUR' },
|
|
115
|
+
{ name: 'GBP (Β£)', value: 'GBP' },
|
|
116
|
+
],
|
|
117
|
+
default: 'INR',
|
|
118
|
+
description: 'Currency symbol for display',
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
async execute() {
|
|
124
|
+
const items = this.getInputData();
|
|
125
|
+
const returnData = [];
|
|
126
|
+
for (let i = 0; i < items.length; i++) {
|
|
127
|
+
const operation = this.getNodeParameter('operation', i);
|
|
128
|
+
if (operation === 'calculateHike') {
|
|
129
|
+
const oldSalary = this.getNodeParameter('oldSalary', i);
|
|
130
|
+
const newSalary = this.getNodeParameter('newSalary', i);
|
|
131
|
+
const currency = this.getNodeParameter('currency', i);
|
|
132
|
+
if (oldSalary <= 0) {
|
|
133
|
+
throw new Error('Old salary must be greater than 0');
|
|
134
|
+
}
|
|
135
|
+
const hikeAmount = newSalary - oldSalary;
|
|
136
|
+
const hikePercentage = (hikeAmount / oldSalary) * 100;
|
|
137
|
+
const isPositive = hikePercentage >= 0;
|
|
138
|
+
let message = '';
|
|
139
|
+
if (hikePercentage > 20) {
|
|
140
|
+
message = 'π Excellent! That\'s a fantastic hike!';
|
|
141
|
+
}
|
|
142
|
+
else if (hikePercentage > 10) {
|
|
143
|
+
message = 'π Great! That\'s a good increment!';
|
|
144
|
+
}
|
|
145
|
+
else if (hikePercentage > 0) {
|
|
146
|
+
message = 'β¨ That\'s a positive change!';
|
|
147
|
+
}
|
|
148
|
+
else if (hikePercentage === 0) {
|
|
149
|
+
message = 'βΈοΈ No change in salary';
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
message = 'β οΈ This is a salary reduction';
|
|
153
|
+
}
|
|
154
|
+
returnData.push({
|
|
155
|
+
json: {
|
|
156
|
+
old_salary: oldSalary,
|
|
157
|
+
new_salary: newSalary,
|
|
158
|
+
hike_amount: Math.round(hikeAmount * 100) / 100,
|
|
159
|
+
hike_percentage: Math.round(hikePercentage * 100) / 100,
|
|
160
|
+
currency: currency,
|
|
161
|
+
is_positive_change: isPositive,
|
|
162
|
+
message: message,
|
|
163
|
+
emoji: isPositive ? 'π' : 'π',
|
|
164
|
+
},
|
|
165
|
+
pairedItem: { item: i },
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
else if (operation === 'calculateNewSalary') {
|
|
169
|
+
const currentSalary = this.getNodeParameter('currentSalary', i);
|
|
170
|
+
const hikePercentage = this.getNodeParameter('hikePercentage', i);
|
|
171
|
+
const currency = this.getNodeParameter('currency', i);
|
|
172
|
+
if (currentSalary <= 0) {
|
|
173
|
+
throw new Error('Current salary must be greater than 0');
|
|
174
|
+
}
|
|
175
|
+
const increment = currentSalary * (hikePercentage / 100);
|
|
176
|
+
const newSalary = currentSalary + increment;
|
|
177
|
+
returnData.push({
|
|
178
|
+
json: {
|
|
179
|
+
current_salary: currentSalary,
|
|
180
|
+
hike_percentage: hikePercentage,
|
|
181
|
+
increment: Math.round(increment * 100) / 100,
|
|
182
|
+
new_salary: Math.round(newSalary * 100) / 100,
|
|
183
|
+
currency: currency,
|
|
184
|
+
},
|
|
185
|
+
pairedItem: { item: i },
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
else if (operation === 'openCalculator') {
|
|
189
|
+
returnData.push({
|
|
190
|
+
json: {
|
|
191
|
+
calculator_url: 'https://app-salary-hike-calculator-w98fve2nkvwgztjlddm5md.streamlit.app/',
|
|
192
|
+
message: 'Open this URL to use the interactive salary calculator',
|
|
193
|
+
description: 'Beautiful web interface with real-time calculations',
|
|
194
|
+
},
|
|
195
|
+
pairedItem: { item: i },
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return [returnData];
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
exports.SalaryHikeCalculator = SalaryHikeCalculator;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#667eea" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2
|
+
<line x1="12" y1="2" x2="12" y2="22"></line>
|
|
3
|
+
<path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"></path>
|
|
4
|
+
<polyline points="7 15 12 20 17 15"></polyline>
|
|
5
|
+
</svg>
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "n8n-nodes-salary-hike-calculator",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "n8n node for calculating salary hikes and increments",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"n8n-community-node-package",
|
|
7
|
+
"salary",
|
|
8
|
+
"calculator",
|
|
9
|
+
"hr",
|
|
10
|
+
"finance"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"homepage": "https://app-salary-hike-calculator-w98fve2nkvwgztjlddm5md.streamlit.app/",
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "Your Name",
|
|
16
|
+
"email": "your.email@example.com"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/yourusername/n8n-nodes-salary-hike-calculator.git"
|
|
21
|
+
},
|
|
22
|
+
"main": "index.js",
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc && gulp build:icons",
|
|
25
|
+
"dev": "tsc --watch",
|
|
26
|
+
"format": "prettier nodes --write",
|
|
27
|
+
"lint": "tslint -p tsconfig.json -c tslint.json",
|
|
28
|
+
"lintfix": "tslint --fix -p tsconfig.json -c tslint.json",
|
|
29
|
+
"prepublishOnly": "npm run build && npm run lint"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist"
|
|
33
|
+
],
|
|
34
|
+
"n8n": {
|
|
35
|
+
"n8nNodesApiVersion": 1,
|
|
36
|
+
"nodes": [
|
|
37
|
+
"dist/nodes/SalaryHikeCalculator/SalaryHikeCalculator.node.js"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^18.0.0",
|
|
42
|
+
"gulp": "^4.0.2",
|
|
43
|
+
"n8n-workflow": "^1.0.0",
|
|
44
|
+
"typescript": "^4.9.5",
|
|
45
|
+
"tslint": "^6.1.3",
|
|
46
|
+
"prettier": "^2.7.1"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"n8n-core": "^1.0.0"
|
|
50
|
+
}
|
|
51
|
+
}
|