@freteclick/quasar-financial-ui 1.0.85

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.
Files changed (51) hide show
  1. package/package.json +18 -0
  2. package/src/components/common/Filters.vue +141 -0
  3. package/src/components/expense/FormExpense.vue +309 -0
  4. package/src/components/expense/TableExpenses.vue +305 -0
  5. package/src/components/invoice/client/ClientInvoiceDetails.vue +213 -0
  6. package/src/components/invoice/client/InvoiceSearching.vue +383 -0
  7. package/src/components/invoice/client/details/InvoiceInvoice.vue +249 -0
  8. package/src/components/invoice/client/details/InvoiceOrders.vue +328 -0
  9. package/src/components/invoice/expense/CreateExpense.vue +539 -0
  10. package/src/components/invoice/expense/DetailExpense.vue +393 -0
  11. package/src/components/invoice/pay/InvoiceDetails.vue +210 -0
  12. package/src/components/invoice/pay/InvoiceSearching.vue +388 -0
  13. package/src/components/invoice/pay/details/InvoiceInvoice.vue +47 -0
  14. package/src/components/invoice/pay/details/InvoiceOrders.vue +342 -0
  15. package/src/components/invoice/receive/InvoiceDetails.vue +281 -0
  16. package/src/components/invoice/receive/InvoiceSearching.vue +359 -0
  17. package/src/components/invoice/receive/details/InvoiceInvoice.vue +371 -0
  18. package/src/components/invoice/receive/details/InvoiceInvoiceBkp.vue +260 -0
  19. package/src/components/invoice/receive/details/InvoiceOrders.vue +370 -0
  20. package/src/i18n/en-us/index.js +8 -0
  21. package/src/i18n/index.js +5 -0
  22. package/src/i18n/pt-br/index.js +30 -0
  23. package/src/pages/Invoice/Client/Details.vue +23 -0
  24. package/src/pages/Invoice/Client/Index.vue +27 -0
  25. package/src/pages/Invoice/Pay/Details.vue +23 -0
  26. package/src/pages/Invoice/Pay/Index.vue +53 -0
  27. package/src/pages/Invoice/Receive/Details.vue +23 -0
  28. package/src/pages/Invoice/Receive/Index.vue +27 -0
  29. package/src/router/routes.js +32 -0
  30. package/src/store/modules/invoice/comission/actions.js +66 -0
  31. package/src/store/modules/invoice/comission/getters.js +7 -0
  32. package/src/store/modules/invoice/comission/index.js +19 -0
  33. package/src/store/modules/invoice/comission/mutation_types.js +8 -0
  34. package/src/store/modules/invoice/comission/mutations.js +42 -0
  35. package/src/store/modules/invoice/expense/actions.js +98 -0
  36. package/src/store/modules/invoice/expense/getters.js +1 -0
  37. package/src/store/modules/invoice/expense/index.js +12 -0
  38. package/src/store/modules/invoice/expense/mutations.js +3 -0
  39. package/src/store/modules/invoice/expense/state.js +5 -0
  40. package/src/store/modules/invoice/pay/actions.js +114 -0
  41. package/src/store/modules/invoice/pay/getters.js +7 -0
  42. package/src/store/modules/invoice/pay/index.js +19 -0
  43. package/src/store/modules/invoice/pay/mutation_types.js +8 -0
  44. package/src/store/modules/invoice/pay/mutations.js +42 -0
  45. package/src/store/modules/invoice/receive/actions.js +152 -0
  46. package/src/store/modules/invoice/receive/actionsBkp.js +77 -0
  47. package/src/store/modules/invoice/receive/getters.js +7 -0
  48. package/src/store/modules/invoice/receive/index.js +19 -0
  49. package/src/store/modules/invoice/receive/mutation_types.js +8 -0
  50. package/src/store/modules/invoice/receive/mutations.js +42 -0
  51. package/src/store/store-flag.d.ts +9 -0
