优化报销功能
This commit is contained in:
1 parent
395c7f717e
commit
4306cbd74b
19 files changed
+2059
-534
No files matched your search
@@ -1001,16 +1001,14 @@ type reimbursementStatusPayload struct {
|
||||
Status int8 `json:"status"`
|
||||
}
|
||||
|
||||
var manualConfirmStatuses = map[int8]bool{
|
||||
0: true, // 草稿
|
||||
1: true, // 审批中
|
||||
2: true, // 已通过
|
||||
3: true, // 已驳回
|
||||
4: true, // 已撤回
|
||||
5: true, // 已打款
|
||||
}
|
||||
// 报销单状态(0草稿 1审批中 2已通过 3已驳回 4已撤回 5已打款)
|
||||
const (
|
||||
reimbursementStatusApproved int8 = 2 // 已通过
|
||||
reimbursementStatusPaid int8 = 5 // 已打款
|
||||
)
|
||||
|
||||
// UpdateStatus POST /backend/reimbursements/:id/status — 手动确认更改单据状态
|
||||
// UpdateStatus POST /backend/reimbursements/:id/status — 报销人确认款项到账(置为「已打款」)。
|
||||
// 其它状态均由审批引擎/流程动作推进,不再支持手工变更。
|
||||
func (c *BackendReimburseController) UpdateStatus() {
|
||||
claims, ok := c.claims()
|
||||
if !ok {
|
||||
@@ -1040,27 +1038,33 @@ func (c *BackendReimburseController) UpdateStatus() {
|
||||
c.reply(200, "success", map[string]interface{}{"status": newStatus})
|
||||
}
|
||||
|
||||
// reimburseUpdateStatusCore 手动确认更改单据状态共享逻辑。
|
||||
// reimburseUpdateStatusCore 报销人确认款项到账共享逻辑。
|
||||
//
|
||||
// 规则:审批通过后,报销金额是否到账由报销人本人确认;确认后单据置为「已打款」。
|
||||
// 草稿/审批中/已通过/已驳回/已撤回等状态一律由流程动作与审批引擎推进,不再支持手工修改。
|
||||
// 返回 (生效状态, HTTP 状态码, 错误信息)。
|
||||
func reimburseUpdateStatusCore(claims *jwtutil.Claims, id uint64, status int8) (int8, int, string) {
|
||||
if !manualConfirmStatuses[status] {
|
||||
return 0, 400, "不支持的状态值"
|
||||
if status != reimbursementStatusPaid {
|
||||
return 0, 400, "仅支持确认收款,其它状态由审批流程自动推进"
|
||||
}
|
||||
row, err := findOwnedReimbursement(claims, id)
|
||||
if err != nil {
|
||||
return 0, 404, "报销单不存在"
|
||||
}
|
||||
if row.Status == status {
|
||||
if row.Status == reimbursementStatusPaid {
|
||||
return row.Status, 200, ""
|
||||
}
|
||||
if row.Status != reimbursementStatusApproved {
|
||||
return 0, 400, "仅审批通过的报销单可以确认到账"
|
||||
}
|
||||
now := time.Now()
|
||||
_, err = models.Orm.QueryTable(new(models.BackendReimbursement)).Filter("id", id).Update(orm.Params{
|
||||
"status": status, "update_time": now,
|
||||
"status": reimbursementStatusPaid, "update_time": now,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, 500, "更新状态失败"
|
||||
}
|
||||
return status, 200, ""
|
||||
return reimbursementStatusPaid, 200, ""
|
||||
}
|
||||
|
||||
// Records GET /backend/reimbursements/:id/records
|
||||
|
||||
Reference in new issue
Block a user