|
@@ -24,35 +24,60 @@
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
- <div class="row justify-end items-center q-px-md q-mb-sm q-gutter-sm">
|
|
|
|
|
- <q-btn color="primary" label="Exportar Relatório" icon="mdi-download" unelevated no-caps />
|
|
|
|
|
- </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"
|
|
|
:loading="loading"
|
|
:loading="loading"
|
|
|
title="Contas a Receber"
|
|
title="Contas a Receber"
|
|
|
description="contas"
|
|
description="contas"
|
|
|
:female="true"
|
|
:female="true"
|
|
|
:columns="columns"
|
|
:columns="columns"
|
|
|
- />
|
|
|
|
|
|
|
+ @on-add-item="openCreate"
|
|
|
|
|
+ >
|
|
|
|
|
+ <template #body-cell-status="{ row }">
|
|
|
|
|
+ <q-td class="text-left">
|
|
|
|
|
+ <q-btn
|
|
|
|
|
+ :color="row.status === 'paid' ? 'positive' : 'orange-7'"
|
|
|
|
|
+ :label="row.status === 'paid' ? 'Pago' : 'Não pago'"
|
|
|
|
|
+ dense
|
|
|
|
|
+ no-caps
|
|
|
|
|
+ unelevated
|
|
|
|
|
+ :disable="!canEdit"
|
|
|
|
|
+ :loading="changingStatusId === row.id"
|
|
|
|
|
+ @click.prevent.stop="changeStatus(row)"
|
|
|
|
|
+ >
|
|
|
|
|
+ <q-tooltip v-if="canEdit">Clique para alterar o status</q-tooltip>
|
|
|
|
|
+ </q-btn>
|
|
|
|
|
+ </q-td>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </DefaultTable>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
import { ref, computed, onMounted } from "vue";
|
|
import { ref, computed, onMounted } from "vue";
|
|
|
-import { Notify } from "quasar";
|
|
|
|
|
|
|
+import { Notify, useQuasar } from "quasar";
|
|
|
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 FinancialCard from "src/components/financial/FinancialCard.vue";
|
|
import FinancialCard from "src/components/financial/FinancialCard.vue";
|
|
|
-import { getFranchiseeReceivables } from "src/api/franchisee_account_receive";
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ getFranchiseeReceivables,
|
|
|
|
|
+ reopenFranchiseeReceivable,
|
|
|
|
|
+} from "src/api/franchisee_account_receive";
|
|
|
|
|
+import AddAccountReceivableDialog from "src/components/financial/AddAccountReceivableDialog.vue";
|
|
|
|
|
+import SettleAccountReceivableDialog from "src/components/financial/SettleAccountReceivableDialog.vue";
|
|
|
|
|
+import { permissionStore } from "src/stores/permission";
|
|
|
|
|
|
|
|
|
|
+const $q = useQuasar();
|
|
|
|
|
+const permissions = permissionStore();
|
|
|
|
|
+const canAdd = permissions.getAccess("franchisor_financial", "add");
|
|
|
|
|
+const canEdit = permissions.getAccess("franchisor_financial", "edit");
|
|
|
const loading = ref(false);
|
|
const loading = ref(false);
|
|
|
const items = ref([]);
|
|
const items = ref([]);
|
|
|
|
|
+const changingStatusId = ref(null);
|
|
|
|
|
|
|
|
const columns = [
|
|
const columns = [
|
|
|
{ name: "unit", label: "Unidade", field: "unit", align: "left" },
|
|
{ name: "unit", label: "Unidade", field: "unit", align: "left" },
|
|
@@ -63,14 +88,6 @@ const columns = [
|
|
|
{ name: "status", label: "Status", field: "status", align: "left" },
|
|
{ name: "status", label: "Status", field: "status", align: "left" },
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
-const STATUS_LABEL = {
|
|
|
|
|
- pending: "Pendente",
|
|
|
|
|
- awaiting_payment: "Aguardando",
|
|
|
|
|
- paid: "Pago",
|
|
|
|
|
- overdue: "Atrasado",
|
|
|
|
|
- cancelled: "Cancelado",
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
const formatCurrency = (value) =>
|
|
const formatCurrency = (value) =>
|
|
|
new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(value ?? 0);
|
|
new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(value ?? 0);
|
|
|
|
|
|
|
@@ -82,13 +99,14 @@ const formatDate = (value) => {
|
|
|
|
|
|
|
|
const rows = computed(() =>
|
|
const rows = computed(() =>
|
|
|
items.value.map((i) => ({
|
|
items.value.map((i) => ({
|
|
|
- id: i.id,
|
|
|
|
|
- unit: i.unit_name ?? `Unidade ${i.unit_id}`,
|
|
|
|
|
|
|
+ ...i,
|
|
|
|
|
+ unit: i.unit_id ? (i.unit_name ?? `Unidade ${i.unit_id}`) : "Conta interna",
|
|
|
description: i.history,
|
|
description: i.history,
|
|
|
- category: "TBR",
|
|
|
|
|
|
|
+ category: i.plan_account
|
|
|
|
|
+ ? `${i.plan_account.code} — ${i.plan_account.description}`
|
|
|
|
|
+ : i.origin === "tbr" ? "TBR" : "—",
|
|
|
value: formatCurrency(Number(i.value)),
|
|
value: formatCurrency(Number(i.value)),
|
|
|
due_date: formatDate(i.due_date),
|
|
due_date: formatDate(i.due_date),
|
|
|
- status: STATUS_LABEL[i.status] ?? i.status,
|
|
|
|
|
})),
|
|
})),
|
|
|
);
|
|
);
|
|
|
|
|
|
|
@@ -121,5 +139,34 @@ const fetchReceivables = async () => {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+const openCreate = () => {
|
|
|
|
|
+ $q.dialog({ component: AddAccountReceivableDialog }).onOk(fetchReceivables);
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const changeStatus = (row) => {
|
|
|
|
|
+ if (row.status !== "paid") {
|
|
|
|
|
+ $q.dialog({
|
|
|
|
|
+ component: SettleAccountReceivableDialog,
|
|
|
|
|
+ componentProps: { receivable: row },
|
|
|
|
|
+ }).onOk(fetchReceivables);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $q.dialog({
|
|
|
|
|
+ title: "Marcar como não pago",
|
|
|
|
|
+ message: `Deseja reabrir a conta "${row.history}"?`,
|
|
|
|
|
+ ok: { color: "primary", label: "Confirmar" },
|
|
|
|
|
+ cancel: { color: "negative", outline: true, label: "Cancelar" },
|
|
|
|
|
+ }).onOk(async () => {
|
|
|
|
|
+ changingStatusId.value = row.id;
|
|
|
|
|
+ try {
|
|
|
|
|
+ await reopenFranchiseeReceivable(row.id);
|
|
|
|
|
+ await fetchReceivables();
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ changingStatusId.value = null;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
onMounted(fetchReceivables);
|
|
onMounted(fetchReceivables);
|
|
|
</script>
|
|
</script>
|