capacitor-hugin-gmp3 0.1.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.
- package/CapacitorHuginGMP3Plugin.podspec +17 -0
- package/Package.swift +28 -0
- package/README.md +275 -0
- package/android/build.gradle +64 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/kerzz/hugin/gmp3/CapacitorHuginGMP3.java +122 -0
- package/android/src/main/java/com/kerzz/hugin/gmp3/CapacitorHuginGMP3Plugin.java +296 -0
- package/android/src/main/java/com/kerzz/hugin/gmp3/JSObjectHelper.java +18 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +519 -0
- package/dist/esm/definitions.d.ts +182 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +32 -0
- package/dist/esm/web.js +36 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +50 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +53 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/HuginGMP3Plugin/HuginGMP3.swift +8 -0
- package/ios/Sources/HuginGMP3Plugin/HuginGMP3Plugin.swift +23 -0
- package/ios/Tests/HuginGMP3PluginTests/HuginGMP3PluginTests.swift +15 -0
- package/package.json +77 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'CapacitorHuginGMP3Plugin'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.homepage = package['repository']['url']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
+
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
+
s.ios.deployment_target = '14.0'
|
|
15
|
+
s.dependency 'Capacitor'
|
|
16
|
+
s.swift_version = '5.1'
|
|
17
|
+
end
|
package/Package.swift
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// swift-tools-version: 5.9
|
|
2
|
+
import PackageDescription
|
|
3
|
+
|
|
4
|
+
let package = Package(
|
|
5
|
+
name: "CapacitorHuginGMP3Plugin",
|
|
6
|
+
platforms: [.iOS(.v14)],
|
|
7
|
+
products: [
|
|
8
|
+
.library(
|
|
9
|
+
name: "CapacitorHuginGMP3Plugin",
|
|
10
|
+
targets: ["CapacitorHuginGMP3Plugin"])
|
|
11
|
+
],
|
|
12
|
+
dependencies: [
|
|
13
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0")
|
|
14
|
+
],
|
|
15
|
+
targets: [
|
|
16
|
+
.target(
|
|
17
|
+
name: "CapacitorHuginGMP3Plugin",
|
|
18
|
+
dependencies: [
|
|
19
|
+
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
|
20
|
+
.product(name: "Cordova", package: "capacitor-swift-pm")
|
|
21
|
+
],
|
|
22
|
+
path: "ios/Sources/CapacitorHuginGMP3Plugin"),
|
|
23
|
+
.testTarget(
|
|
24
|
+
name: "CapacitorHuginGMP3PluginTests",
|
|
25
|
+
dependencies: ["CapacitorHuginGMP3Plugin"],
|
|
26
|
+
path: "ios/Tests/CapacitorHuginGMP3PluginTests")
|
|
27
|
+
]
|
|
28
|
+
)
|
package/README.md
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
# capacitor-hugin-gmp3-plugin
|
|
2
|
+
|
|
3
|
+
Hugin plugin for TCP/IP
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install capacitor-hugin-gmp3
|
|
9
|
+
npx cap sync
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## API
|
|
13
|
+
|
|
14
|
+
<docgen-index>
|
|
15
|
+
|
|
16
|
+
* [`GetLibraryVersion()`](#getlibraryversion)
|
|
17
|
+
* [`Connect(...)`](#connect)
|
|
18
|
+
* [`Sale(...)`](#sale)
|
|
19
|
+
* [`PrintXReport(...)`](#printxreport)
|
|
20
|
+
* [`PrintZReport()`](#printzreport)
|
|
21
|
+
* [`GetVatRates()`](#getvatrates)
|
|
22
|
+
* [`GetDepartments()`](#getdepartments)
|
|
23
|
+
* [`SetDepartment(...)`](#setdepartment)
|
|
24
|
+
* [`SetVatRate(...)`](#setvatrate)
|
|
25
|
+
* [Interfaces](#interfaces)
|
|
26
|
+
|
|
27
|
+
</docgen-index>
|
|
28
|
+
|
|
29
|
+
<docgen-api>
|
|
30
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
31
|
+
|
|
32
|
+
Ana plugin arayüzü. Hugin printer ile iletişim sağlayan tüm metodları tanımlar.
|
|
33
|
+
|
|
34
|
+
### GetLibraryVersion()
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
GetLibraryVersion() => Promise<{ version: string; }>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Kütüphane sürümünü döner.
|
|
41
|
+
|
|
42
|
+
**Returns:** <code>Promise<{ version: string; }></code>
|
|
43
|
+
|
|
44
|
+
--------------------
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### Connect(...)
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
Connect(options: ConnectOptions) => Promise<{ connected: boolean; }>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Cihaza bağlantı kurar.
|
|
54
|
+
|
|
55
|
+
| Param | Type | Description |
|
|
56
|
+
| ------------- | --------------------------------------------------------- | ------------------- |
|
|
57
|
+
| **`options`** | <code><a href="#connectoptions">ConnectOptions</a></code> | Bağlantı bilgileri. |
|
|
58
|
+
|
|
59
|
+
**Returns:** <code>Promise<{ connected: boolean; }></code>
|
|
60
|
+
|
|
61
|
+
--------------------
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
### Sale(...)
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
Sale(options: { saleItem: SaleItem; }) => Promise<{ orderNo?: number; result: boolean; message?: string; }>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Satış işlemi başlatır.
|
|
71
|
+
|
|
72
|
+
| Param | Type | Description |
|
|
73
|
+
| ------------- | ------------------------------------------------------------ | ----------------------------------- |
|
|
74
|
+
| **`options`** | <code>{ saleItem: <a href="#saleitem">SaleItem</a>; }</code> | Satış nesnesi (JSON string olarak). |
|
|
75
|
+
|
|
76
|
+
**Returns:** <code>Promise<{ orderNo?: number; result: boolean; message?: string; }></code>
|
|
77
|
+
|
|
78
|
+
--------------------
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
### PrintXReport(...)
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
PrintXReport(type: 1 | 2 | 3) => Promise<{ result: boolean; message: string; }>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
X raporu yazdırır.
|
|
88
|
+
|
|
89
|
+
| Param | Type | Description |
|
|
90
|
+
| ---------- | ------------------------ | ------------------------- |
|
|
91
|
+
| **`type`** | <code>1 \| 2 \| 3</code> | Rapor tipi (1 \| 2 \| 3). |
|
|
92
|
+
|
|
93
|
+
**Returns:** <code>Promise<{ result: boolean; message: string; }></code>
|
|
94
|
+
|
|
95
|
+
--------------------
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
### PrintZReport()
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
PrintZReport() => Promise<{ result: boolean; }>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Z raporu yazdırır.
|
|
105
|
+
|
|
106
|
+
**Returns:** <code>Promise<{ result: boolean; }></code>
|
|
107
|
+
|
|
108
|
+
--------------------
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
### GetVatRates()
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
GetVatRates() => Promise<string[]>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Kayıtlı KDV oranlarını getirir.
|
|
118
|
+
|
|
119
|
+
**Returns:** <code>Promise<string[]></code>
|
|
120
|
+
|
|
121
|
+
--------------------
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
### GetDepartments()
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
GetDepartments() => Promise<Department[]>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Tanımlı departmanları getirir.
|
|
131
|
+
|
|
132
|
+
**Returns:** <code>Promise<Department[]></code>
|
|
133
|
+
|
|
134
|
+
--------------------
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
### SetDepartment(...)
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
SetDepartment(Department: Department) => Promise<{ result: boolean; }>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Departman ekler veya günceller.
|
|
144
|
+
|
|
145
|
+
| Param | Type | Description |
|
|
146
|
+
| ---------------- | ------------------------------------------------- | -------------------- |
|
|
147
|
+
| **`Department`** | <code><a href="#department">Department</a></code> | Departman bilgileri. |
|
|
148
|
+
|
|
149
|
+
**Returns:** <code>Promise<{ result: boolean; }></code>
|
|
150
|
+
|
|
151
|
+
--------------------
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
### SetVatRate(...)
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
SetVatRate(vatRate: VatRate) => Promise<{ result: boolean; }>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Belirli bir KDV oranını ayarlar.
|
|
161
|
+
|
|
162
|
+
| Param | Type | Description |
|
|
163
|
+
| ------------- | ------------------------------------------- | ----------------- |
|
|
164
|
+
| **`vatRate`** | <code><a href="#vatrate">VatRate</a></code> | KDV oran bilgisi. |
|
|
165
|
+
|
|
166
|
+
**Returns:** <code>Promise<{ result: boolean; }></code>
|
|
167
|
+
|
|
168
|
+
--------------------
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
### Interfaces
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
#### ConnectOptions
|
|
175
|
+
|
|
176
|
+
Bağlantı ayarları.
|
|
177
|
+
|
|
178
|
+
| Prop | Type | Description |
|
|
179
|
+
| ---------------- | ------------------- | -------------------------------- |
|
|
180
|
+
| **`terminalNo`** | <code>string</code> | Terminal numarası (seri numara). |
|
|
181
|
+
| **`ip`** | <code>string</code> | Cihaz IP adresi. |
|
|
182
|
+
| **`port`** | <code>number</code> | Cihaz port numarası. |
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
#### SaleItem
|
|
186
|
+
|
|
187
|
+
Satış bilgisi.
|
|
188
|
+
|
|
189
|
+
| Prop | Type | Description |
|
|
190
|
+
| ---------------------- | ------------------------------------------------------------- | ---------------------------- |
|
|
191
|
+
| **`FiscalItems`** | <code>FiscalItem[]</code> | Satışta yer alan ürünler. |
|
|
192
|
+
| **`Adjustments`** | <code>Adj[]</code> | Satışa uygulanan indirimler. |
|
|
193
|
+
| **`Payments`** | <code>Payment[]</code> | Ödeme bilgileri. |
|
|
194
|
+
| **`FooterNotes`** | <code>string[]</code> | Fiş altı notları. |
|
|
195
|
+
| **`EndOfReceiptInfo`** | <code><a href="#endofreceiptinfo">EndOfReceiptInfo</a></code> | Fiş kapanış bilgisi. |
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
#### FiscalItem
|
|
199
|
+
|
|
200
|
+
Satışta yer alan ürün bilgisi.
|
|
201
|
+
|
|
202
|
+
| Prop | Type | Description |
|
|
203
|
+
| --------------- | ------------------------------------------- | ------------------- |
|
|
204
|
+
| **`Id`** | <code>number</code> | Ürün ID. |
|
|
205
|
+
| **`Quantity`** | <code>number</code> | Miktar. |
|
|
206
|
+
| **`Price`** | <code>number</code> | Fiyat. |
|
|
207
|
+
| **`Name`** | <code>string</code> | Ürün adı. |
|
|
208
|
+
| **`DeptId`** | <code>number</code> | Departman ID. |
|
|
209
|
+
| **`Status`** | <code>number</code> | Ürün durumu. |
|
|
210
|
+
| **`Adj`** | <code><a href="#adj">Adj</a> \| null</code> | Ürüne özel indirim. |
|
|
211
|
+
| **`NoteLine1`** | <code>string \| null</code> | Not satırı 1. |
|
|
212
|
+
| **`NoteLine2`** | <code>string \| null</code> | Not satırı 2. |
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
#### Adj
|
|
216
|
+
|
|
217
|
+
İndirim bilgisi.
|
|
218
|
+
|
|
219
|
+
| Prop | Type | Description |
|
|
220
|
+
| ---------------- | --------------------------- | ---------------- |
|
|
221
|
+
| **`Type`** | <code>number</code> | İndirim tipi. |
|
|
222
|
+
| **`Amount`** | <code>number</code> | İndirim tutarı. |
|
|
223
|
+
| **`percentage`** | <code>number</code> | İndirim yüzdesi. |
|
|
224
|
+
| **`NoteLine1`** | <code>string \| null</code> | Not satırı 1. |
|
|
225
|
+
| **`NoteLine2`** | <code>string \| null</code> | Not satırı 2. |
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
#### Payment
|
|
229
|
+
|
|
230
|
+
Ödeme bilgileri.
|
|
231
|
+
|
|
232
|
+
| Prop | Type | Description |
|
|
233
|
+
| ---------------- | -------------------- | ------------------------------- |
|
|
234
|
+
| **`Type`** | <code>number</code> | Ödeme tipi (örn: nakit, kredi). |
|
|
235
|
+
| **`Index`** | <code>number</code> | Ödeme indexi. |
|
|
236
|
+
| **`PaidTotal`** | <code>number</code> | Ödenen toplam tutar. |
|
|
237
|
+
| **`viaByEFT`** | <code>boolean</code> | EFT ile mi yapıldı? |
|
|
238
|
+
| **`SequenceNo`** | <code>number</code> | Sıra numarası. |
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
#### EndOfReceiptInfo
|
|
242
|
+
|
|
243
|
+
Fiş kapanış bilgileri.
|
|
244
|
+
|
|
245
|
+
| Prop | Type | Description |
|
|
246
|
+
| ---------------------- | --------------------------- | ------------------- |
|
|
247
|
+
| **`CloseReceiptFlag`** | <code>boolean</code> | Fişi kapat. |
|
|
248
|
+
| **`BarcodeFlag`** | <code>boolean</code> | Barkod basılsın mı? |
|
|
249
|
+
| **`Barcode`** | <code>string \| null</code> | Barkod numarası. |
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
#### Department
|
|
253
|
+
|
|
254
|
+
Departman bilgisi.
|
|
255
|
+
|
|
256
|
+
| Prop | Type | Description |
|
|
257
|
+
| --------------- | ------------------------------------------------- | -------------------------------------------------- |
|
|
258
|
+
| **`id`** | <code>1 \| 2 \| 8 \| 7 \| 6 \| 5 \| 4 \| 3</code> | Departman ID (1-8). |
|
|
259
|
+
| **`name`** | <code>string</code> | Departman ismi. |
|
|
260
|
+
| **`vatId`** | <code>1 \| 2 \| 8 \| 7 \| 6 \| 5 \| 4 \| 3</code> | Departmana atanmış KDV ID (1-8). |
|
|
261
|
+
| **`price`** | <code>number</code> | Fiyat (0 - 999.999,99). |
|
|
262
|
+
| **`weighable`** | <code>0 \| 1</code> | Tartılabilir mi? 0 = tartılamaz, 1 = tartılabilir. |
|
|
263
|
+
| **`limit`** | <code>number</code> | Opsiyonel limit. (Eğer varsa) |
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
#### VatRate
|
|
267
|
+
|
|
268
|
+
KDV oran bilgisi.
|
|
269
|
+
|
|
270
|
+
| Prop | Type | Description |
|
|
271
|
+
| ------------- | ------------------------------------------------- | ---------------- |
|
|
272
|
+
| **`index`** | <code>0 \| 1 \| 2 \| 7 \| 6 \| 5 \| 4 \| 3</code> | KDV index (0-7). |
|
|
273
|
+
| **`vatRate`** | <code>number</code> | KDV oranı (%). |
|
|
274
|
+
|
|
275
|
+
</docgen-api>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
mavenCentral()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.7.2'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apply plugin: 'com.android.library'
|
|
19
|
+
|
|
20
|
+
android {
|
|
21
|
+
namespace "com.kerzz.hugin.gmp3"
|
|
22
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
|
|
23
|
+
defaultConfig {
|
|
24
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
|
|
26
|
+
versionCode 1
|
|
27
|
+
versionName "1.0"
|
|
28
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
29
|
+
}
|
|
30
|
+
buildTypes {
|
|
31
|
+
release {
|
|
32
|
+
minifyEnabled false
|
|
33
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
lintOptions {
|
|
37
|
+
abortOnError false
|
|
38
|
+
}
|
|
39
|
+
compileOptions {
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_21
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_21
|
|
42
|
+
}
|
|
43
|
+
repositories {
|
|
44
|
+
flatDir {
|
|
45
|
+
dirs 'libs'
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
repositories {
|
|
51
|
+
google()
|
|
52
|
+
mavenCentral()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
dependencies {
|
|
57
|
+
implementation files('libs/gmp3android.aar')
|
|
58
|
+
implementation fileTree(dir: 'libs', include: ['*.jar', '**/*.aar'])
|
|
59
|
+
implementation project(':capacitor-android')
|
|
60
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
61
|
+
testImplementation "junit:junit:$junitVersion"
|
|
62
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
63
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
64
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
package com.kerzz.hugin.gmp3;
|
|
2
|
+
|
|
3
|
+
import android.util.Log;
|
|
4
|
+
|
|
5
|
+
import com.getcapacitor.JSObject;
|
|
6
|
+
|
|
7
|
+
import gmp3.droid.printer.DeviceInfo;
|
|
8
|
+
import gmp3.droid.printer.HuginPrinter;
|
|
9
|
+
import gmp3.droid.printer.Utility;
|
|
10
|
+
|
|
11
|
+
public class CapacitorHuginGMP3 {
|
|
12
|
+
protected final HuginPrinter huginPrinter = new HuginPrinter();
|
|
13
|
+
private final String TAG = "CapacitorHuginGMP3Plugin";
|
|
14
|
+
protected boolean tcpConnected = false;
|
|
15
|
+
private int tcpRetry = 0;
|
|
16
|
+
private boolean tcpConnect(String ip, Integer port) {
|
|
17
|
+
try {
|
|
18
|
+
if(tcpConnected) return true;
|
|
19
|
+
if (port == null) {
|
|
20
|
+
Log.w(TAG,"Port parametresi eksik.");
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return huginPrinter.TCPConnect(ip, port);
|
|
25
|
+
} catch (RuntimeException e) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
protected boolean connect(String ip, int port, String terminalNo) {
|
|
31
|
+
try {
|
|
32
|
+
tcpConnected = tcpConnect(ip,port);
|
|
33
|
+
if(!tcpConnected) {
|
|
34
|
+
tcpRetry += 1;
|
|
35
|
+
Log.w(TAG,"TCP Bağlantısı sağlanamadı. Tekrar deneniyor: " + tcpRetry);
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
DeviceInfo serverInfo = new DeviceInfo();
|
|
39
|
+
serverInfo.Brand = "HUGIN";
|
|
40
|
+
serverInfo.IP = ip;
|
|
41
|
+
serverInfo.Model = "HUGIN COMPACT";
|
|
42
|
+
serverInfo.Port = port;
|
|
43
|
+
serverInfo.TerminalNo = terminalNo;// "FP11004397";
|
|
44
|
+
serverInfo.Version = "";
|
|
45
|
+
serverInfo.SerialNum = "";
|
|
46
|
+
Log.i(TAG, serverInfo.IP);
|
|
47
|
+
return huginPrinter.Connect(serverInfo, serverInfo.TerminalNo, "");
|
|
48
|
+
} catch (Exception e) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
protected String libraryVersion() {
|
|
54
|
+
return huginPrinter.LibraryVersion();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
protected boolean printZReport() {
|
|
58
|
+
try {
|
|
59
|
+
String[] response = printResponse(huginPrinter.PrintZReport());
|
|
60
|
+
int errorCode = Integer.parseInt(response[0]);
|
|
61
|
+
if(errorCode != 0) {
|
|
62
|
+
System.out.println("Error Code : " + Utility.GetErrorMessage(errorCode));
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return true;
|
|
67
|
+
} catch (Exception e) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
protected boolean printXReport(int type) {
|
|
73
|
+
try {
|
|
74
|
+
String[] response = printResponse(huginPrinter.PrintXReport(type));
|
|
75
|
+
int errorCode = Integer.parseInt(response[0]);
|
|
76
|
+
if(errorCode != 0) {
|
|
77
|
+
System.out.println("Error Code : " + Utility.GetErrorMessage(errorCode));
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
} catch (Exception e) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
protected static String[] printResponse(String response) {
|
|
88
|
+
int res = 6;
|
|
89
|
+
String[] splitted = response.split("\\|", 0);
|
|
90
|
+
if (splitted.length >= 2) {
|
|
91
|
+
res = Integer.parseInt(splitted[0]);
|
|
92
|
+
System.out.println("Error Code : " + Utility.GetErrorMessage(res));
|
|
93
|
+
System.out.println("State : " + Utility.GetStateMessage(Integer.parseInt(splitted[1])));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
System.out.println("Full Response : " + response);
|
|
97
|
+
return splitted;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
protected String sale(JSObject saleItem) {
|
|
101
|
+
String res = huginPrinter.CheckPrinterStatus();
|
|
102
|
+
Log.i(TAG, res);
|
|
103
|
+
String result = huginPrinter.PrintDocumentHeader();
|
|
104
|
+
Log.i(TAG, result);
|
|
105
|
+
String str = huginPrinter.PrintJSONDocumentDeptOnly(saleItem.toString());
|
|
106
|
+
Log.i(TAG, str);
|
|
107
|
+
String[] response = printResponse(str);
|
|
108
|
+
if(response.length > 2) {
|
|
109
|
+
return printResponse(str)[2];
|
|
110
|
+
}
|
|
111
|
+
return "-1";
|
|
112
|
+
// String result = huginPrinter.PrintDocumentHeader();
|
|
113
|
+
// String item1 = huginPrinter.PrintItem(1, 15, 3.00, "Capacitor Ürün", "", 1, 1);
|
|
114
|
+
// String item2 = huginPrinter.PrintItem(1, 30, 3.00, "Capacitor Ürün 2", "", 1, 1);
|
|
115
|
+
// String payment = huginPrinter.PrintPayment(0 , -1 , 300);
|
|
116
|
+
//
|
|
117
|
+
// huginPrinter.CloseReceipt(false);
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
}
|