Skip to content

Commit

Permalink
Merge pull request #2380 from shadrak98/fix-inv-item-descs
Browse files Browse the repository at this point in the history
fix: set invoice item descriptions for missing document types
  • Loading branch information
shadrak98 authored Dec 21, 2024
2 parents b5dd9c0 + 76a3b52 commit b95b2e8
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions press/press/doctype/invoice/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,11 +506,23 @@ def validate_dates(self):

def update_item_descriptions(self):
for item in self.items:
if not item.description and item.document_type == "Site" and item.plan:
site_name = item.document_name.split(".archived")[0]
plan = frappe.get_cached_value("Site Plan", item.plan, "plan_title")
if not item.description:
how_many_days = f"{cint(item.quantity)} day{'s' if item.quantity > 1 else ''}"
item.description = f"{site_name} active for {how_many_days} on {plan} plan"
if item.document_type == "Site" and item.plan:
site_name = item.document_name.split(".archived")[0]
plan = frappe.get_cached_value("Site Plan", item.plan, "plan_title")
item.description = f"{site_name} active for {how_many_days} on {plan} plan"
elif item.document_type in ["Server", "Database Server"]:
server_title = frappe.get_cached_value(item.document_type, item.document_name, "title")
if item.plan == "Add-on Storage plan":
item.description = f"{server_title} Storage Add-on for {how_many_days}"
else:
item.description = f"{server_title} active for {how_many_days}"
elif item.document_type == "Marketplace App":
app_title = frappe.get_cached_value("Marketplace App", item.document_name, "title")
item.description = f"Marketplace app {app_title} active for {how_many_days}"
else:
item.description = "Prepaid Credits"

def add_usage_record(self, usage_record):
if self.type != "Subscription":
Expand Down

0 comments on commit b95b2e8

Please sign in to comment.