fix: refs #7134 remove supplierRisk
This commit is contained in:
parent
1f1fc4d6b9
commit
fce1068fbb
|
@ -10,4 +10,4 @@ import DepartmentDescriptor from 'pages/Department/Card/DepartmentDescriptor.vue
|
||||||
base-url="Departments"
|
base-url="Departments"
|
||||||
:descriptor="DepartmentDescriptor"
|
:descriptor="DepartmentDescriptor"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -2,15 +2,12 @@
|
||||||
import { computed, onBeforeMount, ref } from 'vue';
|
import { computed, onBeforeMount, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { getSupplierRisk } from 'src/composables/getRisk';
|
|
||||||
import tableFooter from 'src/components/VnTable/filters/tableFooter';
|
import tableFooter from 'src/components/VnTable/filters/tableFooter';
|
||||||
import { dashIfEmpty, toCurrency, toDateHourMin } from 'src/filters';
|
import { dashIfEmpty, toCurrency, toDateHourMin } from 'src/filters';
|
||||||
import { useState } from 'composables/useState';
|
import { useState } from 'composables/useState';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
|
|
||||||
import VnTable from 'components/VnTable/VnTable.vue';
|
import VnTable from 'components/VnTable/VnTable.vue';
|
||||||
import VnSubToolbar from 'components/ui/VnSubToolbar.vue';
|
|
||||||
import VnFilter from 'components/VnTable/VnFilter.vue';
|
|
||||||
|
|
||||||
import InvoiceInDescriptorProxy from 'src/pages/InvoiceIn/Card/InvoiceInDescriptorProxy.vue';
|
import InvoiceInDescriptorProxy from 'src/pages/InvoiceIn/Card/InvoiceInDescriptorProxy.vue';
|
||||||
import SupplierBalanceFilter from './SupplierBalanceFilter.vue';
|
import SupplierBalanceFilter from './SupplierBalanceFilter.vue';
|
||||||
|
@ -23,12 +20,10 @@ const state = useState();
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const user = state.getUser();
|
const user = state.getUser();
|
||||||
|
|
||||||
const supplierRisk = ref([]);
|
|
||||||
const tableRef = ref();
|
const tableRef = ref();
|
||||||
const companyId = ref();
|
const companyId = ref();
|
||||||
const companyUser = ref(user.value.companyFk);
|
const companyUser = ref(user.value.companyFk);
|
||||||
const balances = ref([]);
|
const balances = ref([]);
|
||||||
const vnFilterRef = ref({});
|
|
||||||
const userParams = computed(() => {
|
const userParams = computed(() => {
|
||||||
return {
|
return {
|
||||||
supplierId: route.params.id,
|
supplierId: route.params.id,
|
||||||
|
@ -37,31 +32,6 @@ const userParams = computed(() => {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const companyFilterColumn = {
|
|
||||||
align: 'left',
|
|
||||||
name: 'companyId',
|
|
||||||
label: t('Company'),
|
|
||||||
component: 'select',
|
|
||||||
attrs: {
|
|
||||||
url: 'Companies',
|
|
||||||
optionLabel: 'code',
|
|
||||||
optionValue: 'id',
|
|
||||||
sortBy: 'code',
|
|
||||||
},
|
|
||||||
columnFilter: {
|
|
||||||
event: {
|
|
||||||
remove: () => (companyId.value = null),
|
|
||||||
'update:modelValue': (newCompanyFk) => {
|
|
||||||
if (!newCompanyFk) return;
|
|
||||||
vnFilterRef.value.addFilter(newCompanyFk);
|
|
||||||
companyUser.value = newCompanyFk;
|
|
||||||
},
|
|
||||||
blur: () => !companyId.value && (companyId.value = companyUser.value),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
visible: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
{
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
@ -124,18 +94,8 @@ onMounted(async () => {
|
||||||
companyId: companyId.value ?? companyUser.value,
|
companyId: companyId.value ?? companyUser.value,
|
||||||
isConciliated: false,
|
isConciliated: false,
|
||||||
});
|
});
|
||||||
await getRisks();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
async function getRisks() {
|
|
||||||
const filter = {
|
|
||||||
where: { supplierFk: route.params.id, companyFk: companyUser.value },
|
|
||||||
};
|
|
||||||
const { data } = await getSupplierRisk(filter);
|
|
||||||
supplierRisk.value = data;
|
|
||||||
return supplierRisk.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setFooter(data) {
|
function setFooter(data) {
|
||||||
const initialFooter = {
|
const initialFooter = {
|
||||||
invoiceEuros: 0,
|
invoiceEuros: 0,
|
||||||
|
@ -156,28 +116,6 @@ function round(value) {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnSubToolbar class="q-mb-md">
|
|
||||||
<template #st-data>
|
|
||||||
<div class="column justify-center q-px-md q-py-sm">
|
|
||||||
<span class="text-bold">{{ t('Total by company') }}</span>
|
|
||||||
<div class="row justify-center" v-if="supplierRisk?.length">
|
|
||||||
{{ supplierRisk[0].company.code }}:
|
|
||||||
{{ toCurrency(supplierRisk[0].amount) }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<template #st-actions>
|
|
||||||
<div>
|
|
||||||
<VnFilter
|
|
||||||
ref="vnFilterRef"
|
|
||||||
v-model="companyId"
|
|
||||||
data-key="SupplierBalance"
|
|
||||||
:column="companyFilterColumn"
|
|
||||||
search-url="balance"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</VnSubToolbar>
|
|
||||||
<QDrawer side="right" :width="265" v-model="stateStore.rightDrawer">
|
<QDrawer side="right" :width="265" v-model="stateStore.rightDrawer">
|
||||||
<SupplierBalanceFilter data-key="SupplierBalance" />
|
<SupplierBalanceFilter data-key="SupplierBalance" />
|
||||||
</QDrawer>
|
</QDrawer>
|
||||||
|
|
|
@ -1,344 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { onBeforeMount, reactive, ref } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import { useRoute } from 'vue-router';
|
|
||||||
import { getSupplierRisk } from 'src/composables/getRisk';
|
|
||||||
import { useDialogPluginComponent } from 'quasar';
|
|
||||||
|
|
||||||
import { usePrintService } from 'composables/usePrintService';
|
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
|
||||||
import FormModelPopup from 'components/FormModelPopup.vue';
|
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
|
||||||
import VnInputDate from 'components/common/VnInputDate.vue';
|
|
||||||
import VnInputNumber from 'components/common/VnInputNumber.vue';
|
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
|
||||||
const route = useRoute();
|
|
||||||
const { notify } = useNotify();
|
|
||||||
const { sendEmail, openReport } = usePrintService();
|
|
||||||
const { dialogRef } = useDialogPluginComponent();
|
|
||||||
|
|
||||||
const $props = defineProps({
|
|
||||||
companyId: {
|
|
||||||
type: Number,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
bankId: {
|
|
||||||
type: Number,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
totalCredit: {
|
|
||||||
type: Number,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
promise: {
|
|
||||||
type: Function,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
extraFields: {
|
|
||||||
type: [String],
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const currenciesOptions = ref([]);
|
|
||||||
const closeButton = ref(null);
|
|
||||||
const urlCreate = ref([]);
|
|
||||||
const companyOptions = ref([]);
|
|
||||||
const bankOptions = ref([]);
|
|
||||||
const recordFindOne = ref([]);
|
|
||||||
const viewReceipt = ref();
|
|
||||||
const shouldSendEmail = ref(false);
|
|
||||||
const maxAmount = ref();
|
|
||||||
const accountingType = ref({});
|
|
||||||
const isCash = ref(false);
|
|
||||||
const formModelRef = ref(false);
|
|
||||||
|
|
||||||
const filterBanks = {
|
|
||||||
fields: ['id', 'bank', 'accountingTypeFk'],
|
|
||||||
include: { relation: 'accountingType' },
|
|
||||||
order: 'id',
|
|
||||||
limit: 30,
|
|
||||||
};
|
|
||||||
|
|
||||||
const filterRecordFindOne = {
|
|
||||||
fields: [],
|
|
||||||
where: {
|
|
||||||
id: route.params.id,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const initialData = reactive({
|
|
||||||
received: '2001-01-01T11:00:00.000Z',
|
|
||||||
supplierFk: '1',
|
|
||||||
amount: 123123,
|
|
||||||
currencyFk: 1,
|
|
||||||
bankFk: 3,
|
|
||||||
concept: 'Credit Card, ',
|
|
||||||
amountToReturn: null,
|
|
||||||
orderBy: 'issued',
|
|
||||||
payMethodFk: 1,
|
|
||||||
bankingFees: 0,
|
|
||||||
companyFk: 442,
|
|
||||||
divisa: null,
|
|
||||||
});
|
|
||||||
|
|
||||||
onBeforeMount(() => {
|
|
||||||
urlCreate.value = `Suppliers/${route.params.id}/createPayment`;
|
|
||||||
});
|
|
||||||
|
|
||||||
function setPaymentType(accounting) {
|
|
||||||
if (!accounting) return;
|
|
||||||
accountingType.value = accounting.accountingType;
|
|
||||||
|
|
||||||
initialData.concept = [];
|
|
||||||
initialData.received = Date.vnNew();
|
|
||||||
isCash.value = accountingType.value.code == 'cash';
|
|
||||||
viewReceipt.value = isCash.value;
|
|
||||||
if (accountingType.value.daysInFuture)
|
|
||||||
initialData.received.setDate(
|
|
||||||
initialData.received.getDate() + accountingType.value.daysInFuture
|
|
||||||
);
|
|
||||||
maxAmount.value = accountingType.value && accountingType.value.maxAmount;
|
|
||||||
|
|
||||||
if (accountingType.value.code == 'compensation') return (initialData.concept = '');
|
|
||||||
if (accountingType.value.receiptconcept)
|
|
||||||
initialData.concept.push(accountingType.value.receiptconcept);
|
|
||||||
if (initialData.concept) initialData.concept.push(initialData.concept);
|
|
||||||
|
|
||||||
initialData.concept = initialData.concept.join(', ');
|
|
||||||
}
|
|
||||||
|
|
||||||
const calculateFromAmount = (event) => {
|
|
||||||
initialData.amountToReturn =
|
|
||||||
parseFloat(initialData.deliveredAmount) + parseFloat(event) * -1;
|
|
||||||
};
|
|
||||||
|
|
||||||
const calculateFromDeliveredAmount = (event) => {
|
|
||||||
initialData.amountToReturn = parseFloat(event) - initialData.amount;
|
|
||||||
};
|
|
||||||
|
|
||||||
function onBeforeSave(data) {
|
|
||||||
const exceededAmount = data.amount > maxAmount.value;
|
|
||||||
if (isCash.value && exceededAmount)
|
|
||||||
return notify(t('Amount exceeded', { maxAmount: maxAmount.value }), 'negative');
|
|
||||||
|
|
||||||
if (isCash.value && shouldSendEmail.value && !data.email)
|
|
||||||
return notify(t(`There is no assigned email for this supplier`), 'negative');
|
|
||||||
|
|
||||||
data.dueDate = data.received;
|
|
||||||
data.bankFk = data.bankFk.id;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onDataSaved(formData, { id }) {
|
|
||||||
try {
|
|
||||||
if (shouldSendEmail.value && isCash.value)
|
|
||||||
await sendEmail(`Receipts/${id}/receipt-email`, {
|
|
||||||
recipient: formData.email,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (viewReceipt.value) openReport(`Receipts/${id}/receipt-pdf`);
|
|
||||||
} finally {
|
|
||||||
if ($props.promise) $props.promise();
|
|
||||||
if (closeButton.value) closeButton.value.click();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getAmount() {
|
|
||||||
const filter = {
|
|
||||||
where: {
|
|
||||||
supplierFk: route.params.id,
|
|
||||||
companyFk: initialData.companyFk,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const { data } = await getSupplierRisk(filter);
|
|
||||||
initialData.amount = (data?.length && data[0].amount) || undefined;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<QDialog ref="dialogRef" persistent>
|
|
||||||
<FetchData
|
|
||||||
@on-fetch="(data) => (companyOptions = data)"
|
|
||||||
auto-load
|
|
||||||
url="Companies"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FetchData
|
|
||||||
:filter="filterRecordFindOne"
|
|
||||||
url="Suppliers/findOne"
|
|
||||||
auto-load
|
|
||||||
@on-fetch="({ email }) => (initialData.email = email)"
|
|
||||||
/>
|
|
||||||
<FetchData
|
|
||||||
url="Currencies"
|
|
||||||
:filter="{ fields: ['id', 'name'] }"
|
|
||||||
order="code"
|
|
||||||
@on-fetch="(data) => (currenciesOptions = data)"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<FormModelPopup
|
|
||||||
ref="formModelRef"
|
|
||||||
:form-initial-data="initialData"
|
|
||||||
:observe-form-changes="false"
|
|
||||||
:url-create="urlCreate"
|
|
||||||
:mapper="onBeforeSave"
|
|
||||||
@on-data-saved="onDataSaved"
|
|
||||||
>
|
|
||||||
<template #form-inputs="{ data, validate }">
|
|
||||||
<span ref="closeButton" class="row justify-end close-icon" v-close-popup>
|
|
||||||
<QIcon name="close" size="sm" />
|
|
||||||
</span>
|
|
||||||
{{ data }}
|
|
||||||
<h5 class="q-mt-none">{{ t('New payment') }}</h5>
|
|
||||||
<VnRow>
|
|
||||||
<VnInputDate
|
|
||||||
:label="t('Date')"
|
|
||||||
:required="true"
|
|
||||||
v-model="data.received"
|
|
||||||
/>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('Company')"
|
|
||||||
:options="companyOptions"
|
|
||||||
:required="true"
|
|
||||||
:rules="validate('entry.companyFk')"
|
|
||||||
hide-selected
|
|
||||||
option-label="code"
|
|
||||||
option-value="id"
|
|
||||||
v-model="data.companyFk"
|
|
||||||
@update:model-value="getAmount()"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
<VnRow>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('Bank')"
|
|
||||||
v-model="data.bankFk"
|
|
||||||
url="Accountings"
|
|
||||||
option-label="bank"
|
|
||||||
:include="{ relation: 'accountingType' }"
|
|
||||||
sort-by="id"
|
|
||||||
:limit="0"
|
|
||||||
@update:model-value="
|
|
||||||
(value, options) => setPaymentType(value, options)
|
|
||||||
"
|
|
||||||
:emit-value="false"
|
|
||||||
>
|
|
||||||
<template #option="scope">
|
|
||||||
<QItem v-bind="scope.itemProps">
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel>
|
|
||||||
{{ scope.opt.id }}: {{ scope.opt.bank }}
|
|
||||||
</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
</VnSelect>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('supplier.billingData.payMethodFk')"
|
|
||||||
v-model="data.payMethodFk"
|
|
||||||
url="Paymethods"
|
|
||||||
auto-load
|
|
||||||
option-value="id"
|
|
||||||
option-label="name"
|
|
||||||
hide-selected
|
|
||||||
:rules="validate('supplier.payMethodFk')"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
|
|
||||||
<VnInputNumber
|
|
||||||
:label="t('Amount')"
|
|
||||||
:required="true"
|
|
||||||
@update:model-value="calculateFromAmount($event)"
|
|
||||||
clearable
|
|
||||||
v-model.number="data.amount"
|
|
||||||
/>
|
|
||||||
<VnInput
|
|
||||||
:label="t('Reference')"
|
|
||||||
:required="true"
|
|
||||||
clearable
|
|
||||||
v-model="data.concept"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div v-if="data.bankFk?.accountingType?.code == 'cash'">
|
|
||||||
<div class="text-h6">{{ t('Cash') }}</div>
|
|
||||||
<VnRow>
|
|
||||||
<VnInputNumber
|
|
||||||
:label="t('Delivered amount')"
|
|
||||||
@update:model-value="calculateFromDeliveredAmount($event)"
|
|
||||||
clearable
|
|
||||||
v-model="data.deliveredAmount"
|
|
||||||
/>
|
|
||||||
<VnInputNumber
|
|
||||||
:label="t('Amount to return')"
|
|
||||||
disable
|
|
||||||
v-model="data.amountToReturn"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
<VnRow>
|
|
||||||
<QCheckbox v-model="viewReceipt" :label="t('View recipt')" />
|
|
||||||
<QCheckbox v-model="shouldSendEmail" :label="t('Send email')" />
|
|
||||||
</VnRow>
|
|
||||||
</div>
|
|
||||||
<VnRow>
|
|
||||||
<VnSelect
|
|
||||||
v-if="$props.extraFields.includes('orderBy')"
|
|
||||||
:label="t('Type')"
|
|
||||||
v-model="data.orderBy"
|
|
||||||
:options="[
|
|
||||||
{ id: 'issued', name: 'Fecha de expedición' },
|
|
||||||
{ id: 'bookEntried', name: 'Fecha de asiento' },
|
|
||||||
{ id: 'booked', name: 'Fecha contable' },
|
|
||||||
{ id: 'dueDate', name: 'Fecha de vencimiento' },
|
|
||||||
]"
|
|
||||||
option-value="id"
|
|
||||||
option-label="name"
|
|
||||||
hide-selected
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
<VnRow class="row">
|
|
||||||
<VnSelect
|
|
||||||
v-if="$props.extraFields.includes('currencyFk')"
|
|
||||||
:label="t('Currency')"
|
|
||||||
v-model="data.currencyFk"
|
|
||||||
:options="currenciesOptions"
|
|
||||||
option-value="id"
|
|
||||||
option-label="name"
|
|
||||||
hide-selected
|
|
||||||
/>
|
|
||||||
<VnInputNumber
|
|
||||||
v-if="data.currencyFk !== 1"
|
|
||||||
:label="t('Divisa')"
|
|
||||||
v-model="data.divisa"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
</template>
|
|
||||||
</FormModelPopup>
|
|
||||||
</QDialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
New payment: Añadir pago
|
|
||||||
Date: Fecha
|
|
||||||
Company: Empresa
|
|
||||||
Bank: Caja
|
|
||||||
Amount: Importe
|
|
||||||
Reference: Referencia
|
|
||||||
Cash: Efectivo
|
|
||||||
currencyFk: Moneda
|
|
||||||
Type: Tipo
|
|
||||||
Delivered amount: Cantidad entregada
|
|
||||||
Amount to return: Cantidad a devolver
|
|
||||||
View recipt: Ver recibido
|
|
||||||
Send email: Enviar correo
|
|
||||||
Compensation: Compensación
|
|
||||||
Compensation account: Cuenta para compensar
|
|
||||||
Supplier Compensation Reference: ({supplierId}) Ntro Proveedor {supplierName}
|
|
||||||
Client Compensation Reference: ({clientId}) Ntro Cliente {clientName}
|
|
||||||
There is no assigned email for this client: No hay correo asignado para este cliente
|
|
||||||
Amount exceeded: Según ley contra el fraude no se puede recibir cobros por importe igual o superior a {maxAmount}
|
|
||||||
</i18n>
|
|
Loading…
Reference in New Issue