@freteclick/quasar-financial-ui 1.0.97 → 1.0.98

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.97",
3
+ "version": "1.0.98",
4
4
  "author": "FreteClick",
5
5
  "description": "FreteClick financial Quasar UI Component",
6
6
  "license": "MIT",
@@ -15,4 +15,4 @@
15
15
  "browserslist": [
16
16
  "last 1 version, not dead, ie >= 11"
17
17
  ]
18
- }
18
+ }
@@ -1,27 +1,70 @@
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 :indeterminate="isLoading"
5
- size ="sm"
4
+ <q-circular-progress
5
+ :indeterminate="isLoading"
6
+ size="sm"
6
7
  color="primary"
7
8
  class="q-ma-md"
8
9
  />
9
10
  Carregando...
10
11
  </div>
11
12
 
12
- <!-- BILLET VIEWER -->
13
+ <div :class="showInfoBox ? 'full-width q-pa-lg' : 'hidden'">
14
+ <div class="q-pa-md q-gutter-sm">
15
+ <q-banner inline-actions rounded class="bg-primary text-white text-center">
16
+ <h6>Este boleto não pode ser gerado agora, pois a fatura está em aberto.</h6>
17
+ </q-banner>
18
+ </div>
19
+ </div>
20
+
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>
45
+
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
+ </div>
55
+ </div>
13
56
 
57
+ <!-- BILLET VIEWER ITAU -->
14
58
  <div :class="showBillet ? 'full-width q-pa-lg' : 'hidden'">
15
59
  <q-form
16
- ref ="myForm"
17
- :action="payment !== null ? payment.invoiceUrl : ''"
18
- method ="post"
19
- class ="q-mt-sm row justify-center items-center"
20
- target ="BILLET"
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"
21
65
  >
22
- <input type="hidden" name="DC" :value="itauHash" />
66
+ <input type="hidden" name="DC" :value="itauHash"/>
23
67
  </q-form>
24
-
25
68
  <div style="height: 1200px">
26
69
  <iframe name="BILLET" width="100%" height="100%" frameBorder="0">
27
70
  <p>This browser does not support IFrame.</p>
@@ -30,41 +73,44 @@
30
73
  </div>
31
74
 
32
75
  <!-- BILLET GENERATOR TRIGGER -->
33
-
34
- <div class="col-12 q-pt-lg" v-if="paymentIsPending && billetMustBeCreated">
35
- <div
36
- style="min-height: 80vh;"
37
- class="row justify-center items-center"
38
- >
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
+ />
39
97
  <q-form
40
- :action="payment ? payment.invoiceUrl : ''"
41
- method ="post"
42
- target ="_blank"
98
+ ref="billetForm"
99
+ :action="payment ? payment.invoiceUrl : ''"
100
+ method="post"
101
+ target="_blank"
43
102
  >
44
- <input type="hidden" name="DC" :value="itauHash" />
45
- <q-btn
46
- type ="submit"
47
- icon ="money"
48
- size ="lg"
49
- color ="primary"
50
- label ="Gerar boleto"
51
- @click ="loadOnFocus = true"
52
- :disable="isPaid"
53
- />
103
+ <input type="hidden" name="DC" :value="itauHash"/>
54
104
  </q-form>
55
105
  </div>
56
106
  </div>
57
107
 
58
108
  <!-- PAID MESSAGE -->
59
-
60
109
  <div class="col-12" v-if="payment !== null && isPaid">
61
- <div
62
- class="row items-center justify-center"
63
- style="min-height: 90vh;"
64
- >
110
+ <div class="row items-center justify-center" style="min-height: 90vh;">
65
111
  <q-banner class="text-white bg-positive text-center text-h3" rounded>
66
112
  <template v-slot:avatar>
67
- <q-icon name="thumb_up" color="white" />
113
+ <q-icon name="thumb_up" color="white"/>
68
114
  </template>
69
115
  O boleto foi pago
70
116
  </q-banner>
@@ -74,23 +120,26 @@
74
120
  </template>
75
121
 
76
122
  <script>
77
- import { date, extend } from 'quasar';
78
- import { mapActions, mapGetters } from 'vuex';
123
+ import {mapActions, mapGetters} from 'vuex';
124
+ import axios from 'axios';
125
+ import {ENTRYPOINT} from '../../../../../../../../src/config/entrypoint';
79
126
 
