payrolla-mcp 0.2.5 → 0.2.6

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 +85 -33
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -281,34 +281,68 @@ 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
+ for (let i = 0; i < periodCount; i++) {
298
+ const calcDate = new Date(year, i, 1);
299
+ const calcYear = calcDate.getFullYear();
300
+ const calcMonth = calcDate.getMonth() + 1;
301
+ const periodPayEvents = (emp.payEvents || []).filter(
302
+ (pe) => pe.year === calcYear && pe.month === calcMonth
303
+ );
304
+ const extraPayments = periodPayEvents.map((pe) => ({
305
+ name: pe.name,
306
+ amount: pe.amount,
307
+ type: pe.type,
308
+ paymentType: pe.paymentType
309
+ }));
310
+ const result = await calculatePayroll(client, {
311
+ name: emp.name,
312
+ wage: adjustedWage,
313
+ calculationType: emp.calculationType,
314
+ ssiType: emp.ssiType,
315
+ year: calcYear,
316
+ month: calcMonth,
317
+ periodCount: 1,
318
+ extraPayments: extraPayments.length > 0 ? extraPayments : void 0,
319
+ customParams,
320
+ cumulativeIncomeTaxBase,
321
+ cumulativeMinWageIncomeTaxBase,
322
+ transferredSSIBase1,
323
+ transferredSSIBase2
324
+ });
325
+ empTotalCost += result.totalCost;
326
+ empTotalNet += result.totalNet;
327
+ empTotalGross += result.totalGross;
328
+ const lastPeriod = result.periods[0];
329
+ cumulativeIncomeTaxBase = lastPeriod.cumulativeIncomeTaxBase;
330
+ cumulativeMinWageIncomeTaxBase = lastPeriod.cumulativeMinWageIncomeTaxBase;
331
+ transferredSSIBase1 = lastPeriod.transferredSSIBase1;
332
+ transferredSSIBase2 = lastPeriod.transferredSSIBase2;
333
+ }
334
+ employeeResults.push({
304
335
  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
- });
336
+ originalWage: emp.wage,
337
+ adjustedWage,
338
+ yearlyCost: empTotalCost,
339
+ yearlyNet: empTotalNet,
340
+ yearlyGross: empTotalGross
341
+ });
342
+ totalYearlyCost += empTotalCost;
343
+ totalYearlyNet += empTotalNet;
344
+ totalYearlyGross += empTotalGross;
345
+ }
312
346
  const effectiveTaxBrackets = customParams.incomeTaxLimits || defaults.incomeTaxBrackets.map((b) => ({
313
347
  limit: b.limit,
314
348
  rate: b.rate
@@ -320,10 +354,10 @@ async function simulateBudget(client, input) {
320
354
  effectiveTaxBrackets
321
355
  },
322
356
  summary: {
323
- totalYearlyCost: result.summary.totalYearlyCost,
324
- totalYearlyNet: result.summary.totalYearlyNet,
325
- totalYearlyGross: result.summary.totalYearlyGross,
326
- costPerEmployee: result.summary.totalYearlyCost / employees.length
357
+ totalYearlyCost,
358
+ totalYearlyNet,
359
+ totalYearlyGross,
360
+ costPerEmployee: totalYearlyCost / employees.length
327
361
  },
328
362
  employees: employeeResults
329
363
  };
@@ -554,6 +588,20 @@ var ExtraPaymentSchema = z2.object({
554
588
  z2.enum(["RegularPayment", "Overtime", "SocialAid", "ExtraPay"])
555
589
  ]).optional().describe("Payment type (1: RegularPayment, 2: Overtime, 3: SocialAid, 4: ExtraPay)")
556
590
  });
591
+ var PayEventSchema = z2.object({
592
+ month: z2.number().min(1).max(12).describe("Month when the payment occurs (1-12)"),
593
+ year: z2.number().describe("Year when the payment occurs"),
594
+ name: z2.string().describe('Payment name (e.g., "Q2 Bonus")'),
595
+ amount: z2.number().describe("Payment amount"),
596
+ type: z2.enum(["Net", "Gross"]).describe("Whether the amount is net or gross"),
597
+ paymentType: z2.union([
598
+ z2.literal(1),
599
+ z2.literal(2),
600
+ z2.literal(3),
601
+ z2.literal(4),
602
+ z2.enum(["RegularPayment", "Overtime", "SocialAid", "ExtraPay"])
603
+ ]).optional().describe("Payment category: 1/RegularPayment, 2/Overtime, 3/SocialAid, 4/ExtraPay (default: 4)")
604
+ });
557
605
  var CustomParamsSchema = z2.object({
558
606
  minWage: z2.number().optional().describe("Custom minimum wage (gross)"),
559
607
  minWageNet: z2.number().optional().describe("Custom minimum wage (net)"),
@@ -691,7 +739,9 @@ function registerTools(server, client) {
691
739
  employees: z2.array(z2.object({
692
740
  name: z2.string().describe("Employee name"),
693
741
  wage: z2.number().describe("Current wage amount"),
694
- calculationType: z2.enum(["Gross", "Net"]).describe("Wage type")
742
+ calculationType: z2.enum(["Gross", "Net"]).describe("Wage type"),
743
+ ssiType: z2.enum(["S4A", "S4B", "S4C"]).optional().describe("SSI type (default: S4A)"),
744
+ payEvents: z2.array(PayEventSchema).optional().describe("Extra payments at specific months (e.g., bonuses)")
695
745
  })).describe("Array of employees"),
696
746
  year: z2.number().describe("Calculation year"),
697
747
  periodCount: z2.number().min(1).max(12).describe("Number of months (use 12 for yearly)"),
@@ -728,7 +778,9 @@ function registerTools(server, client) {
728
778
  employees: z2.array(z2.object({
729
779
  name: z2.string().describe("Employee name"),
730
780
  wage: z2.number().describe("Current wage"),
731
- calculationType: z2.enum(["Gross", "Net"]).describe("Wage type")
781
+ calculationType: z2.enum(["Gross", "Net"]).describe("Wage type"),
782
+ ssiType: z2.enum(["S4A", "S4B", "S4C"]).optional().describe("SSI type (default: S4A)"),
783
+ payEvents: z2.array(PayEventSchema).optional().describe("Extra payments at specific months (e.g., bonuses)")
732
784
  })).describe("Array of employees"),
733
785
  year: z2.number().describe("Calculation year"),
734
786
  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.6",
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",