forked from verdnatura/salix-front
Merge branch 'master' into Hotfix-CreateRequest
This commit is contained in:
commit
75c33dabf1
|
@ -38,7 +38,7 @@ const onDataSaved = (dataSaved) => {
|
||||||
@on-fetch="(data) => (warehousesOptions = data)"
|
@on-fetch="(data) => (warehousesOptions = data)"
|
||||||
auto-load
|
auto-load
|
||||||
url="Warehouses"
|
url="Warehouses"
|
||||||
:filter="{ fields: ['id', 'name'], order: 'name ASC', limit: 30 }"
|
:filter="{ fields: ['id', 'name'], order: 'name ASC' }"
|
||||||
/>
|
/>
|
||||||
<FetchData
|
<FetchData
|
||||||
@on-fetch="(data) => (temperaturesOptions = data)"
|
@on-fetch="(data) => (temperaturesOptions = data)"
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { useRoute } from 'vue-router';
|
||||||
import { useAcl } from 'src/composables/useAcl';
|
import { useAcl } from 'src/composables/useAcl';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import FetchData from 'components/FetchData.vue';
|
import { getClientRisk } from '../composables/getClientRisk';
|
||||||
|
|
||||||
import { toCurrency, toDate, toDateHourMin } from 'src/filters';
|
import { toCurrency, toDate, toDateHourMin } from 'src/filters';
|
||||||
import { useState } from 'composables/useState';
|
import { useState } from 'composables/useState';
|
||||||
|
@ -16,7 +16,7 @@ import { useVnConfirm } from 'composables/useVnConfirm';
|
||||||
import VnTable from 'components/VnTable/VnTable.vue';
|
import VnTable from 'components/VnTable/VnTable.vue';
|
||||||
import VnInput from 'components/common/VnInput.vue';
|
import VnInput from 'components/common/VnInput.vue';
|
||||||
import VnSubToolbar from 'components/ui/VnSubToolbar.vue';
|
import VnSubToolbar from 'components/ui/VnSubToolbar.vue';
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
import VnFilter from 'components/VnTable/VnFilter.vue';
|
||||||
|
|
||||||
import CustomerNewPayment from 'src/pages/Customer/components/CustomerNewPayment.vue';
|
import CustomerNewPayment from 'src/pages/Customer/components/CustomerNewPayment.vue';
|
||||||
import InvoiceOutDescriptorProxy from 'src/pages/InvoiceOut/Card/InvoiceOutDescriptorProxy.vue';
|
import InvoiceOutDescriptorProxy from 'src/pages/InvoiceOut/Card/InvoiceOutDescriptorProxy.vue';
|
||||||
|
@ -25,7 +25,7 @@ const { openConfirmationModal } = useVnConfirm();
|
||||||
const { sendEmail, openReport } = usePrintService();
|
const { sendEmail, openReport } = usePrintService();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { hasAny } = useAcl();
|
const { hasAny } = useAcl();
|
||||||
const currentBalance = ref({});
|
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const state = useState();
|
const state = useState();
|
||||||
|
@ -33,28 +33,53 @@ const stateStore = useStateStore();
|
||||||
const user = state.getUser();
|
const user = state.getUser();
|
||||||
|
|
||||||
const clientRisk = ref([]);
|
const clientRisk = ref([]);
|
||||||
const companies = ref([]);
|
|
||||||
const tableRef = ref();
|
const tableRef = ref();
|
||||||
const companyId = ref(user.value.companyFk);
|
const companyId = ref();
|
||||||
|
const companyUser = ref(user.value.companyFk);
|
||||||
const balances = ref([]);
|
const balances = ref([]);
|
||||||
const vnFilterRef = ref({});
|
const vnFilterRef = ref({});
|
||||||
const filter = computed(() => {
|
const filter = computed(() => {
|
||||||
return {
|
return {
|
||||||
clientId: route.params.id,
|
clientId: route.params.id,
|
||||||
companyId: companyId.value ?? user.value.companyFk,
|
companyId: companyId.value ?? companyUser.value,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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: 'right',
|
align: 'left',
|
||||||
name: 'payed',
|
name: 'payed',
|
||||||
label: t('Date'),
|
label: t('Date'),
|
||||||
format: ({ payed }) => toDate(payed),
|
format: ({ payed }) => toDate(payed),
|
||||||
cardVisible: true,
|
cardVisible: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
align: 'right',
|
align: 'left',
|
||||||
name: 'created',
|
name: 'created',
|
||||||
label: t('Creation date'),
|
label: t('Creation date'),
|
||||||
format: ({ created }) => toDateHourMin(created),
|
format: ({ created }) => toDateHourMin(created),
|
||||||
|
@ -65,7 +90,12 @@ const columns = computed(() => [
|
||||||
label: t('Employee'),
|
label: t('Employee'),
|
||||||
columnField: {
|
columnField: {
|
||||||
component: 'userLink',
|
component: 'userLink',
|
||||||
attrs: ({ row }) => ({ workerId: row.workerFk, name: row.userName }),
|
attrs: ({ row }) => {
|
||||||
|
return {
|
||||||
|
workerId: row.workerFk,
|
||||||
|
name: row.userName,
|
||||||
|
};
|
||||||
|
},
|
||||||
},
|
},
|
||||||
cardVisible: true,
|
cardVisible: true,
|
||||||
},
|
},
|
||||||
|
@ -77,13 +107,13 @@ const columns = computed(() => [
|
||||||
class: 'extend',
|
class: 'extend',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
align: 'right',
|
align: 'left',
|
||||||
name: 'bankFk',
|
name: 'bankFk',
|
||||||
label: t('Bank'),
|
label: t('Bank'),
|
||||||
cardVisible: true,
|
cardVisible: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
align: 'right',
|
align: 'left',
|
||||||
name: 'debit',
|
name: 'debit',
|
||||||
label: t('Debit'),
|
label: t('Debit'),
|
||||||
format: ({ debit }) => debit && toCurrency(debit),
|
format: ({ debit }) => debit && toCurrency(debit),
|
||||||
|
@ -136,20 +166,37 @@ const columns = computed(() => [
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
stateStore.rightDrawer = true;
|
stateStore.rightDrawer = true;
|
||||||
|
companyId.value = companyUser.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
async function getCurrentBalance(data) {
|
async function getClientRisks() {
|
||||||
currentBalance.value[companyId.value] = {
|
const filter = {
|
||||||
amount: 0,
|
where: { clientFk: route.params.id, companyFk: companyUser.value },
|
||||||
code: companies.value.find((c) => c.id === companyId.value)?.code,
|
|
||||||
};
|
};
|
||||||
|
const { data } = await getClientRisk(filter);
|
||||||
|
clientRisk.value = data;
|
||||||
|
return clientRisk.value;
|
||||||
|
}
|
||||||
|
|
||||||
for (const balance of data) {
|
async function getCurrentBalance() {
|
||||||
currentBalance.value[balance.companyFk] = {
|
const currentBalance = (await getClientRisks()).find((balance) => {
|
||||||
code: balance.company.code,
|
return balance.companyFk === companyId.value;
|
||||||
amount: balance.amount,
|
});
|
||||||
};
|
return currentBalance && currentBalance.amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onFetch(data) {
|
||||||
|
balances.value = [];
|
||||||
|
for (const [index, balance] of data.entries()) {
|
||||||
|
if (index === 0) {
|
||||||
|
balance.balance = await getCurrentBalance();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const previousBalance = data[index - 1];
|
||||||
|
balance.balance =
|
||||||
|
previousBalance?.balance - (previousBalance?.debit - previousBalance?.credit);
|
||||||
}
|
}
|
||||||
|
balances.value = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const showNewPaymentDialog = () => {
|
const showNewPaymentDialog = () => {
|
||||||
|
@ -169,43 +216,25 @@ const showBalancePdf = ({ id }) => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
|
||||||
url="Companies"
|
|
||||||
auto-load
|
|
||||||
@on-fetch="(data) => (companies = data)"
|
|
||||||
></FetchData>
|
|
||||||
<FetchData
|
|
||||||
v-if="companies.length > 0"
|
|
||||||
url="clientRisks"
|
|
||||||
:filter="{
|
|
||||||
include: { relation: 'company', scope: { fields: ['code'] } },
|
|
||||||
where: { clientFk: route.params.id },
|
|
||||||
}"
|
|
||||||
auto-load
|
|
||||||
@on-fetch="getCurrentBalance"
|
|
||||||
></FetchData>
|
|
||||||
|
|
||||||
<VnSubToolbar class="q-mb-md">
|
<VnSubToolbar class="q-mb-md">
|
||||||
<template #st-data>
|
<template #st-data>
|
||||||
<div class="column justify-center q-px-md q-py-sm">
|
<div class="column justify-center q-px-md q-py-sm">
|
||||||
<span class="text-bold">{{ t('Total by company') }}</span>
|
<span class="text-bold">{{ t('Total by company') }}</span>
|
||||||
<div class="row justify-center">
|
<div class="row justify-center" v-if="clientRisk?.length">
|
||||||
{{ currentBalance[companyId]?.code }}:
|
{{ clientRisk[0].company.code }}:
|
||||||
{{ toCurrency(currentBalance[companyId]?.amount) }}
|
{{ toCurrency(clientRisk[0].amount) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #st-actions>
|
<template #st-actions>
|
||||||
<div>
|
<div>
|
||||||
<VnSelect
|
<VnFilter
|
||||||
:label="t('Company')"
|
|
||||||
ref="vnFilterRef"
|
ref="vnFilterRef"
|
||||||
v-model="companyId"
|
v-model="companyId"
|
||||||
data-key="CustomerBalance"
|
data-key="CustomerBalance"
|
||||||
:options="companies"
|
:column="companyFilterColumn"
|
||||||
option-label="code"
|
search-url="balance"
|
||||||
option-value="id"
|
/>
|
||||||
></VnSelect>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</VnSubToolbar>
|
</VnSubToolbar>
|
||||||
|
@ -219,6 +248,7 @@ const showBalancePdf = ({ id }) => {
|
||||||
:right-search="false"
|
:right-search="false"
|
||||||
:is-editable="false"
|
:is-editable="false"
|
||||||
:column-search="false"
|
:column-search="false"
|
||||||
|
@on-fetch="onFetch"
|
||||||
:disable-option="{ card: true }"
|
:disable-option="{ card: true }"
|
||||||
auto-load
|
auto-load
|
||||||
>
|
>
|
||||||
|
|
|
@ -28,7 +28,7 @@ const showSmsDialog = () => {
|
||||||
quasar.dialog({
|
quasar.dialog({
|
||||||
component: VnSmsDialog,
|
component: VnSmsDialog,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
phone: $props.customer.phone || $props.customer.mobile,
|
phone: $props.customer.mobile || $props.customer.phone,
|
||||||
promise: sendSms,
|
promise: sendSms,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -184,6 +184,7 @@ const getItemPackagingType = (ticketSales) => {
|
||||||
:disable-option="{ card: true, table: true }"
|
:disable-option="{ card: true, table: true }"
|
||||||
class="full-width"
|
class="full-width"
|
||||||
:disable-infinite-scroll="true"
|
:disable-infinite-scroll="true"
|
||||||
|
redirect="ticket"
|
||||||
>
|
>
|
||||||
<template #column-nickname="{ row }">
|
<template #column-nickname="{ row }">
|
||||||
<span class="link">
|
<span class="link">
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
|
export async function getClientRisk(_filter) {
|
||||||
|
const filter = {
|
||||||
|
..._filter,
|
||||||
|
include: { relation: 'company', scope: { fields: ['code'] } },
|
||||||
|
};
|
||||||
|
|
||||||
|
return await axios(`ClientRisks`, {
|
||||||
|
params: { filter: JSON.stringify(filter) },
|
||||||
|
});
|
||||||
|
}
|
|
@ -99,7 +99,7 @@ const travelDialogRef = ref(false);
|
||||||
const tableRef = ref();
|
const tableRef = ref();
|
||||||
const travel = ref(null);
|
const travel = ref(null);
|
||||||
const userParams = ref({
|
const userParams = ref({
|
||||||
dated: Date.vnNew(),
|
dated: Date.vnNew().toJSON(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const filter = ref({
|
const filter = ref({
|
||||||
|
@ -219,6 +219,7 @@ function round(value) {
|
||||||
data-key="StockBoughts"
|
data-key="StockBoughts"
|
||||||
url="StockBoughts/getStockBought"
|
url="StockBoughts/getStockBought"
|
||||||
save-url="StockBoughts/crud"
|
save-url="StockBoughts/crud"
|
||||||
|
search-url="StockBoughts"
|
||||||
order="reserve DESC"
|
order="reserve DESC"
|
||||||
:right-search="false"
|
:right-search="false"
|
||||||
:is-editable="true"
|
:is-editable="true"
|
||||||
|
@ -281,6 +282,7 @@ function round(value) {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
min-width: 35%;
|
||||||
}
|
}
|
||||||
.text-negative {
|
.text-negative {
|
||||||
color: $negative !important;
|
color: $negative !important;
|
||||||
|
|
|
@ -18,7 +18,7 @@ const $props = defineProps({
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const customUrl = `StockBoughts/getStockBoughtDetail?workerFk=${$props.workerFk}&date=${$props.dated}`;
|
const customUrl = `StockBoughts/getStockBoughtDetail?workerFk=${$props.workerFk}&dated=${$props.dated}`;
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
|
|
@ -27,7 +27,7 @@ onMounted(async () => {
|
||||||
<VnFilterPanel
|
<VnFilterPanel
|
||||||
:data-key="props.dataKey"
|
:data-key="props.dataKey"
|
||||||
:search-button="true"
|
:search-button="true"
|
||||||
search-url="table"
|
search-url="StockBoughts"
|
||||||
@set-user-params="setUserParams"
|
@set-user-params="setUserParams"
|
||||||
>
|
>
|
||||||
<template #tags="{ tag, formatFn }">
|
<template #tags="{ tag, formatFn }">
|
||||||
|
@ -36,12 +36,19 @@ onMounted(async () => {
|
||||||
<span>{{ formatFn(tag.value) }}</span>
|
<span>{{ formatFn(tag.value) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #body="{ params }">
|
<template #body="{ params, searchFn }">
|
||||||
<QItem class="q-my-sm">
|
<QItem class="q-my-sm">
|
||||||
<QItemSection>
|
<QItemSection>
|
||||||
<VnInputDate
|
<VnInputDate
|
||||||
id="date"
|
id="date"
|
||||||
v-model="params.dated"
|
v-model="params.dated"
|
||||||
|
@update:model-value="
|
||||||
|
(value) => {
|
||||||
|
params.dated = value;
|
||||||
|
setUserParams(params);
|
||||||
|
searchFn();
|
||||||
|
}
|
||||||
|
"
|
||||||
:label="t('Date')"
|
:label="t('Date')"
|
||||||
is-outlined
|
is-outlined
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -207,6 +207,7 @@ const onThermographCreated = async (data) => {
|
||||||
option-label="thermographFk"
|
option-label="thermographFk"
|
||||||
:disable="viewAction === 'edit'"
|
:disable="viewAction === 'edit'"
|
||||||
:tooltip="t('New thermograph')"
|
:tooltip="t('New thermograph')"
|
||||||
|
:roles-allowed-to-create="['logistic']"
|
||||||
>
|
>
|
||||||
<template #form>
|
<template #form>
|
||||||
<CreateThermographForm
|
<CreateThermographForm
|
||||||
|
|
|
@ -96,7 +96,7 @@ watch(
|
||||||
sort-by="code, townFk"
|
sort-by="code, townFk"
|
||||||
option-value="geoFk"
|
option-value="geoFk"
|
||||||
option-label="code"
|
option-label="code"
|
||||||
:filter-options="['code', 'geoFk']"
|
:filter-options="['code']"
|
||||||
hide-selected
|
hide-selected
|
||||||
dense
|
dense
|
||||||
outlined
|
outlined
|
||||||
|
@ -105,11 +105,14 @@ watch(
|
||||||
<template #option="{ itemProps, opt }">
|
<template #option="{ itemProps, opt }">
|
||||||
<QItem v-bind="itemProps">
|
<QItem v-bind="itemProps">
|
||||||
<QItemSection v-if="opt.code">
|
<QItemSection v-if="opt.code">
|
||||||
<QItemLabel>{{ opt.code }}</QItemLabel>
|
<QItemLabel>
|
||||||
<QItemLabel caption
|
{{ `${opt.code}, ${opt.town?.name}` }}
|
||||||
>{{ opt.town?.province?.name }},
|
</QItemLabel>
|
||||||
{{ opt.town?.province?.country?.name }}</QItemLabel
|
<QItemLabel caption>
|
||||||
>
|
{{
|
||||||
|
`${opt.town?.province?.name}, ${opt.town?.province?.country?.name}`
|
||||||
|
}}
|
||||||
|
</QItemLabel>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -22,7 +22,12 @@ const agencies = ref([]);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FetchData url="agencies" @on-fetch="(data) => (agencies = data)" auto-load />
|
<FetchData
|
||||||
|
url="AgencyModes"
|
||||||
|
:filter="{ fields: ['id', 'name'] }"
|
||||||
|
@on-fetch="(data) => (agencies = data)"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
<VnFilterPanel
|
<VnFilterPanel
|
||||||
:data-key="props.dataKey"
|
:data-key="props.dataKey"
|
||||||
:search-button="true"
|
:search-button="true"
|
||||||
|
|
|
@ -73,6 +73,7 @@ const columns = computed(() => [
|
||||||
inWhere: true,
|
inWhere: true,
|
||||||
attrs: {
|
attrs: {
|
||||||
url: 'AgencyModes',
|
url: 'AgencyModes',
|
||||||
|
fields: ['id', 'name'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
columnField: {
|
columnField: {
|
||||||
|
|
Loading…
Reference in New Issue