@freteclick/quasar-financial-ui 1.0.103 → 1.0.104

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@freteclick/quasar-financial-ui",
3
- "version": "1.0.103",
3
+ "version": "1.0.104",
4
4
  "author": "FreteClick",
5
5
  "description": "FreteClick financial Quasar UI Component",
6
6
  "license": "MIT",
@@ -93,10 +93,7 @@
93
93
  </q-tab-panel>
94
94
 
95
95
  <q-tab-panel name="invoice" class="q-pa-none">
96
- <InvoiceInvoice
97
- :invoiceId="invoiceId"
98
- :orderId ="orderId"
99
- />
96
+ <InvoiceInvoice ref="invoiceBillet" :invoiceId="invoiceId" :orderId="orderId" :invoice="invoice" />
100
97
  </q-tab-panel>
101
98
  </q-tab-panels>
102
99
  </div>
@@ -1,12 +1,7 @@
1
1
  <template>
2
2
  <div class="row items-center justify-center">
3
3
  <div class="flex flex-center" v-if="isLoading">
4
- <q-circular-progress
5
- :indeterminate="isLoading"
6
- size="sm"
7
- color="primary"
8
- class="q-ma-md"
9
- />
4
+ <q-circular-progress :indeterminate="isLoading" size="sm" color="primary" class="q-ma-md" />
10
5
  Carregando...
11
6
  </div>
12
7
 
@@ -18,99 +13,38 @@
18
13
  </div>
19
14
  </div>
20
15
 
21
- <!-- BILLET VIEWER SICRED -->
22
- <div :class="showBilletSicred ? 'full-width q-pa-lg' : 'hidden'">
23
- <div class="col-12 q-pt-lg" v-if="paymentInstitution === 'sicred'">
24
- <!-- <div class="row justify-center items-center">
25
- <q-btn
26
- icon="money"
27
- size="lg"
28
- color="primary"
29
- label="Abrir Boleto Pix"
30
- :loading="isLoadingDownload"
31
- @click="clickDownloadBilletSicred()"
32
- :disable="isPaid"
33
- />
34
- </div> -->
35
-
36
- <div style="height: 1200px">
37
- <iframe
38
- :src="invoiceUrlSicred"
39
- name="BILLETINTER" id="billet_sicred" width="100%" height="100%" frameBorder="0">
40
- <p>This browser does not support IFrame.</p>
41
- </iframe>
42
- </div>
43
- </div>
44
- </div>
16
+ <div class="col-12 q-pt-lg">
17
+ <div class="row justify-center items-center gutter-2">
18
+ <div class="q-pa-sm">
19
+ <q-btn icon="money" size="lg" color="primary"
20
+ :label="invoiceBankId === null ? 'Gerar Boleto' : 'Boleto gerado'" :loading="isLoading"
21
+ @click="generateSicredBillet()" :disable="isPaid || invoiceBankId !== null" />
22
+ </div>
23
+ <div class="q-pa-sm">
24
+ <q-btn icon="visibility" size="lg" color="primary" label="Ver Boleto" :loading="isLoadingDownload"
25
+ @click="clickDownloadBilletSicred()" :disable="invoiceBankId === null" />
26
+ </div>
27
+
45
28
 
46
- <!-- BILLET VIEWER INTER -->
47
- <div :class="showBilletInter ? 'full-width q-pa-lg' : 'hidden'">
48
- <div style="height: 1200px">
49
- <iframe
50
- :src="invoiceUrlInter"
51
- name="BILLETINTER" id="billet_inter" width="100%" height="100%" frameBorder="0">
52
- <p>This browser does not support IFrame.</p>
53
- </iframe>
54
29
  </div>
55
30
  </div>
56
31
 
