Initial admin edits
This commit is contained in:
@@ -9,6 +9,7 @@ import IconSuccessCircle from '@/components/icons/IconSuccessCircle.vue'
|
||||
import { formatCurrency, formatDateTime } from '@/utils/format'
|
||||
import { useRequirePricedOrder } from '@/composables/useRequirePricedOrder'
|
||||
import type { BankAccount } from '@/types'
|
||||
import { PAYMENT_RECIPIENT_COMPANY_SLUG } from '@/utils/constants'
|
||||
|
||||
const router = useRouter()
|
||||
const orderStore = useOrderStore()
|
||||
@@ -16,7 +17,13 @@ const catalogStore = useCatalogStore()
|
||||
const bankAccounts = ref<BankAccount[]>([])
|
||||
|
||||
const { orderId, order } = useRequirePricedOrder()
|
||||
const companyName = computed(() => order.value?.companyName ?? '')
|
||||
|
||||
const paymentRecipientName = computed(() => {
|
||||
const fromCatalog = catalogStore.companies.find(
|
||||
(c) => c.slug === PAYMENT_RECIPIENT_COMPANY_SLUG,
|
||||
)?.name
|
||||
return fromCatalog ?? 'نادمی تکس'
|
||||
})
|
||||
|
||||
watch(
|
||||
orderId,
|
||||
@@ -49,12 +56,9 @@ const expiryMessage = computed(() => {
|
||||
return `مهلت پرداخت این فاکتور تا ${formatDateTime(expiry)} است.`
|
||||
})
|
||||
|
||||
const accountsSectionTitle = computed(() => {
|
||||
const name = companyName.value.replace(/^شرکت\s+/u, '')
|
||||
return name
|
||||
? `شماره حسابهای واریز — ${name}`
|
||||
: 'شماره حسابهای واریز'
|
||||
})
|
||||
const accountsSectionTitle = computed(
|
||||
() => `شماره حسابهای واریز — ${paymentRecipientName.value}`,
|
||||
)
|
||||
|
||||
function formatCardNumber(value: string) {
|
||||
const digits = value.replace(/\D/g, '')
|
||||
|
||||
@@ -49,7 +49,11 @@ const checks = computed<CheckData[]>(() => {
|
||||
|
||||
return orderStore
|
||||
.userOrders(authStore.user.id)
|
||||
.filter((o) => o.settlementType === 'check' && o.checks?.length)
|
||||
.filter(
|
||||
(o) =>
|
||||
(o.settlementType === 'check' || o.settlementType === 'cash_check') &&
|
||||
o.checks?.length,
|
||||
)
|
||||
.flatMap((o) => o.checks ?? [])
|
||||
})
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useOrderStore } from '@/stores/order'
|
||||
import PageHeader from '@/components/layout/PageHeader.vue'
|
||||
@@ -11,9 +11,21 @@ import IconCheckBook from '@/components/icons/IconCheckBook.vue'
|
||||
import { formatCurrency } from '@/utils/format'
|
||||
import { isInvoicePriced } from '@/utils/orderInvoice'
|
||||
import { useRequirePricedOrder } from '@/composables/useRequirePricedOrder'
|
||||
import { usePublicContact } from '@/composables/usePublicContact'
|
||||
import type { SettlementType } from '@/types'
|
||||
|
||||
const router = useRouter()
|
||||
const orderStore = useOrderStore()
|
||||
const {
|
||||
load: loadPublicSettings,
|
||||
defaultSettlementCash,
|
||||
defaultSettlementCheck,
|
||||
defaultSettlementCashCheck,
|
||||
} = usePublicContact()
|
||||
|
||||
onMounted(() => {
|
||||
void loadPublicSettings()
|
||||
})
|
||||
|
||||
const { orderId, order, invoiceReady } = useRequirePricedOrder()
|
||||
const submitting = ref(false)
|
||||
@@ -31,7 +43,7 @@ const invoiceLabel = computed(() =>
|
||||
order.value?.finalAmount ? formatCurrency(order.value.finalAmount) : '—',
|
||||
)
|
||||
|
||||
async function selectType(type: 'cash' | 'check') {
|
||||
async function selectType(type: SettlementType) {
|
||||
if (submitting.value || !isInvoicePriced(order.value)) {
|
||||
formError.value = 'تا قبل از قیمتگذاری مدیریت، امکان انتخاب روش تسویه وجود ندارد.'
|
||||
return
|
||||
@@ -40,7 +52,7 @@ async function selectType(type: 'cash' | 'check') {
|
||||
formError.value = ''
|
||||
try {
|
||||
await orderStore.chooseSettlement(orderId.value, type)
|
||||
if (type === 'cash') {
|
||||
if (type === 'cash' || type === 'cash_check') {
|
||||
router.replace(`/orders/${orderId.value}/cash`)
|
||||
} else {
|
||||
orderStore.startCheckDraft(orderId.value)
|
||||
@@ -87,6 +99,7 @@ async function selectType(type: 'cash' | 'check') {
|
||||
|
||||
<div class="settlement-mobile-options">
|
||||
<button
|
||||
v-if="defaultSettlementCash"
|
||||
type="button"
|
||||
class="settlement-card"
|
||||
:disabled="submitting"
|
||||
@@ -99,6 +112,7 @@ async function selectType(type: 'cash' | 'check') {
|
||||
<p>پرداخت از طریق واریز به حساب شرکت</p>
|
||||
</button>
|
||||
<button
|
||||
v-if="defaultSettlementCheck"
|
||||
type="button"
|
||||
class="settlement-card"
|
||||
:disabled="submitting"
|
||||
@@ -110,6 +124,22 @@ async function selectType(type: 'cash' | 'check') {
|
||||
<h3>تسویه چکی</h3>
|
||||
<p>پرداخت بر اساس مبلغ فاکتور با ثبت چک</p>
|
||||
</button>
|
||||
<button
|
||||
v-if="defaultSettlementCashCheck"
|
||||
type="button"
|
||||
class="settlement-card"
|
||||
:disabled="submitting"
|
||||
@click="selectType('cash_check')"
|
||||
>
|
||||
<span
|
||||
class="settlement-card__icon settlement-card__icon--check settlement-card__icon--hybrid"
|
||||
>
|
||||
<IconCashSettlement :size="28" />
|
||||
<IconCheckBook :size="28" />
|
||||
</span>
|
||||
<h3>تسویه نقدی-چکی</h3>
|
||||
<p>ابتدا واریز نقدی، سپس ثبت چک برای مابقی تسویه</p>
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
@@ -155,6 +185,7 @@ async function selectType(type: 'cash' | 'check') {
|
||||
|
||||
<div v-else class="desktop-settlement-grid">
|
||||
<button
|
||||
v-if="defaultSettlementCash"
|
||||
type="button"
|
||||
class="settlement-card settlement-card--desktop"
|
||||
:disabled="submitting"
|
||||
@@ -167,6 +198,7 @@ async function selectType(type: 'cash' | 'check') {
|
||||
<p>پرداخت از طریق واریز به حساب شرکت</p>
|
||||
</button>
|
||||
<button
|
||||
v-if="defaultSettlementCheck"
|
||||
type="button"
|
||||
class="settlement-card settlement-card--desktop"
|
||||
:disabled="submitting"
|
||||
@@ -178,6 +210,20 @@ async function selectType(type: 'cash' | 'check') {
|
||||
<h3>تسویه چکی</h3>
|
||||
<p>پرداخت بر اساس مبلغ فاکتور با ثبت چک</p>
|
||||
</button>
|
||||
<button
|
||||
v-if="defaultSettlementCashCheck"
|
||||
type="button"
|
||||
class="settlement-card settlement-card--desktop"
|
||||
:disabled="submitting"
|
||||
@click="selectType('cash_check')"
|
||||
>
|
||||
<span class="settlement-card__icon settlement-card__icon--check settlement-card__icon--hybrid">
|
||||
<IconCashSettlement :size="32" />
|
||||
<IconCheckBook :size="32" />
|
||||
</span>
|
||||
<h3>تسویه نقدی-چکی</h3>
|
||||
<p>ابتدا واریز نقدی، سپس ثبت چک برای مابقی تسویه</p>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -331,6 +377,10 @@ async function selectType(type: 'cash' | 'check') {
|
||||
background: var(--color-primary-light);
|
||||
}
|
||||
|
||||
.settlement-card__icon--hybrid {
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.settlement-card h3 {
|
||||
margin: 0 0 8px;
|
||||
font-size: 1.0625rem;
|
||||
|
||||
Reference in New Issue
Block a user