前期预收
This commit is contained in:
@@ -13,7 +13,7 @@ class PreAdvanceReport(models.Model):
|
||||
前期预收报表(数据源:receivable.modify.line):
|
||||
- 收款日期(reconciliation_date)早于应收日期(due_date)
|
||||
- 收款日期和应收日期不在同一年同一月(跨月才算预收)
|
||||
- 查询日期对应应收账单的 due_date(应收日期在查询日之后)
|
||||
- 应收日期限制在查询月当月(如查1月,只显示应收日期在1月的记录)
|
||||
- 金额取收款记录的 amount
|
||||
- 按应收账单聚合,每张账单只出一行
|
||||
"""
|
||||
@@ -26,18 +26,24 @@ class PreAdvanceReport(models.Model):
|
||||
|
||||
date_start = params.get("date_start")
|
||||
summary_only = params.get("summary_only", False)
|
||||
# 应收日期在查询日当月及之后(即未来应收)
|
||||
# 应收日期限制在查询月当月(即1月份查就只查1月份的应收)
|
||||
cutoff_date = datetime.datetime.fromisoformat(date_start).date() if date_start else this_month_last
|
||||
# 取查询日所在月的第一天,应收日期 >= 该月第一天
|
||||
# 取查询日所在月的第一天和最后一天
|
||||
cutoff_month_first = cutoff_date.replace(day=1)
|
||||
if cutoff_month_first.month == 12:
|
||||
next_month_first = cutoff_month_first.replace(year=cutoff_month_first.year + 1, month=1, day=1)
|
||||
else:
|
||||
next_month_first = cutoff_month_first.replace(month=cutoff_month_first.month + 1, day=1)
|
||||
cutoff_month_last = next_month_first - datetime.timedelta(days=1)
|
||||
|
||||
# 核心逻辑:前期预收 = 截止到查询日之前已提前收取的未来应收款
|
||||
# 条件1:due_date >= 查询月第一天(未来/当期应收)
|
||||
# 核心逻辑:前期预收 = 截止到查询日之前已提前收取的当月应收款
|
||||
# 条件1:due_date 在查询月当月
|
||||
# 条件2:存在收款记录(后续再精确过滤)
|
||||
# 注意:不在此处限制 reconciliation_date,因为需要先查出所有相关记录再做聚合
|
||||
domain = [
|
||||
('reconciliation_date', '!=', False),
|
||||
('receivable_id.due_date', '>=', cutoff_month_first),
|
||||
('receivable_id.due_date', '>=', cutoff_month_first), # 应收月 >= 查询月月初
|
||||
('receivable_id.due_date', '<=', cutoff_month_last), # 应收月 <= 查询月月末
|
||||
('receivable_id.is_invalid', '!=', True),
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user