Add salesperson commissions on issued invoices and a cheque register.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-11 01:09:59 +03:30
co-authored by Cursor
parent 535c428270
commit 9a991fc1f1
22 changed files with 1238 additions and 11 deletions
+49 -1
View File
@@ -131,6 +131,24 @@ async function invite() {
}
}
async function changeCommission(user: OrgUserDto, raw: string) {
if (!canInvite.value) return;
const next = Number(raw);
if (!Number.isFinite(next) || next === Number(user.commissionPercent ?? 0)) return;
error.value = '';
try {
await api.patch(`/users/${user.id}/commission`, { commissionPercent: next });
await load();
} catch (e) {
if (axios.isAxiosError(e)) {
const msg = (e.response?.data as { message?: string | string[] })?.message;
error.value = Array.isArray(msg) ? msg.join('، ') : (msg ?? 'ذخیره پورسانت ناموفق بود');
} else {
error.value = 'ذخیره پورسانت ناموفق بود';
}
}
}
async function changeRole(user: OrgUserDto, next: string) {
const nextRole = next as UserRole;
if (nextRole === user.role) return;
@@ -157,7 +175,7 @@ onMounted(load);
<div class="head-copy">
<h1>تیم و نقش‌ها</h1>
<p class="lead">
زمینه فعالیت سازمان و کاربران را اینجا مدیریت کنید. تنظیمات سازمانی فقط برای مالک و مدیر است.
زمینه فعالیت سازمان، نقش‌ها و درصد پیش‌فرض پورسانت هر کارشناس را اینجا مدیریت کنید.
</p>
</div>
</header>
@@ -224,6 +242,18 @@ onMounted(load);
<p class="muted">{{ user.email }}</p>
</div>
<div class="role-cell">
<label class="comm-field">
<span>پورسانت %</span>
<input
type="number"
min="0"
max="100"
step="0.1"
:value="user.commissionPercent ?? 0"
:disabled="!canInvite"
@change="changeCommission(user, ($event.target as HTMLInputElement).value)"
/>
</label>
<template v-if="canInvite">
<select
:value="user.role"
@@ -373,6 +403,24 @@ select {
margin: 0.2rem 0 0;
}
.role-cell {
display: flex;
align-items: center;
gap: 0.55rem;
}
.comm-field {
display: grid;
gap: 0.15rem;
font-size: 0.75rem;
color: #64748b;
}
.comm-field input {
width: 4.8rem;
padding: 0 0.45rem;
}
.role-pill {
background: #f0fdfa;
color: #0f766e;