@jars-lt/jars-app-sdk 0.1.0 → 0.2.1

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/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/client.ts
2
- import createClient from "openapi-fetch";
2
+ import createClientDefault from "openapi-fetch";
3
3
 
4
4
  // src/errors.ts
5
5
  var JarsApiError = class _JarsApiError extends Error {
@@ -100,6 +100,9 @@ var InvoicesResource = class {
100
100
  body: { externalStatus }
101
101
  });
102
102
  }
103
+ postingPreview(id) {
104
+ return this.client.request("get", "/api/invoices/{id}/posting-preview", { params: { id } });
105
+ }
103
106
  };
104
107
 
105
108
  // src/resources/journal.ts
@@ -126,15 +129,50 @@ var ReportsResource = class {
126
129
  trialBalance(params) {
127
130
  return this.client.request("get", "/api/reports/trial-balance", { query: params });
128
131
  }
132
+ /**
133
+ * Chronological postings for one account. `from` and `to` are required;
134
+ * `account` is optional but omitting it asks for every account.
135
+ *
136
+ * Rejects with 400 `REPORT_TOO_BROAD` when the query would return more than
137
+ * 10,000 lines — the result is never truncated, because the caller computes a
138
+ * running balance across these lines. Narrow by account or by period.
139
+ */
129
140
  generalLedger(params) {
130
141
  return this.client.request("get", "/api/reports/general-ledger", { query: params });
131
142
  }
143
+ accountAnalytics(params) {
144
+ return this.client.request("get", "/api/reports/account-analytics", { query: params });
145
+ }
146
+ /**
147
+ * Settlement balances per partner.
148
+ *
149
+ * Returns `{ rows, totals, rowCount, unfilteredRowCount, truncated }`.
150
+ * `totals` are computed over the full set — before the `nonZeroOnly` filter
151
+ * and before the row cap — so they tie out whatever `rows` contains.
152
+ *
153
+ * `nonZeroOnly` defaults to true: rows whose closing balance is zero are
154
+ * omitted. Pass `nonZeroOnly: false` for the complete list.
155
+ */
132
156
  partnerBalance(params) {
133
157
  return this.client.request("get", "/api/reports/partner-balance", { query: params });
134
158
  }
159
+ /** Salary/advance balances per employee. `from` and `to` are required. */
160
+ employeeBalance(params) {
161
+ return this.client.request("get", "/api/reports/employee-balance", { query: params });
162
+ }
163
+ /**
164
+ * Cash book for one register: opening balance plus posted cash movements.
165
+ *
166
+ * Rejects with 400 `REPORT_TOO_BROAD` above 10,000 lines, for the same reason
167
+ * as `generalLedger`.
168
+ */
135
169
  cashBook(params) {
136
170
  return this.client.request("get", "/api/reports/cash-book", { query: params });
137
171
  }
172
+ /** Balance sheet + P&L. `year` is required; pass `to` for an interim period. */
173
+ financialStatements(params) {
174
+ return this.client.request("get", "/api/reports/financial-statements", { query: params });
175
+ }
138
176
  isafExport(params) {
139
177
  return this.client.request("get", "/api/reports/isaf-export", { query: params });
140
178
  }
@@ -172,7 +210,368 @@ var LookupsResource = class {
172
210
  }
173
211
  };
174
212
 
