bug fix in wallet match bank account in business settings

This commit is contained in:
Hesabix 2025-04-03 19:31:18 +00:00
parent b794ea76b7
commit e34d8e887b
3 changed files with 86 additions and 59 deletions

View file

@ -235,7 +235,7 @@ class BusinessController extends AbstractController
if (array_key_exists('walletMatchBank', $params)) { if (array_key_exists('walletMatchBank', $params)) {
$bank = $entityManager->getRepository(BankAccount::class)->findOneBy([ $bank = $entityManager->getRepository(BankAccount::class)->findOneBy([
'bid' => $business->getId(), 'bid' => $business->getId(),
'id' => $params['walletMatchBank']['id'] 'id' => $params['walletMatchBank']
]); ]);
if ($bank) { if ($bank) {
$business->setWalletEnable($params['walletEnabled']); $business->setWalletEnable($params['walletEnabled']);

View file

@ -533,7 +533,7 @@ class Explore
'smsCharge' => $item->getSmsCharge(), 'smsCharge' => $item->getSmsCharge(),
'shortlinks' => $item->isShortlinks(), 'shortlinks' => $item->isShortlinks(),
'walletEnabled' => $item->isWalletEnable(), 'walletEnabled' => $item->isWalletEnable(),
'walletMatchBank' => null, 'walletMatchBank' => $item->getWalletMatchBank()->getId(),
'updateSellPrice' => $item->isCommodityUpdateSellPriceAuto(), 'updateSellPrice' => $item->isCommodityUpdateSellPriceAuto(),
'updateBuyPrice' => $item->isCommodityUpdateBuyPriceAuto(), 'updateBuyPrice' => $item->isCommodityUpdateBuyPriceAuto(),
]; ];

View file

@ -364,8 +364,12 @@ export default {
maliyatafzode: 9, maliyatafzode: 9,
shortlinks: false, shortlinks: false,
walletEnabled: false, walletEnabled: false,
walletMatchBank: '', walletMatchBank: null,
year: {}, year: {
startShamsi: '',
endShamsi: '',
label: ''
},
updateSellPrice: false, updateSellPrice: false,
updateBuyPrice: false, updateBuyPrice: false,
profitCalcType: 'lis' profitCalcType: 'lis'
@ -373,6 +377,15 @@ export default {
listBanks: [], listBanks: [],
} }
}, },
watch: {
'content.year.endShamsi': {
handler(newVal) {
if (newVal) {
this.content.year.label = `سال مالی منتهی به ${newVal}`;
}
}
}
},
methods: { methods: {
checkBanksExist() { checkBanksExist() {
if (this.listBanks.length === 0) { if (this.listBanks.length === 0) {
@ -399,6 +412,7 @@ export default {
icon: 'error', icon: 'error',
confirmButtonText: 'قبول' confirmButtonText: 'قبول'
}); });
return;
} }
if (this.content.walletEnabled && (this.content.walletMatchBank === undefined || this.content.walletMatchBank === null)) { if (this.content.walletEnabled && (this.content.walletMatchBank === undefined || this.content.walletMatchBank === null)) {
Swal.fire({ Swal.fire({
@ -406,11 +420,12 @@ export default {
icon: 'error', icon: 'error',
confirmButtonText: 'قبول' confirmButtonText: 'قبول'
}); });
return;
} }
else {
//submit data //submit data
this.loading = true; this.loading = true;
let data = axios.post('/api/business/insert', { let data = {
'bid': localStorage.getItem('activeBid'), 'bid': localStorage.getItem('activeBid'),
'name': this.content.name, 'name': this.content.name,
'legal_name': this.content.legal_name, 'legal_name': this.content.legal_name,
@ -437,7 +452,9 @@ export default {
'commodityUpdateBuyPriceAuto': this.content.updateBuyPrice, 'commodityUpdateBuyPriceAuto': this.content.updateBuyPrice,
'commodityUpdateSellPriceAuto': this.content.updateSellPrice, 'commodityUpdateSellPriceAuto': this.content.updateSellPrice,
'profitCalcType': this.content.profitCalcType 'profitCalcType': this.content.profitCalcType
}) };
axios.post('/api/business/insert', data)
.then((response) => { .then((response) => {
this.loading = false; this.loading = false;
if (response.data.result == 1) { if (response.data.result == 1) {
@ -445,7 +462,6 @@ export default {
text: 'با موفقیت ثبت شد.', text: 'با موفقیت ثبت شد.',
icon: 'success', icon: 'success',
confirmButtonText: 'قبول', confirmButtonText: 'قبول',
}) })
} }
else if (response.data.result === 0) { else if (response.data.result === 0) {
@ -456,7 +472,14 @@ export default {
}); });
} }
}) })
} .catch((error) => {
this.loading = false;
Swal.fire({
text: 'خطا در ثبت اطلاعات',
icon: 'error',
confirmButtonText: 'قبول'
});
});
} }
}, },
async beforeMount() { async beforeMount() {
@ -467,17 +490,21 @@ export default {
this.content.arzmain = this.moneys[0]; this.content.arzmain = this.moneys[0];
}) })
//get list of banks
await axios.post('/api/bank/list').then((response) => {
this.listBanks = response.data;
});
//get business info //get business info
let data = axios.post('/api/business/get/info/' + localStorage.getItem('activeBid')) let data = await axios.post('/api/business/get/info/' + localStorage.getItem('activeBid'))
.then((response) => { .then((response) => {
this.content = response.data; this.content = response.data;
// اگر walletMatchBank یک آبجکت است، فقط id آن را نگه میداریم
if (this.content.walletMatchBank && typeof this.content.walletMatchBank === 'object') {
this.content.walletMatchBank = this.content.walletMatchBank.id;
}
this.loading = false; this.loading = false;
}); });
//get list of banks
axios.post('/api/bank/list').then((response) => {
this.listBanks = response.data;
})
} }
} }
</script> </script>