@@ -0,0 +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>
@@ -0,0 +1,210 @@
1
+ <template>
2
+ <q-card style="min-height: 90vh;">
3
+ <q-inner-loading :showing="isLoading">
4
+ <q-spinner-gears size="50px" color="primary" />
5
+ </q-inner-loading>
6
+
7
+ <transition-group appear
8
+ enter-active-class="animated fadeIn"
9
+ leave-active-class="animated fadeOut"
10
+ >
11
+
12
+ <div v-if="invoice !== null"
13
+ class="row q-pa-sm q-col-gutter-sm"
14
+ key ="status"
15
+ >
16
+ <div class="col-xs-12">
17
+ <div class="text-h5 q-pt-sm q-pb-sm">{{ this.provider.name }}</div>
18
+ </div>
19
+ <div class="col-xs-12 col-sm-4">
20
+ <q-markup-table flat dense
21
+ separator="none"
22
+ class ="bg-grey-4 full-height"
23
+ >
24
+ <tbody>
25
+ <tr>
26
+ <td class="text-left text-bold">Número da fatura</td>
27
+ <td class="text-left">
28
+ {{ `#${this.invoice['@id'].match(/^\/finance\/pay\/([a-z0-9-]*)$/)[1]}` }}
29
+ </td>
30
+ </tr>
31
+ <tr>
32
+ <td class="text-left text-bold">Valor da fatura</td>
33
+ <td class="text-left">
34
+ {{ formatMoney(this.invoice.price) }}
35
+ </td>
36
+ </tr>
37
+ <tr>
38
+ <td class="text-left text-bold">Vencimento</td>
39
+ <td class="text-left">
40
+ {{ this.invoice.dueDate }}
41
+ </td>
42
+ </tr>
43
+ </tbody>
44
+ </q-markup-table>
45
+ </div>
46
+ <div class ="col-xs-12 col-sm-8">
47
+ <div
48
+ class ="row items-center justify-center full-height rounded-borders"
49
+ :style="`background-color: ${this.invoice.status.color}`"
50
+ >
51
+ <div class="text-white text-h6">
52
+ {{ $t(`invoice.statuses.${invoice.status.status}`) }}
53
+ </div>
54
+ </div>
55
+ </div>
56
+ </div>
57
+
58
+ <div v-if="invoice !== null"
59
+ class="row"
60
+ key ="order_tabs"
61
+ >
62
+ <div class="col-12">
63
+ <q-tabs
64
+ :horizontal="$q.screen.gt.xs"
65
+ align ="justify"
66
+ v-model ="currentTab"
67
+ class ="bg-white text-primary"
68
+ >
69
+ <q-tab
70
+ name ="details"
71
+ label="Detalhes"
72
+ />
73
+ <q-tab
74
+ name ="orders"
75
+ label="Despesa"
76
+ />
77
+ </q-tabs>
78
+
79
+ <q-separator />
80
+
81
+ <q-tab-panels
82
+ v-model="currentTab"
83
+ >
84
+ <q-tab-panel name="details" class="q-pa-none">
85
+ <InvoiceInvoice
86
+ :invoiceId="invoiceId"
87
+ @updated ="requestInvoice(invoiceId)"
88
+ />
89
+ </q-tab-panel>
90
+ <q-tab-panel name="orders" class="q-pa-none">
91
+ <InvoiceOrders
92
+ :invoiceId="invoiceId"
93
+ />
94
+ </q-tab-panel>
95
+ </q-tab-panels>
96
+ </div>
97
+ </div>
98
+
99
+ </transition-group>
100
+
101
+ <div v-if="invoice === null && notFound"
102
+ class="row items-center justify-center"
103
+ style="min-height: 90vh;"
104
+ >
105
+ <q-banner class="text-white bg-red text-center text-h3" rounded>
106
+ <template v-slot:avatar>
107
+ <q-icon name="error" color="white" />
108
+ </template>
109
+ A fatura não foi encontrada
110
+ </q-banner>
111
+ </div>
112
+ </q-card>
113
+ </template>
114
+
115
+ <script>
116
+ import { mapActions, mapGetters } from 'vuex';
117
+ import InvoiceOrders from './details/InvoiceOrders';
118
+ import InvoiceInvoice from './details/InvoiceInvoice';
119
+ import { formatMoney, formatDateYmdTodmY } from '@freteclick/quasar-common-ui/src/utils/formatter';
120
+
121
+ export default {
122
+ components: {
123
+ InvoiceInvoice,
124
+ InvoiceOrders ,
125
+ },
126
+
127
+ created() {
128
+ if (this.$route.params.id)
129
+ this.invoiceId = decodeURIComponent(this.$route.params.id);
130
+
131
+ if (this.myCompany !== null && this.invoiceId !== null) {
132
+ this.requestInvoice(this.invoiceId);
133
+ }
134
+ },
135
+
136
+ data() {
137
+ return {
138
+ currentTab: 'details',
139
+ invoiceId : null,
140
+ orderId : null,
141
+ invoice : null,
142
+ isLoading : false,
143
+ notFound : false,
144
+ provider : {
145
+ name: '',
146
+ },
147
+ };
148
+ },
149
+
150
+ computed: {
151
+ ...mapGetters({
152
+ myCompany: 'people/currentCompany',
153
+ }),
154
+ },
155
+
156
+ watch: {
157
+ myCompany(company) {
158
+ if (company !== null) {
159
+ this.requestInvoice(this.invoiceId);
160
+ }
161
+ },
162
+ },
163
+
164
+ methods: {
165
+ ...mapActions({
166
+ getInvoice: 'payInvoice/getInvoice',
167
+ }),
168
+
169
+ formatMoney(value) {
170
+ return formatMoney(value, 'BRL', 'pt-br');
171
+ },
172
+
173
+ requestInvoice(invoiceId) {
174
+ let params = {};
175
+
176
+ params['myCompany'] = this.myCompany.id;
177
+
178
+ this.isLoading = true;
179
+
180
+ this.getInvoice({ invoiceId, params })
181
+ .then(data => {
182
+ this.isLoading = false;
183
+
184
+ if (data['@id']) {
185
+ this.invoice = data;
186
+ this.notFound = false;
187
+
188
+ // format date
189
+
190
+ if (this.invoice.dueDate)
191
+ this.invoice.dueDate = formatDateYmdTodmY(this.invoice.dueDate);
192
+
193
+ // set order
194
+
195
+ if (this.invoice.order.length > 0) {
196
+ this.orderId = this.invoice.order[0].order['@id'].replace(/[^0-9]/g,'');
197
+ this.provider.name = `${this.invoice.order[0].order.provider.name} ${this.invoice.order[0].order.provider.alias}`;
198
+ }
199
+ }
200
+ })
201
+ .catch(error => {
202
+ this.provider.name = '';
203
+ this.isLoading = false;
204
+ this.invoice = null;
205
+ this.notFound = true;
206
+ });
207
+ },
208
+ },
209
+ };
210
+ </script>