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,57 +420,66 @@ 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,
'field': this.content.field, 'field': this.content.field,
'type': this.content.type, 'type': this.content.type,
'shenasemeli': this.content.shenasemeli, 'shenasemeli': this.content.shenasemeli,
'codeeqtesadi': this.content.codeeqtesadi, 'codeeqtesadi': this.content.codeeqtesadi,
'shomaresabt': this.content.shomaresabt, 'shomaresabt': this.content.shomaresabt,
'country': this.content.country, 'country': this.content.country,
'ostan': this.content.ostan, 'ostan': this.content.ostan,
'shahrestan': this.content.shahrestan, 'shahrestan': this.content.shahrestan,
'postalcode': this.content.postalcode, 'postalcode': this.content.postalcode,
'tel': this.content.tel, 'tel': this.content.tel,
'mobile': this.content.mobile, 'mobile': this.content.mobile,
'address': this.content.address, 'address': this.content.address,
'website': this.content.website, 'website': this.content.website,
'email': this.content.email, 'email': this.content.email,
'arzmain': this.content.arzmain, 'arzmain': this.content.arzmain,
'maliyatafzode': this.content.maliyatafzode, 'maliyatafzode': this.content.maliyatafzode,
'shortlinks': this.content.shortlinks, 'shortlinks': this.content.shortlinks,
'walletEnabled': this.content.walletEnabled, 'walletEnabled': this.content.walletEnabled,
'walletMatchBank': this.content.walletMatchBank, 'walletMatchBank': this.content.walletMatchBank,
'year': this.content.year, 'year': this.content.year,
'commodityUpdateBuyPriceAuto': this.content.updateBuyPrice, 'commodityUpdateBuyPriceAuto': this.content.updateBuyPrice,
'commodityUpdateSellPriceAuto': this.content.updateSellPrice, 'commodityUpdateSellPriceAuto': this.content.updateSellPrice,
'profitCalcType': this.content.profitCalcType 'profitCalcType': this.content.profitCalcType
}) };
.then((response) => {
this.loading = false;
if (response.data.result == 1) {
Swal.fire({
text: 'با موفقیت ثبت شد.',
icon: 'success',
confirmButtonText: 'قبول',
}) axios.post('/api/business/insert', data)
} .then((response) => {
else if (response.data.result === 0) { this.loading = false;
Swal.fire({ if (response.data.result == 1) {
text: 'تکمیل موارد ستاره دار الزامی است.', Swal.fire({
icon: 'error', text: 'با موفقیت ثبت شد.',
confirmButtonText: 'قبول' icon: 'success',
}); confirmButtonText: 'قبول',
} })
}) }
} else if (response.data.result === 0) {
Swal.fire({
text: 'تکمیل موارد ستاره دار الزامی است.',
icon: 'error',
confirmButtonText: 'قبول'
});
}
})
.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>