Skip to content

Commit

Permalink
fix: avoid duplicating invoice items for drafts
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Jan 13, 2025
1 parent 991b180 commit 0af02b9
Showing 1 changed file with 19 additions and 29 deletions.
48 changes: 19 additions & 29 deletions weblate_web/invoices/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,35 +662,25 @@ def duplicate(
extra=extra if extra is not None else self.extra,
)
for item in self.all_items:
if kind == InvoiceKind.DRAFT:
if item.package:
# Load description and price from the package
invoice.invoiceitem_set.create(
quantity=item.quantity,
quantity_unit=item.quantity_unit,
package=item.package,
start_date=start_date or item.start_date,
end_date=end_date or item.end_date,
)
else:
invoice.invoiceitem_set.create(
description=item.description,
quantity=item.quantity,
quantity_unit=item.quantity_unit,
unit_price=item.unit_price,
package=item.package,
start_date=start_date or item.start_date,
end_date=end_date or item.end_date,
)
invoice.invoiceitem_set.create(
description=item.description,
quantity=item.quantity,
quantity_unit=item.quantity_unit,
unit_price=item.unit_price,
package=item.package,
start_date=start_date or item.start_date,
end_date=end_date or item.end_date,
)
if kind == InvoiceKind.DRAFT and item.package:
# Load description and price from the package
invoice.invoiceitem_set.create(
quantity=item.quantity,
quantity_unit=item.quantity_unit,
package=item.package,
start_date=start_date or item.start_date,
end_date=end_date or item.end_date,
)
else:
invoice.invoiceitem_set.create(
description=item.description,
quantity=item.quantity,
quantity_unit=item.quantity_unit,
unit_price=item.unit_price,
package=item.package,
start_date=start_date or item.start_date,
end_date=end_date or item.end_date,
)
return invoice

def create_payment(
Expand Down

0 comments on commit 0af02b9

Please sign in to comment.