@freteclick/quasar-financial-ui 1.0.85 → 1.0.87
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 +17 -17
- package/src/components/common/Filters.vue +140 -140
- package/src/components/expense/FormExpense.vue +309 -309
- package/src/components/expense/TableExpenses.vue +305 -305
- package/src/components/invoice/client/ClientInvoiceDetails.vue +212 -212
- package/src/components/invoice/client/InvoiceSearching.vue +382 -382
- package/src/components/invoice/client/details/InvoiceInvoice.vue +248 -248
- package/src/components/invoice/client/details/InvoiceOrders.vue +327 -327
- package/src/components/invoice/expense/CreateExpense.vue +539 -539
- package/src/components/invoice/expense/DetailExpense.vue +393 -393
- package/src/components/invoice/pay/InvoiceDetails.vue +210 -210
- package/src/components/invoice/pay/InvoiceSearching.vue +388 -388
- package/src/components/invoice/pay/details/InvoiceInvoice.vue +47 -47
- package/src/components/invoice/pay/details/InvoiceOrders.vue +342 -342
- package/src/components/invoice/receive/InvoiceDetails.vue +280 -280
- package/src/components/invoice/receive/InvoiceSearching.vue +359 -359
- package/src/components/invoice/receive/details/InvoiceInvoice.vue +453 -371
- package/src/components/invoice/receive/details/InvoiceInvoiceBkp.vue +259 -259
- package/src/components/invoice/receive/details/InvoiceOrders.vue +369 -369
- package/src/i18n/en-us/index.js +8 -8
- package/src/i18n/index.js +5 -5
- package/src/i18n/pt-br/index.js +30 -30
- package/src/pages/Invoice/Client/Details.vue +23 -23
- package/src/pages/Invoice/Client/Index.vue +26 -26
- package/src/pages/Invoice/Pay/Details.vue +23 -23
- package/src/pages/Invoice/Pay/Index.vue +53 -53
- package/src/pages/Invoice/Receive/Details.vue +23 -23
- package/src/pages/Invoice/Receive/Index.vue +26 -26
- package/src/router/routes.js +32 -32
- package/src/store/modules/invoice/comission/actions.js +66 -66
- package/src/store/modules/invoice/comission/getters.js +6 -6
- package/src/store/modules/invoice/comission/index.js +19 -19
- package/src/store/modules/invoice/comission/mutation_types.js +7 -7
- package/src/store/modules/invoice/comission/mutations.js +42 -42
- package/src/store/modules/invoice/expense/actions.js +98 -98
- package/src/store/modules/invoice/expense/getters.js +1 -1
- package/src/store/modules/invoice/expense/index.js +12 -12
- package/src/store/modules/invoice/expense/mutations.js +3 -3
- package/src/store/modules/invoice/expense/state.js +5 -5
- package/src/store/modules/invoice/pay/actions.js +114 -114
- package/src/store/modules/invoice/pay/getters.js +6 -6
- package/src/store/modules/invoice/pay/index.js +19 -19
- package/src/store/modules/invoice/pay/mutation_types.js +7 -7
- package/src/store/modules/invoice/pay/mutations.js +42 -42
- package/src/store/modules/invoice/receive/actions.js +163 -152
- package/src/store/modules/invoice/receive/actionsBkp.js +77 -77
- package/src/store/modules/invoice/receive/getters.js +6 -6
- package/src/store/modules/invoice/receive/index.js +19 -19
- package/src/store/modules/invoice/receive/mutation_types.js +7 -7
- package/src/store/modules/invoice/receive/mutations.js +42 -42
- package/src/store/store-flag.d.ts +9 -9
|
@@ -1,393 +1,393 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<div class="row q-mb-md q-gutter-sm justify-end">
|
|
4
|
-
<q-btn :label="$t('Cancelar despesa')" icon="cancel" color="negative" @click="removeExpense"
|
|
5
|
-
:loading="deleting" />
|
|
6
|
-
</div>
|
|
7
|
-
<q-form @submit="editExpense">
|
|
8
|
-
<div class="row">
|
|
9
|
-
<div class="col-xs-12 q-mb-md">
|
|
10
|
-
<q-select stack-label emit-value map-options lazy-rules v-model="item.category"
|
|
11
|
-
:label="$t('Categoria da despesa')" :options="categories"
|
|
12
|
-
:rules="[(val) => val !== null || 'Selecione uma categoria']" />
|
|
13
|
-
</div>
|
|
14
|
-
<div class="col-xs-12 q-mb-md">
|
|
15
|
-
<q-input lazy-rules stack-label v-model="item.description" type="text" :label="$t('Descrição da despesa')"
|
|
16
|
-
class="q-mt-md" :rules="[isInvalid()]" />
|
|
17
|
-
</div>
|
|
18
|
-
<div class="col-xs-12 q-mb-md">
|
|
19
|
-
<q-select v-if="item.provider" stack-label emit-value map-options lazy-rules v-model="item.provider"
|
|
20
|
-
:label="$t('Fornecedor')" :options="providers"
|
|
21
|
-
:rules="[(val) => val !== null || 'Selecione um fornecedor']" />
|
|
22
|
-
<PeopleAutocomplete v-else :source="searchPeople" option-value="optionValue" :isLoading="isSearching"
|
|
23
|
-
label="Definir o fornecedor" @selected="onSelectClient" placeholder="Pesquisar..." />
|
|
24
|
-
|
|
25
|
-
<q-btn v-if="item.provider" @click="item.provider = null" align="right">
|
|
26
|
-
Alterar
|
|
27
|
-
</q-btn>
|
|
28
|
-
</div>
|
|
29
|
-
<div class="col-xs-12 q-mb-md">
|
|
30
|
-
<q-input lazy-rules stack-label reverse-fill-mask v-model="item.amount" prefix="R$" type="text"
|
|
31
|
-
:label="$t('Valor')" class="q-mt-md" :rules="[isInvalid()]" mask="#,##" fill-mask="0" />
|
|
32
|
-
</div>
|
|
33
|
-
<div class="col-xs-12 q-mb-md">
|
|
34
|
-
<q-input stack-label v-model="item.dueDate" :label="$t('Data primeiro vencimento')" mask="##/##/####"
|
|
35
|
-
class="q-mb-sm" :rules="[isInvalid('date')]">
|
|
36
|
-
<template v-slot:append>
|
|
37
|
-
<q-icon name="event" class="cursor-pointer">
|
|
38
|
-
<q-popup-proxy ref="qDateProxy1" transition-show="scale" transition-hide="scale">
|
|
39
|
-
<q-date v-model="item.dueDate" mask="DD/MM/YYYY" @input="() => $refs.qDateProxy1.hide()" />
|
|
40
|
-
</q-popup-proxy>
|
|
41
|
-
</q-icon>
|
|
42
|
-
</template>
|
|
43
|
-
</q-input>
|
|
44
|
-
</div>
|
|
45
|
-
<div class="col-xs-12 q-mb-md">
|
|
46
|
-
<q-select stack-label emit-value map-options lazy-rules v-model="item.status" :label="$t('Status')"
|
|
47
|
-
:options="statuses" :rules="[(val) => val !== null || 'Selecione um status']" />
|
|
48
|
-
</div>
|
|
49
|
-
</div>
|
|
50
|
-
<div class="row justify-end">
|
|
51
|
-
<q-btn :loading="saving" icon="save" type="submit" :label="$t('Salvar')" size="md" color="primary"
|
|
52
|
-
class="q-mt-md" />
|
|
53
|
-
</div>
|
|
54
|
-
</q-form>
|
|
55
|
-
</div>
|
|
56
|
-
</template>
|
|
57
|
-
|
|
58
|
-
<script>
|
|
59
|
-
import { mapActions, mapGetters } from "vuex";
|
|
60
|
-
import { formatDateYmdTodmY } from "@freteclick/quasar-common-ui/src/utils/formatter";
|
|
61
|
-
|
|
62
|
-
import PeopleAutocomplete from "@freteclick/quasar-common-ui/src/components/common/PeopleAutocomplete";
|
|
63
|
-
|
|
64
|
-
export default {
|
|
65
|
-
components: {
|
|
66
|
-
PeopleAutocomplete,
|
|
67
|
-
},
|
|
68
|
-
props: {
|
|
69
|
-
id: {
|
|
70
|
-
type: String,
|
|
71
|
-
required: true,
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
created() {
|
|
76
|
-
this.loadSelectableOptions();
|
|
77
|
-
this.loadInvoice();
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
data() {
|
|
81
|
-
return {
|
|
82
|
-
isSearching: false,
|
|
83
|
-
saving: false,
|
|
84
|
-
isLoading: false,
|
|
85
|
-
deleting: false,
|
|
86
|
-
item: {
|
|
87
|
-
category: null,
|
|
88
|
-
description: null,
|
|
89
|
-
provider: null,
|
|
90
|
-
amount: null,
|
|
91
|
-
dueDate: null,
|
|
92
|
-
status: null,
|
|
93
|
-
},
|
|
94
|
-
categories: [],
|
|
95
|
-
providers: [],
|
|
96
|
-
statuses: [],
|
|
97
|
-
};
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
computed: {
|
|
101
|
-
...mapGetters({
|
|
102
|
-
myCompany: "people/currentCompany",
|
|
103
|
-
}),
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
methods: {
|
|
107
|
-
...mapActions({
|
|
108
|
-
getStatuses: "payInvoice/getStatuses",
|
|
109
|
-
getCategories: 'categories/getCategories',
|
|
110
|
-
getInvoice: "payInvoice/getInvoice",
|
|
111
|
-
createCategory: "expense/createCategory",
|
|
112
|
-
createProvider: "expense/createProvider",
|
|
113
|
-
updateExpense: "expense/updateExpense",
|
|
114
|
-
deleteExpense: "expense/deleteExpense",
|
|
115
|
-
search: "people/searchPeople",
|
|
116
|
-
}),
|
|
117
|
-
onSelectClient(item) {
|
|
118
|
-
this.item.provider = item.id;
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
searchPeople(input) {
|
|
122
|
-
this.isSearching = true;
|
|
123
|
-
|
|
124
|
-
return this.search(input).then((result) => {
|
|
125
|
-
this.isSearching = false;
|
|
126
|
-
|
|
127
|
-
if (result && result.success) {
|
|
128
|
-
let items = [];
|
|
129
|
-
for (let i = 0; i < result.data.length; i++) {
|
|
130
|
-
items.push({
|
|
131
|
-
label:
|
|
132
|
-
result.data[i].id +
|
|
133
|
-
" - " +
|
|
134
|
-
result.data[i].name +
|
|
135
|
-
" - " +
|
|
136
|
-
result.data[i].alias,
|
|
137
|
-
value: result.data[i],
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
return items;
|
|
141
|
-
} else {
|
|
142
|
-
this.isSearching = false;
|
|
143
|
-
this.$q.notify({
|
|
144
|
-
message: this.$t("messages.gmapsReqNoData"),
|
|
145
|
-
position: "bottom",
|
|
146
|
-
type: "negative",
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
},
|
|
151
|
-
loadSelectableOptions() {
|
|
152
|
-
// load categories
|
|
153
|
-
this.loadCategories();
|
|
154
|
-
|
|
155
|
-
// load statuses
|
|
156
|
-
this.loadStatuses();
|
|
157
|
-
},
|
|
158
|
-
loadCategories() {
|
|
159
|
-
this.getCategories({
|
|
160
|
-
params: {
|
|
161
|
-
context: "expense",
|
|
162
|
-
company: this.myCompany.id,
|
|
163
|
-
},
|
|
164
|
-
}).then((members) => {
|
|
165
|
-
if (members.length) {
|
|
166
|
-
let items = [];
|
|
167
|
-
|
|
168
|
-
items.push({
|
|
169
|
-
label: null,
|
|
170
|
-
value: null,
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
members.forEach((item, i) => {
|
|
174
|
-
items.push({
|
|
175
|
-
label: item.name,
|
|
176
|
-
value: item["@id"],
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
this.categories = items;
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
},
|
|
183
|
-
|
|
184
|
-
loadStatuses() {
|
|
185
|
-
this.getStatuses({
|
|
186
|
-
visibility: "public",
|
|
187
|
-
context: "invoice",
|
|
188
|
-
realStatus: ["open", "pending", "canceled", "closed"],
|
|
189
|
-
}).then((statuses) => {
|
|
190
|
-
if (statuses.length) {
|
|
191
|
-
let data = [];
|
|
192
|
-
for (let index in statuses) {
|
|
193
|
-
let item = statuses[index];
|
|
194
|
-
data.push({
|
|
195
|
-
label: this.$t(`invoice.statuses.${item.status}`),
|
|
196
|
-
value: item.status,
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
this.statuses = data;
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
},
|
|
203
|
-
|
|
204
|
-
addCategory() {
|
|
205
|
-
this.dialogs.category.saving = true;
|
|
206
|
-
|
|
207
|
-
this.createCategory({
|
|
208
|
-
values: {
|
|
209
|
-
name: this.dialogs.category.expense.name,
|
|
210
|
-
context: this.dialogs.category.expense.context,
|
|
211
|
-
parent: this.dialogs.category.expense.parent,
|
|
212
|
-
company: `/people/${this.myCompany.id}`,
|
|
213
|
-
},
|
|
214
|
-
})
|
|
215
|
-
.then((response) => {
|
|
216
|
-
this.$q.notify({
|
|
217
|
-
message: this.$t("Dados salvos com sucesso!"),
|
|
218
|
-
position: "bottom",
|
|
219
|
-
type: "positive",
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
this.loadCategories();
|
|
223
|
-
})
|
|
224
|
-
.finally(() => {
|
|
225
|
-
this.dialogs.category.saving = false;
|
|
226
|
-
});
|
|
227
|
-
},
|
|
228
|
-
|
|
229
|
-
addProvider() {
|
|
230
|
-
this.dialogs.provider.saving = true;
|
|
231
|
-
|
|
232
|
-
this.createProvider({
|
|
233
|
-
values: {
|
|
234
|
-
name: this.dialogs.provider.item.name,
|
|
235
|
-
alias: this.dialogs.provider.item.alias,
|
|
236
|
-
peopleType: this.dialogs.provider.item.type,
|
|
237
|
-
document: this.dialogs.provider.item.document,
|
|
238
|
-
},
|
|
239
|
-
params: {
|
|
240
|
-
myCompany: this.myCompany.id,
|
|
241
|
-
},
|
|
242
|
-
})
|
|
243
|
-
.then((response) => {
|
|
244
|
-
this.$q.notify({
|
|
245
|
-
message: this.$t("Dados salvos com sucesso!"),
|
|
246
|
-
position: "bottom",
|
|
247
|
-
type: "positive",
|
|
248
|
-
});
|
|
249
|
-
})
|
|
250
|
-
.catch((error) => {
|
|
251
|
-
this.$q.notify({
|
|
252
|
-
message: this.$t(error.message),
|
|
253
|
-
position: "bottom",
|
|
254
|
-
type: "negative",
|
|
255
|
-
});
|
|
256
|
-
})
|
|
257
|
-
.finally(() => {
|
|
258
|
-
this.dialogs.provider.saving = false;
|
|
259
|
-
});
|
|
260
|
-
},
|
|
261
|
-
|
|
262
|
-
editExpense() {
|
|
263
|
-
this.saving = true;
|
|
264
|
-
|
|
265
|
-
this.updateExpense({
|
|
266
|
-
id: this.id,
|
|
267
|
-
values: {
|
|
268
|
-
company: this.myCompany.id,
|
|
269
|
-
category: parseInt(this.item.category.replace(/\D/g, "")),
|
|
270
|
-
provider: parseInt(this.item.provider.replace(/\D/g, "")),
|
|
271
|
-
amount: parseFloat(this.item.amount.replace(",", ".")),
|
|
272
|
-
dueDate: this.item.dueDate
|
|
273
|
-
? this.item.dueDate.replace(
|
|
274
|
-
/^(\d{2})\/(\d{2})\/(\d{4})$/g,
|
|
275
|
-
"$3-$2-$1"
|
|
276
|
-
)
|
|
277
|
-
: null,
|
|
278
|
-
description: this.item.description,
|
|
279
|
-
status: this.item.status,
|
|
280
|
-
},
|
|
281
|
-
params: {
|
|
282
|
-
myCompany: this.myCompany.id,
|
|
283
|
-
},
|
|
284
|
-
})
|
|
285
|
-
.then((data) => {
|
|
286
|
-
this.$q.notify({
|
|
287
|
-
message: this.$t("Dados salvos com sucesso!"),
|
|
288
|
-
position: "bottom",
|
|
289
|
-
type: "positive",
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
this.$emit("updated", data);
|
|
293
|
-
})
|
|
294
|
-
.catch((error) => {
|
|
295
|
-
this.$q.notify({
|
|
296
|
-
message: this.$t(error.message),
|
|
297
|
-
position: "bottom",
|
|
298
|
-
type: "negative",
|
|
299
|
-
});
|
|
300
|
-
})
|
|
301
|
-
.finally(() => {
|
|
302
|
-
this.saving = false;
|
|
303
|
-
});
|
|
304
|
-
},
|
|
305
|
-
|
|
306
|
-
removeExpense() {
|
|
307
|
-
if (window.confirm(this.$t("Realmente deseja cancelar esta despesa?"))) {
|
|
308
|
-
this.deleting = true;
|
|
309
|
-
|
|
310
|
-
this.deleteExpense({
|
|
311
|
-
id: this.id,
|
|
312
|
-
values: {
|
|
313
|
-
company: this.myCompany.id,
|
|
314
|
-
},
|
|
315
|
-
})
|
|
316
|
-
.then((data) => {
|
|
317
|
-
this.$q.notify({
|
|
318
|
-
message: this.$t("Despesa cancelada com sucesso!"),
|
|
319
|
-
position: "bottom",
|
|
320
|
-
type: "positive",
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
this.loadInvoice();
|
|
324
|
-
|
|
325
|
-
this.$emit("updated", data);
|
|
326
|
-
})
|
|
327
|
-
.catch((error) => {
|
|
328
|
-
this.$q.notify({
|
|
329
|
-
message: this.$t(error.message),
|
|
330
|
-
position: "bottom",
|
|
331
|
-
type: "negative",
|
|
332
|
-
});
|
|
333
|
-
})
|
|
334
|
-
.finally(() => {
|
|
335
|
-
this.deleting = false;
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
},
|
|
339
|
-
|
|
340
|
-
loadInvoice() {
|
|
341
|
-
let params = {};
|
|
342
|
-
|
|
343
|
-
this.isLoading = true;
|
|
344
|
-
|
|
345
|
-
this.getInvoice({
|
|
346
|
-
invoiceId: this.id,
|
|
347
|
-
params: {
|
|
348
|
-
myCompany: this.myCompany.id,
|
|
349
|
-
},
|
|
350
|
-
})
|
|
351
|
-
.then((data) => {
|
|
352
|
-
if (data["@id"]) {
|
|
353
|
-
this.item.category = data.category;
|
|
354
|
-
this.item.description = data.description;
|
|
355
|
-
this.item.provider = data.order[0].order.provider["@id"].replace(
|
|
356
|
-
/people/g,
|
|
357
|
-
"providers"
|
|
358
|
-
);
|
|
359
|
-
|
|
360
|
-
this.providers.push({
|
|
361
|
-
label:
|
|
362
|
-
data.order[0].order.provider.name ||
|
|
363
|
-
data.order[0].order.provider.alias,
|
|
364
|
-
value: this.item.provider,
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
this.item.amount = (parseFloat(data.price) + 0.001).toFixed(2);
|
|
368
|
-
this.item.dueDate = formatDateYmdTodmY(data.dueDate);
|
|
369
|
-
this.item.status = data.status.status;
|
|
370
|
-
}
|
|
371
|
-
})
|
|
372
|
-
.catch((error) => { })
|
|
373
|
-
.finally(() => {
|
|
374
|
-
this.isLoading = false;
|
|
375
|
-
});
|
|
376
|
-
},
|
|
377
|
-
|
|
378
|
-
isInvalid(field) {
|
|
379
|
-
return (val) => {
|
|
380
|
-
if (field == "date") {
|
|
381
|
-
if (!/^\d{2}\/\d{2}\/\d{4}$/g.test(val))
|
|
382
|
-
return this.$t("A data não é válida");
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
if (!(val && val.length > 0))
|
|
386
|
-
return this.$t("Este campo é obrigatório");
|
|
387
|
-
|
|
388
|
-
return true;
|
|
389
|
-
};
|
|
390
|
-
},
|
|
391
|
-
},
|
|
392
|
-
};
|
|
393
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div class="row q-mb-md q-gutter-sm justify-end">
|
|
4
|
+
<q-btn :label="$t('Cancelar despesa')" icon="cancel" color="negative" @click="removeExpense"
|
|
5
|
+
:loading="deleting" />
|
|
6
|
+
</div>
|
|
7
|
+
<q-form @submit="editExpense">
|
|
8
|
+
<div class="row">
|
|
9
|
+
<div class="col-xs-12 q-mb-md">
|
|
10
|
+
<q-select stack-label emit-value map-options lazy-rules v-model="item.category"
|
|
11
|
+
:label="$t('Categoria da despesa')" :options="categories"
|
|
12
|
+
:rules="[(val) => val !== null || 'Selecione uma categoria']" />
|
|
13
|
+
</div>
|
|
14
|
+
<div class="col-xs-12 q-mb-md">
|
|
15
|
+
<q-input lazy-rules stack-label v-model="item.description" type="text" :label="$t('Descrição da despesa')"
|
|
16
|
+
class="q-mt-md" :rules="[isInvalid()]" />
|
|
17
|
+
</div>
|
|
18
|
+
<div class="col-xs-12 q-mb-md">
|
|
19
|
+
<q-select v-if="item.provider" stack-label emit-value map-options lazy-rules v-model="item.provider"
|
|
20
|
+
:label="$t('Fornecedor')" :options="providers"
|
|
21
|
+
:rules="[(val) => val !== null || 'Selecione um fornecedor']" />
|
|
22
|
+
<PeopleAutocomplete v-else :source="searchPeople" option-value="optionValue" :isLoading="isSearching"
|
|
23
|
+
label="Definir o fornecedor" @selected="onSelectClient" placeholder="Pesquisar..." />
|
|
24
|
+
|
|
25
|
+
<q-btn v-if="item.provider" @click="item.provider = null" align="right">
|
|
26
|
+
Alterar
|
|
27
|
+
</q-btn>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="col-xs-12 q-mb-md">
|
|
30
|
+
<q-input lazy-rules stack-label reverse-fill-mask v-model="item.amount" prefix="R$" type="text"
|
|
31
|
+
:label="$t('Valor')" class="q-mt-md" :rules="[isInvalid()]" mask="#,##" fill-mask="0" />
|
|
32
|
+
</div>
|
|
33
|
+
<div class="col-xs-12 q-mb-md">
|
|
34
|
+
<q-input stack-label v-model="item.dueDate" :label="$t('Data primeiro vencimento')" mask="##/##/####"
|
|
35
|
+
class="q-mb-sm" :rules="[isInvalid('date')]">
|
|
36
|
+
<template v-slot:append>
|
|
37
|
+
<q-icon name="event" class="cursor-pointer">
|
|
38
|
+
<q-popup-proxy ref="qDateProxy1" transition-show="scale" transition-hide="scale">
|
|
39
|
+
<q-date v-model="item.dueDate" mask="DD/MM/YYYY" @input="() => $refs.qDateProxy1.hide()" />
|
|
40
|
+
</q-popup-proxy>
|
|
41
|
+
</q-icon>
|
|
42
|
+
</template>
|
|
43
|
+
</q-input>
|
|
44
|
+
</div>
|
|
45
|
+
<div class="col-xs-12 q-mb-md">
|
|
46
|
+
<q-select stack-label emit-value map-options lazy-rules v-model="item.status" :label="$t('Status')"
|
|
47
|
+
:options="statuses" :rules="[(val) => val !== null || 'Selecione um status']" />
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
<div class="row justify-end">
|
|
51
|
+
<q-btn :loading="saving" icon="save" type="submit" :label="$t('Salvar')" size="md" color="primary"
|
|
52
|
+
class="q-mt-md" />
|
|
53
|
+
</div>
|
|
54
|
+
</q-form>
|
|
55
|
+
</div>
|
|
56
|
+
</template>
|
|
57
|
+
|
|
58
|
+
<script>
|
|
59
|
+
import { mapActions, mapGetters } from "vuex";
|
|
60
|
+
import { formatDateYmdTodmY } from "@freteclick/quasar-common-ui/src/utils/formatter";
|
|
61
|
+
|
|
62
|
+
import PeopleAutocomplete from "@freteclick/quasar-common-ui/src/components/common/PeopleAutocomplete";
|
|
63
|
+
|
|
64
|
+
export default {
|
|
65
|
+
components: {
|
|
66
|
+
PeopleAutocomplete,
|
|
67
|
+
},
|
|
68
|
+
props: {
|
|
69
|
+
id: {
|
|
70
|
+
type: String,
|
|
71
|
+
required: true,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
created() {
|
|
76
|
+
this.loadSelectableOptions();
|
|
77
|
+
this.loadInvoice();
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
data() {
|
|
81
|
+
return {
|
|
82
|
+
isSearching: false,
|
|
83
|
+
saving: false,
|
|
84
|
+
isLoading: false,
|
|
85
|
+
deleting: false,
|
|
86
|
+
item: {
|
|
87
|
+
category: null,
|
|
88
|
+
description: null,
|
|
89
|
+
provider: null,
|
|
90
|
+
amount: null,
|
|
91
|
+
dueDate: null,
|
|
92
|
+
status: null,
|
|
93
|
+
},
|
|
94
|
+
categories: [],
|
|
95
|
+
providers: [],
|
|
96
|
+
statuses: [],
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
computed: {
|
|
101
|
+
...mapGetters({
|
|
102
|
+
myCompany: "people/currentCompany",
|
|
103
|
+
}),
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
methods: {
|
|
107
|
+
...mapActions({
|
|
108
|
+
getStatuses: "payInvoice/getStatuses",
|
|
109
|
+
getCategories: 'categories/getCategories',
|
|
110
|
+
getInvoice: "payInvoice/getInvoice",
|
|
111
|
+
createCategory: "expense/createCategory",
|
|
112
|
+
createProvider: "expense/createProvider",
|
|
113
|
+
updateExpense: "expense/updateExpense",
|
|
114
|
+
deleteExpense: "expense/deleteExpense",
|
|
115
|
+
search: "people/searchPeople",
|
|
116
|
+
}),
|
|
117
|
+
onSelectClient(item) {
|
|
118
|
+
this.item.provider = item.id;
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
searchPeople(input) {
|
|
122
|
+
this.isSearching = true;
|
|
123
|
+
|
|
124
|
+
return this.search(input).then((result) => {
|
|
125
|
+
this.isSearching = false;
|
|
126
|
+
|
|
127
|
+
if (result && result.success) {
|
|
128
|
+
let items = [];
|
|
129
|
+
for (let i = 0; i < result.data.length; i++) {
|
|
130
|
+
items.push({
|
|
131
|
+
label:
|
|
132
|
+
result.data[i].id +
|
|
133
|
+
" - " +
|
|
134
|
+
result.data[i].name +
|
|
135
|
+
" - " +
|
|
136
|
+
result.data[i].alias,
|
|
137
|
+
value: result.data[i],
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
return items;
|
|
141
|
+
} else {
|
|
142
|
+
this.isSearching = false;
|
|
143
|
+
this.$q.notify({
|
|
144
|
+
message: this.$t("messages.gmapsReqNoData"),
|
|
145
|
+
position: "bottom",
|
|
146
|
+
type: "negative",
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
loadSelectableOptions() {
|
|
152
|
+
// load categories
|
|
153
|
+
this.loadCategories();
|
|
154
|
+
|
|
155
|
+
// load statuses
|
|
156
|
+
this.loadStatuses();
|
|
157
|
+
},
|
|
158
|
+
loadCategories() {
|
|
159
|
+
this.getCategories({
|
|
160
|
+
params: {
|
|
161
|
+
context: "expense",
|
|
162
|
+
company: this.myCompany.id,
|
|
163
|
+
},
|
|
164
|
+
}).then((members) => {
|
|
165
|
+
if (members.length) {
|
|
166
|
+
let items = [];
|
|
167
|
+
|
|
168
|
+
items.push({
|
|
169
|
+
label: null,
|
|
170
|
+
value: null,
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
members.forEach((item, i) => {
|
|
174
|
+
items.push({
|
|
175
|
+
label: item.name,
|
|
176
|
+
value: item["@id"],
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
this.categories = items;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
loadStatuses() {
|
|
185
|
+
this.getStatuses({
|
|
186
|
+
visibility: "public",
|
|
187
|
+
context: "invoice",
|
|
188
|
+
realStatus: ["open", "pending", "canceled", "closed"],
|
|
189
|
+
}).then((statuses) => {
|
|
190
|
+
if (statuses.length) {
|
|
191
|
+
let data = [];
|
|
192
|
+
for (let index in statuses) {
|
|
193
|
+
let item = statuses[index];
|
|
194
|
+
data.push({
|
|
195
|
+
label: this.$t(`invoice.statuses.${item.status}`),
|
|
196
|
+
value: item.status,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
this.statuses = data;
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
addCategory() {
|
|
205
|
+
this.dialogs.category.saving = true;
|
|
206
|
+
|
|
207
|
+
this.createCategory({
|
|
208
|
+
values: {
|
|
209
|
+
name: this.dialogs.category.expense.name,
|
|
210
|
+
context: this.dialogs.category.expense.context,
|
|
211
|
+
parent: this.dialogs.category.expense.parent,
|
|
212
|
+
company: `/people/${this.myCompany.id}`,
|
|
213
|
+
},
|
|
214
|
+
})
|
|
215
|
+
.then((response) => {
|
|
216
|
+
this.$q.notify({
|
|
217
|
+
message: this.$t("Dados salvos com sucesso!"),
|
|
218
|
+
position: "bottom",
|
|
219
|
+
type: "positive",
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
this.loadCategories();
|
|
223
|
+
})
|
|
224
|
+
.finally(() => {
|
|
225
|
+
this.dialogs.category.saving = false;
|
|
226
|
+
});
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
addProvider() {
|
|
230
|
+
this.dialogs.provider.saving = true;
|
|
231
|
+
|
|
232
|
+
this.createProvider({
|
|
233
|
+
values: {
|
|
234
|
+
name: this.dialogs.provider.item.name,
|
|
235
|
+
alias: this.dialogs.provider.item.alias,
|
|
236
|
+
peopleType: this.dialogs.provider.item.type,
|
|
237
|
+
document: this.dialogs.provider.item.document,
|
|
238
|
+
},
|
|
239
|
+
params: {
|
|
240
|
+
myCompany: this.myCompany.id,
|
|
241
|
+
},
|
|
242
|
+
})
|
|
243
|
+
.then((response) => {
|
|
244
|
+
this.$q.notify({
|
|
245
|
+
message: this.$t("Dados salvos com sucesso!"),
|
|
246
|
+
position: "bottom",
|
|
247
|
+
type: "positive",
|
|
248
|
+
});
|
|
249
|
+
})
|
|
250
|
+
.catch((error) => {
|
|
251
|
+
this.$q.notify({
|
|
252
|
+
message: this.$t(error.message),
|
|
253
|
+
position: "bottom",
|
|
254
|
+
type: "negative",
|
|
255
|
+
});
|
|
256
|
+
})
|
|
257
|
+
.finally(() => {
|
|
258
|
+
this.dialogs.provider.saving = false;
|
|
259
|
+
});
|
|
260
|
+
},
|
|
261
|
+
|
|
262
|
+
editExpense() {
|
|
263
|
+
this.saving = true;
|
|
264
|
+
|
|
265
|
+
this.updateExpense({
|
|
266
|
+
id: this.id,
|
|
267
|
+
values: {
|
|
268
|
+
company: this.myCompany.id,
|
|
269
|
+
category: parseInt(this.item.category.replace(/\D/g, "")),
|
|
270
|
+
provider: parseInt(this.item.provider.replace(/\D/g, "")),
|
|
271
|
+
amount: parseFloat(this.item.amount.replace(",", ".")),
|
|
272
|
+
dueDate: this.item.dueDate
|
|
273
|
+
? this.item.dueDate.replace(
|
|
274
|
+
/^(\d{2})\/(\d{2})\/(\d{4})$/g,
|
|
275
|
+
"$3-$2-$1"
|
|
276
|
+
)
|
|
277
|
+
: null,
|
|
278
|
+
description: this.item.description,
|
|
279
|
+
status: this.item.status,
|
|
280
|
+
},
|
|
281
|
+
params: {
|
|
282
|
+
myCompany: this.myCompany.id,
|
|
283
|
+
},
|
|
284
|
+
})
|
|
285
|
+
.then((data) => {
|
|
286
|
+
this.$q.notify({
|
|
287
|
+
message: this.$t("Dados salvos com sucesso!"),
|
|
288
|
+
position: "bottom",
|
|
289
|
+
type: "positive",
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
this.$emit("updated", data);
|
|
293
|
+
})
|
|
294
|
+
.catch((error) => {
|
|
295
|
+
this.$q.notify({
|
|
296
|
+
message: this.$t(error.message),
|
|
297
|
+
position: "bottom",
|
|
298
|
+
type: "negative",
|
|
299
|
+
});
|
|
300
|
+
})
|
|
301
|
+
.finally(() => {
|
|
302
|
+
this.saving = false;
|
|
303
|
+
});
|
|
304
|
+
},
|
|
305
|
+
|
|
306
|
+
removeExpense() {
|
|
307
|
+
if (window.confirm(this.$t("Realmente deseja cancelar esta despesa?"))) {
|
|
308
|
+
this.deleting = true;
|
|
309
|
+
|
|
310
|
+
this.deleteExpense({
|
|
311
|
+
id: this.id,
|
|
312
|
+
values: {
|
|
313
|
+
company: this.myCompany.id,
|
|
314
|
+
},
|
|
315
|
+
})
|
|
316
|
+
.then((data) => {
|
|
317
|
+
this.$q.notify({
|
|
318
|
+
message: this.$t("Despesa cancelada com sucesso!"),
|
|
319
|
+
position: "bottom",
|
|
320
|
+
type: "positive",
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
this.loadInvoice();
|
|
324
|
+
|
|
325
|
+
this.$emit("updated", data);
|
|
326
|
+
})
|
|
327
|
+
.catch((error) => {
|
|
328
|
+
this.$q.notify({
|
|
329
|
+
message: this.$t(error.message),
|
|
330
|
+
position: "bottom",
|
|
331
|
+
type: "negative",
|
|
332
|
+
});
|
|
333
|
+
})
|
|
334
|
+
.finally(() => {
|
|
335
|
+
this.deleting = false;
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
|
|
340
|
+
loadInvoice() {
|
|
341
|
+
let params = {};
|
|
342
|
+
|
|
343
|
+
this.isLoading = true;
|
|
344
|
+
|
|
345
|
+
this.getInvoice({
|
|
346
|
+
invoiceId: this.id,
|
|
347
|
+
params: {
|
|
348
|
+
myCompany: this.myCompany.id,
|
|
349
|
+
},
|
|
350
|
+
})
|
|
351
|
+
.then((data) => {
|
|
352
|
+
if (data["@id"]) {
|
|
353
|
+
this.item.category = data.category;
|
|
354
|
+
this.item.description = data.description;
|
|
355
|
+
this.item.provider = data.order[0].order.provider["@id"].replace(
|
|
356
|
+
/people/g,
|
|
357
|
+
"providers"
|
|
358
|
+
);
|
|
359
|
+
|
|
360
|
+
this.providers.push({
|
|
361
|
+
label:
|
|
362
|
+
data.order[0].order.provider.name ||
|
|
363
|
+
data.order[0].order.provider.alias,
|
|
364
|
+
value: this.item.provider,
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
this.item.amount = (parseFloat(data.price) + 0.001).toFixed(2);
|
|
368
|
+
this.item.dueDate = formatDateYmdTodmY(data.dueDate);
|
|
369
|
+
this.item.status = data.status.status;
|
|
370
|
+
}
|
|
371
|
+
})
|
|
372
|
+
.catch((error) => { })
|
|
373
|
+
.finally(() => {
|
|
374
|
+
this.isLoading = false;
|
|
375
|
+
});
|
|
376
|
+
},
|
|
377
|
+
|
|
378
|
+
isInvalid(field) {
|
|
379
|
+
return (val) => {
|
|
380
|
+
if (field == "date") {
|
|
381
|
+
if (!/^\d{2}\/\d{2}\/\d{4}$/g.test(val))
|
|
382
|
+
return this.$t("A data não é válida");
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if (!(val && val.length > 0))
|
|
386
|
+
return this.$t("Este campo é obrigatório");
|
|
387
|
+
|
|
388
|
+
return true;
|
|
389
|
+
};
|
|
390
|
+
},
|
|
391
|
+
},
|
|
392
|
+
};
|
|
393
|
+
</script>
|