213
+ // src/resources/cash-registers.ts
214
+ var CashRegistersResource = class {
215
+ constructor(client) {
216
+ this.client = client;
217
+ }
218
+ list(params) {
219
+ return this.client.request("get", "/api/cash-registers", { query: toQuery(params) });
220
+ }
221
+ create(body) {
222
+ return this.client.request("post", "/api/cash-registers", { body });
223
+ }
224
+ update(id, body) {
225
+ return this.client.request("put", "/api/cash-registers/{id}", { params: { id }, body });
226
+ }
227
+ remove(id) {
228
+ return this.client.request("delete", "/api/cash-registers/{id}", { params: { id } });
229
+ }
230
+ };
231
+
232
+ // src/resources/projects.ts
233
+ var ProjectsResource = class {
234
+ constructor(client) {
235
+ this.client = client;
236
+ }
237
+ list(params) {
238
+ return this.client.request("get", "/api/projects", { query: toQuery(params) });
239
+ }
240
+ get(id) {
241
+ return this.client.request("get", "/api/projects/{id}", { params: { id } });
242
+ }
243
+ create(body) {
244
+ return this.client.request("post", "/api/projects", { body });
245
+ }
246
+ update(id, body) {
247
+ return this.client.request("put", "/api/projects/{id}", { params: { id }, body });
248
+ }
249
+ remove(id) {
250
+ return this.client.request("delete", "/api/projects/{id}", { params: { id } });
251
+ }
252
+ };
253
+
254
+ // src/resources/professions.ts
255
+ var ProfessionsResource = class {
256
+ constructor(client) {
257
+ this.client = client;
258
+ }
259
+ list(params) {
260
+ return this.client.request("get", "/api/professions", { query: toQuery(params) });
261
+ }
262
+ get(id) {
263
+ return this.client.request("get", "/api/professions/{id}", { params: { id } });
264
+ }
265
+ create(body) {
266
+ return this.client.request("post", "/api/professions", { body });
267
+ }
268
+ update(id, body) {
269
+ return this.client.request("put", "/api/professions/{id}", { params: { id }, body });
270
+ }
271
+ remove(id) {
272
+ return this.client.request("delete", "/api/professions/{id}", { params: { id } });
273
+ }
274
+ };
275
+
276
+ // src/resources/perdiem-rates.ts
277
+ var PerDiemRatesResource = class {
278
+ constructor(client) {
279
+ this.client = client;
280
+ }
281
+ list(params) {
282
+ return this.client.request("get", "/api/perdiem-rates", { query: toQuery(params) });
283
+ }
284
+ create(body) {
285
+ return this.client.request("post", "/api/perdiem-rates", { body });
286
+ }
287
+ update(id, body) {
288
+ return this.client.request("put", "/api/perdiem-rates/{id}", { params: { id }, body });
289
+ }
290
+ remove(id) {
291
+ return this.client.request("delete", "/api/perdiem-rates/{id}", { params: { id } });
292
+ }
293
+ };
294
+
295
+ // src/resources/price-lists.ts
296
+ var PriceListsResource = class {
297
+ constructor(client) {
298
+ this.client = client;
299
+ }
300
+ list(params) {
301
+ return this.client.request("get", "/api/price-lists", { query: toQuery(params) });
302
+ }
303
+ get(id) {
304
+ return this.client.request("get", "/api/price-lists/{id}", { params: { id } });
305
+ }
306
+ create(body) {
307
+ return this.client.request("post", "/api/price-lists", { body });
308
+ }
309
+ update(id, body) {
310
+ return this.client.request("put", "/api/price-lists/{id}", { params: { id }, body });
311
+ }
312
+ remove(id) {
313
+ return this.client.request("delete", "/api/price-lists/{id}", { params: { id } });
314
+ }
315
+ };
316
+
317
+ // src/resources/fixed-assets.ts
318
+ var FixedAssetsResource = class {
319
+ constructor(client) {
320
+ this.client = client;
321
+ }
322
+ list(params) {
323
+ return this.client.request("get", "/api/fixed-assets", { query: toQuery(params) });
324
+ }
325
+ get(id) {
326
+ return this.client.request("get", "/api/fixed-assets/{id}", { params: { id } });
327
+ }
328
+ create(body) {
329
+ return this.client.request("post", "/api/fixed-assets", { body });
330
+ }
331
+ update(id, body) {
332
+ return this.client.request("put", "/api/fixed-assets/{id}", { params: { id }, body });
333
+ }
334
+ remove(id) {
335
+ return this.client.request("delete", "/api/fixed-assets/{id}", { params: { id } });
336
+ }
337
+ dispose(id, body) {
338
+ return this.client.request("post", "/api/fixed-assets/{id}/dispose", { params: { id }, body });
339
+ }
340
+ };
341
+
342
+ // src/resources/employees.ts
343
+ var EmployeesResource = class {
344
+ constructor(client) {
345
+ this.client = client;
346
+ }
347
+ list(params) {
348
+ return this.client.request("get", "/api/employees", { query: toQuery(params) });
349
+ }
350
+ get(id) {
351
+ return this.client.request("get", "/api/employees/{id}", { params: { id } });
352
+ }
353
+ create(body) {
354
+ return this.client.request("post", "/api/employees", { body });
355
+ }
356
+ update(id, body) {
357
+ return this.client.request("put", "/api/employees/{id}", { params: { id }, body });
358
+ }
359
+ remove(id) {
360
+ return this.client.request("delete", "/api/employees/{id}", { params: { id } });
361
+ }
362
+ nextCode() {
363
+ return this.client.request("get", "/api/employees/next-code");
364
+ }
365
+ verifyPin(body) {
366
+ return this.client.request("post", "/api/employees/verify-pin", { body });
367
+ }
368
+ };
369
+
370
+ // src/resources/cash-orders.ts
371
+ var CashOrdersResource = class {
372
+ constructor(client) {
373
+ this.client = client;
374
+ }
375
+ list(params) {
376
+ return this.client.request("get", "/api/cash-orders", { query: toQuery(params) });
377
+ }
378
+ get(id) {
379
+ return this.client.request("get", "/api/cash-orders/{id}", { params: { id } });
380
+ }
381
+ create(body) {
382
+ return this.client.request("post", "/api/cash-orders", { body });
383
+ }
384
+ update(id, body) {
385
+ return this.client.request("put", "/api/cash-orders/{id}", { params: { id }, body });
386
+ }
387
+ remove(id) {
388
+ return this.client.request("delete", "/api/cash-orders/{id}", { params: { id } });
389
+ }
390
+ setExternalStatus(id, body) {
391
+ return this.client.request("patch", "/api/cash-orders/{id}/external-status", { params: { id }, body });
392
+ }
393
+ post(id) {
394
+ return this.client.request("post", "/api/cash-orders/{id}/post", { params: { id } });
395
+ }
396
+ unpost(id) {
397
+ return this.client.request("post", "/api/cash-orders/{id}/unpost", { params: { id } });
398
+ }
399
+ fiscalize(id, body) {
400
+ return this.client.request("post", "/api/cash-orders/{id}/fiscalize", { params: { id }, body: body ?? {} });
401
+ }
402
+ };
403
+
404
+ // src/resources/bank-transactions.ts
405
+ var BankTransactionsResource = class {
406
+ constructor(client) {
407
+ this.client = client;
408
+ }
409
+ list(params) {
410
+ return this.client.request("get", "/api/bank-transactions", { query: toQuery(params) });
411
+ }
412
+ get(id) {
413
+ return this.client.request("get", "/api/bank-transactions/{id}", { params: { id } });
414
+ }
415
+ create(body) {
416
+ return this.client.request("post", "/api/bank-transactions", { body });
417
+ }
418
+ update(id, body) {
419
+ return this.client.request("put", "/api/bank-transactions/{id}", { params: { id }, body });
420
+ }
421
+ /**
422
+ * Link the transaction to invoices (payment matching). Separate from `update`
423
+ * because it works at any status — `update` refuses a posted transaction,
424
+ * while allocations must stay editable after posting (a prepayment is posted
425
+ * before its invoice exists).
426
+ */
427
+ setAllocations(id, body) {
428
+ return this.client.request("put", "/api/bank-transactions/{id}/allocations", { params: { id }, body });
429
+ }
430
+ setExternalStatus(id, body) {
431
+ return this.client.request("patch", "/api/bank-transactions/{id}/external-status", { params: { id }, body });
432
+ }
433
+ post(id) {
434
+ return this.client.request("post", "/api/bank-transactions/{id}/post", { params: { id } });
435
+ }
436
+ unpost(id) {
437
+ return this.client.request("post", "/api/bank-transactions/{id}/unpost", { params: { id } });
438
+ }
439
+ };
440
+
441
+ // src/resources/business-trips.ts
442
+ var BusinessTripsResource = class {
443
+ constructor(client) {
444
+ this.client = client;
445
+ }
446
+ list(params) {
447
+ return this.client.request("get", "/api/business-trips", { query: toQuery(params) });
448
+ }
449
+ create(body) {
450
+ return this.client.request("post", "/api/business-trips", { body });
451
+ }
452
+ update(id, body) {
453
+ return this.client.request("put", "/api/business-trips/{id}", { params: { id }, body });
454
+ }
455
+ remove(id) {
456
+ return this.client.request("delete", "/api/business-trips/{id}", { params: { id } });
457
+ }
458
+ postAdvance(id) {
459
+ return this.client.request("post", "/api/business-trips/{id}/post-advance", { params: { id } });
460
+ }
461
+ postSettlement(id) {
462
+ return this.client.request("post", "/api/business-trips/{id}/post-settlement", { params: { id } });
463
+ }
464
+ unpost(id) {
465
+ return this.client.request("post", "/api/business-trips/{id}/unpost", { params: { id } });
466
+ }
467
+ };
468
+
469
+ // src/resources/payroll.ts
470
+ var PayrollResource = class {
471
+ constructor(client) {
472
+ this.client = client;
473
+ }
474
+ list(params) {
475
+ return this.client.request("get", "/api/payroll", { query: toQuery(params) });
476
+ }
477
+ preview(body) {
478
+ return this.client.request("post", "/api/payroll/preview", { body });
479
+ }
480
+ post(body) {
481
+ return this.client.request("post", "/api/payroll/post", { body });
482
+ }
483
+ unpost(id) {
484
+ return this.client.request("post", "/api/payroll/{id}/unpost", { params: { id } });
485
+ }
486
+ };
487
+
488
+ // src/resources/depreciation.ts
489
+ var DepreciationResource = class {
490
+ constructor(client) {
491
+ this.client = client;
492
+ }
493
+ list(params) {
494
+ return this.client.request("get", "/api/depreciation", { query: toQuery(params) });
495
+ }
496
+ preview(body) {
497
+ return this.client.request("post", "/api/depreciation/preview", { body });
498
+ }
499
+ post(body) {
500
+ return this.client.request("post", "/api/depreciation/post", { body });
501
+ }
502
+ unpost(id) {
503
+ return this.client.request("post", "/api/depreciation/{id}/unpost", { params: { id } });
504
+ }
505
+ };
506
+
507
+ // src/resources/numberings.ts
508
+ var NumberingsResource = class {
509
+ constructor(client) {
510
+ this.client = client;
511
+ }
512
+ list(params) {
513
+ return this.client.request("get", "/api/numberings", { query: toQuery(params) });
514
+ }
515
+ update(prefix, body) {
516
+ return this.client.request("put", "/api/numberings/{prefix}", { params: { prefix }, body });
517
+ }
518
+ };
519
+
520
+ // src/resources/exchange-rates.ts
521
+ var ExchangeRatesResource = class {
522
+ constructor(client) {
523
+ this.client = client;
524
+ }
525
+ list(params) {
526
+ return this.client.request("get", "/api/exchange-rates", { query: toQuery(params) });
527
+ }
528
+ };
529
+
530
+ // src/resources/bank-statements.ts
531
+ var BankStatementsResource = class {
532
+ constructor(client) {
533
+ this.client = client;
534
+ }
535
+ list(params) {
536
+ return this.client.request("get", "/api/bank-statements", { query: toQuery(params) });
537
+ }
538
+ remove(id) {
539
+ return this.client.request("delete", "/api/bank-statements/{id}", { params: { id } });
540
+ }
541
+ detect(file, filename) {
542
+ const fd = new FormData();
543
+ fd.append("file", file, filename);
544
+ return this.client.request("post", "/api/bank-statements/detect", { body: fd });
545
+ }
546
+ import(file, fields, filename) {
547
+ const fd = new FormData();
548
+ fd.append("file", file, filename);
549
+ if (fields) {
550
+ for (const [key, value] of Object.entries(fields)) {
551
+ fd.append(key, value);
552
+ }
553
+ }
554
+ return this.client.request("post", "/api/bank-statements/import", { body: fd });
555
+ }
556
+ };
557
+
558
+ // src/resources/sales-receipts.ts
559
+ var SalesReceiptsResource = class {
560
+ constructor(client) {
561
+ this.client = client;
562
+ }
563
+ /**
564
+ * Books a batch of external sales as CashOrder RECEIPT (DRAFT) documents.
565
+ * Returns `{ results: [...] }`, one entry per item — `'created' | 'duplicate' | 'error'` —
566
+ * positional with `items`.
567
+ */
568
+ ingest(items) {
569
+ return this.client.request("post", "/api/sales/receipts", { body: { items } });
570
+ }
571
+ };
572
+
175
573
  // src/client.ts
