diff --git a/hesabixCore/src/Controller/BusinessController.php b/hesabixCore/src/Controller/BusinessController.php index 4917388..2451186 100644 --- a/hesabixCore/src/Controller/BusinessController.php +++ b/hesabixCore/src/Controller/BusinessController.php @@ -235,7 +235,7 @@ class BusinessController extends AbstractController if (array_key_exists('walletMatchBank', $params)) { $bank = $entityManager->getRepository(BankAccount::class)->findOneBy([ 'bid' => $business->getId(), - 'id' => $params['walletMatchBank']['id'] + 'id' => $params['walletMatchBank'] ]); if ($bank) { $business->setWalletEnable($params['walletEnabled']); diff --git a/hesabixCore/src/Service/Explore.php b/hesabixCore/src/Service/Explore.php index 2706296..6f8a11a 100644 --- a/hesabixCore/src/Service/Explore.php +++ b/hesabixCore/src/Service/Explore.php @@ -533,7 +533,7 @@ class Explore 'smsCharge' => $item->getSmsCharge(), 'shortlinks' => $item->isShortlinks(), 'walletEnabled' => $item->isWalletEnable(), - 'walletMatchBank' => null, + 'walletMatchBank' => $item->getWalletMatchBank()->getId(), 'updateSellPrice' => $item->isCommodityUpdateSellPriceAuto(), 'updateBuyPrice' => $item->isCommodityUpdateBuyPriceAuto(), ]; diff --git a/webUI/src/views/acc/settings/bussiness.vue b/webUI/src/views/acc/settings/bussiness.vue index e695e0d..87fcba8 100644 --- a/webUI/src/views/acc/settings/bussiness.vue +++ b/webUI/src/views/acc/settings/bussiness.vue @@ -364,8 +364,12 @@ export default { maliyatafzode: 9, shortlinks: false, walletEnabled: false, - walletMatchBank: '', - year: {}, + walletMatchBank: null, + year: { + startShamsi: '', + endShamsi: '', + label: '' + }, updateSellPrice: false, updateBuyPrice: false, profitCalcType: 'lis' @@ -373,6 +377,15 @@ export default { listBanks: [], } }, + watch: { + 'content.year.endShamsi': { + handler(newVal) { + if (newVal) { + this.content.year.label = `سال مالی منتهی به ${newVal}`; + } + } + } + }, methods: { checkBanksExist() { if (this.listBanks.length === 0) { @@ -399,6 +412,7 @@ export default { icon: 'error', confirmButtonText: 'قبول' }); + return; } if (this.content.walletEnabled && (this.content.walletMatchBank === undefined || this.content.walletMatchBank === null)) { Swal.fire({ @@ -406,57 +420,66 @@ export default { icon: 'error', confirmButtonText: 'قبول' }); + return; } - else { - //submit data - this.loading = true; - let data = axios.post('/api/business/insert', { - 'bid': localStorage.getItem('activeBid'), - 'name': this.content.name, - 'legal_name': this.content.legal_name, - 'field': this.content.field, - 'type': this.content.type, - 'shenasemeli': this.content.shenasemeli, - 'codeeqtesadi': this.content.codeeqtesadi, - 'shomaresabt': this.content.shomaresabt, - 'country': this.content.country, - 'ostan': this.content.ostan, - 'shahrestan': this.content.shahrestan, - 'postalcode': this.content.postalcode, - 'tel': this.content.tel, - 'mobile': this.content.mobile, - 'address': this.content.address, - 'website': this.content.website, - 'email': this.content.email, - 'arzmain': this.content.arzmain, - 'maliyatafzode': this.content.maliyatafzode, - 'shortlinks': this.content.shortlinks, - 'walletEnabled': this.content.walletEnabled, - 'walletMatchBank': this.content.walletMatchBank, - 'year': this.content.year, - 'commodityUpdateBuyPriceAuto': this.content.updateBuyPrice, - 'commodityUpdateSellPriceAuto': this.content.updateSellPrice, - 'profitCalcType': this.content.profitCalcType - }) - .then((response) => { - this.loading = false; - if (response.data.result == 1) { - Swal.fire({ - text: 'با موفقیت ثبت شد.', - icon: 'success', - confirmButtonText: 'قبول', + + //submit data + this.loading = true; + let data = { + 'bid': localStorage.getItem('activeBid'), + 'name': this.content.name, + 'legal_name': this.content.legal_name, + 'field': this.content.field, + 'type': this.content.type, + 'shenasemeli': this.content.shenasemeli, + 'codeeqtesadi': this.content.codeeqtesadi, + 'shomaresabt': this.content.shomaresabt, + 'country': this.content.country, + 'ostan': this.content.ostan, + 'shahrestan': this.content.shahrestan, + 'postalcode': this.content.postalcode, + 'tel': this.content.tel, + 'mobile': this.content.mobile, + 'address': this.content.address, + 'website': this.content.website, + 'email': this.content.email, + 'arzmain': this.content.arzmain, + 'maliyatafzode': this.content.maliyatafzode, + 'shortlinks': this.content.shortlinks, + 'walletEnabled': this.content.walletEnabled, + 'walletMatchBank': this.content.walletMatchBank, + 'year': this.content.year, + 'commodityUpdateBuyPriceAuto': this.content.updateBuyPrice, + 'commodityUpdateSellPriceAuto': this.content.updateSellPrice, + 'profitCalcType': this.content.profitCalcType + }; - }) - } - else if (response.data.result === 0) { - Swal.fire({ - text: 'تکمیل موارد ستاره دار الزامی است.', - icon: 'error', - confirmButtonText: 'قبول' - }); - } - }) - } + axios.post('/api/business/insert', data) + .then((response) => { + this.loading = false; + if (response.data.result == 1) { + Swal.fire({ + text: 'با موفقیت ثبت شد.', + 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() { @@ -467,17 +490,21 @@ export default { 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 - 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) => { 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; }); - //get list of banks - axios.post('/api/bank/list').then((response) => { - this.listBanks = response.data; - }) - } }