diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 0cab099..0000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,12 +0,0 @@ -repos: - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.11.7' - hooks: - - id: ruff - args: [--fix, --exit-non-zero-on-fix] - - id: ruff-format - - repo: https://github.com/adamchainz/django-upgrade - rev: "1.24.0" - hooks: - - id: django-upgrade - args: [--target-version, "5.2"] diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 0000000..7eb4fef --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,8 @@ +extends: default + +rules: + document-start: disable + line-length: + max: 120 + truthy: + allowed-values: ["true", "false", "on", "off"] diff --git a/bbs/api/queries/inventory.py b/bbs/api/queries/inventory.py index 0059297..ca1e497 100644 --- a/bbs/api/queries/inventory.py +++ b/bbs/api/queries/inventory.py @@ -75,32 +75,24 @@ class InventoryQueries: inventory_purchases = sum((product["purchase_value"] for product in product_data), Decimal(0)) product_sales = sum((product["sales_value"] for product in product_data), Decimal(0)) - deposits = ( - models.Transaction.objects.filter(created__range=(start_time, end_time)).aggregate(total=Sum("amount"))[ - "total" - ] - or Decimal(0) - ) - order_purchases = ( - models.Order.objects.filter(created__range=(start_time, end_time)).aggregate(total=Sum("order_sum"))[ - "total" - ] - or Decimal(0) - ) - deposits_start = ( - models.Transaction.objects.filter(created__lt=start_time).aggregate(total=Sum("amount"))["total"] - or Decimal(0) - ) - orders_start = ( - models.Order.objects.filter(created__lt=start_time).aggregate(total=Sum("order_sum"))["total"] or Decimal(0) - ) - deposits_end = ( - models.Transaction.objects.filter(created__lte=end_time).aggregate(total=Sum("amount"))["total"] - or Decimal(0) - ) - orders_end = ( - models.Order.objects.filter(created__lte=end_time).aggregate(total=Sum("order_sum"))["total"] or Decimal(0) - ) + deposits = models.Transaction.objects.filter(created__range=(start_time, end_time)).aggregate( + total=Sum("amount") + )["total"] or Decimal(0) + order_purchases = models.Order.objects.filter(created__range=(start_time, end_time)).aggregate( + total=Sum("order_sum") + )["total"] or Decimal(0) + deposits_start = models.Transaction.objects.filter(created__lt=start_time).aggregate(total=Sum("amount"))[ + "total" + ] or Decimal(0) + orders_start = models.Order.objects.filter(created__lt=start_time).aggregate(total=Sum("order_sum"))[ + "total" + ] or Decimal(0) + deposits_end = models.Transaction.objects.filter(created__lte=end_time).aggregate(total=Sum("amount"))[ + "total" + ] or Decimal(0) + orders_end = models.Order.objects.filter(created__lte=end_time).aggregate(total=Sum("order_sum"))[ + "total" + ] or Decimal(0) return InventoryReport( products=[InventoryReportProduct(**product) for product in product_data], diff --git a/prek.toml b/prek.toml new file mode 100644 index 0000000..7e859fc --- /dev/null +++ b/prek.toml @@ -0,0 +1,23 @@ +#:schema https://www.schemastore.org/prek.json + +[[repos]] +repo = "https://github.com/astral-sh/ruff-pre-commit" +rev = "v0.11.7" +hooks = [ + { id = "ruff", args = ["--fix", "--exit-non-zero-on-fix"] }, + { id = "ruff-format" }, +] + +[[repos]] +repo = "https://github.com/adamchainz/django-upgrade" +rev = "1.24.0" +hooks = [ + { id = "django-upgrade", args = ["--target-version", "5.2"] }, +] + +[[repos]] +repo = "https://github.com/adrienverge/yamllint" +rev = "v1.38.0" +hooks = [ + { id = "yamllint" }, +]