|
@@ -26,38 +26,16 @@
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
- <div class="row justify-end items-center q-px-md q-mb-sm q-gutter-sm">
|
|
|
|
|
- <DefaultSelect
|
|
|
|
|
- v-model="statusFilter"
|
|
|
|
|
- label="Status"
|
|
|
|
|
- :options="statusFilterOptions"
|
|
|
|
|
- outlined
|
|
|
|
|
- dense
|
|
|
|
|
- emit-value
|
|
|
|
|
- map-options
|
|
|
|
|
- style="min-width: 180px"
|
|
|
|
|
- @update:model-value="loadData"
|
|
|
|
|
- />
|
|
|
|
|
- <q-btn
|
|
|
|
|
- v-if="canAdd"
|
|
|
|
|
- color="primary"
|
|
|
|
|
- label="Nova conta"
|
|
|
|
|
- icon="mdi-plus"
|
|
|
|
|
- unelevated
|
|
|
|
|
- no-caps
|
|
|
|
|
- @click="openCreate"
|
|
|
|
|
- />
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
<div class="q-px-md">
|
|
<div class="q-px-md">
|
|
|
<DefaultTable
|
|
<DefaultTable
|
|
|
v-model:rows="rows"
|
|
v-model:rows="rows"
|
|
|
no-api-call
|
|
no-api-call
|
|
|
- :add-item="false"
|
|
|
|
|
|
|
+ :add-item="canAdd"
|
|
|
title="Contas a Pagar"
|
|
title="Contas a Pagar"
|
|
|
- descricao="contas"
|
|
|
|
|
- :feminino="true"
|
|
|
|
|
|
|
+ description="contas"
|
|
|
|
|
+ :female="true"
|
|
|
:columns="columns"
|
|
:columns="columns"
|
|
|
|
|
+ @on-add-item="openCreate"
|
|
|
>
|
|
>
|
|
|
<template #body-cell-origin="{ row }">
|
|
<template #body-cell-origin="{ row }">
|
|
|
<q-td class="text-left">
|
|
<q-td class="text-left">
|
|
@@ -77,39 +55,18 @@
|
|
|
|
|
|
|
|
<template #body-cell-status="{ row }">
|
|
<template #body-cell-status="{ row }">
|
|
|
<q-td class="text-left">
|
|
<q-td class="text-left">
|
|
|
- <q-chip
|
|
|
|
|
- :color="statusMeta(row.status).color"
|
|
|
|
|
- text-color="white"
|
|
|
|
|
- dense
|
|
|
|
|
- square
|
|
|
|
|
- :label="statusMeta(row.status).label"
|
|
|
|
|
- />
|
|
|
|
|
- </q-td>
|
|
|
|
|
- </template>
|
|
|
|
|
-
|
|
|
|
|
- <template #body-cell-actions="{ row }">
|
|
|
|
|
- <q-td auto-width>
|
|
|
|
|
<q-btn
|
|
<q-btn
|
|
|
- v-if="canEdit && row.status !== 'paid' && row.status !== 'cancelled'"
|
|
|
|
|
- color="primary-2"
|
|
|
|
|
- label="Dar baixa"
|
|
|
|
|
|
|
+ :color="row.status === 'paid' ? 'positive' : 'secondary'"
|
|
|
|
|
+ :label="row.status === 'paid' ? 'Pago' : 'Não pago'"
|
|
|
dense
|
|
dense
|
|
|
no-caps
|
|
no-caps
|
|
|
unelevated
|
|
unelevated
|
|
|
- class="q-px-sm"
|
|
|
|
|
- @click="openSettle(row)"
|
|
|
|
|
- />
|
|
|
|
|
- <q-btn
|
|
|
|
|
- v-else-if="canEdit && row.status === 'paid'"
|
|
|
|
|
- color="grey-7"
|
|
|
|
|
- label="Reabrir"
|
|
|
|
|
- dense
|
|
|
|
|
- no-caps
|
|
|
|
|
- outline
|
|
|
|
|
- class="q-px-sm"
|
|
|
|
|
|
|
+ :disable="!canEdit"
|
|
|
:loading="reopeningId === row.id"
|
|
:loading="reopeningId === row.id"
|
|
|
- @click="onReopen(row)"
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ @click.stop="changeStatus(row)"
|
|
|
|
|
+ >
|
|
|
|
|
+ <q-tooltip v-if="canEdit">Clique para alterar o status</q-tooltip>
|
|
|
|
|
+ </q-btn>
|
|
|
</q-td>
|
|
</q-td>
|
|
|
</template>
|
|
</template>
|
|
|
</DefaultTable>
|
|
</DefaultTable>
|
|
@@ -125,6 +82,7 @@
|
|
|
|
|
|
|
|
<DefaultInputDatePicker
|
|
<DefaultInputDatePicker
|
|
|
v-model="settleForm.payment_date"
|
|
v-model="settleForm.payment_date"
|
|
|
|
|
+ v-model:untreated-date="settleForm.payment_date_iso"
|
|
|
label="Data do pagamento"
|
|
label="Data do pagamento"
|
|
|
/>
|
|
/>
|
|
|
|
|
|
|
@@ -182,9 +140,11 @@
|
|
|
label="Valor"
|
|
label="Valor"
|
|
|
class="col-6"
|
|
class="col-6"
|
|
|
outlined
|
|
outlined
|
|
|
|
|
+ :rules="[() => Number(createForm.value) > 0 || 'Informe o valor']"
|
|
|
/>
|
|
/>
|
|
|
<DefaultInputDatePicker
|
|
<DefaultInputDatePicker
|
|
|
v-model="createForm.due_date"
|
|
v-model="createForm.due_date"
|
|
|
|
|
+ v-model:untreated-date="createForm.due_date_iso"
|
|
|
label="Vencimento"
|
|
label="Vencimento"
|
|
|
class="col-6"
|
|
class="col-6"
|
|
|
/>
|
|
/>
|
|
@@ -223,7 +183,6 @@ import {
|
|
|
|
|
|
|
|
import DefaultHeaderPage from "src/components/layout/DefaultHeaderPage.vue";
|
|
import DefaultHeaderPage from "src/components/layout/DefaultHeaderPage.vue";
|
|
|
import DefaultTable from "src/components/defaults/DefaultTable.vue";
|
|
import DefaultTable from "src/components/defaults/DefaultTable.vue";
|
|
|
-import DefaultSelect from "src/components/defaults/DefaultSelect.vue";
|
|
|
|
|
import DefaultInput from "src/components/defaults/DefaultInput.vue";
|
|
import DefaultInput from "src/components/defaults/DefaultInput.vue";
|
|
|
import DefaultCurrencyInput from "src/components/defaults/DefaultCurrencyInput.vue";
|
|
import DefaultCurrencyInput from "src/components/defaults/DefaultCurrencyInput.vue";
|
|
|
import DefaultInputDatePicker from "src/components/defaults/DefaultInputDatePicker.vue";
|
|
import DefaultInputDatePicker from "src/components/defaults/DefaultInputDatePicker.vue";
|
|
@@ -240,26 +199,17 @@ const canEdit = computed(() =>
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
const rows = ref([]);
|
|
const rows = ref([]);
|
|
|
-const statusFilter = ref(null);
|
|
|
|
|
|
|
|
|
|
const settleDialog = ref(false);
|
|
const settleDialog = ref(false);
|
|
|
const selected = ref(null);
|
|
const selected = ref(null);
|
|
|
const settling = ref(false);
|
|
const settling = ref(false);
|
|
|
const reopeningId = ref(null);
|
|
const reopeningId = ref(null);
|
|
|
-const settleForm = ref({ payment_date: null, discount: 0, fine: 0 });
|
|
|
|
|
|
|
+const settleForm = ref({ payment_date: null, payment_date_iso: null, discount: 0, fine: 0 });
|
|
|
|
|
|
|
|
const createDialog = ref(false);
|
|
const createDialog = ref(false);
|
|
|
const createFormRef = ref(null);
|
|
const createFormRef = ref(null);
|
|
|
const creating = ref(false);
|
|
const creating = ref(false);
|
|
|
-const createForm = ref({ history: "", value: 0, due_date: null, obs: "" });
|
|
|
|
|
-
|
|
|
|
|
-const statusFilterOptions = [
|
|
|
|
|
- { label: "Todos", value: null },
|
|
|
|
|
- { label: "Pendentes", value: "pending" },
|
|
|
|
|
- { label: "Pagos", value: "paid" },
|
|
|
|
|
- { label: "Vencidos", value: "overdue" },
|
|
|
|
|
- { label: "Cancelados", value: "cancelled" },
|
|
|
|
|
-];
|
|
|
|
|
|
|
+const createForm = ref({ history: "", value: 0, due_date: null, due_date_iso: null, obs: "" });
|
|
|
|
|
|
|
|
const columns = [
|
|
const columns = [
|
|
|
{ name: "origin", label: "Origem", field: "origin", align: "left" },
|
|
{ name: "origin", label: "Origem", field: "origin", align: "left" },
|
|
@@ -267,7 +217,6 @@ const columns = [
|
|
|
{ name: "value", label: "Valor", field: "value", align: "left" },
|
|
{ name: "value", label: "Valor", field: "value", align: "left" },
|
|
|
{ name: "due_date", label: "Vencimento", field: "due_date", align: "left" },
|
|
{ name: "due_date", label: "Vencimento", field: "due_date", align: "left" },
|
|
|
{ name: "status", label: "Status", field: "status", align: "left" },
|
|
{ name: "status", label: "Status", field: "status", align: "left" },
|
|
|
- { name: "actions", label: "Ações", field: "actions", align: "right" },
|
|
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
function formatCurrency(value) {
|
|
function formatCurrency(value) {
|
|
@@ -277,17 +226,6 @@ function formatCurrency(value) {
|
|
|
}).format(Number(value ?? 0));
|
|
}).format(Number(value ?? 0));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const STATUS_META = {
|
|
|
|
|
- pending: { label: "Pendente", color: "orange-7" },
|
|
|
|
|
- paid: { label: "Pago", color: "positive" },
|
|
|
|
|
- overdue: { label: "Vencido", color: "negative" },
|
|
|
|
|
- cancelled: { label: "Cancelado", color: "grey-6" },
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-function statusMeta(status) {
|
|
|
|
|
- return STATUS_META[status] ?? { label: status, color: "grey-6" };
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
const settleNetValue = computed(() => {
|
|
const settleNetValue = computed(() => {
|
|
|
const base = Number(selected.value?.value ?? 0);
|
|
const base = Number(selected.value?.value ?? 0);
|
|
|
return base - Number(settleForm.value.discount ?? 0) + Number(settleForm.value.fine ?? 0);
|
|
return base - Number(settleForm.value.discount ?? 0) + Number(settleForm.value.fine ?? 0);
|
|
@@ -319,29 +257,35 @@ const totals = computed(() => {
|
|
|
|
|
|
|
|
async function loadData() {
|
|
async function loadData() {
|
|
|
try {
|
|
try {
|
|
|
- const params = statusFilter.value ? { status: statusFilter.value } : {};
|
|
|
|
|
- rows.value = await getPayablesMe(params);
|
|
|
|
|
|
|
+ rows.value = await getPayablesMe();
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
console.error("Erro ao buscar contas a pagar:", e);
|
|
console.error("Erro ao buscar contas a pagar:", e);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function openSettle(row) {
|
|
function openSettle(row) {
|
|
|
|
|
+ const today = new Date();
|
|
|
selected.value = row;
|
|
selected.value = row;
|
|
|
settleForm.value = {
|
|
settleForm.value = {
|
|
|
- payment_date: new Date().toISOString().slice(0, 10),
|
|
|
|
|
|
|
+ payment_date: today.toLocaleDateString("pt-BR"),
|
|
|
|
|
+ payment_date_iso: today.toISOString().slice(0, 10),
|
|
|
discount: Number(row.discount ?? 0),
|
|
discount: Number(row.discount ?? 0),
|
|
|
fine: Number(row.fine ?? 0),
|
|
fine: Number(row.fine ?? 0),
|
|
|
};
|
|
};
|
|
|
settleDialog.value = true;
|
|
settleDialog.value = true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function changeStatus(row) {
|
|
|
|
|
+ if (row.status === "paid") onReopen(row);
|
|
|
|
|
+ else openSettle(row);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
async function onSettle() {
|
|
async function onSettle() {
|
|
|
if (!selected.value) return;
|
|
if (!selected.value) return;
|
|
|
settling.value = true;
|
|
settling.value = true;
|
|
|
try {
|
|
try {
|
|
|
await settlePayableMe(selected.value.id, {
|
|
await settlePayableMe(selected.value.id, {
|
|
|
- payment_date: settleForm.value.payment_date,
|
|
|
|
|
|
|
+ payment_date: settleForm.value.payment_date_iso,
|
|
|
discount: settleForm.value.discount,
|
|
discount: settleForm.value.discount,
|
|
|
fine: settleForm.value.fine,
|
|
fine: settleForm.value.fine,
|
|
|
});
|
|
});
|
|
@@ -367,7 +311,14 @@ async function onReopen(row) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function openCreate() {
|
|
function openCreate() {
|
|
|
- createForm.value = { history: "", value: 0, due_date: null, obs: "" };
|
|
|
|
|
|
|
+ const today = new Date();
|
|
|
|
|
+ createForm.value = {
|
|
|
|
|
+ history: "",
|
|
|
|
|
+ value: 0,
|
|
|
|
|
+ due_date: today.toLocaleDateString("pt-BR"),
|
|
|
|
|
+ due_date_iso: today.toISOString().slice(0, 10),
|
|
|
|
|
+ obs: "",
|
|
|
|
|
+ };
|
|
|
createDialog.value = true;
|
|
createDialog.value = true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -379,7 +330,7 @@ async function onCreate() {
|
|
|
await createPayableMe({
|
|
await createPayableMe({
|
|
|
history: createForm.value.history,
|
|
history: createForm.value.history,
|
|
|
value: createForm.value.value,
|
|
value: createForm.value.value,
|
|
|
- due_date: createForm.value.due_date,
|
|
|
|
|
|
|
+ due_date: createForm.value.due_date_iso,
|
|
|
obs: createForm.value.obs || null,
|
|
obs: createForm.value.obs || null,
|
|
|
});
|
|
});
|
|
|
createDialog.value = false;
|
|
createDialog.value = false;
|