feat: allow repeated bill generation and editable deposit deductions

This commit is contained in:
2026-07-15 09:12:36 +08:00
parent c86550f894
commit 6f23f8a9f1
6 changed files with 109 additions and 84 deletions

View File

@@ -356,14 +356,13 @@ const BillsPage: React.FC = () => {
name="billingMonth"
label="账单月份"
rules={[{ required: true, message: '请选择账单月份' }]}
extra="只能选择已结束月份,每个月只能生成一次账单"
extra="选择任意账单月份;重复生成时无变化不生成,有变化则生成差额账单"
>
<DatePicker
style={{ width: '100%' }}
picker="month"
placeholder="选择月份"
format="YYYY-MM"
disabledDate={(current) => !!current && !current.endOf('month').isBefore(dayjs(), 'day')}
/>
</Form.Item>
</Form>

View File

@@ -120,6 +120,7 @@ const DepositsPage: React.FC = () => {
const values = await refundForm.validateFields();
await api.put(`/deposits/${refundModal.id}/refund`, {
refundDate: values.refundDate.format('YYYY-MM-DD'),
deductionAmount: values.deductionAmount || 0,
notes: values.notes,
});
message.success('退还操作完成');
@@ -210,7 +211,13 @@ const DepositsPage: React.FC = () => {
type="primary"
onClick={() => {
setRefundModal(record);
refundForm.setFieldsValue({ refundDate: dayjs() });
refundForm.setFieldsValue({
refundDate: dayjs(),
deductionAmount: Math.min(
moneyNumber(record.amount),
moneyNumber(record.personalExpenseAmount),
),
});
}}
>
退
@@ -361,33 +368,24 @@ const DepositsPage: React.FC = () => {
<strong>¥{moneyNumber(refundModal?.personalExpenseAmount).toFixed(2)}</strong>
</div>
<div style={{ marginTop: 4 }}>
:{' '}
<strong style={{ color: '#fa8c16' }}>
¥
{Math.min(
moneyNumber(refundModal?.amount),
moneyNumber(refundModal?.personalExpenseAmount),
).toFixed(2)}
</strong>
</div>
<div style={{ marginTop: 4 }}>
退:{' '}
<strong style={{ color: '#52c41a' }}>
¥
{Math.max(
0,
moneyNumber(refundModal?.amount) -
Math.min(
moneyNumber(refundModal?.amount),
moneyNumber(refundModal?.personalExpenseAmount),
),
).toFixed(2)}
</strong>
</div>
</div>
<Form.Item name="refundDate" label="退还日期" rules={[{ required: true }]}>
<DatePicker style={{ width: '100%' }} placeholder="选择退还日期" format="YYYY-MM-DD" />
</Form.Item>
<Form.Item
name="deductionAmount"
label="扣除金额(元)"
extra="默认填入未出账个人附加费,不能超过当前可用押金"
>
<InputNumber
min={0}
max={moneyNumber(refundModal?.amount)}
precision={2}
style={{ width: '100%' }}
/>
</Form.Item>
<Form.Item name="notes" label="备注">
<Input.TextArea rows={2} />
</Form.Item>