capacitor-hugin-gmp3 0.2.3 → 0.2.4

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.
@@ -335,4 +335,94 @@ public class CapacitorHuginGMP3Plugin extends Plugin {
335
335
  }
336
336
  }
337
337
 
338
+ @PluginMethod
339
+ public void SetVatRates(PluginCall call) {
340
+
341
+ // --- Parametreleri Al ---
342
+ JSArray ratesArray = call.getArray("vatRates");
343
+
344
+ if (ratesArray == null) {
345
+ call.reject("Parametre olarak 'vatRates' array gönderilmelidir.");
346
+ return;
347
+ }
348
+
349
+ try {
350
+ for (i in 0..7) {
351
+ printerService.SetVATRate(i, BigDecimal(-1))
352
+ }
353
+ // Makbuzu iptal et
354
+ printerService.VoidReceipt();
355
+
356
+ // Sonuçları tutmak için liste
357
+ JSArray results = new JSArray();
358
+
359
+ for (int i = 0; i < ratesArray.length(); i++) {
360
+ JSObject item = ratesArray.getJSONObject(i);
361
+
362
+ // Tek tek index ve vatRate al
363
+ Integer indexValue = item.getInteger("index");
364
+ Double vatRateValue = item.getDouble("vatRate");
365
+
366
+ // --- Null Kontrol ---
367
+ if (indexValue == null || vatRateValue == null) {
368
+
369
+ JSObject errorObj = JSObjectHelper.result(false,
370
+ "Satır " + i + ": index ve vatRate zorunludur.");
371
+ results.put(errorObj);
372
+ continue;
373
+ }
374
+
375
+ int index = indexValue;
376
+ double vatRate = vatRateValue;
377
+
378
+ // --- Validasyon ---
379
+ if (index < 0 || index > 8) {
380
+ JSObject errorObj = JSObjectHelper.result(false,
381
+ "Satır " + i + ": index 0 ile 8 arasında olmalıdır.");
382
+ results.put(errorObj);
383
+ continue;
384
+ }
385
+
386
+ if (vatRate < -1 || vatRate > 100) {
387
+ JSObject errorObj = JSObjectHelper.result(false,
388
+ "Satır " + i + ": vatRate 0 ile 100 arasında olmalıdır.");
389
+ results.put(errorObj);
390
+ continue;
391
+ }
392
+
393
+ // --- KDV Set Et ---
394
+ try {
395
+ String response = printerService.SetVATRate(index, vatRate);
396
+ String[] parts = PrinterCoverService.printResponse(response);
397
+ int errorCode = Integer.parseInt(parts[0]);
398
+
399
+ if (errorCode != 0) {
400
+ String msg = "Satır " + i + ": KDV set edilemedi. Kod: " +
401
+ errorCode + " - " + Utility.GetErrorMessage(errorCode);
402
+
403
+ results.put(JSObjectHelper.result(false, msg));
404
+
405
+ } else {
406
+ results.put(JSObjectHelper.result(true,
407
+ "Satır " + i + ": KDV başarıyla ayarlandı."));
408
+ }
409
+
410
+ } catch (Exception ex) {
411
+ results.put(JSObjectHelper.result(false,
412
+ "Satır " + i + ": SetVATRate işleminde hata: " + ex.getMessage()));
413
+ }
414
+ }
415
+
416
+ // Sonuçları döndür
417
+ JSObject resultObj = new JSObject();
418
+ resultObj.put("results", results);
419
+
420
+ call.resolve(resultObj);
421
+
422
+ } catch (Exception e) {
423
+ call.reject("SetVatRates işleminde genel hata oluştu.", e);
424
+ }
425
+ }
426
+
427
+
338
428
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-hugin-gmp3",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Hugin plugin for TCP/IP",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",