empuno 1.3.0 → 1.4.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.
Files changed (3) hide show
  1. package/README.md +20 -0
  2. package/empuno.mjs +21 -5
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -55,6 +55,26 @@ komutu CLI güncellemesi olmadan görünür.
55
55
  `flash.created` ya da `redirect.params` içindedir.
56
56
  - Geçmiş veri aktarımı (`data-migration.*`) davet/e-posta/bildirim göndermez.
57
57
 
58
+ ## Başka sistemden geçiş
59
+
60
+ Eski sistemin geçmişini JSON ya da Excel'den alınmış CSV ile taşıyın. Çalışan her
61
+ satırda TC (`identity_number`), sicil no ya da `employee_id` ile belirtilir;
62
+ tekrar çalıştırmak güvenlidir (aynı kayıt `skipped` döner).
63
+
64
+ ```bash
65
+ empuno migrate employees calisanlar.csv --validate # önce yazmadan doğrula
66
+ empuno migrate employees calisanlar.csv # ayrılmışlar dahil
67
+ empuno migrate leaves izinler.csv
68
+ empuno migrate advances avanslar.csv # devreden bakiye: deducted_amount
69
+ empuno migrate expenses masraflar.csv
70
+ empuno migrate payroll bordrolar.csv --decimal , # geçmiş bordro; 38.000,50 biçimi
71
+ empuno migrate documents manifest.csv # file sütunu: dosya yolu
72
+ ```
73
+
74
+ Geçmiş bordro tutarları yeniden hesaplanmaz, aynen saklanır; empuno sonraki ayı
75
+ aktarılan kümülatif gelir vergisi matrahıyla devralır. Alanlar:
76
+ `empuno describe data-migration.payroll.commit`.
77
+
58
78
  ## Talepler (empuno ekibine)
59
79
 
60
80
  Ajanınız yapamadığı bir işlemi, bir hatayı ya da geliştirme önerisini empuno
package/empuno.mjs CHANGED
@@ -21,7 +21,7 @@ import os from 'node:os';
21
21
  import path from 'node:path';
22
22
  import crypto from 'node:crypto';
23
23
 
24
- const VERSION = '1.3.0'; // EMPUNO_CLI_VERSION — config/agent_api.php cli_version + package.json ile aynı tutulur
24
+ const VERSION = '1.4.0'; // EMPUNO_CLI_VERSION — config/agent_api.php cli_version + package.json ile aynı tutulur
25
25
  const NPM_PACKAGE = 'empuno';
26
26
  const DEFAULT_URL = 'https://empuno.com';
27
27
  const CATALOG_TTL_MS = 10 * 60 * 1000;
@@ -848,6 +848,8 @@ const MIGRATE_KINDS = {
848
848
  advances: { path: '/manager/data-migration/advances/commit', chunk: 200 },
849
849
  expenses: { path: '/manager/data-migration/expenses/commit', chunk: 200 },
850
850
  documents: { path: '/manager/data-migration/documents/commit', chunk: 10 },
851
+ // Dönem sırasıyla gönderilir: aynı ayın bordroları aynı istekte kalır, kümülatif zincir aydan aya kurulur.
852
+ payroll: { path: '/manager/data-migration/payroll/commit', chunk: 300, sortBy: 'period' },
851
853
  };
852
854
 
853
855
  /** Basit CSV ayrıştırıcı: tırnak, "" kaçışı, ; ya da , ayırıcı (başlıktan seçilir), BOM. */
@@ -893,6 +895,13 @@ function parseCsv(text) {
893
895
  });
894
896
  }
895
897
 