57
- <!-- BILLET VIEWER ITAU -->
58
- <div :class="showBillet ? 'full-width q-pa-lg' : 'hidden'">
59
- <q-form
60
- ref="myForm"
61
- :action="payment !== null ? payment.invoiceUrl : ''"
62
- method="post"
63
- class="q-mt-sm row justify-center items-center"
64
- target="BILLET"
65
- >
66
- <input type="hidden" name="DC" :value="itauHash"/>
67
- </q-form>
32
+ <!-- BILLET VIEWER SICRED -->
33
+ <div :class="showBilletSicred ? 'full-width q-pa-lg' : 'hidden'">
68
34
  <div style="height: 1200px">
69
- <iframe name="BILLET" width="100%" height="100%" frameBorder="0">
35
+ <iframe :src="invoiceUrlSicred" name="BILLETINTER" id="billet_sicred" width="100%" height="100%"
36
+ frameBorder="0">
70
37
  <p>This browser does not support IFrame.</p>
71
38
  </iframe>
72
39
  </div>
73
40
  </div>
74
41
 
75
- <!-- BILLET GENERATOR TRIGGER -->
76
- <div class="col-12 q-pt-lg" v-if="paymentIsPending && billetMustBeCreated && paymentInstitution === 'itau'">
77
- <div style="min-height: 80vh;" class="row justify-center items-center">
78
- <q-btn
79
- icon="money"
80
- size="lg"
81
- color="primary"
82
- label="Gerar boleto"
83
- :loading="retrievingHash"
84
- @click="() => {
85
- this.retrievingHash = true;
86
- this.getItauHash().then(hash => {
87
- if (hash !== null) {
88
- this.loadOnFocus = true;
89
- this.$refs.billetForm.$el.submit();
90
- }
91
- }).finally(() => {
92
- this.retrievingHash = false;
93
- });
94
- }"
95
- :disable="isPaid"
96
- />
97
- <q-form
98
- ref="billetForm"
99
- :action="payment ? payment.invoiceUrl : ''"
100
- method="post"
101
- target="_blank"
102
- >
103
- <input type="hidden" name="DC" :value="itauHash"/>
104
- </q-form>
105
- </div>
106
- </div>
107
-
108
42
  <!-- PAID MESSAGE -->
109
- <div class="col-12" v-if="payment !== null && isPaid">
110
- <div class="row items-center justify-center" style="min-height: 90vh;">
43
+ <div class="col-12" v-if="isPaid">
44
+ <div class="row items-center justify-center q-pt-lg">
111
45
  <q-banner class="text-white bg-positive text-center text-h3" rounded>
112
46
  <template v-slot:avatar>
113
- <q-icon name="thumb_up" color="white"/>
47
+ <q-icon name="thumb_up" color="white" />
114
48
  </template>
115
49
  O boleto foi pago
116
50
  </q-banner>
@@ -120,9 +54,9 @@
120
54
  </template>
121
55
 
122
56
  <script>
123
- import {mapActions, mapGetters} from 'vuex';
57
+ import { mapActions, mapGetters } from 'vuex';
124
58
  import axios from 'axios';
125
- import {ENTRYPOINT} from '@freteclick/../../src/config/entrypoint';
59
+ import { ENTRYPOINT } from '@freteclick/../../src/config/entrypoint';
126
60
 