80
127
  export default {
81
128
  props: {
82
129
  invoiceId: {
83
- type : String,
130
+ type: String,
84
131
  required: true,
85
132
  },
86
- orderId : {
87
- type : String,
133
+ orderId: {
134
+ type: String,
88
135
  required: true,
89
136
  },
90
137
  },
91
138
 
139
+ components: {},
140
+
92
141
  mounted() {
93
- window.addEventListener ('focus', this.loadItauDataOnFocus);
142
+ window.addEventListener('focus', this.loadItauDataOnFocus);
94
143
  },
95
144
 
96
145
  beforeDestroy() {
@@ -103,12 +152,20 @@ export default {
103
152
 
104
153
  data() {
105
154
  return {
106
- isLoading : false,
107
- payment : null,
108
- isPaid : false,
109
- itauHash : null,
110
- showBillet : false,
155
+ invoiceUrlInter: null,
156
+ invoiceUrlSicred: null,
157
+ showBilletInter: null,
158
+ showBilletSicred: null,
159
+ showInfoBox: null,
160
+ isLoadingDownload: false,
161
+ isLoading: false,
162
+ payment: null,
163
+ isPaid: false,
164
+ itauHash: null,
165
+ showBillet: false,
111
166
  loadOnFocus: false,
167
+ retrievingHash: false,
168
+ paymentInstitution: null
112
169
  };
113
170
  },
114
171
 
@@ -116,27 +173,24 @@ export default {
116
173
  ...mapGetters({
117
174
  myCompany: 'people/currentCompany',
118
175
  }),
119
-
120
176
  paymentIsPending() {
121
177
  if (this.payment === null)
122
178
  return false;
123
179
 
124
- return ['waiting payment', 'outdated billing']
125
- .includes(this.payment.status);
180
+ return this.payment.invoiceRealStatus === 'pending';
126
181
  },
127
-
128
182
  billetMustBeCreated() {
129
183
  if (this.payment === null)
130
184
  return false;
131
185
 
132
- return this.payment.paymentType == 'choose_pending';
186
+ return this.payment.paymentType === 'choose_pending' || this.payment.paymentStatus !== 'paid';
133
187
  },
134
188
  },
135
189
 
136
190
  watch: {
137
191
  myCompany(company) {
138
192
  if (company !== null) {
139
- this.getPaymentStatus();
193
+ this.$router.push("/finance/receive");
140
194
  }
141
195
  },
142
196
 
@@ -144,28 +198,57 @@ export default {
144
198
  if (!data)
145
199
  return;
146
200
 
147
- if (data.paymentType == 'choose_pending' || data.paymentStatus == 'no_finished') {
148
- this.isPaid = false;
149
- this.getItauHash();
201
+ this.isPaid = data.paymentStatus === 'paid';
202
+
203
+ if(this.payment.paymentStatus === 'open')
204
+ {
205
+ this.showInfoBox = true;
150
206
  }
151
- else {
152
- if (data.paymentType == 'billet') {
153
- if (data.paymentStatus == 'paid')
154
- this.isPaid = true;
155
- else {
156
- this.isPaid = false;
157
207
 
158
- if (data.paymentStatus == 'created')
159
- this.getItauHash()
160
- .then(hash => {
161
- if (hash !== null)
162
- this.showBillet = true;
163
- });
164
- else
165
- this.showBillet = false;
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
+
166
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
+ }
167
240
  }
241
+
168
242
  }
243
+
244
+ this.$emit(
245
+ 'billetStatus',
246
+ {
247
+ hasBillet: data.paymentType === 'billet' && data.paymentStatus === 'created',
248
+ isPaid: data.paymentStatus === 'paid'
249
+ }
250
+ );
251
+
169
252
  },
170
253
 
171
254
  showBillet(show) {
@@ -177,73 +260,198 @@ export default {
177
260
 
178
261
  methods: {
179
262
  ...mapActions({
180
- getItauData: 'payInvoice/bankItau',
263
+ getItauData: 'receiveInvoice/bankItau',
264
+ getInterData: 'receiveInvoice/bankInter',
265
+ getSicredData: 'receiveInvoice/bankSicred',
266
+ getBankPerInvoiceId: 'receiveInvoice/getBankPerInvoiceId',
181
267
  }),
182
268
 
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);
294
+
295
+ console.log(url);
296
+
297
+ return url;
298
+ });
299
+ },
300
+
301
+ clickDownloadBilletSicred() {
302
+ let urlTmp = ENTRYPOINT + `/download?invoiceUrl=${this.payment.invoiceUrl}`;
303
+ window.open(urlTmp);
304
+ },
305
+
306
+ 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
+ },
323
+
183
324
  loadItauDataOnFocus() {
184
325
  if (this.loadOnFocus) {
185
- this.getPaymentStatus()
186
- .then(data => {
187
- this.loadOnFocus = false;
188
- });
326
+ this.getPaymentStatus().then(data => {
327
+ this.loadOnFocus = false;
328
+ });
189
329
  }
190
330
  },
191
331
 
192
332
  getItauHash() {
193
333
  let params = {};
194
334
 
195
- this.isLoading = true;
196
-
197
335
  if (this.myCompany !== null)
198
336
  params['myCompany'] = this.myCompany.id;
199
337
 
200
338
  return this.getItauData({
201
339
  invoiceId: this.invoiceId,
202
340
  operation: 'itauhash',
203
- params : params
204
- })
205
- .then(data => {
206
- if (data !== null) {
207
- return this.itauHash = data;
208
- }
341
+ params: params
342
+ }).then(data => {
343
+ if (data !== null) {
344
+ return this.itauHash = data;
345
+ }
346
+ return null;
347
+ }).catch(error => {
209
348
 
210
- return null;
211
- })
212
- .catch(error => {
213
-
214
- })
215
- .finally(() => {
216
- this.isLoading = false;
217
- });
349
+ });
218
350
  },
219
351
 
220
352
  getPaymentStatus() {
353
+
354
+ if (this.isLoading) {
355
+ return null;
356
+ }
357
+
221
358
  let params = {};
222
359
 
223
360
  this.isLoading = true;
224
361
 
225
- if (this.myCompany !== null)
362
+ if (this.myCompany !== null) {
226
363
  params['myCompany'] = this.myCompany.id;
364
+ }
227
365
 
228
- return this.getItauData({
229
- invoiceId: this.invoiceId,
230
- operation: 'payment',
231
- params : params
232
- })
233
- .then(data => {
234
- if (data !== null) {
235
- return this.payment = data;
236
- }
366
+ return this.getBank().then(data2 => {
237
367
 
238
- return null;
239
- })
240
- .catch(error => {
241
-
242
- })
243
- .finally(() => {
244
- this.isLoading = false;
245
- });
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
+
451
+ }
452
+
453
+ });
246
454
  },
247
455
  },