898
+ /** --decimal , : Türk dışa aktarımlarındaki 38.000,50 → 38000.50 (TC, tarih, sicil no dokunulmaz). */
899
+ function commaDecimals(record) {
900
+ for (const [k, v] of Object.entries(record)) {
901
+ if (typeof v === 'string' && /^-?(\d{1,3}(\.\d{3})+|\d+)(,\d+)?$/.test(v) && /[.,]/.test(v)) record[k] = v.replace(/\./g, '').replace(',', '.');
902
+ }
903
+ }
904
+
896
905
  function readRecordsFile(file) {
897
906
  if (!fs.existsSync(file)) throw new UsageError(`dosya bulunamadı: ${file}`);
898
907
  const text = fs.readFileSync(file, 'utf8');
@@ -908,14 +917,19 @@ async function cmdMigrate(args) {
908
917
  const { flags, fields, positional } = args;
909
918
  const [kind, file] = positional;
910
919
  if (!kind || !MIGRATE_KINDS[kind] || !file) {
911
- throw new UsageError(`kullanım: empuno migrate <${Object.keys(MIGRATE_KINDS).join('|')}> <kayitlar.json|.csv> [--validate] [--on_existing update] [--employee_id N] [--chunk N]
920
+ throw new UsageError(`kullanım: empuno migrate <${Object.keys(MIGRATE_KINDS).join('|')}> <kayitlar.json|.csv> [--validate] [--on_existing update] [--employee_id N] [--chunk N] [--decimal ,]
912
921
  alanlar: empuno describe data-migration.${kind && MIGRATE_KINDS[kind] ? kind : 'employees'}.commit · rehber: https://empuno.com/api-docs/agent#gecis`);
913
922
  }
914
923
  const auth = resolveAuth(flags);
915
924
  requireKey(auth);
916
925
  const opts = fieldMap(fields);
917
926
  const spec = MIGRATE_KINDS[kind];
918
- const records = readRecordsFile(file);
927
+ const raw = readRecordsFile(file);
928
+ if (opts.decimal === ',') raw.forEach(commaDecimals);
929
+ // Sıralanan türlerde sonuçtaki index yine dosyadaki sırayı gösterir.
930
+ const order = raw.map((_, i) => i);
931
+ if (spec.sortBy) order.sort((a, b) => String(raw[a][spec.sortBy] ?? '').localeCompare(String(raw[b][spec.sortBy] ?? '')) || a - b);
932
+ const records = order.map((i) => raw[i]);
919
933
  const chunkSize = Math.max(1, Math.min(Number(opts.chunk) || spec.chunk, spec.chunk));
920
934
  const validate = Boolean(flags.validate);
921
935
  const baseDir = path.dirname(path.resolve(file));
@@ -954,11 +968,12 @@ alanlar: empuno describe data-migration.${kind && MIGRATE_KINDS[kind] ? kind : '
954
968
  if (!response.ok) {
955
969
  // Doğrulama hatası (422) tüm parçayı etkiler: sunucunun errors'ını kayıt indeksine çevir.
956
970
  summary.failed += chunk.length;
957
- summary.results.push({ chunk_offset: offset, action: 'failed', status: response.status, message: r.message, errors: r.errors });
971
+ summary.results.push({ chunk_offset: offset, indexes: order.slice(offset, offset + chunk.length), action: 'failed', status: response.status, message: r.message, errors: r.errors });
958
972
  continue;
959
973
  }
960
974
  for (const key of ['created', 'updated', 'skipped', 'failed']) summary[key] += Number(r[key] || 0);
961
- for (const row of r.results || []) summary.results.push({ ...row, index: offset + Number(row.index ?? 0) });
975
+ for (const row of r.results || []) summary.results.push({ ...row, index: order[offset + Number(row.index ?? 0)] });
976
+ if (r.periods) (summary.periods ??= []).push(...r.periods);
962
977
  if (isTTY) warn(`${Math.min(offset + chunkSize, records.length)}/${records.length} işlendi`);
963
978
  }
964
979
 
@@ -1109,6 +1124,7 @@ GEÇİŞ (başka sistemden geçmiş veri — JSON ya da CSV; davet/e-posta/bildi
1109
1124
  empuno migrate advances avanslar.csv # geçmiş avans + devreden bakiye (deducted_amount)
1110
1125
  empuno migrate expenses masraflar.csv # ödenmiş geçmiş masraf (kategori adla)
1111
1126
  empuno migrate documents manifest.csv # file sütunu: dosya yolu; ≤10'arlı gönderilir
1127
+ empuno migrate payroll bordrolar.csv # geçmiş bordro (müşavir değerleri aynen); kilitli 'ödendi' dönem + kümülatif GV matrahı
1112
1128
  alanlar: empuno describe data-migration.<tür>.commit · sıra: çalışanlar → izin → avans → masraf → evrak
1113
1129
 
1114
1130
  TALEPLER (geliştirme isteği, hata, eleştiri, soru → empuno ekibi)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "empuno",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "empuno İK platformunun komut satırı: yönetim panelindeki tüm işlemleri (izin, bordro, vardiya, PDKS, zimmet, masraf, işe alım) yapay zekâ ajanlarına ve otomasyonlara açar.",
5
5
  "type": "module",
6
6
  "bin": {