payrolla-mcp 0.2.5 → 0.2.7

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.
Files changed (2) hide show
  1. package/dist/index.js +88 -33
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -281,34 +281,71 @@ async function simulateBudget(client, input) {
281
281
  const { employees, year, periodCount, scenario } = input;
282
282
  const defaults = getDefaultParams({ year });
283
283
  const customParams = applyScenario(defaults, scenario);
284
- const adjustedEmployees = employees.map((emp) => ({
285
- name: emp.name,
286
- wage: applyRaise(emp.wage, scenario.salaryRaisePercent),
287
- calculationType: emp.calculationType,
288
- originalWage: emp.wage
289
- }));
290
- const result = await calculateBulkPayroll(client, {
291
- employees: adjustedEmployees.map((emp) => ({
292
- name: emp.name,
293
- wage: emp.wage,
294
- calculationType: emp.calculationType
295
- })),
296
- year,
297
- month: 1,
298
- periodCount,
299
- customParams
300
- });
301
- const employeeResults = adjustedEmployees.map((emp, index) => {
302
- const empResult = result.employees[index];
303
- return {
284
+ const employeeResults = [];
285
+ let totalYearlyCost = 0;
286
+ let totalYearlyNet = 0;
287
+ let totalYearlyGross = 0;
288
+ for (const emp of employees) {
289
+ const adjustedWage = applyRaise(emp.wage, scenario.salaryRaisePercent);
290
+ let cumulativeIncomeTaxBase = 0;
291
+ let cumulativeMinWageIncomeTaxBase = 0;
292
+ let transferredSSIBase1 = 0;
293
+ let transferredSSIBase2 = 0;
294
+ let empTotalCost = 0;
295
+ let empTotalNet = 0;
296
+ let empTotalGross = 0;
297
+ const empPeriods = [];
298
+ for (let i = 0; i < periodCount; i++) {
299
+ const calcDate = new Date(year, i, 1);
300
+ const calcYear = calcDate.getFullYear();
301
+ const calcMonth = calcDate.getMonth() + 1;
302
+ const periodPayEvents = (emp.payEvents || []).filter(
303
+ (pe) => pe.year === calcYear && pe.month === calcMonth
304
+ );
305
+ const extraPayments = periodPayEvents.map((pe) => ({
306
+ name: pe.name,
307
+ amount: pe.amount,
308
+ type: pe.type,
309
+ paymentType: pe.paymentType
310
+ }));
311
+ const result = await calculatePayroll(client, {
312
+ name: emp.name,
313
+ wage: adjustedWage,
314
+ calculationType: emp.calculationType,
315
+ ssiType: emp.ssiType,
316
+ year: calcYear,
317
+ month: calcMonth,
318
+ periodCount: 1,
319
+ extraPayments: extraPayments.length > 0 ? extraPayments : void 0,
320
+ customParams,
321
+ cumulativeIncomeTaxBase,
322
+ cumulativeMinWageIncomeTaxBase,
323
+ transferredSSIBase1,
324
+ transferredSSIBase2
325
+ });
326
+ empTotalCost += result.totalCost;
327
+ empTotalNet += result.totalNet;
328
+ empTotalGross += result.totalGross;
329
+ const lastPeriod = result.periods[0];
330
+ empPeriods.push(lastPeriod);
331
+ cumulativeIncomeTaxBase = lastPeriod.cumulativeIncomeTaxBase;
332
+ cumulativeMinWageIncomeTaxBase = lastPeriod.cumulativeMinWageIncomeTaxBase;
333
+ transferredSSIBase1 = lastPeriod.transferredSSIBase1;
334
+ transferredSSIBase2 = lastPeriod.transferredSSIBase2;
335
+ }
336
+ employeeResults.push({
304
337
  name: emp.name,
305
- originalWage: emp.originalWage,
306
- adjustedWage: emp.wage,
307
- yearlyCost: empResult.totalCost,
308
- yearlyNet: empResult.totalNet,
309
- yearlyGross: empResult.totalGross
310
- };
311
- });
338
+ originalWage: emp.wage,
339
+ adjustedWage,
340
+ yearlyCost: empTotalCost,
341
+ yearlyNet: empTotalNet,
342
+ yearlyGross: empTotalGross,
343
+ periods: empPeriods
344
+ });
345
+ totalYearlyCost += empTotalCost;
346
+ totalYearlyNet += empTotalNet;
347
+ totalYearlyGross += empTotalGross;
348
+ }
312
349
  const effectiveTaxBrackets = customParams.incomeTaxLimits || defaults.incomeTaxBrackets.map((b) => ({
313
350
  limit: b.limit,
314
351
  rate: b.rate
@@ -320,10 +357,10 @@ async function simulateBudget(client, input) {
320
357
  effectiveTaxBrackets
321
358
  },
322
359
  summary: {
323
- totalYearlyCost: result.summary.totalYearlyCost,
324
- totalYearlyNet: result.summary.totalYearlyNet,
325
- totalYearlyGross: result.summary.totalYearlyGross,
326
- costPerEmployee: result.summary.totalYearlyCost / employees.length
360
+ totalYearlyCost,
361
+ totalYearlyNet,
362
+ totalYearlyGross,
363
+ costPerEmployee: totalYearlyCost / employees.length
327
364
  },
328
365
  employees: employeeResults
329
366
  };
@@ -554,6 +591,20 @@ var ExtraPaymentSchema = z2.object({
554
591
  z2.enum(["RegularPayment", "Overtime", "SocialAid", "ExtraPay"])
555
592
  ]).optional().describe("Payment type (1: RegularPayment, 2: Overtime, 3: SocialAid, 4: ExtraPay)")
556
593
  });
594
+ var PayEventSchema = z2.object({
595
+ month: z2.number().min(1).max(12).describe("Month when the payment occurs (1-12)"),
596
+ year: z2.number().describe("Year when the payment occurs"),
597
+ name: z2.string().describe('Payment name (e.g., "Q2 Bonus")'),
598
+ amount: z2.number().describe("Payment amount"),
599
+ type: z2.enum(["Net", "Gross"]).describe("Whether the amount is net or gross"),
600
+ paymentType: z2.union([
601
+ z2.literal(1),
602
+ z2.literal(2),
603
+ z2.literal(3),
604
+ z2.literal(4),
605
+ z2.enum(["RegularPayment", "Overtime", "SocialAid", "ExtraPay"])
606
+ ]).optional().describe("Payment category: 1/RegularPayment, 2/Overtime, 3/SocialAid, 4/ExtraPay (default: 4)")
607
+ });
557
608
  var CustomParamsSchema = z2.object({
558
609
  minWage: z2.number().optional().describe("Custom minimum wage (gross)"),
559
610
  minWageNet: z2.number().optional().describe("Custom minimum wage (net)"),
@@ -691,7 +742,9 @@ function registerTools(server, client) {
691
742
  employees: z2.array(z2.object({
692
743
  name: z2.string().describe("Employee name"),
693
744
  wage: z2.number().describe("Current wage amount"),
694
- calculationType: z2.enum(["Gross", "Net"]).describe("Wage type")
745
+ calculationType: z2.enum(["Gross", "Net"]).describe("Wage type"),
746
+ ssiType: z2.enum(["S4A", "S4B", "S4C"]).optional().describe("SSI type (default: S4A)"),
747
+ payEvents: z2.array(PayEventSchema).optional().describe("Extra payments at specific months (e.g., bonuses)")
695
748
  })).describe("Array of employees"),
696
749
  year: z2.number().describe("Calculation year"),
697
750
  periodCount: z2.number().min(1).max(12).describe("Number of months (use 12 for yearly)"),
@@ -728,7 +781,9 @@ function registerTools(server, client) {
728
781
  employees: z2.array(z2.object({
729
782
  name: z2.string().describe("Employee name"),
730
783
  wage: z2.number().describe("Current wage"),
731
- calculationType: z2.enum(["Gross", "Net"]).describe("Wage type")
784
+ calculationType: z2.enum(["Gross", "Net"]).describe("Wage type"),
785
+ ssiType: z2.enum(["S4A", "S4B", "S4C"]).optional().describe("SSI type (default: S4A)"),
786
+ payEvents: z2.array(PayEventSchema).optional().describe("Extra payments at specific months (e.g., bonuses)")
732
787
  })).describe("Array of employees"),
733
788
  year: z2.number().describe("Calculation year"),
734
789
  periodCount: z2.number().min(1).max(12).describe("Number of months"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payrolla-mcp",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "MCP server for Payrolla payroll budget simulations - enables LLMs to calculate Turkish payroll and simulate budget scenarios",
5
5
  "author": "Payrolla",
6
6
  "license": "MIT",