bug fix in open balance
This commit is contained in:
parent
da074d2e89
commit
f609c4176f
|
@ -136,6 +136,37 @@ class OpenbalanceController extends AbstractController
|
||||||
if (!$acc)
|
if (!$acc)
|
||||||
throw $this->createAccessDeniedException();
|
throw $this->createAccessDeniedException();
|
||||||
|
|
||||||
|
// بررسی مجوز تغییر تراز افتتاحیه
|
||||||
|
$years = $entityManagerInterface->getRepository(\App\Entity\Year::class)->findBy([
|
||||||
|
'bid' => $acc['bid']
|
||||||
|
], ['start' => 'ASC']);
|
||||||
|
|
||||||
|
$currentYear = $acc['year'];
|
||||||
|
$isFirstYear = false;
|
||||||
|
$hasMultipleYears = count($years) > 1;
|
||||||
|
|
||||||
|
// بررسی اینکه آیا سال فعلی اولین سال مالی است
|
||||||
|
if (count($years) > 0) {
|
||||||
|
$firstYear = $years[0];
|
||||||
|
$isFirstYear = ($currentYear->getId() === $firstYear->getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
$canModify = $isFirstYear && !$hasMultipleYears;
|
||||||
|
|
||||||
|
if (!$canModify) {
|
||||||
|
$message = '';
|
||||||
|
if ($hasMultipleYears && !$isFirstYear) {
|
||||||
|
$message = 'تراز افتتاحیه فقط مختص سال مالی اول است. برای سالهای بعدی از بستن سال مالی استفاده کنید.';
|
||||||
|
} elseif ($hasMultipleYears && $isFirstYear) {
|
||||||
|
$message = 'این کسب و کار دارای چندین سال مالی است. تراز افتتاحیه فقط در سال اول قابل تغییر است.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->json([
|
||||||
|
'result' => 0,
|
||||||
|
'message' => $message
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
$params = [];
|
$params = [];
|
||||||
if ($content = $request->getContent()) {
|
if ($content = $request->getContent()) {
|
||||||
$params = json_decode($content, true);
|
$params = json_decode($content, true);
|
||||||
|
@ -157,7 +188,7 @@ class OpenbalanceController extends AbstractController
|
||||||
$doc->setSubmitter($this->getUser());
|
$doc->setSubmitter($this->getUser());
|
||||||
$doc->setYear($acc['year']);
|
$doc->setYear($acc['year']);
|
||||||
$doc->setDes('سند افتتاحیه');
|
$doc->setDes('سند افتتاحیه');
|
||||||
$doc->setDate($jdate->jdate('Y/n/d', time()));
|
$doc->setDate($jdate->jdate('Y/n/d', $acc['year']->getStart()));
|
||||||
$doc->setType('open_balance');
|
$doc->setType('open_balance');
|
||||||
$doc->setCode($provider->getAccountingCode($acc['bid'],'accounting'));
|
$doc->setCode($provider->getAccountingCode($acc['bid'],'accounting'));
|
||||||
$entityManagerInterface->persist($doc);
|
$entityManagerInterface->persist($doc);
|
||||||
|
@ -233,7 +264,7 @@ class OpenbalanceController extends AbstractController
|
||||||
$doc->setSubmitter($this->getUser());
|
$doc->setSubmitter($this->getUser());
|
||||||
$doc->setYear($acc['year']);
|
$doc->setYear($acc['year']);
|
||||||
$doc->setDes('سند افتتاحیه');
|
$doc->setDes('سند افتتاحیه');
|
||||||
$doc->setDate($jdate->jdate('Y/n/d', time()));
|
$doc->setDate($jdate->jdate('Y/n/d', $acc['year']->getStart()));
|
||||||
$doc->setType('open_balance');
|
$doc->setType('open_balance');
|
||||||
$doc->setCode($provider->getAccountingCode($acc['bid'],'accounting'));
|
$doc->setCode($provider->getAccountingCode($acc['bid'],'accounting'));
|
||||||
$entityManagerInterface->persist($doc);
|
$entityManagerInterface->persist($doc);
|
||||||
|
@ -309,7 +340,7 @@ class OpenbalanceController extends AbstractController
|
||||||
$doc->setSubmitter($this->getUser());
|
$doc->setSubmitter($this->getUser());
|
||||||
$doc->setYear($acc['year']);
|
$doc->setYear($acc['year']);
|
||||||
$doc->setDes('سند افتتاحیه');
|
$doc->setDes('سند افتتاحیه');
|
||||||
$doc->setDate($jdate->jdate('Y/n/d', time()));
|
$doc->setDate($jdate->jdate('Y/n/d', $acc['year']->getStart()));
|
||||||
$doc->setType('open_balance');
|
$doc->setType('open_balance');
|
||||||
$doc->setCode($provider->getAccountingCode($acc['bid'],'accounting'));
|
$doc->setCode($provider->getAccountingCode($acc['bid'],'accounting'));
|
||||||
$entityManagerInterface->persist($doc);
|
$entityManagerInterface->persist($doc);
|
||||||
|
@ -385,7 +416,7 @@ class OpenbalanceController extends AbstractController
|
||||||
$doc->setSubmitter($this->getUser());
|
$doc->setSubmitter($this->getUser());
|
||||||
$doc->setYear($acc['year']);
|
$doc->setYear($acc['year']);
|
||||||
$doc->setDes('سند افتتاحیه');
|
$doc->setDes('سند افتتاحیه');
|
||||||
$doc->setDate($jdate->jdate('Y/n/d', time()));
|
$doc->setDate($jdate->jdate('Y/n/d', $acc['year']->getStart()));
|
||||||
$doc->setType('open_balance');
|
$doc->setType('open_balance');
|
||||||
$doc->setCode($provider->getAccountingCode($acc['bid'],'accounting'));
|
$doc->setCode($provider->getAccountingCode($acc['bid'],'accounting'));
|
||||||
$entityManagerInterface->persist($doc);
|
$entityManagerInterface->persist($doc);
|
||||||
|
@ -468,7 +499,7 @@ class OpenbalanceController extends AbstractController
|
||||||
$doc->setSubmitter($this->getUser());
|
$doc->setSubmitter($this->getUser());
|
||||||
$doc->setYear($acc['year']);
|
$doc->setYear($acc['year']);
|
||||||
$doc->setDes('سند افتتاحیه');
|
$doc->setDes('سند افتتاحیه');
|
||||||
$doc->setDate($jdate->jdate('Y/n/d', time()));
|
$doc->setDate($jdate->jdate('Y/n/d', $acc['year']->getStart()));
|
||||||
$doc->setType('open_balance');
|
$doc->setType('open_balance');
|
||||||
$doc->setCode($provider->getAccountingCode($acc['bid'],'accounting'));
|
$doc->setCode($provider->getAccountingCode($acc['bid'],'accounting'));
|
||||||
$entityManagerInterface->persist($doc);
|
$entityManagerInterface->persist($doc);
|
||||||
|
@ -533,4 +564,93 @@ class OpenbalanceController extends AbstractController
|
||||||
$entityManagerInterface->flush();
|
$entityManagerInterface->flush();
|
||||||
return $this->json($extractor->operationSuccess());
|
return $this->json($extractor->operationSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Route('/api/openbalance/check-permission', name: 'app_openbalance_check_permission')]
|
||||||
|
public function app_openbalance_check_permission(Access $access, EntityManagerInterface $entityManagerInterface, Extractor $extractor): Response
|
||||||
|
{
|
||||||
|
$acc = $access->hasRole('accounting');
|
||||||
|
if (!$acc)
|
||||||
|
throw $this->createAccessDeniedException();
|
||||||
|
|
||||||
|
// بررسی تعداد سالهای مالی کسب و کار
|
||||||
|
$years = $entityManagerInterface->getRepository(\App\Entity\Year::class)->findBy([
|
||||||
|
'bid' => $acc['bid']
|
||||||
|
], ['start' => 'ASC']);
|
||||||
|
|
||||||
|
$currentYear = $acc['year'];
|
||||||
|
$isFirstYear = false;
|
||||||
|
$hasMultipleYears = count($years) > 1;
|
||||||
|
|
||||||
|
// بررسی اینکه آیا سال فعلی اولین سال مالی است
|
||||||
|
if (count($years) > 0) {
|
||||||
|
$firstYear = $years[0];
|
||||||
|
$isFirstYear = ($currentYear->getId() === $firstYear->getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
// بررسی اینکه آیا سند افتتاحیه قبلاً ایجاد شده
|
||||||
|
$existingDoc = $entityManagerInterface->getRepository(HesabdariDoc::class)->findOneBy([
|
||||||
|
'year' => $currentYear,
|
||||||
|
'bid' => $acc['bid'],
|
||||||
|
'type' => 'open_balance',
|
||||||
|
'money' => $acc['money']
|
||||||
|
]);
|
||||||
|
|
||||||
|
$canModify = $isFirstYear && !$hasMultipleYears;
|
||||||
|
$message = '';
|
||||||
|
|
||||||
|
if ($hasMultipleYears && !$isFirstYear) {
|
||||||
|
$message = 'تراز افتتاحیه فقط مختص سال مالی اول است. برای سالهای بعدی از بستن سال مالی استفاده کنید.';
|
||||||
|
} elseif ($hasMultipleYears && $isFirstYear) {
|
||||||
|
$message = 'این کسب و کار دارای چندین سال مالی است. تراز افتتاحیه فقط در سال اول قابل تغییر است.';
|
||||||
|
} elseif ($existingDoc) {
|
||||||
|
$message = 'سند افتتاحیه قبلاً ایجاد شده است.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->json([
|
||||||
|
'canModify' => $canModify,
|
||||||
|
'isFirstYear' => $isFirstYear,
|
||||||
|
'hasMultipleYears' => $hasMultipleYears,
|
||||||
|
'existingDoc' => $existingDoc ? true : false,
|
||||||
|
'message' => $message,
|
||||||
|
'yearsCount' => count($years)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* بررسی مجوز تغییر تراز افتتاحیه
|
||||||
|
*/
|
||||||
|
private function checkOpeningBalancePermission(EntityManagerInterface $entityManagerInterface, array $acc): array
|
||||||
|
{
|
||||||
|
// بررسی تعداد سالهای مالی کسب و کار
|
||||||
|
$years = $entityManagerInterface->getRepository(\App\Entity\Year::class)->findBy([
|
||||||
|
'bid' => $acc['bid']
|
||||||
|
], ['start' => 'ASC']);
|
||||||
|
|
||||||
|
$currentYear = $acc['year'];
|
||||||
|
$isFirstYear = false;
|
||||||
|
$hasMultipleYears = count($years) > 1;
|
||||||
|
|
||||||
|
// بررسی اینکه آیا سال فعلی اولین سال مالی است
|
||||||
|
if (count($years) > 0) {
|
||||||
|
$firstYear = $years[0];
|
||||||
|
$isFirstYear = ($currentYear->getId() === $firstYear->getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
$canModify = $isFirstYear && !$hasMultipleYears;
|
||||||
|
$message = '';
|
||||||
|
|
||||||
|
if ($hasMultipleYears && !$isFirstYear) {
|
||||||
|
$message = 'تراز افتتاحیه فقط مختص سال مالی اول است. برای سالهای بعدی از بستن سال مالی استفاده کنید.';
|
||||||
|
} elseif ($hasMultipleYears && $isFirstYear) {
|
||||||
|
$message = 'این کسب و کار دارای چندین سال مالی است. تراز افتتاحیه فقط در سال اول قابل تغییر است.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'canModify' => $canModify,
|
||||||
|
'message' => $message,
|
||||||
|
'isFirstYear' => $isFirstYear,
|
||||||
|
'hasMultipleYears' => $hasMultipleYears,
|
||||||
|
'yearsCount' => count($years)
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
</v-toolbar>
|
</v-toolbar>
|
||||||
<v-container>
|
<v-container>
|
||||||
<v-row class="pa-1">
|
<v-row class="pa-1">
|
||||||
|
<v-col v-if="!permission.canModify" cols="12" sm="12" md="12">
|
||||||
|
<v-alert :title="'محدودیت دسترسی'" :text="permission.message" type="warning"></v-alert>
|
||||||
|
</v-col>
|
||||||
<v-col v-if="sums.degSum != sums.shareSum" cols="12" sm="12" md="12">
|
<v-col v-if="sums.degSum != sums.shareSum" cols="12" sm="12" md="12">
|
||||||
<v-alert :title="$t('dialog.error')" :text="$t('dialog.openbalance_notvalid')" type="warning"></v-alert>
|
<v-alert :title="$t('dialog.error')" :text="$t('dialog.openbalance_notvalid')" type="warning"></v-alert>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
@ -82,7 +85,7 @@
|
||||||
</v-tooltip>
|
</v-tooltip>
|
||||||
</template>
|
</template>
|
||||||
<v-spacer></v-spacer>
|
<v-spacer></v-spacer>
|
||||||
<v-btn :loading="loading" @click="saveBanks()" icon="" color="green">
|
<v-btn :loading="loading" :disabled="!permission.canModify" @click="saveBanks()" icon="" color="green">
|
||||||
<v-tooltip activator="parent" :text="$t('dialog.save')" location="bottom" />
|
<v-tooltip activator="parent" :text="$t('dialog.save')" location="bottom" />
|
||||||
<v-icon icon="mdi-content-save"></v-icon>
|
<v-icon icon="mdi-content-save"></v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
@ -92,7 +95,7 @@
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col v-for="item in data.banks" :key="item.info.id" cols="12" sm="6" md="4">
|
<v-col v-for="item in data.banks" :key="item.info.id" cols="12" sm="6" md="4">
|
||||||
<div class="form-floating mb-3">
|
<div class="form-floating mb-3">
|
||||||
<money3 v-bind="currencyConfig" min=0 class="form-control" v-model="item.openbalance" />
|
<money3 v-bind="currencyConfig" min=0 class="form-control" v-model="item.openbalance" :disabled="!permission.canModify" />
|
||||||
<label for="floatingInput">{{ item.info.name }} ({{ $filters.getActiveMoney().symbol }}) </label>
|
<label for="floatingInput">{{ item.info.name }} ({{ $filters.getActiveMoney().symbol }}) </label>
|
||||||
</div>
|
</div>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
@ -111,7 +114,7 @@
|
||||||
</v-tooltip>
|
</v-tooltip>
|
||||||
</template>
|
</template>
|
||||||
<v-spacer></v-spacer>
|
<v-spacer></v-spacer>
|
||||||
<v-btn :loading="loading" @click="saveCashdesks()" icon="" color="green">
|
<v-btn :loading="loading" :disabled="!permission.canModify" @click="saveCashdesks()" icon="" color="green">
|
||||||
<v-tooltip activator="parent" :text="$t('dialog.save')" location="bottom" />
|
<v-tooltip activator="parent" :text="$t('dialog.save')" location="bottom" />
|
||||||
<v-icon icon="mdi-content-save"></v-icon>
|
<v-icon icon="mdi-content-save"></v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
@ -121,7 +124,7 @@
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col v-for="item in data.cashdesks" :key="item.info.id" cols="12" sm="6" md="4">
|
<v-col v-for="item in data.cashdesks" :key="item.info.id" cols="12" sm="6" md="4">
|
||||||
<div class="form-floating mb-3">
|
<div class="form-floating mb-3">
|
||||||
<money3 v-bind="currencyConfig" min=0 class="form-control" v-model="item.openbalance" />
|
<money3 v-bind="currencyConfig" min=0 class="form-control" v-model="item.openbalance" :disabled="!permission.canModify" />
|
||||||
<label for="floatingInput">{{ item.info.name }} ({{ $filters.getActiveMoney().symbol }}) </label>
|
<label for="floatingInput">{{ item.info.name }} ({{ $filters.getActiveMoney().symbol }}) </label>
|
||||||
</div>
|
</div>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
@ -140,7 +143,7 @@
|
||||||
</v-tooltip>
|
</v-tooltip>
|
||||||
</template>
|
</template>
|
||||||
<v-spacer></v-spacer>
|
<v-spacer></v-spacer>
|
||||||
<v-btn :loading="loading" @click="saveSalarys()" icon="" color="green">
|
<v-btn :loading="loading" :disabled="!permission.canModify" @click="saveSalarys()" icon="" color="green">
|
||||||
<v-tooltip activator="parent" :text="$t('dialog.save')" location="bottom" />
|
<v-tooltip activator="parent" :text="$t('dialog.save')" location="bottom" />
|
||||||
<v-icon icon="mdi-content-save"></v-icon>
|
<v-icon icon="mdi-content-save"></v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
@ -150,7 +153,7 @@
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col v-for="item in data.salarys" :key="item.info.id" cols="12" sm="6" md="4">
|
<v-col v-for="item in data.salarys" :key="item.info.id" cols="12" sm="6" md="4">
|
||||||
<div class="form-floating mb-3">
|
<div class="form-floating mb-3">
|
||||||
<money3 v-bind="currencyConfig" min=0 class="form-control" v-model="item.openbalance" />
|
<money3 v-bind="currencyConfig" min=0 class="form-control" v-model="item.openbalance" :disabled="!permission.canModify" />
|
||||||
<label for="floatingInput">{{ item.info.name }} ({{ $filters.getActiveMoney().symbol }}) </label>
|
<label for="floatingInput">{{ item.info.name }} ({{ $filters.getActiveMoney().symbol }}) </label>
|
||||||
</div>
|
</div>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
@ -169,7 +172,7 @@
|
||||||
</v-tooltip>
|
</v-tooltip>
|
||||||
</template>
|
</template>
|
||||||
<v-spacer></v-spacer>
|
<v-spacer></v-spacer>
|
||||||
<v-btn :loading="loading" @click="saveShareholders()" icon="" color="green">
|
<v-btn :loading="loading" :disabled="!permission.canModify" @click="saveShareholders()" icon="" color="green">
|
||||||
<v-tooltip activator="parent" :text="$t('dialog.save')" location="bottom" />
|
<v-tooltip activator="parent" :text="$t('dialog.save')" location="bottom" />
|
||||||
<v-icon icon="mdi-content-save"></v-icon>
|
<v-icon icon="mdi-content-save"></v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
@ -179,7 +182,7 @@
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col v-for="item in data.shareholders" :key="item.info.id" cols="12" sm="6" md="4">
|
<v-col v-for="item in data.shareholders" :key="item.info.id" cols="12" sm="6" md="4">
|
||||||
<div class="form-floating mb-3">
|
<div class="form-floating mb-3">
|
||||||
<money3 v-bind="currencyConfig" min=0 class="form-control" v-model="item.openbalance" />
|
<money3 v-bind="currencyConfig" min=0 class="form-control" v-model="item.openbalance" :disabled="!permission.canModify" />
|
||||||
<label for="floatingInput">{{ item.info.nikename }} ({{ $filters.getActiveMoney().symbol }}) </label>
|
<label for="floatingInput">{{ item.info.nikename }} ({{ $filters.getActiveMoney().symbol }}) </label>
|
||||||
</div>
|
</div>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
@ -204,6 +207,7 @@
|
||||||
<v-btn
|
<v-btn
|
||||||
v-bind="props"
|
v-bind="props"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
|
:disabled="!permission.canModify"
|
||||||
@click="saveInventory()"
|
@click="saveInventory()"
|
||||||
color="success"
|
color="success"
|
||||||
variant="text"
|
variant="text"
|
||||||
|
@ -240,7 +244,7 @@
|
||||||
</td>
|
</td>
|
||||||
<td class="text-center" style="width: 100px;">
|
<td class="text-center" style="width: 100px;">
|
||||||
<Hnumberinput
|
<Hnumberinput
|
||||||
v-model="item.count"
|
v-model="item.count" :disabled="!permission.canModify"
|
||||||
density="compact"
|
density="compact"
|
||||||
hide-details
|
hide-details
|
||||||
class="my-0"
|
class="my-0"
|
||||||
|
@ -250,7 +254,7 @@
|
||||||
</td>
|
</td>
|
||||||
<td class="text-center" style="width: 120px;">
|
<td class="text-center" style="width: 120px;">
|
||||||
<Hnumberinput
|
<Hnumberinput
|
||||||
v-model="item.price"
|
v-model="item.price" :disabled="!permission.canModify"
|
||||||
density="compact"
|
density="compact"
|
||||||
hide-details
|
hide-details
|
||||||
class="my-0"
|
class="my-0"
|
||||||
|
@ -310,7 +314,7 @@
|
||||||
<div class="d-flex justify-space-between mb-2">
|
<div class="d-flex justify-space-between mb-2">
|
||||||
<div style="width: 48%;">
|
<div style="width: 48%;">
|
||||||
<Hnumberinput
|
<Hnumberinput
|
||||||
v-model="item.count"
|
v-model="item.count" :disabled="!permission.canModify"
|
||||||
density="compact"
|
density="compact"
|
||||||
label="تعداد"
|
label="تعداد"
|
||||||
hide-details
|
hide-details
|
||||||
|
@ -321,7 +325,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div style="width: 48%;">
|
<div style="width: 48%;">
|
||||||
<Hnumberinput
|
<Hnumberinput
|
||||||
v-model="item.price"
|
v-model="item.price" :disabled="!permission.canModify"
|
||||||
density="compact"
|
density="compact"
|
||||||
label="قیمت واحد"
|
label="قیمت واحد"
|
||||||
hide-details
|
hide-details
|
||||||
|
@ -434,13 +438,31 @@ export default {
|
||||||
show: false,
|
show: false,
|
||||||
text: '',
|
text: '',
|
||||||
color: 'error'
|
color: 'error'
|
||||||
|
},
|
||||||
|
permission: {
|
||||||
|
canModify: true,
|
||||||
|
message: '',
|
||||||
|
isFirstYear: false,
|
||||||
|
hasMultipleYears: false,
|
||||||
|
existingDoc: false,
|
||||||
|
yearsCount: 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.loadData();
|
this.loadData();
|
||||||
|
this.checkPermission();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
checkPermission() {
|
||||||
|
axios.post('/api/openbalance/check-permission').then((response) => {
|
||||||
|
this.permission = response.data;
|
||||||
|
}).catch(error => {
|
||||||
|
console.error('Error checking permission:', error);
|
||||||
|
this.permission.canModify = false;
|
||||||
|
this.permission.message = 'خطا در بررسی مجوز';
|
||||||
|
});
|
||||||
|
},
|
||||||
loadData() {
|
loadData() {
|
||||||
this.sums.banks = 0;
|
this.sums.banks = 0;
|
||||||
this.sums.cashdesks = 0;
|
this.sums.cashdesks = 0;
|
||||||
|
@ -509,35 +531,147 @@ export default {
|
||||||
},
|
},
|
||||||
saveBanks() {
|
saveBanks() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
axios.post('/api/openbalance/save/banks', this.data.banks).then((Response) => {
|
|
||||||
|
// ابتدا بررسی مجوز
|
||||||
|
axios.post('/api/openbalance/check-permission').then((permissionResponse) => {
|
||||||
|
if (!permissionResponse.data.canModify) {
|
||||||
|
this.loading = false;
|
||||||
|
this.snackbar.text = permissionResponse.data.message;
|
||||||
|
this.snackbar.color = 'error';
|
||||||
|
this.snackbar.show = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// اگر مجوز داشت، ذخیره کن
|
||||||
|
axios.post('/api/openbalance/save/banks', this.data.banks).then((Response) => {
|
||||||
|
this.loading = false;
|
||||||
|
this.loadData();
|
||||||
|
this.sheet.banks = false;
|
||||||
|
this.snackbar.text = 'اطلاعات بانکها با موفقیت ذخیره شد';
|
||||||
|
this.snackbar.color = 'success';
|
||||||
|
this.snackbar.show = true;
|
||||||
|
}).catch(error => {
|
||||||
|
this.loading = false;
|
||||||
|
this.snackbar.text = 'خطا در ذخیره اطلاعات';
|
||||||
|
this.snackbar.color = 'error';
|
||||||
|
this.snackbar.show = true;
|
||||||
|
console.error('Error saving banks:', error);
|
||||||
|
});
|
||||||
|
}).catch(error => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.loadData();
|
this.snackbar.text = 'خطا در بررسی مجوز';
|
||||||
this.sheet.banks = false;
|
this.snackbar.color = 'error';
|
||||||
})
|
this.snackbar.show = true;
|
||||||
|
console.error('Error checking permission:', error);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
saveCashdesks() {
|
saveCashdesks() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
axios.post('/api/openbalance/save/cashdesks', this.data.cashdesks).then((Response) => {
|
|
||||||
|
// ابتدا بررسی مجوز
|
||||||
|
axios.post('/api/openbalance/check-permission').then((permissionResponse) => {
|
||||||
|
if (!permissionResponse.data.canModify) {
|
||||||
|
this.loading = false;
|
||||||
|
this.snackbar.text = permissionResponse.data.message;
|
||||||
|
this.snackbar.color = 'error';
|
||||||
|
this.snackbar.show = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// اگر مجوز داشت، ذخیره کن
|
||||||
|
axios.post('/api/openbalance/save/cashdesks', this.data.cashdesks).then((Response) => {
|
||||||
|
this.loading = false;
|
||||||
|
this.loadData();
|
||||||
|
this.sheet.cashdesks = false;
|
||||||
|
this.snackbar.text = 'اطلاعات صندوقها با موفقیت ذخیره شد';
|
||||||
|
this.snackbar.color = 'success';
|
||||||
|
this.snackbar.show = true;
|
||||||
|
}).catch(error => {
|
||||||
|
this.loading = false;
|
||||||
|
this.snackbar.text = 'خطا در ذخیره اطلاعات';
|
||||||
|
this.snackbar.color = 'error';
|
||||||
|
this.snackbar.show = true;
|
||||||
|
console.error('Error saving cashdesks:', error);
|
||||||
|
});
|
||||||
|
}).catch(error => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.loadData();
|
this.snackbar.text = 'خطا در بررسی مجوز';
|
||||||
this.sheet.cashdesks = false;
|
this.snackbar.color = 'error';
|
||||||
})
|
this.snackbar.show = true;
|
||||||
|
console.error('Error checking permission:', error);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
saveSalarys() {
|
saveSalarys() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
axios.post('/api/openbalance/save/salarys', this.data.salarys).then((Response) => {
|
|
||||||
|
// ابتدا بررسی مجوز
|
||||||
|
axios.post('/api/openbalance/check-permission').then((permissionResponse) => {
|
||||||
|
if (!permissionResponse.data.canModify) {
|
||||||
|
this.loading = false;
|
||||||
|
this.snackbar.text = permissionResponse.data.message;
|
||||||
|
this.snackbar.color = 'error';
|
||||||
|
this.snackbar.show = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// اگر مجوز داشت، ذخیره کن
|
||||||
|
axios.post('/api/openbalance/save/salarys', this.data.salarys).then((Response) => {
|
||||||
|
this.loading = false;
|
||||||
|
this.loadData();
|
||||||
|
this.sheet.salarys = false;
|
||||||
|
this.snackbar.text = 'اطلاعات تنخواهگردانها با موفقیت ذخیره شد';
|
||||||
|
this.snackbar.color = 'success';
|
||||||
|
this.snackbar.show = true;
|
||||||
|
}).catch(error => {
|
||||||
|
this.loading = false;
|
||||||
|
this.snackbar.text = 'خطا در ذخیره اطلاعات';
|
||||||
|
this.snackbar.color = 'error';
|
||||||
|
this.snackbar.show = true;
|
||||||
|
console.error('Error saving salarys:', error);
|
||||||
|
});
|
||||||
|
}).catch(error => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.loadData();
|
this.snackbar.text = 'خطا در بررسی مجوز';
|
||||||
this.sheet.salarys = false;
|
this.snackbar.color = 'error';
|
||||||
})
|
this.snackbar.show = true;
|
||||||
|
console.error('Error checking permission:', error);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
saveShareholders() {
|
saveShareholders() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
axios.post('/api/openbalance/save/shareholders', this.data.shareholders).then((Response) => {
|
|
||||||
|
// ابتدا بررسی مجوز
|
||||||
|
axios.post('/api/openbalance/check-permission').then((permissionResponse) => {
|
||||||
|
if (!permissionResponse.data.canModify) {
|
||||||
|
this.loading = false;
|
||||||
|
this.snackbar.text = permissionResponse.data.message;
|
||||||
|
this.snackbar.color = 'error';
|
||||||
|
this.snackbar.show = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// اگر مجوز داشت، ذخیره کن
|
||||||
|
axios.post('/api/openbalance/save/shareholders', this.data.shareholders).then((Response) => {
|
||||||
|
this.loading = false;
|
||||||
|
this.loadData();
|
||||||
|
this.sheet.shareholders = false;
|
||||||
|
this.snackbar.text = 'اطلاعات سهامداران با موفقیت ذخیره شد';
|
||||||
|
this.snackbar.color = 'success';
|
||||||
|
this.snackbar.show = true;
|
||||||
|
}).catch(error => {
|
||||||
|
this.loading = false;
|
||||||
|
this.snackbar.text = 'خطا در ذخیره اطلاعات';
|
||||||
|
this.snackbar.color = 'error';
|
||||||
|
this.snackbar.show = true;
|
||||||
|
console.error('Error saving shareholders:', error);
|
||||||
|
});
|
||||||
|
}).catch(error => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.loadData();
|
this.snackbar.text = 'خطا در بررسی مجوز';
|
||||||
this.sheet.shareholders = false;
|
this.snackbar.color = 'error';
|
||||||
})
|
this.snackbar.show = true;
|
||||||
|
console.error('Error checking permission:', error);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
calculateTotalPrice(item) {
|
calculateTotalPrice(item) {
|
||||||
item.totalPrice = parseFloat(item.count || 0) * parseFloat(item.price || 0);
|
item.totalPrice = parseFloat(item.count || 0) * parseFloat(item.price || 0);
|
||||||
|
@ -609,19 +743,37 @@ export default {
|
||||||
totalPrice: parseFloat(item.totalPrice)
|
totalPrice: parseFloat(item.totalPrice)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
axios.post('/api/openbalance/save/commodities', commoditiesData).then((Response) => {
|
// ابتدا بررسی مجوز
|
||||||
this.loading = false;
|
axios.post('/api/openbalance/check-permission').then((permissionResponse) => {
|
||||||
this.loadData();
|
if (!permissionResponse.data.canModify) {
|
||||||
this.sheet.inventory = false;
|
this.loading = false;
|
||||||
this.snackbar.text = this.$t('dialog.inventory.save_success');
|
this.snackbar.text = permissionResponse.data.message;
|
||||||
this.snackbar.color = 'success';
|
this.snackbar.color = 'error';
|
||||||
this.snackbar.show = true;
|
this.snackbar.show = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// اگر مجوز داشت، ذخیره کن
|
||||||
|
axios.post('/api/openbalance/save/commodities', commoditiesData).then((Response) => {
|
||||||
|
this.loading = false;
|
||||||
|
this.loadData();
|
||||||
|
this.sheet.inventory = false;
|
||||||
|
this.snackbar.text = 'اطلاعات موجودی کالا با موفقیت ذخیره شد';
|
||||||
|
this.snackbar.color = 'success';
|
||||||
|
this.snackbar.show = true;
|
||||||
|
}).catch(error => {
|
||||||
|
this.loading = false;
|
||||||
|
this.snackbar.text = 'خطا در ذخیره اطلاعات';
|
||||||
|
this.snackbar.color = 'error';
|
||||||
|
this.snackbar.show = true;
|
||||||
|
console.error('Error saving inventory:', error);
|
||||||
|
});
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.snackbar.text = this.$t('dialog.inventory.save_error');
|
this.snackbar.text = 'خطا در بررسی مجوز';
|
||||||
this.snackbar.color = 'error';
|
this.snackbar.color = 'error';
|
||||||
this.snackbar.show = true;
|
this.snackbar.show = true;
|
||||||
console.error('Error saving inventory:', error);
|
console.error('Error checking permission:', error);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
validateInventory() {
|
validateInventory() {
|
||||||
|
|
Loading…
Reference in a new issue