更新密码找回uniapp
This commit is contained in:
1 parent
7f9a66da0f
commit
3fdda89833
1304 files changed
+3503
-26132
No files matched your search
@@ -9,9 +9,6 @@ import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
// applyToBill 向一张往来账核销 take 金额(正数)。
|
||||
// 正数账(应收/应付)核销使 settled 增加;红字账(负额)反向移动,
|
||||
// 统一口径:余额 = amount - settled,核销使 |余额| 趋近 0。
|
||||
func applyToBill(o orm.QueryExecutor, bill *models.ErpPartnerBill, take float64) (float64, error) {
|
||||
if take <= 0 {
|
||||
return 0, nil
|
||||
@@ -32,20 +29,16 @@ func applyToBill(o orm.QueryExecutor, bill *models.ErpPartnerBill, take float64)
|
||||
return 0, err
|
||||
}
|
||||
used := take
|
||||
if absf(delta) > absf(take) { // 不超过剩余余额
|
||||
if absf(delta) > absf(take) {
|
||||
used = absf(bill.Amount - bill.SettledAmount)
|
||||
}
|
||||
return used, nil
|
||||
}
|
||||
|
||||
// autoOffsetBill 新账入账时与反向挂账互抵:
|
||||
// 红字退货账优先抵扣同单位未结的正数往来账;正数账优先吸收红字余额(预收预付)。
|
||||
// 返回该账本行插入时应携带的已核销额(正数账吸收红字的场景)。
|
||||
func autoOffsetBill(o orm.QueryExecutor, bill *models.ErpPartnerBill) (float64, error) {
|
||||
if absf(bill.Amount) < 0.005 {
|
||||
return 0, nil
|
||||
}
|
||||
// 查找同单位、同向相反、未结清的账
|
||||
var opps []models.ErpPartnerBill
|
||||
qs := o.QueryTable(new(models.ErpPartnerBill)).
|
||||
Filter("tenant_id", bill.TenantID).
|
||||
@@ -56,7 +49,6 @@ func autoOffsetBill(o orm.QueryExecutor, bill *models.ErpPartnerBill) (float64,
|
||||
_, _ = qs.OrderBy("bill_date", "id").All(&opps)
|
||||
|
||||
if bill.Amount > 0 {
|
||||
// 正数账:先吸收红字(负额未结账)
|
||||
consumed := 0.0
|
||||
for i := range opps {
|
||||
b := &opps[i]
|
||||
@@ -82,7 +74,6 @@ func autoOffsetBill(o orm.QueryExecutor, bill *models.ErpPartnerBill) (float64,
|
||||
return round2(consumed), nil
|
||||
}
|
||||
|
||||
// 红字账(amount<0):插入后抵扣正数账
|
||||
var pos []models.ErpPartnerBill
|
||||
_, _ = o.QueryTable(new(models.ErpPartnerBill)).
|
||||
Filter("tenant_id", bill.TenantID).
|
||||
@@ -115,7 +106,6 @@ func autoOffsetBill(o orm.QueryExecutor, bill *models.ErpPartnerBill) (float64,
|
||||
need -= used
|
||||
}
|
||||
if consumed > 0 {
|
||||
// 红字自身推进 settled(负向)
|
||||
newSettled := round2(-consumed)
|
||||
status := int8(1)
|
||||
if absf(bill.Amount-newSettled) < 0.005 {
|
||||
@@ -129,7 +119,6 @@ func autoOffsetBill(o orm.QueryExecutor, bill *models.ErpPartnerBill) (float64,
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// OffsetAfterBillInsert 往来账插入后的互抵处理(正数账已在插入时携带 settled 的不再调用)。
|
||||
func OffsetAfterBillInsert(o orm.QueryExecutor, billID uint64) {
|
||||
var bill models.ErpPartnerBill
|
||||
if err := o.QueryTable(new(models.ErpPartnerBill)).Filter("id", billID).One(&bill); err != nil {
|
||||
@@ -140,17 +129,11 @@ func OffsetAfterBillInsert(o orm.QueryExecutor, billID uint64) {
|
||||
}
|
||||
}
|
||||
|
||||
// SettleItem 核销明细入参
|
||||
type SettleItem struct {
|
||||
PartnerBillID uint64 `json:"partner_bill_id"`
|
||||
Amount float64 `json:"amount"`
|
||||
}
|
||||
|
||||
// ConfirmFundBill 收付款单确认生效:
|
||||
// - fund_type=1/2(收款/付款):按 settles 逐笔核销,未指定则自动 FIFO
|
||||
// (到期日→账期日升序,仅正数余额账);核销余量作为预收/预付留在单上。
|
||||
// - fund_type=3/4(其他收入/费用):仅登记资金流水。
|
||||
// - 同时校验:草稿态、金额>0、核销对象为同租户同往来单位且类型匹配。
|
||||
func ConfirmFundBill(fundID uint64, tenantID string, settles []SettleItem, operatorName string) error {
|
||||
o := models.Orm
|
||||
tx, err := o.Begin()
|
||||
@@ -245,7 +228,6 @@ func ConfirmFundBill(fundID uint64, tenantID string, settles []SettleItem, opera
|
||||
return nil
|
||||
}
|
||||
|
||||
// autoFifoSettle 未指定核销明细时,按到期日/账期日升序自动分摊。
|
||||
func autoFifoSettle(tx orm.QueryExecutor, fund *models.ErpFundBill, billType int8, amount float64) ([]SettleItem, error) {
|
||||
var bills []models.ErpPartnerBill
|
||||
qs := tx.QueryTable(new(models.ErpPartnerBill)).
|
||||
@@ -280,7 +262,6 @@ func autoFifoSettle(tx orm.QueryExecutor, fund *models.ErpFundBill, billType int
|
||||
return items, nil
|
||||
}
|
||||
|
||||
// VoidFundBill 作废收付款单:仅草稿或确认但未核销任何往来账的单据。
|
||||
func VoidFundBill(fundID uint64, tenantID string) error {
|
||||
var fund models.ErpFundBill
|
||||
if err := models.Orm.QueryTable(new(models.ErpFundBill)).
|
||||
|
||||
Reference in new issue
Block a user