127
61
  export default {
128
62
  props: {
@@ -134,38 +68,60 @@ export default {
134
68
  type: String,
135
69
  required: true,
136
70
  },
71
+ invoice: {
72
+ type: Object,
73
+ required: true,
74
+ },
137
75
  },
138
76
 
139
77
  components: {},
140
78
 
141
79
  mounted() {
142
- window.addEventListener('focus', this.loadItauDataOnFocus);
143
- },
144
-
145
- beforeDestroy() {
146
- window.removeEventListener('focus', this.loadItauDataOnFocus);
147
80
  },
148
81
 
149
82
  created() {
150
- this.getPaymentStatus();
83
+ this.getBank();
84
+
85
+ if (this.invoice.status.status === 'paid') {
86
+ this.isPaid = true;
87
+ this.showBilletSicred = true;
88
+ }
89
+
90
+ if (this.invoice.paymentType === 'boleto' || this.invoice.invoiceBankId !== null) {
91
+ this.paymentType = 'boleto';
92
+ this.showBilletSicred = true;
93
+ this.invoiceBankId = this.invoice.invoiceBankId;
94
+ }
95
+
96
+ if (this.invoice.paymentType !== null) {
97
+ this.paymentType = this.invoice.paymentType;
98
+ }
99
+
100
+ console.log(this.invoice);
101
+ console.log(this.invoice.invoiceBankId);
102
+
103
+ console.log('Dados de pagamento: ', this.payment);
104
+
105
+ this.clickDownloadBilletSicred();
106
+
151
107
  },
152
108
 
153
109
  data() {
154
110
  return {
155
- invoiceUrlInter: null,
156
111
  invoiceUrlSicred: null,
157
- showBilletInter: null,
158
- showBilletSicred: null,
112
+ showBilletSicred: false,
159
113
  showInfoBox: null,
160
114
  isLoadingDownload: false,
161
115
  isLoading: false,
162
- payment: null,
163
- isPaid: false,
164
- itauHash: null,
116
+ payment: null, // Recebe dados de pagamento
117
+ isPaid: false, // Indica se a fatura foi paga
165
118
  showBillet: false,
166
119
  loadOnFocus: false,
167
120
  retrievingHash: false,
168
- paymentInstitution: null
121
+ paymentInstitution: null,
122
+ paymentStatus: null,
123
+ paymentType: null,
124
+ invoiceBankId: null
169
125
  };
170
126
  },
171
127
 
@@ -179,11 +135,12 @@ export default {
179
135
 
180
136
  return this.payment.invoiceRealStatus === 'pending';
181
137
  },
138
+ // O Boleto deve ser Criado
182
139
  billetMustBeCreated() {
183
140
  if (this.payment === null)
184
141
  return false;
185
142
 
186
- return this.payment.paymentType === 'choose_pending' || this.payment.paymentStatus !== 'paid';
143
+ return this.payment.paymentType === 'boleto' || this.payment.paymentStatus !== 'paid';
187
144
  },
188
145
  },
189
146
 
@@ -194,162 +151,46 @@ export default {
194
151
  }
195
152
  },
196
153
 
197
- payment(data) {
198
- if (!data)
199
- return;
200
-
201
- this.isPaid = data.paymentStatus === 'paid';
202
-
203
- if(this.payment.paymentStatus === 'open')
204
- {
205
- this.showInfoBox = true;
206
- }
207
-
208
- if (data.paymentType == 'billet') {
209
-
210
- if (data.paymentStatus !== 'open') {
211
-
212
- this.showInfoBox = false;
213
-
214
- if (this.paymentInstitution === 'itau') {
215
- this.getItauHash().then(hash => {
216
- if (hash !== null) {
217
- this.showBillet = true;
218
- }
219
- });
220
-
221
- } else if(this.paymentInstitution === 'inter') {
222
-
223
- this.showBillet = false;
224
- let urlTmp = ENTRYPOINT + `/vendor/pdf.js/web/viewer.html?file=/finance/${this.invoiceId}/download?timestamp${new Date().getTime()}`;
225
- this.invoiceUrlInter = urlTmp;
226
- this.isLoading = false;
227
- this.showBilletInter = true;
228
-
229
- }
230
- else {
231
-
232
- this.showBillet = false;
233
- let urlTmp = ENTRYPOINT + `/vendor/pdf.js/web/viewer.html?file=/finance/${this.invoiceId}/bank/sicred/download?timestamp${new Date().getTime()}`;
234
- // let urlTmp = ENTRYPOINT + `/download?invoiceUrl=${this.payment.invoiceUrl}`;
235
- this.invoiceUrlSicred = urlTmp;
236
- this.isLoading = false;
237
- this.showBilletSicred = true;
238
-
239
- }
240
- }
241
-
242
- }
243
-
244
- this.$emit(
245
- 'billetStatus',
246
- {
247
- hasBillet: data.paymentType === 'billet' && data.paymentStatus === 'created',
248
- isPaid: data.paymentStatus === 'paid'
249
- }
250
- );
251
-
252
- },
253
-
254
- showBillet(show) {
255
- if (show == true) {
256
- this.$refs.myForm.$el.submit();
257
- }
258
- },
259
154
  },
