Merge pull request '#8667: Modified ClientPayment' (!1622) from 8667-FixClientNewPayment into dev
gitea/salix-front/pipeline/head This commit looks good Details

Reviewed-on: #1622
Reviewed-by: Javier Segarra <jsegarra@verdnatura.es>
This commit is contained in:
Javier Segarra 2025-03-31 08:17:33 +00:00
commit 8c75ec41d8
2 changed files with 26 additions and 27 deletions

View File

@ -20,6 +20,7 @@ import VnFilter from 'components/VnTable/VnFilter.vue';
import CustomerNewPayment from 'src/pages/Customer/components/CustomerNewPayment.vue';
import InvoiceOutDescriptorProxy from 'src/pages/InvoiceOut/Card/InvoiceOutDescriptorProxy.vue';
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
const { openConfirmationModal } = useVnConfirm();
const { sendEmail, openReport } = usePrintService();
@ -89,15 +90,7 @@ const columns = computed(() => [
{
align: 'left',
label: t('Employee'),
columnField: {
component: 'userLink',
attrs: ({ row }) => {
return {
workerId: row.workerFk,
name: row.userName,
};
},
},
name: 'workerFk',
cardVisible: true,
},
{
@ -131,7 +124,6 @@ const columns = computed(() => [
align: 'left',
name: 'balance',
label: t('Balance'),
format: ({ balance }) => toCurrency(balance),
cardVisible: true,
},
{
@ -146,12 +138,14 @@ const columns = computed(() => [
actions: [
{
title: t('globals.downloadPdf'),
isPrimary: true,
icon: 'cloud_download',
show: (row) => row.isInvoice,
action: (row) => showBalancePdf(row),
},
{
title: t('Send compensation'),
isPrimary: true,
icon: 'outgoing_mail',
show: (row) => !!row.isCompensation,
action: ({ id }) =>
@ -256,6 +250,12 @@ const showBalancePdf = ({ id }) => {
<template #column-balance="{ rowIndex }">
{{ toCurrency(balances[rowIndex]?.balance) }}
</template>
<template #column-workerFk="{ row }">
<span class="link" @click.stop>
{{ row.userName }}
<WorkerDescriptorProxy :id="row.workerFk" />
</span>
</template>
<template #column-description="{ row }">
<span class="link" v-if="row.isInvoice" @click.stop>
{{ t('bill', { ref: row.description }) }}

View File

@ -3,18 +3,20 @@ import { onBeforeMount, reactive, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import axios from 'axios';
import { getClientRisk } from '../composables/getClientRisk';
import { useDialogPluginComponent } from 'quasar';
import FormModelPopup from 'components/FormModelPopup.vue';
import { getClientRisk } from '../composables/getClientRisk';
import { usePrintService } from 'composables/usePrintService';
import useNotify from 'src/composables/useNotify.js';
import FormModelPopup from 'components/FormModelPopup.vue';
import FetchData from 'components/FetchData.vue';
import FormModel from 'components/FormModel.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';
import VnAccountNumber from 'src/components/common/VnAccountNumber.vue';
const { t } = useI18n();
const route = useRoute();
@ -48,7 +50,7 @@ const maxAmount = ref();
const accountingType = ref({});
const isCash = ref(false);
const formModelRef = ref(false);
const amountToReturn = ref();
const filterBanks = {
fields: ['id', 'bank', 'accountingTypeFk'],
include: { relation: 'accountingType' },
@ -90,7 +92,7 @@ function setPaymentType(data, accounting) {
let descriptions = [];
if (accountingType.value.receiptDescription)
descriptions.push(accountingType.value.receiptDescription);
if (data.description) descriptions.push(data.description);
if (data.description > 0) descriptions.push(data.description);
data.description = descriptions.join(', ');
}
@ -100,7 +102,7 @@ const calculateFromAmount = (event) => {
};
const calculateFromDeliveredAmount = (event) => {
initialData.amountToReturn = parseFloat(event) - initialData.amountPaid;
amountToReturn.value = event - initialData.amountPaid;
};
function onBeforeSave(data) {
@ -121,17 +123,16 @@ async function onDataSaved(formData, { id }) {
recipient: formData.email,
});
if (viewReceipt.value) openReport(`Receipts/${id}/receipt-pdf`);
if (viewReceipt.value) openReport(`Receipts/${id}/receipt-pdf`, {}, '_blank');
} finally {
if ($props.promise) $props.promise();
if (closeButton.value) closeButton.value.click();
}
}
async function accountShortToStandard({ target: { value } }) {
async function getSupplierClientReferences(value) {
if (!value) return (initialData.description = '');
initialData.compensationAccount = value.replace('.', '0'.repeat(11 - value.length));
const params = { bankAccount: initialData.compensationAccount };
const params = { bankAccount: value };
const { data } = await axios(`Clients/getClientOrSupplierReference`, { params });
if (!data.clientId) {
initialData.description = t('Supplier Compensation Reference', {
@ -241,17 +242,16 @@ async function getAmountPaid() {
@update:model-value="getAmountPaid()"
/>
</VnRow>
<div v-if="data.bankFk?.accountingType?.code == 'compensation'">
<div v-if="accountingType.code == 'compensation'">
<div class="text-h6">
{{ t('Compensation') }}
</div>
<VnRow>
<VnInputNumber
<VnAccountNumber
:label="t('Compensation account')"
clearable
v-model="data.compensationAccount"
@blur="accountShortToStandard"
@blur="getSupplierClientReferences(data.compensationAccount)"
/>
</VnRow>
</div>
@ -261,8 +261,7 @@ async function getAmountPaid() {
clearable
v-model="data.description"
/>
<div v-if="data.bankFk?.accountingType?.code == 'cash'">
<div v-if="accountingType.code == 'cash'">
<div class="text-h6">{{ t('Cash') }}</div>
<VnRow>
<VnInputNumber
@ -274,7 +273,7 @@ async function getAmountPaid() {
<VnInputNumber
:label="t('Amount to return')"
disable
v-model="data.amountToReturn"
v-model="amountToReturn"
/>
</VnRow>
<VnRow>