fix(admin): convert toman to rial when recording session payment/discount
PaymentStep sent the toman amount straight through as amount_rials (and the fixed discount value as discount_value), so a 500,000 toman payment was stored as 5,000,000... no — as 500,000 rial (10x too small). Apply tomanToRial before sending the payment amount and the fixed-discount value; percent discount and rule-based discount are unaffected. Verified stored value is now correct rial. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@ import { ChevronDownIcon } from '@heroicons/react/24/outline';
|
||||
import { toast } from 'sonner';
|
||||
import { api } from '../../lib/api';
|
||||
import type { ApiResponse } from '../../lib/api';
|
||||
import { formatRial } from '../../lib/utils';
|
||||
import { formatRial, formatDateTime, tomanToRial } from '../../lib/utils';
|
||||
import type { DiscountSuggestion } from '../../types';
|
||||
import type { SessionCardData } from '../SessionServiceCard';
|
||||
import SearchableSelect from '../ui/SearchableSelect';
|
||||
@@ -80,7 +80,9 @@ export default function PaymentStep({ recordUuid, session, walletBalance, onCont
|
||||
|
||||
const applyDiscount = () => {
|
||||
if (!discountType || discountValue <= 0) return;
|
||||
discountMut.mutate({ discount_type: discountType, discount_value: discountValue });
|
||||
// percent درصد است (بدون تبدیل)؛ fixed مبلغ تومان است → ریال.
|
||||
const value = discountType === 'fixed' ? tomanToRial(discountValue) : discountValue;
|
||||
discountMut.mutate({ discount_type: discountType, discount_value: value });
|
||||
};
|
||||
const applyRule = (ruleUuid: string) => {
|
||||
discountMut.mutate({ discount_rule_uuid: ruleUuid });
|
||||
@@ -91,7 +93,7 @@ export default function PaymentStep({ recordUuid, session, walletBalance, onCont
|
||||
};
|
||||
const submitPayment = (method: string) => {
|
||||
if (amount <= 0) return;
|
||||
payMut.mutate({ method, amount_rials: amount, paid_at: isoToUnix(paymentDate) });
|
||||
payMut.mutate({ method, amount_rials: tomanToRial(amount), paid_at: isoToUnix(paymentDate) });
|
||||
};
|
||||
|
||||
const finalPrice = session.final_price_rials ?? 0;
|
||||
|
||||
Reference in New Issue
Block a user