修复创建发票时找不到邮箱错误

This commit is contained in:
jingrow 2025-04-22 12:13:02 +08:00
parent cfc64b7c10
commit a1ee06ecea

View File

@ -1110,9 +1110,24 @@ class Team(Document):
def create_upcoming_invoice(self):
today = jingrow.utils.today()
return jingrow.get_pg(
pagetype="Invoice", team=self.name, period_start=today, type="Subscription"
).insert()
# 获取团队关联用户的email
user_email = jingrow.db.get_value("User", self.user, "email")
# 如果用户没有email则使用备选邮箱格式
customer_email = user_email or f"{self.name}@example.com"
# 创建发票时使用用户email
invoice = jingrow.get_pg({
"pagetype": "Invoice",
"team": self.name,
"date": today,
"status": "Draft",
"customer_email": customer_email,
# 其他字段...
}).insert()
return invoice
def notify_with_email(self, recipients: list[str], **kwargs):
if not self.send_notifications: