فهرست منبع

feat: adiciona tab de contratos em tbr

ebagabee 1 ماه پیش
والد
کامیت
6e76e57d78
2فایلهای تغییر یافته به همراه23 افزوده شده و 44 حذف شده
  1. 5 0
      src/api/franchisee_contract.js
  2. 18 44
      src/pages/tbr/tabs/ContractsTab.vue

+ 5 - 0
src/api/franchisee_contract.js

@@ -1,5 +1,10 @@
 import api from "src/api";
 
+export const getActiveFranchiseeContracts = async () => {
+  const { data } = await api.get("/franchisee-contract/active");
+  return data.payload;
+};
+
 export const getFranchiseeContractsByUnit = async (unitId) => {
   const { data } = await api.get("/franchisee-contract", {
     params: { unit_id: unitId },

+ 18 - 44
src/pages/tbr/tabs/ContractsTab.vue

@@ -1,33 +1,30 @@
 <template>
   <DefaultTable
-    v-model:rows="rows"
     :columns="columns"
-    title="Contratos TBR"
-    description="contratos"
-    :female="false"
-    :no-api-call="true"
+    :api-call="loadContracts"
     :show-search-field="true"
+    :female="false"
+    title="Contratos"
+    description="contratos"
   >
-    <template #body-cell-tbr_value="{ row }">
-      <q-td>{{ formatToBRLCurrency(row.tbr_value) }}</q-td>
+    <template #body-cell-tbr_fixed_value="{ row }">
+      <q-td>{{ formatToBRLCurrency(row.tbr_fixed_value) }}</q-td>
     </template>
 
     <template #body-cell-royalties="{ row }">
-      <q-td>{{ formatPercentage(row.base_royalties_percentage) }}</q-td>
+      <q-td>{{ formatPercentage(row.tbr_fixed_value_percentage) }}</q-td>
     </template>
 
     <template #body-cell-fnm="{ row }">
-      <q-td>{{ formatPercentage(row.base_fnm_percentage) }}</q-td>
+      <q-td>{{ formatPercentage(row.marketing_fund_percentage) }}</q-td>
     </template>
 
     <template #body-cell-maintenance="{ row }">
-      <q-td>{{ formatPercentage(row.maintenance_percentage) }}</q-td>
+      <q-td>{{ formatPercentage(row.maintance_tax_percentage) }}</q-td>
     </template>
 
     <template #body-cell-ref_month="{ row }">
-      <q-td>{{
-        formatRefMonth(row.contract_month_current, row.contract_validity_months)
-      }}</q-td>
+      <q-td>{{ formatRefMonth(row.contract_month_current, row.validity_months) }}</q-td>
     </template>
 
     <template #body-cell-actions>
@@ -39,36 +36,20 @@
 </template>
 
 <script setup>
-import { ref, onMounted } from "vue";
 import DefaultTable from "src/components/defaults/DefaultTable.vue";
-import { getFranchiseeTbrs } from "src/api/tbr";
+import { getActiveFranchiseeContracts } from "src/api/franchisee_contract";
 import { formatToBRLCurrency, formatPercentage } from "src/helpers/utils";
 
-const rows = ref([]);
+const loadContracts = () => getActiveFranchiseeContracts();
 
 const columns = [
-  { name: "id", label: "ID", field: "id", align: "left" },
+  { name: "protocol", label: "ID", field: "protocol", align: "left" },
   { name: "unit_name", label: "Unidade", field: "unit_name", align: "left" },
-  { name: "tbr_value", label: "TBR", field: "tbr_value", align: "left" },
-  {
-    name: "royalties",
-    label: "Royalties",
-    field: "base_royalties_percentage",
-    align: "left",
-  },
-  { name: "fnm", label: "FNM", field: "base_fnm_percentage", align: "left" },
-  {
-    name: "maintenance",
-    label: "Manutenção",
-    field: "maintenance_percentage",
-    align: "left",
-  },
-  {
-    name: "ref_month",
-    label: "Ref. Mês",
-    field: "contract_month_current",
-    align: "left",
-  },
+  { name: "tbr_fixed_value", label: "TBR", field: "tbr_fixed_value", align: "left" },
+  { name: "royalties", label: "Royalties", field: "tbr_fixed_value_percentage", align: "left" },
+  { name: "fnm", label: "FNM", field: "marketing_fund_percentage", align: "left" },
+  { name: "maintenance", label: "Manutenção", field: "maintance_tax_percentage", align: "left" },
+  { name: "ref_month", label: "Ref. Mês", field: "contract_month_current", align: "left" },
   { name: "actions", label: "Ações", field: "actions", align: "center" },
 ];
 
@@ -77,11 +58,4 @@ function formatRefMonth(current, total) {
   const pad = (n) => String(n).padStart(2, "0");
   return `${pad(current)}/${pad(total)}`;
 }
-
-async function loadData() {
-  const result = await getFranchiseeTbrs();
-  rows.value = result?.data ?? result ?? [];
-}
-
-onMounted(loadData);
 </script>