248
456
  };
249
- </script>
457
+ </script>
@@ -34,31 +34,59 @@
34
34
  <td class="text-left text-bold">Número da fatura</td>
35
35
  <td class="text-left">
36
36
  {{
37
- `#${this.invoice["@id"].match(
38
- /^\/finance\/receive\/([a-z0-9-]*)$/
39
- )[1]
40
- }`
37
+ `#${this.invoice["@id"].match(
38
+ /^\/finance\/receive\/([a-z0-9-]*)$/
39
+ )[1]
40
+ }`
41
41
  }}
42
42
 
43
43
  <q-btn flat round dense color="positive" icon="autorenew" @click="confirm = true" />
44
44
  </td>
45
45
  </tr>
46
+
47
+ <tr>
48
+ <td class="text-left text-bold">Vencimento</td>
49
+ <td class="text-left">
50
+ <EditInvoiceDuedate v-if="editDueDate" :dueDate="invoice.dueDate"
51
+ :invoiceId="invoice['@id'] || ''" @saved="(data) => (invoice = data)" />
52
+ <div v-else>
53
+ {{ invoice.dueDate }}
54
+ </div>
55
+ </td>
56
+ </tr>
57
+
46
58
  <tr>
47
59
  <td class="text-left text-bold">Valor da fatura</td>
48
60
  <td class="text-left">
49
61
  {{ formatMoney(this.invoice.price) }}
