@freteclick/quasar-financial-ui 1.0.92 → 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.92",
3
+ "version": "1.0.94",
4
4
  "author": "FreteClick",
5
5
  "description": "FreteClick financial Quasar UI Component",
6
6
  "license": "MIT",
@@ -34,21 +34,16 @@
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
- <tr>
47
- <td class="text-left text-bold">Valor da fatura</td>
48
- <td class="text-left">
49
- {{ formatMoney(this.invoice.price) }}
50
- </td>
51
- </tr>
46
+
52
47
  <tr>
53
48
  <td class="text-left text-bold">Vencimento</td>
54
49
  <td class="text-left">
@@ -59,6 +54,31 @@
59
54
  </div>
60
55
  </td>
61
56
  </tr>
57
+
58
+ <tr>
59
+ <td class="text-left text-bold">Valor da fatura</td>
60
+ <td class="text-left">
61
+ {{ formatMoney(this.invoice.price) }}
62
+ </td>
63
+ </tr>
64
+
65
+ <tr>
66
+ <td class="text-left text-bold">Desconto</td>
67
+ <td class="text-left">
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) }}
79
+ </td>
80
+ </tr>
81
+
62
82
  </tbody>
63
83
  </q-markup-table>
64
84
  </div>
@@ -74,12 +94,11 @@
74
94
  <div class="col-xs-12 text-h6 text-center">
75
95
  {{ $t(`invoice.statuses.${invoice.status.status}`) }}
76
96
  </div>
77
- <InvoiceActions :invoice="invoice" @changed="
78
- (newInvoice) => {
79
- this.invoice = newInvoice;
80
- this.$refs.invoiceBillet.refresh();
81
- }
82
- " />
97
+ <InvoiceActions :invoice="invoice" @changed="(newInvoice) => {
98
+ this.invoice = newInvoice;
99
+ this.$refs.invoiceBillet.refresh();
100
+ }
101
+ " />
83
102
  </div>
84
103
  </div>
85
104
  </div>
@@ -95,18 +114,17 @@
95
114
 
96
115
  <q-tab-panels v-model="currentTab">
97
116
  <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
- " />
117
+ <InvoiceInvoice ref="invoiceBillet" :invoiceId="invoiceId" :orderId="orderId" @billetStatus="(status) => {
118
+ this.editDueDate = status.hasBillet === false;
119
+ }
120
+ " />
103
121
  </q-tab-panel>
104
122
 
105
123
  <q-tab-panel name="orders" class="q-pa-none">
106
124
  <InvoiceOrders :invoiceId="invoiceId" :invoice="{
107
125
  '@id': invoice ? invoice['@id'] : null,
108
126
  status: invoice ? invoice.status.realStatus : null,
109
- billet: editDueDate ? false : true,
127
+ billet: editDueDate = true,
110
128
  }" />
111
129
  </q-tab-panel>
112
130
  </q-tab-panels>
@@ -136,6 +154,8 @@ import {
136
154
  import EditInvoiceDuedate from "@freteclick/quasar-common-ui/src/components/common/EditInvoiceDuedate.vue";
137
155
  import InvoiceActions from "@freteclick/quasar-common-ui/src/components/common/InvoiceActions.vue";
138
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
+
139
159
 
140
160
  export default {
141
161
  components: {
@@ -144,6 +164,7 @@ export default {
144
164
  EditInvoiceDuedate,
145
165
  InvoiceActions,
146
166
  InvoiceEditActions,
167
+ EditInvoiceDiscount,
147
168
  },
148
169
 
149
170
  created() {
@@ -152,6 +173,7 @@ export default {
152
173
 
153
174
  if (this.myCompany !== null && this.invoiceId !== null) {
154
175
  this.requestInvoice(this.invoiceId);
176
+ this.requestInvoiceDiscount(this.invoiceId);
155
177
  }
156
178
  },
157
179
 
@@ -162,6 +184,7 @@ export default {
162
184
  invoiceId: null,
163
185
  orderId: null,
164
186
  invoice: null,
187
+ discount: null,
165
188
  isLoading: false,
166
189
  editDueDate: false,
167
190
  notFound: false,
@@ -184,6 +207,7 @@ export default {
184
207
  myCompany(company) {
185
208
  if (company !== null) {
186
209
  this.requestInvoice(this.invoiceId);
210
+ this.requestInvoiceDiscount(this.invoiceId);
187
211
  }
188
212
  },
189
213
  },
@@ -191,6 +215,7 @@ export default {
191
215
  methods: {
192
216
  ...mapActions({
193
217
  getInvoice: "receiveInvoice/getInvoice",
218
+ getInvoiceDiscount: "receiveInvoice/getInvoiceDiscount",
194
219
  renewInvoice: "receiveInvoice/renewInvoice",
195
220
  }),
196
221
 
@@ -226,6 +251,27 @@ export default {
226
251
  this.notFound = true;
227
252
  });
228
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
+
229
275
  requestInvoice(invoiceId) {
230
276
  if (this.isLoading) return;
231
277
 
@@ -278,4 +324,4 @@ export default {
278
324
  },
279
325
  },
280
326
  };
281
- </script>
327
+ </script>
@@ -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',