260
155
 
261
156
  methods: {
262
157
  ...mapActions({
263
- getItauData: 'receiveInvoice/bankItau',
264
- getInterData: 'receiveInvoice/bankInter',
265
158
  getSicredData: 'receiveInvoice/bankSicred',
159
+ getInvoice: 'receiveInvoice/getInvoice',
266
160
  getBankPerInvoiceId: 'receiveInvoice/getBankPerInvoiceId',
267
161
  }),
268
162
 
269
- mountInvoiceUrlInter() {
270
- let invoiceUrl = encodeURIComponent(this.payment.invoiceUrl);
271
- return axios({
272
- url: ENTRYPOINT + `/download?invoiceUrl=${invoiceUrl}&timestamp=${new Date().getTime()}`,
273
- method: 'get',
274
- responseType: 'blob'
275
- }).then((response) => {
276
- let blob = new Blob([response.data], {type: 'application/pdf'}), url = window.URL.createObjectURL(blob);
277
- return url;
278
- });
279
- },
280
-
281
- clickDownloadBilletInter() {
282
- let urlTmp = ENTRYPOINT + `/vendor/pdf.js/web/viewer.html?file=/finance/${this.invoiceId}/download?timestamp${new Date().getTime()}`;
283
- window.open(urlTmp);
284
- },
285
-
286
- mountInvoiceUrlSicred() {
287
- let invoiceUrl = encodeURIComponent(this.payment.invoiceUrl);
288
- return axios({
289
- url: ENTRYPOINT + `/download?invoiceUrl=${invoiceUrl}&timestamp=${new Date().getTime()}`,
290
- method: 'get',
291
- responseType: 'blob'
292
- }).then((response) => {
293
- let blob = new Blob([response.data], {type: 'application/pdf'}), url = window.URL.createObjectURL(blob);
163
+ // Ver boleto ou baixar
164
+ clickDownloadBilletSicred() {
165
+ if (this.isLoadingDownload) {
166
+ return null;
167
+ }
294
168
 
295
- console.log(url);
169
+ this.isLoadingDownload = true;
296
170
 
297
- return url;
298
- });
299
- },
171
+ const viewerUrl = ENTRYPOINT + `/vendor/pdf.js/web/viewer.html?file=/finance/${this.invoiceId}/bank/sicred/download?timestamp=${new Date().getTime()}`;
172
+ this.invoiceUrlSicred = viewerUrl;
173
+ this.showBilletSicred = true;
300
174
 
301
- clickDownloadBilletSicred() {
302
- let urlTmp = ENTRYPOINT + `/download?invoiceUrl=${this.payment.invoiceUrl}`;
303
- window.open(urlTmp);
175
+ this.isLoadingDownload = false;
304
176
  },
305
177
 
178
+ // Consulta informações do banco
306
179
  getBank() {
307
- return this.getBankPerInvoiceId({
308
- invoiceId: this.invoiceId
309
- }).then(data => {
310
- if (data !== null) {
311
- this.paymentInstitution = data.config_value;
312
- this.getPaymentStatus();
313
- return data;
314
- }
315
- return null;
316
- }).catch(error => {
317
- });
318
- },
319
-
320
- refresh() {
321
- this.getPaymentStatus();
322
- },
180
+ return this.getBankPerInvoiceId({ invoiceId: this.invoiceId })
181
+ .then(data => {
182
+ if (data !== null) {
183
+ this.paymentInstitution = data.config_value;
184
+ return data;
185
+ }
186
+ return null;
323
187
 
324
- loadItauDataOnFocus() {
325
- if (this.loadOnFocus) {
326
- this.getPaymentStatus().then(data => {
327
- this.loadOnFocus = false;
188
+ }).catch(error => {
328
189
  });
329
- }
330
- },
331
-
332
- getItauHash() {
333
- let params = {};
334
-
335
- if (this.myCompany !== null)
336
- params['myCompany'] = this.myCompany.id;
337
-
338
- return this.getItauData({
339
- invoiceId: this.invoiceId,
340
- operation: 'itauhash',
341
- params: params
342
- }).then(data => {
343
- if (data !== null) {
344
- return this.itauHash = data;
345
- }
346
- return null;
347
- }).catch(error => {
348
-
349
- });
350
190
  },
351
191
 
352
- getPaymentStatus() {
192
+ // Gera o boleto
193
+ generateSicredBillet() {
353
194
 
354
195
  if (this.isLoading) {
355
196
  return null;
@@ -363,94 +204,36 @@ export default {
363
204
  params['myCompany'] = this.myCompany.id;
364
205
  }
365
206
 
366
- return this.getBank().then(data2 => {
367
-
368
- if (this.paymentInstitution === 'itau') {
369
-
370
- this.getItauData({
371
- invoiceId: this.invoiceId,
372
- operation: 'payment',
373
- params: params
374
- }).then(data => {
375
- if (data !== null) {
376
- return this.payment = data;
377
- }
378
- return null;
379
- }).catch(error => {
380
-
381
- }).finally(() => {
382
- this.isLoading = false;
383
- // this.isLoading = false;
384
- });
385
-
386
- } else if(this.paymentInstitution === 'inter'){
387
-
388
- this.getInterData({
389
- invoiceId: this.invoiceId,
390
- operation: 'payment',
391
- params: params
392
- }).then(data => {
393
- if (data !== null) {
394
- if (!data.response.success) {
395
- let msgErro = data.response.error;
396
- this.$q.notify({
397
- message: msgErro,
398
- html: true,
399
- group: false,
400
- multiLine: true,
401
- position: 'bottom',
402
- type: 'negative',
403
- });
404
- return this.payment = null;
405
- } else {
406
- return this.payment = data.response.data;
407
- }
408
- } else {
409
- return this.payment = null;
410
- }
411
- return null;
412
- }).catch(error => {
413
- console.table(error);
414
- }).finally(() => {
415
- this.isLoading = false;
416
- });
417
-
418
- }
419
- else {
420
-
421
- this.getSicredData({
422
- invoiceId: this.invoiceId,
423
- operation: 'payment',
424
- params: params
425
- }).then(data => {
426
- if (data !== null) {
427
- if (!data.response.success) {
428
- let msgErro = data.response.error;
429
- this.$q.notify({
430
- message: msgErro,
431
- html: true,
432
- group: false,
433
- multiLine: true,
434
- position: 'bottom',
435
- type: 'negative',
436
- });
437
- return this.payment = null;
438
- } else {
439
- return this.payment = data.response.data;
440
- }
441
- } else {
442
- return this.payment = null;
443
- }
444
- return null;
445
- }).catch(error => {
446
- console.table(error);
447
- }).finally(() => {
448
- this.isLoading = false;
449
- });
450
-
207
+ this.getSicredData({
208
+ invoiceId: this.invoiceId,
209
+ operation: 'payment',
210
+ params: params
211
+ }).then(data => {
212
+ if (data !== null) {
213
+ if (!data.response.success) {
214
+ let msgErro = data.response.error;
215
+ this.$q.notify({
216
+ message: msgErro,
217
+ html: true,
218
+ group: false,
219
+ multiLine: true,
220
+ position: 'bottom',
221
+ type: 'negative',
222
+ });
223
+ return this.payment = null;
224
+ } else {
225
+ return this.payment = data.response.data;
226
+ }
227
+ } else {
228
+ return this.payment = null;
451
229
  }
452
230
 
231
+ }).catch(error => {
232
+ console.table(error);
233
+ }).finally(() => {
234
+ this.isLoading = false;
453
235
  });
236
+
454
237
  },
455
238
  },
456
239
  };