50
62
  </td>
51
63
  </tr>
64
+
52
65
  <tr>
53
- <td class="text-left text-bold">Vencimento</td>
66
+ <td class="text-left text-bold">Desconto</td>
54
67
  <td class="text-left">
55
- <EditInvoiceDuedate v-if="editDueDate" :dueDate="invoice.dueDate"
56
- :invoiceId="invoice['@id'] || ''" @saved="(data) => (invoice = data)" />
68
+
69
+ <EditInvoiceDiscount v-if="discount" :discount="discount" :invoiceId="invoice['@id'] || ''"
70
+ @saved="requestInvoice(invoiceId)" />
71
+
57
72
  <div v-else>
58
- {{ invoice.dueDate }}
73
+ <EditInvoiceDiscount :discount="discount" :invoiceId="invoice['@id'] || ''"
74
+ @saved="requestInvoice(invoiceId)" />
59
75
  </div>
76
+
60
77
  </td>
61
78
  </tr>
79
+
80
+ <tr>
81
+ <td class="text-left text-bold">Total a Pagar</td>
82
+ <td class="text-left" v-if="discount">
83
+ {{ formatMoney(this.invoice.realPrice) }}
84
+ </td>
85
+ <td class="text-left" v-else>
86
+ {{ formatMoney(this.invoice.price) }}
87
+ </td>
88
+ </tr>
89
+
62
90
  </tbody>
63
91
  </q-markup-table>
64
92
  </div>
@@ -74,12 +102,11 @@
74
102
  <div class="col-xs-12 text-h6 text-center">
75
103
  {{ $t(`invoice.statuses.${invoice.status.status}`) }}
76
104
  </div>
77
- <InvoiceActions :invoice="invoice" @changed="
78
- (newInvoice) => {
79
- this.invoice = newInvoice;
80
- this.$refs.invoiceBillet.refresh();
81
- }
82
- " />
105
+ <InvoiceActions :invoice="invoice" @changed="(newInvoice) => {
106
+ this.invoice = newInvoice;
107
+ this.$refs.invoiceBillet.refresh();
108
+ }
109
+ " />
83
110
  </div>
84
111
  </div>
85
112
  </div>
@@ -95,18 +122,17 @@
95
122
 
96
123
  <q-tab-panels v-model="currentTab">
97
124
  <q-tab-panel name="invoice" class="q-pa-none">
98
- <InvoiceInvoice ref="invoiceBillet" :invoiceId="invoiceId" :orderId="orderId" @billetStatus="
99
- (status) => {
100
- this.editDueDate = status.hasBillet === false;
101
- }
102
- " />
125
+ <InvoiceInvoice ref="invoiceBillet" :invoiceId="invoiceId" :orderId="orderId" @billetStatus="(status) => {
126
+ this.editDueDate = status.hasBillet === false;
127
+ }
128
+ " />
103
129
  </q-tab-panel>
104
130
 
105
131
  <q-tab-panel name="orders" class="q-pa-none">
106
132
  <InvoiceOrders :invoiceId="invoiceId" :invoice="{
107
133
  '@id': invoice ? invoice['@id'] : null,
108
134
  status: invoice ? invoice.status.realStatus : null,
109
- billet: editDueDate ? false : true,
135
+ billet: editDueDate = true,
110
136
  }" />
111
137
  </q-tab-panel>
112
138
  </q-tab-panels>