574
+ var createClient = typeof createClientDefault === "function" ? createClientDefault : createClientDefault.default;
176
575
  var DEFAULT_BASE_URL = "https://app.jars.lt";
177
576
  function safeJson(text) {
178
577
  try {
@@ -191,6 +590,22 @@ var JarsClient = class {
191
590
  reports;
192
591
  auditLogs;
193
592
  lookups;
593
+ cashRegisters;
594
+ projects;
595
+ professions;
596
+ perDiemRates;
597
+ priceLists;
598
+ fixedAssets;
599
+ employees;
600
+ cashOrders;
601
+ bankTransactions;
602
+ businessTrips;
603
+ payroll;
604
+ depreciation;
605
+ numberings;
606
+ exchangeRates;
607
+ bankStatements;
608
+ salesReceipts;
194
609
  baseUrl;
195
610
  authHeader;
196
611
  fetchImpl;
@@ -211,6 +626,22 @@ var JarsClient = class {
211
626
  this.reports = new ReportsResource(this);
212
627
  this.auditLogs = new AuditLogsResource(this);
213
628
  this.lookups = new LookupsResource(this);
629
+ this.cashRegisters = new CashRegistersResource(this);
630
+ this.projects = new ProjectsResource(this);
631
+ this.professions = new ProfessionsResource(this);
632
+ this.perDiemRates = new PerDiemRatesResource(this);
633
+ this.priceLists = new PriceListsResource(this);
634
+ this.fixedAssets = new FixedAssetsResource(this);
635
+ this.employees = new EmployeesResource(this);
636
+ this.cashOrders = new CashOrdersResource(this);
637
+ this.bankTransactions = new BankTransactionsResource(this);
638
+ this.businessTrips = new BusinessTripsResource(this);
639
+ this.payroll = new PayrollResource(this);
640
+ this.depreciation = new DepreciationResource(this);
641
+ this.numberings = new NumberingsResource(this);
642
+ this.exchangeRates = new ExchangeRatesResource(this);
643
+ this.bankStatements = new BankStatementsResource(this);
644
+ this.salesReceipts = new SalesReceiptsResource(this);
214
645
  }
215
646
  async request(method, path, opts = {}) {
216
647
  const finalPath = opts.params ? path.replace(/\{([^}]+)\}/g, (_, key) => {
@@ -226,8 +657,13 @@ var JarsClient = class {
226
657
  const headers = new Headers({ Authorization: this.authHeader });
227
658
  let body;
228
659
  if (opts.body !== void 0) {
229
- headers.set("content-type", "application/json");
230
- body = JSON.stringify(opts.body);
660
+ const isForm = typeof FormData !== "undefined" && opts.body instanceof FormData;
661
+ if (isForm) {
662
+ body = opts.body;
663
+ } else {
664
+ headers.set("content-type", "application/json");
665
+ body = JSON.stringify(opts.body);
666
+ }
231
667
  }
232
668
  let res;
233
669
  try {
@@ -254,14 +690,30 @@ var JarsClient = class {
254
690
  };
255
691
  export {
256
692
  AuditLogsResource,
693
+ BankStatementsResource,
694
+ BankTransactionsResource,
695
+ BusinessTripsResource,
696
+ CashOrdersResource,
697
+ CashRegistersResource,
257
698
  DEFAULT_BASE_URL,
699
+ DepreciationResource,
700
+ EmployeesResource,
701
+ ExchangeRatesResource,
702
+ FixedAssetsResource,
258
703
  InvoicesResource,
259
704
  JarsApiError,
260
705
  JarsClient,
261
706
  JournalResource,
262
707
  LookupsResource,
708
+ NumberingsResource,
263
709
  PartnersResource,
710
+ PayrollResource,
711
+ PerDiemRatesResource,
712
+ PriceListsResource,
264
713
  ProductsResource,
265
- ReportsResource
714
+ ProfessionsResource,
715
+ ProjectsResource,
716
+ ReportsResource,
717
+ SalesReceiptsResource
266
718
  };
267
719
  //# sourceMappingURL=index.js.map