refactor: migrate ConfirmView to Salix
gitea/hedera-web/pipeline/pr-beta This commit looks good
Details
gitea/hedera-web/pipeline/pr-beta This commit looks good
Details
This commit is contained in:
parent
9c0ec3e29d
commit
6d8432f095
|
@ -10,9 +10,10 @@ import useNotify from 'src/composables/useNotify.js';
|
||||||
import { currency } from 'src/lib/filters.js';
|
import { currency } from 'src/lib/filters.js';
|
||||||
import { tpvStore } from 'stores/tpv';
|
import { tpvStore } from 'stores/tpv';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
|
import { onUserId } from 'src/utils/onUserId';
|
||||||
|
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const jApi = inject('jApi');
|
const api = inject('api');
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
|
@ -75,35 +76,89 @@ const paymentOptionsArray = computed(() => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const getOrder = async () => {
|
const getOrder = async (clientFk) => {
|
||||||
try {
|
try {
|
||||||
const { results } = await jApi.execQuery(
|
const { data: { credit: userCredit } } = await api.get(
|
||||||
`CALL myOrder_getTax(#id);
|
`clients/${clientFk}`,
|
||||||
SELECT o.id, o.sent, o.notes, o.companyFk,
|
{
|
||||||
ag.description agency, v.code method,
|
params: {
|
||||||
ad.nickname, ad.postalCode, ad.city, ad.street,
|
filter: {
|
||||||
t.*, c.credit, myClient_getDebt(NULL) debt
|
fields: ['credit'],
|
||||||
FROM myOrder o
|
}
|
||||||
JOIN vn.agencyMode ag ON ag.id = o.agencyModeFk
|
}
|
||||||
LEFT JOIN myAddress ad ON ad.id = o.addressFk
|
}
|
||||||
JOIN vn.deliveryMethod v ON v.id = o.deliveryMethodFk
|
|
||||||
JOIN myClient c
|
|
||||||
JOIN (
|
|
||||||
SELECT
|
|
||||||
IFNULL(SUM(taxableBase), 0) taxableBase,
|
|
||||||
IFNULL(SUM(tax), 0) tax
|
|
||||||
FROM tmp.orderAmount
|
|
||||||
) t
|
|
||||||
WHERE o.id = #id;
|
|
||||||
DROP TEMPORARY TABLE
|
|
||||||
tmp.orderAmount,
|
|
||||||
tmp.orderTax;`,
|
|
||||||
{ id: orderId.value }
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const orderData = results[1]?.data[0];
|
const { data: orderTaxes } = await api.get(`Orders/${orderId.value}/getTaxes`);
|
||||||
|
|
||||||
|
const filter = {
|
||||||
|
where: {
|
||||||
|
clientFk,
|
||||||
|
isConfirmed: false,
|
||||||
|
source_app: 'WEB',
|
||||||
|
},
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
relation: 'address',
|
||||||
|
scope: {
|
||||||
|
fields: ['nickname', 'city', 'postalCode', 'street'],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
relation: 'agencyMode',
|
||||||
|
scope: {
|
||||||
|
fields: ['description'],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
relation: 'deliveryMethod',
|
||||||
|
scope: {
|
||||||
|
fields: ['code'],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
fields: [
|
||||||
|
'id',
|
||||||
|
'landed',
|
||||||
|
'delivery_method_id',
|
||||||
|
'taxableBase',
|
||||||
|
'addressFk',
|
||||||
|
'agencyModeFk',
|
||||||
|
'companyFk',
|
||||||
|
'note',
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
const { data: salixOrder } = await api.get(`Orders/${orderId.value}`, {
|
||||||
|
params: {
|
||||||
|
filter: JSON.stringify(filter)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const { data: salixDebt } = await api.post(
|
||||||
|
'applications/myClient_getDebt/execute-func',
|
||||||
|
{
|
||||||
|
schema: 'hedera',
|
||||||
|
params: ['NULL'],
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const orderData = {
|
||||||
|
id: salixOrder.id,
|
||||||
|
notes: salixOrder.note,
|
||||||
|
companyFk: salixOrder.companyFk,
|
||||||
|
agency: salixOrder.agencyMode.description,
|
||||||
|
method: salixOrder.deliveryMethod.code,
|
||||||
|
nickname: salixOrder.address.nickname,
|
||||||
|
postalCode: salixOrder.address.postalCode,
|
||||||
|
city: salixOrder.address.city,
|
||||||
|
street: salixOrder.address.street,
|
||||||
|
taxableBase: orderTaxes[0].taxableBase,
|
||||||
|
tax: orderTaxes[0].tax,
|
||||||
|
credit: userCredit,
|
||||||
|
debt: salixDebt,
|
||||||
|
};
|
||||||
|
|
||||||
const { sent, ...restOfData } = orderData;
|
|
||||||
const total = orderData.taxableBase + orderData.tax || 0;
|
const total = orderData.taxableBase + orderData.tax || 0;
|
||||||
const totalDebt = orderData.debt + total;
|
const totalDebt = orderData.debt + total;
|
||||||
exceededCredit.value = totalDebt - orderData.credit;
|
exceededCredit.value = totalDebt - orderData.credit;
|
||||||
|
@ -118,10 +173,10 @@ const getOrder = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const formattedData = {
|
const formattedData = {
|
||||||
landed: new Date(sent),
|
landed: new Date(salixOrder.landed),
|
||||||
total,
|
total,
|
||||||
debt: orderData.debt || 0,
|
debt: orderData.debt || 0,
|
||||||
...restOfData
|
...orderData
|
||||||
};
|
};
|
||||||
order.value = formattedData;
|
order.value = formattedData;
|
||||||
|
|
||||||
|
@ -151,15 +206,21 @@ const getOrder = async () => {
|
||||||
|
|
||||||
const getTransferAccounts = async () => {
|
const getTransferAccounts = async () => {
|
||||||
try {
|
try {
|
||||||
const data = await jApi.query(`SELECT name, iban FROM mainAccountBank`);
|
const filter = {
|
||||||
transferAccounts.value = data;
|
include: [
|
||||||
|
{ relation: 'account', scope: { include: [ 'bankEntity' ]} } ,
|
||||||
|
],
|
||||||
|
};
|
||||||
|
const { data: mainAccountData } = await api.get('MainAccounts', {
|
||||||
|
params: { filter: JSON.stringify(filter) },
|
||||||
|
});
|
||||||
|
transferAccounts.value = mainAccountData;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
await getOrder();
|
|
||||||
await getTransferAccounts();
|
await getTransferAccounts();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -170,9 +231,15 @@ const modifyOrder = () => {
|
||||||
const confirmOrder = async () => {
|
const confirmOrder = async () => {
|
||||||
try {
|
try {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
await jApi.execQuery('CALL myOrder_confirm(#id)', {
|
await api.post(
|
||||||
id: orderId.value
|
'applications/myOrder_confirm/execute-proc',
|
||||||
});
|
{
|
||||||
|
schema: 'hedera',
|
||||||
|
params: [
|
||||||
|
orderId.value,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
);
|
||||||
appStore.unloadOrder();
|
appStore.unloadOrder();
|
||||||
$q.dialog({
|
$q.dialog({
|
||||||
message: t('orderConfirmed'),
|
message: t('orderConfirmed'),
|
||||||
|
@ -206,6 +273,9 @@ onBeforeMount(() => {
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
orderId.value = route.params.id || basketOrderId.value;
|
orderId.value = route.params.id || basketOrderId.value;
|
||||||
|
|
||||||
|
onUserId(getOrder);
|
||||||
|
|
||||||
await fetchData();
|
await fetchData();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -294,12 +364,12 @@ onMounted(async () => {
|
||||||
</div>
|
</div>
|
||||||
<QList>
|
<QList>
|
||||||
<QItem
|
<QItem
|
||||||
v-for="(account, index) in transferAccounts"
|
v-for="(transferAccount, index) in transferAccounts"
|
||||||
:key="index"
|
:key="index"
|
||||||
>
|
>
|
||||||
<QItemSection>
|
<QItemSection>
|
||||||
<div>{{ account.name }}</div>
|
<div>{{ transferAccount.account.bankEntity.name }}</div>
|
||||||
<div>{{ account.iban }}</div>
|
<div>{{ transferAccount.account.iban }}</div>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
</QList>
|
</QList>
|
||||||
|
|
Loading…
Reference in New Issue