feat: refs #7134 #7134 split newPayment

This commit is contained in:
Javier Segarra 2024-11-11 14:22:18 +01:00
parent da99d82504
commit 7b8093c048
2 changed files with 70 additions and 19 deletions

View File

@ -18,7 +18,7 @@ import VnInput from 'components/common/VnInput.vue';
import VnSubToolbar from 'components/ui/VnSubToolbar.vue';
import VnFilter from 'components/VnTable/VnFilter.vue';
import CreateNewPayment from 'src/components/CreateNewPayment.vue';
import SupplierNewPayment from 'src/pages/Supplier/Card/SupplierNewPayment.vue';
import InvoiceOutDescriptorProxy from 'src/pages/InvoiceOut/Card/InvoiceOutDescriptorProxy.vue';
const { openConfirmationModal } = useVnConfirm();
@ -36,6 +36,7 @@ const supplierRisk = ref([]);
const tableRef = ref();
const companyId = ref();
const companyUser = ref(user.value.companyFk);
const bankUser = ref(user.value.localBankFk);
const balances = ref([]);
const vnFilterRef = ref({});
const filter = computed(() => {
@ -200,11 +201,14 @@ async function onFetch(data) {
}
const showNewPaymentDialog = () => {
debugger;
quasar.dialog({
component: CreateNewPayment,
component: SupplierNewPayment,
componentProps: {
companyId: companyId.value,
bankId: bankUser.value,
totalCredit: supplierRisk.value[0]?.amount,
extraFields: ['currencyFk', 'orderBy'],
promise: () => tableRef.value.reload(),
},
});
@ -241,7 +245,7 @@ const showBalancePdf = ({ id }) => {
<VnTable
ref="tableRef"
data-key="CustomerBalance"
url="Receipts/filter"
url="Suppliers/receipts"
search-url="balance"
:user-params="filter"
:columns="columns"
@ -305,6 +309,8 @@ es:
Company: Empresa
Total by company: Total por empresa
New payment: Añadir pago
supplierNewpayment: Añadir pago de proveedor
clientNewpayment: Añadir pago de cliente
Date: Fecha
Creation date: Fecha de creación
Employee: Empleado

View File

@ -3,7 +3,7 @@ import { onBeforeMount, reactive, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import axios from 'axios';
import { getClientRisk } from 'src/composables/getRisk';
import { getSupplierRisk } from 'src/composables/getRisk';
import { useDialogPluginComponent } from 'quasar';
import { usePrintService } from 'composables/usePrintService';
@ -27,6 +27,10 @@ const $props = defineProps({
type: Number,
required: true,
},
bankId: {
type: Number,
required: true,
},
totalCredit: {
type: Number,
required: true,
@ -35,13 +39,18 @@ const $props = defineProps({
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 clientFindOne = ref([]);
const recordFindOne = ref([]);
const viewReceipt = ref();
const shouldSendEmail = ref(false);
const maxAmount = ref();
@ -56,8 +65,8 @@ const filterBanks = {
limit: 30,
};
const filterClientFindOne = {
fields: ['email'],
const filterRecordFindOne = {
fields: [],
where: {
id: route.params.id,
},
@ -65,13 +74,15 @@ const filterClientFindOne = {
const initialData = reactive({
amountPaid: $props.totalCredit,
clientFk: route.params.id,
supplierFk: route.params.id,
companyFk: $props.companyId,
email: clientFindOne.value.email,
bankFk: $props.bankId,
email: recordFindOne.value.email,
currencyFk: 1,
});
onBeforeMount(() => {
urlCreate.value = `Clients/${route.params.id}/createReceipt`;
urlCreate.value = `Suppliers/${route.params.id}/createReceipt`;
});
function setPaymentType(accounting) {
@ -112,7 +123,7 @@ function onBeforeSave(data) {
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 client'), 'negative');
return notify(t(`There is no assigned email for this supplier`), 'negative');
data.bankFk = data.bankFk.id;
return data;
@ -153,12 +164,11 @@ async function accountShortToStandard({ target: { value } }) {
async function getAmountPaid() {
const filter = {
where: {
clientFk: route.params.id,
supplierFk: route.params.id,
companyFk: initialData.companyFk,
},
};
const { data } = await getClientRisk(filter);
const { data } = await getSupplierRisk(filter);
initialData.amountPaid = (data?.length && data[0].amount) || undefined;
}
</script>
@ -177,10 +187,17 @@ async function getAmountPaid() {
url="Accountings"
/>
<FetchData
:filter="filterClientFindOne"
@on-fetch="({ email }) => (initialData.email = email)"
: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
url="Clients/findOne"
/>
<FormModel
ref="formModelRef"
@ -194,9 +211,8 @@ async function getAmountPaid() {
<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')"
@ -287,6 +303,33 @@ async function getAmountPaid() {
<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="['issued', ' bookEntried', ' booked', ' dueDate']"
option-value="id"
option-label="name"
hide-selected
/>
</VnRow>
<VnRow class="row">
<VnSelect
v-if="$props.extraFields.includes('currencyFk')"
:label="t('currencyFk')"
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>
<div class="q-mt-lg row justify-end">
<QBtn
:disabled="formModelRef.isLoading"
@ -320,6 +363,8 @@ es:
Amount: Importe
Reference: Referencia
Cash: Efectivo
currencyFk: Moneda
Type: Tipo
Delivered amount: Cantidad entregada
Amount to return: Cantidad a devolver
View recipt: Ver recibido