@freteclick/quasar-financial-ui 1.0.93 → 1.0.94

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.93",
3
+ "version": "1.0.94",
4
4
  "author": "FreteClick",
5
5
  "description": "FreteClick financial Quasar UI Component",
6
6
  "license": "MIT",
@@ -34,34 +34,51 @@
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"
56
- :dueDate="invoice.dueDate"
57
- :invoiceId="invoice['@id'] || ''"
58
- @saved="(data) => (invoice = data)"
59
- />
60
- <div v-else>
61
- {{ invoice.dueDate }}
62
- </div>
68
+
69
+ <EditInvoiceDiscount :discount="discount" :invoiceId="invoice['@id'] || ''"
70
+ @saved="(data) => (discount = data)" />
71
+
72
+ </td>
73
+ </tr>
74
+
75
+ <tr>
76
+ <td class="text-left text-bold">Total a Pagar</td>
77
+ <td class="text-left">
78
+ {{ formatMoney(this.invoice.price) }}
63
79
  </td>
64
80
  </tr>
81
+
65
82
  </tbody>
66
83
  </q-markup-table>
67
84
  </div>
@@ -77,12 +94,11 @@
77
94
  <div class="col-xs-12 text-h6 text-center">
78
95
  {{ $t(`invoice.statuses.${invoice.status.status}`) }}
79
96
  </div>
80
- <InvoiceActions :invoice="invoice" @changed="
81
- (newInvoice) => {
82
- this.invoice = newInvoice;
83
- this.$refs.invoiceBillet.refresh();
84
- }
85
- " />
97
+ <InvoiceActions :invoice="invoice" @changed="(newInvoice) => {
98
+ this.invoice = newInvoice;
99
+ this.$refs.invoiceBillet.refresh();
100
+ }
101
+ " />
86
102
  </div>
87
103
  </div>
88
104
  </div>
@@ -98,11 +114,10 @@
98
114
 
99
115
  <q-tab-panels v-model="currentTab">
100
116
  <q-tab-panel name="invoice" class="q-pa-none">
101
- <InvoiceInvoice ref="invoiceBillet" :invoiceId="invoiceId" :orderId="orderId" @billetStatus="
102
- (status) => {
103
- this.editDueDate = status.hasBillet === false;
104
- }
105
- " />
117
+ <InvoiceInvoice ref="invoiceBillet" :invoiceId="invoiceId" :orderId="orderId" @billetStatus="(status) => {
118
+ this.editDueDate = status.hasBillet === false;
119
+ }
120
+ " />
106
121
  </q-tab-panel>
107
122
 
108
123
  <q-tab-panel name="orders" class="q-pa-none">
@@ -139,6 +154,8 @@ import {
139
154
  import EditInvoiceDuedate from "@freteclick/quasar-common-ui/src/components/common/EditInvoiceDuedate.vue";
140
155
  import InvoiceActions from "@freteclick/quasar-common-ui/src/components/common/InvoiceActions.vue";
141
156
  import InvoiceEditActions from "@freteclick/quasar-common-ui/src/components/common/InvoiceEditActions.vue";
157
+ import EditInvoiceDiscount from "@freteclick/quasar-common-ui/src/components/common/EditInvoiceDiscount.vue";
158
+
142
159
 
143
160
  export default {
144
161
  components: {
@@ -147,6 +164,7 @@ export default {
147
164
  EditInvoiceDuedate,
148
165
  InvoiceActions,
149
166
  InvoiceEditActions,
167
+ EditInvoiceDiscount,
150
168
  },
151
169
 
152
170
  created() {
@@ -155,6 +173,7 @@ export default {
155
173
 
156
174
  if (this.myCompany !== null && this.invoiceId !== null) {
157
175
  this.requestInvoice(this.invoiceId);
176
+ this.requestInvoiceDiscount(this.invoiceId);
158
177
  }
159
178
  },
160
179
 
@@ -165,6 +184,7 @@ export default {
165
184
  invoiceId: null,
166
185
  orderId: null,
167
186
  invoice: null,
187
+ discount: null,
168
188
  isLoading: false,
169
189
  editDueDate: false,
170
190
  notFound: false,
@@ -187,6 +207,7 @@ export default {
187
207
  myCompany(company) {
188
208
  if (company !== null) {
189
209
  this.requestInvoice(this.invoiceId);
210
+ this.requestInvoiceDiscount(this.invoiceId);
190
211
  }
191
212
  },
192
213
  },
@@ -194,6 +215,7 @@ export default {
194
215
  methods: {
195
216
  ...mapActions({
196
217
  getInvoice: "receiveInvoice/getInvoice",
218
+ getInvoiceDiscount: "receiveInvoice/getInvoiceDiscount",
197
219
  renewInvoice: "receiveInvoice/renewInvoice",
198
220
  }),
199
221
 
@@ -229,6 +251,27 @@ export default {
229
251
  this.notFound = true;
230
252
  });
231
253
  },
254
+
255
+
256
+ async requestInvoiceDiscount(invoiceId) {
257
+ try {
258
+ this.isLoading = true;
259
+
260
+ const data = await this.getInvoiceDiscount({ invoiceId });
261
+
262
+ this.isLoading = false;
263
+
264
+ if (data["hydra:member"]) {
265
+ this.discount = data["hydra:member"][0];
266
+ }
267
+ } catch (error) {
268
+ this.isLoading = false;
269
+ this.discount = null;
270
+ }
271
+ },
272
+
273
+
274
+
232
275
  requestInvoice(invoiceId) {
233
276
  if (this.isLoading) return;
234
277
 
@@ -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
 
@@ -143,6 +150,23 @@ export const updateInvoiceDuedate = ({ commit }, { id, dueDate, params }) => {
143
150
  });
144
151
  };
145
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
+
146
170
  export const deleteInvoiceOrder = ({ commit }, { invoiceId, orderId, params }) => {
147
171
  let options = {
148
172
  method: 'PUT',