@@ -136,6 +162,8 @@ import {
136
162
  import EditInvoiceDuedate from "@freteclick/quasar-common-ui/src/components/common/EditInvoiceDuedate.vue";
137
163
  import InvoiceActions from "@freteclick/quasar-common-ui/src/components/common/InvoiceActions.vue";
138
164
  import InvoiceEditActions from "@freteclick/quasar-common-ui/src/components/common/InvoiceEditActions.vue";
165
+ import EditInvoiceDiscount from "@freteclick/quasar-common-ui/src/components/common/EditInvoiceDiscount.vue";
166
+
139
167
 
140
168
  export default {
141
169
  components: {
@@ -144,6 +172,7 @@ export default {
144
172
  EditInvoiceDuedate,
145
173
  InvoiceActions,
146
174
  InvoiceEditActions,
175
+ EditInvoiceDiscount,
147
176
  },
148
177
 
149
178
  created() {
@@ -152,6 +181,7 @@ export default {
152
181
 
153
182
  if (this.myCompany !== null && this.invoiceId !== null) {
154
183
  this.requestInvoice(this.invoiceId);
184
+ // this.requestInvoiceDiscount(this.invoiceId);
155
185
  }
156
186
  },
157
187
 
@@ -162,6 +192,7 @@ export default {
162
192
  invoiceId: null,
163
193
  orderId: null,
164
194
  invoice: null,
195
+ discount: null,
165
196
  isLoading: false,
166
197
  editDueDate: false,
167
198
  notFound: false,
@@ -184,12 +215,14 @@ export default {
184
215
  myCompany(company) {
185
216
  if (company !== null) {
186
217
  this.requestInvoice(this.invoiceId);
218
+ // this.requestInvoiceDiscount(this.invoiceId);
187
219
  }
188
220
  },
189
221
  },
190
222
 
191
223
  methods: {
192
224
  ...mapActions({
225
+ getInvoiceDiscount: "receiveInvoice/getInvoiceDiscount",
193
226
  getInvoice: "receiveInvoice/getInvoice",
194
227
  renewInvoice: "receiveInvoice/renewInvoice",
195
228
  }),
@@ -226,6 +259,7 @@ export default {
226
259
  this.notFound = true;
227
260
  });
228
261
  },
262
+
229
263
  requestInvoice(invoiceId) {
230
264
  if (this.isLoading) return;
231
265
 
@@ -239,6 +273,8 @@ export default {
239
273
  .then((data) => {
240
274
  this.isLoading = false;
241
275
 
276
+ this.requestInvoiceDiscount(invoiceId);
277
+
242
278
  if (data["@id"]) {
243
279
  this.invoice = data;
244
280
  this.notFound = false;
@@ -276,6 +312,29 @@ export default {
276
312
  this.notFound = true;
277
313
  });
278
314
  },
315
+
316
+ // consulta descontos para esta fatura
317
+ requestInvoiceDiscount(invoiceId) {
318
+ // if (this.isLoading) return;
319
+
320
+ this.isLoading = true;
321
+
322
+ this.getInvoiceDiscount({ invoiceId })
323
+ .then((data) => {
324
+
325
+ this.isLoading = false;
326
+
327
+ if (data["hydra:member"]) {
328
+ this.discount = data["hydra:member"][0];
329
+ }
330
+
331
+ })
332
+ .catch((error) => {
333
+ this.isLoading = false;
334
+ this.discount = null;
335
+ })
336
+ },
337
+
279
338
  },
280
339
  };
281
- </script>
340
+ </script>
@@ -206,8 +206,8 @@ export default {
206
206
  data: [],
207
207
  filters: {
208
208
  orderType: {
209
- label: "Todos",
210
- value: null,
209
+ label: "Venda",
210
+ value: "sale",
211
211
  },
212
212
  date: {
213
213
  from: "",
@@ -1,16 +1,49 @@
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 :indeterminate="isLoading"
5
- size="sm"
6
- color="primary"
7
- class="q-ma-md"
4
+ <q-circular-progress
5
+ :indeterminate="isLoading"
6
+ size="sm"
7
+ color="primary"
8
+ class="q-ma-md"
8
9
  />
9
10
  Carregando...
10
11
  </div>
11
12
 
12
- <!-- BILLET VIEWER INTER -->
13
+ <div :class="showInfoBox ? 'full-width q-pa-lg' : 'hidden'">
14
+ <div class="q-pa-md q-gutter-sm">
15
+ <q-banner inline-actions rounded class="bg-primary text-white text-center">
16
+ <h6>Este boleto não pode ser gerado agora, pois a fatura está em aberto.</h6>
17
+ </q-banner>
18
+ </div>
19
+ </div>
20
+
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>
13
45
 
46
+ <!-- BILLET VIEWER INTER -->
14
47
  <div :class="showBilletInter ? 'full-width q-pa-lg' : 'hidden'">
15
48
  <div style="height: 1200px">
16
49
  <iframe
@@ -22,7 +55,6 @@
22
55
  </div>
23
56
 
24
57
  <!-- BILLET VIEWER ITAU -->
25
-
26
58
  <div :class="showBillet ? 'full-width q-pa-lg' : 'hidden'">
27
59
  <q-form
28
60
  ref="myForm"
@@ -33,7 +65,6 @@
33
65
  >
34
66
  <input type="hidden" name="DC" :value="itauHash"/>
35
67
  </q-form>
36
-
37
68
  <div style="height: 1200px">
38
69
  <iframe name="BILLET" width="100%" height="100%" frameBorder="0">
39
70
  <p>This browser does not support IFrame.</p>
@@ -42,7 +73,6 @@
42
73
  </div>
43
74
 
44
75
  <!-- BILLET GENERATOR TRIGGER -->
45
-
46
76
  <div class="col-12 q-pt-lg" v-if="paymentIsPending && billetMustBeCreated && paymentInstitution === 'itau'">
47
77
  <div style="min-height: 80vh;" class="row justify-center items-center">
48
78
  <q-btn
@@ -75,22 +105,7 @@
75
105
  </div>
76
106
  </div>
77
107
 
78
- <div class="col-12 q-pt-lg" v-if="paymentIsPending && paymentInstitution === 'inter'">
79
- <div style="min-height: 80vh;" class="row justify-center items-center">
80
- <q-btn
81
- icon="money"
82
- size="lg"
83
- color="primary"
84
- label="Abrir Boleto"
85
- :loading="isLoadingDownload"
86
- @click="clickDownloadBilletInter()"
87
- :disable="isPaid"
88
- />
89
- </div>
90
- </div>
91
-
92
108
  <!-- PAID MESSAGE -->
93
-
94
109
  <div class="col-12" v-if="payment !== null && isPaid">
95
110
  <div class="row items-center justify-center" style="min-height: 90vh;">
96
111
  <q-banner class="text-white bg-positive text-center text-h3" rounded>
@@ -107,7 +122,7 @@
107
122
  <script>
108
123
  import {mapActions, mapGetters} from 'vuex';
109
124
  import axios from 'axios';
110
- import {ENTRYPOINT} from '@app/src/config/entrypoint';
125
+ import {ENTRYPOINT} from '../../../../../../../../src/config/entrypoint';
111
126
 
112
127
  export default {
113
128
  props: {
@@ -121,6 +136,8 @@ export default {
121
136
  },
122
137
  },
123
138
 
139
+ components: {},
140
+
124
141
  mounted() {
125
142
  window.addEventListener('focus', this.loadItauDataOnFocus);
126
143
  },
@@ -136,7 +153,10 @@ export default {
136
153
  data() {
137
154
  return {
138
155
  invoiceUrlInter: null,
156
+ invoiceUrlSicred: null,
139
157
  showBilletInter: null,
158
+ showBilletSicred: null,
159
+ showInfoBox: null,
140
160
  isLoadingDownload: false,
141
161
  isLoading: false,
142
162
  payment: null,
@@ -145,7 +165,7 @@ export default {
145
165
  showBillet: false,
146
166
  loadOnFocus: false,
147
167
  retrievingHash: false,
148
- paymentInstitution: null // 'itau','inter'
168
+ paymentInstitution: null
149
169
  };
150
170
  },
151
171
 
@@ -180,9 +200,16 @@ export default {
180
200
 
181
201
  this.isPaid = data.paymentStatus === 'paid';
182
202
 
203
+ if(this.payment.paymentStatus === 'open')
204
+ {
205
+ this.showInfoBox = true;
206
+ }
207
+
183
208
  if (data.paymentType == 'billet') {
184
209
 
185
- if (data.paymentStatus == 'created' && this.isPaid === false) {
210
+ if (data.paymentStatus !== 'open') {
211
+
212
+ this.showInfoBox = false;
186
213
 
187
214
  if (this.paymentInstitution === 'itau') {
188
215
  this.getItauHash().then(hash => {
@@ -191,7 +218,7 @@ export default {
191
218
  }
192
219
  });
193
220
 
194
- } else { // -------------------------------------- Banco Inter
221
+ } else if(this.paymentInstitution === 'inter') {
195
222
 
196
223
  this.showBillet = false;
197
224
  let urlTmp = ENTRYPOINT + `/vendor/pdf.js/web/viewer.html?file=/finance/${this.invoiceId}/download?timestamp${new Date().getTime()}`;
@@ -200,11 +227,16 @@ export default {
200
227
  this.showBilletInter = true;
201
228
 
202
229
  }
203
- } else {
204
- this.showBillet = false;
205
- if (this.paymentInstitution === 'inter') {
206
- this.isPaid = data.status === 'paid';
207
- }
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
+ }
208
240
  }
209
241
 
210
242
  }
@@ -230,6 +262,7 @@ export default {
230
262
  ...mapActions({
231
263
  getItauData: 'receiveInvoice/bankItau',
232
264
  getInterData: 'receiveInvoice/bankInter',
265
+ getSicredData: 'receiveInvoice/bankSicred',
233
266
  getBankPerInvoiceId: 'receiveInvoice/getBankPerInvoiceId',
234
267
  }),
235
268
 
@@ -250,6 +283,26 @@ export default {
250
283
  window.open(urlTmp);
251
284
  },
252
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);
294
+
295
+ console.log(url);
296
+
297
+ return url;
298
+ });
299
+ },
300
+
301
+ clickDownloadBilletSicred() {
302
+ let urlTmp = ENTRYPOINT + `/download?invoiceUrl=${this.payment.invoiceUrl}`;
303
+ window.open(urlTmp);
304
+ },
305
+
253
306
  getBank() {
254
307
  return this.getBankPerInvoiceId({
255
308
  invoiceId: this.invoiceId
@@ -312,7 +365,7 @@ export default {
312
365
 
313
366
  return this.getBank().then(data2 => {
314
367
 
315
- if (this.paymentInstitution === 'itau') { // ------------------------------ Banco 'itau'
368
+ if (this.paymentInstitution === 'itau') {
316
369
 
317
370
  this.getItauData({
318
371
  invoiceId: this.invoiceId,
@@ -330,7 +383,7 @@ export default {
330
383
  // this.isLoading = false;
331
384
  });
332
385
 
333
- } else { // ------------------------------ Banco 'inter'
386
+ } else if(this.paymentInstitution === 'inter'){
334
387
 
335
388
  this.getInterData({
336
389
  invoiceId: this.invoiceId,
@@ -363,6 +416,39 @@ export default {
363
416
  });
364
417
 
365
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
+
451
+ }
366
452
 
367
453
  });
368
454
  },
@@ -2,29 +2,29 @@
2
2
  export const routes = [
3
3
  {
4
4
  path : '/finance/',
5
- component: () => import('@app/src/layouts/AdminLayout.vue'),
5
+ component: () => import('../../../../../src/layouts/AdminLayout.vue'),
6
6
  children : [
7
7
  { name: 'ClientInvoiceIndex', path: 'client', component: () => import('../pages/Invoice/Client/Index.vue') },
8
8
  { name: 'ClientInvoiceDetails', path: 'client/id/:id', component: () => import('../pages/Invoice/Client/Details.vue') },
9
-
10
- {
11
- name: 'FinancePayIndex',
12
- path: 'pay',
9
+
10
+ {
11
+ name: 'FinancePayIndex',
12
+ path: 'pay',
13
13
  component: () => import('../pages/Invoice/Pay/Index.vue')
14
14
  },
15
- {
16
- name: 'PayDetails',
17
- path: 'pay/id/:id',
18
- component: () => import('../pages/Invoice/Pay/Details.vue')
15
+ {
16
+ name: 'PayDetails',
17
+ path: 'pay/id/:id',
18
+ component: () => import('../pages/Invoice/Pay/Details.vue')
19
19
  },
20
- {
21
- name: 'FinanceReceiveIndex',
22
- path: 'receive',
20
+ {
21
+ name: 'FinanceReceiveIndex',
22
+ path: 'receive',
23
23
  component: () => import('../pages/Invoice/Receive/Index.vue')
24
24
  },
25
- {
26
- name: 'ReceiveDetails',
27
- path: 'receive/id/:id',
25
+ {
26
+ name: 'ReceiveDetails',
27
+ path: 'receive/id/:id',
28
28
  component: () => import('../pages/Invoice/Receive/Details.vue')
29
29
  },
30
30
  ]
@@ -1,5 +1,5 @@
1
1
  import SubmissionError from '@freteclick/quasar-common-ui/src/error/SubmissionError';
2
- import { fetch } from '@app/src/boot/myapi';
2
+ import { fetch } from '../../../../../../../../src/boot/myapi';
3
3
  import * as types from './mutation_types';
4
4
 
5
5
  const RESOURCE_ENDPOINT = '/finance/comission';
@@ -1,5 +1,5 @@
1
1
  import SubmissionError from '@freteclick/quasar-common-ui/src/error/SubmissionError';
2
- import { fetch } from '@app/src/boot/myapi';
2
+ import { fetch } from '../../../../../../../../src/boot/myapi';
3
3
 
4
4
 
5
5
 
@@ -1,5 +1,5 @@
1
1
  import SubmissionError from '@freteclick/quasar-common-ui/src/error/SubmissionError';
2
- import { fetch } from '@app/src/boot/myapi';
2
+ import { fetch } from '../../../../../../../../src/boot/myapi';
3
3
  import * as types from './mutation_types';
4
4
 
5
5
  const RESOURCE_ENDPOINT = '/finance/pay';
@@ -1,5 +1,5 @@
1
1
  import SubmissionError from '@freteclick/quasar-common-ui/src/error/SubmissionError';
2
- import { fetch } from '@app/src/boot/myapi';
2
+ import { fetch } from '../../../../../../../../src/boot/myapi';
3
3
  import * as types from './mutation_types';
4
4
 
5
5
  const RESOURCE_ENDPOINT = '/finance/receive';
@@ -63,6 +63,13 @@ export const getInvoice = ({ commit }, { invoiceId, params }) => {
63
63
  });
64
64
  };
65
65
 
66
+ export const getInvoiceDiscount = ({ commit }, { invoiceId, params }) => {
67
+ return fetch(`/discounts?type=invoice&invoiceId=${invoiceId}`)
68
+ .then(response => response.json())
69
+ .then(data => {
70
+ return data;
71
+ });
72
+ };
66
73
 
67
74
  export const renewInvoice = ({ commit }, { invoiceId, params }) => {
68
75
 
@@ -104,6 +111,17 @@ export const bankInter = ({ commit }, { invoiceId, operation, params = {} }) =>
104
111
  });
105
112
  };
106
113
 
114
+ export const bankSicred = ({ commit }, { invoiceId, operation, params = {} }) => {
115
+ return fetch(`/finance/receive/${invoiceId}/bank/sicred/${operation}`, { params })
116
+ .then(response => response.json())
117
+ .then(data => {
118
+ if (data.response) {
119
+ return data;
120
+ }
121
+ return null;
122
+ });
123
+ };
124
+
107
125
  export const getBankPerInvoiceId = ({ commit }, { invoiceId, params = {} }) => {
108
126
  return fetch(`/finance/receive/${invoiceId}/bank`, { params })
109
127
  .then(response => response.json())
@@ -132,6 +150,23 @@ export const updateInvoiceDuedate = ({ commit }, { id, dueDate, params }) => {
132
150
  });
133
151
  };
134
152
 
153
+ export const updateInvoiceDuedateApiSicred = ({commit}, {id, dueDate, params}) => {
154
+ let options = {
155
+ method: 'PUT',
156
+ body: JSON.stringify({ dueDate }),
157
+ params: params
158
+ };
159
+
160
+ return fetch(`${id}`, options)
161
+ .then(response => response.json())
162
+ .then(invoice => {
163
+ if (invoice['@id'])
164
+ return invoice;
165
+
166
+ return null;
167
+ });
168
+ }
169
+
135
170
  export const deleteInvoiceOrder = ({ commit }, { invoiceId, orderId, params }) => {
136
171
  let options = {
137
172
  method: 'PUT',
@@ -1,5 +1,5 @@
1
1
  import SubmissionError from '@freteclick/quasar-common-ui/src/error/SubmissionError';
2
- import { fetch } from '@app/src/boot/myapi';
2
+ import { fetch } from '../../../../../../../../src/boot/myapi';
3
3
  import * as types from './mutation_types';
4
4
 
5
5
  const RESOURCE_ENDPOINT = '/finance/receive';