Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Merge branch 'master' of github.com:mirumee/saleor into feature/invoices

Tomasz Szymanski3721ce453a2d
diff --cc .isort.cfg
index a40f38033c,b21b7d4a4b..f3dc5ed82a
--- a/.isort.cfg
+++ b/.isort.cfg
@@@ -1,2 -1,2 +1,2 @@@
[settings]
- known_third_party = PIL,babel,braintree,celery,dj_database_url,dj_email_url,django,django_cache_url,django_countries,django_filters,django_measurement,django_prices,django_prices_openexchangerates,django_prices_vatlayer,draftjs_sanitizer,faker,freezegun,geolite2,google_measurement_protocol,graphene,graphene_django,graphene_federation,graphql,graphql_jwt,graphql_relay,html_to_draftjs,i18naddress,jaeger_client,jwt,markdown,measurement,mptt,oauthlib,opentracing,phonenumber_field,phonenumbers,pkg_resources,prices,promise,pytest,pytz,razorpay,requests,sentry_sdk,storages,stripe,templated_email,text_unidecode,tqdm,versatileimagefield,weasyprint
-known_third_party = PIL,babel,braintree,celery,dj_database_url,dj_email_url,django,django_cache_url,django_countries,django_filters,django_measurement,django_prices,django_prices_openexchangerates,django_prices_vatlayer,draftjs_sanitizer,faker,freezegun,geolite2,google_measurement_protocol,graphene,graphene_django,graphene_federation,graphql,graphql_relay,html_to_draftjs,i18naddress,jaeger_client,jwt,markdown,measurement,mptt,oauthlib,opentracing,phonenumber_field,phonenumbers,pkg_resources,prices,promise,pytest,pytimeparse,pytz,razorpay,requests,sentry_sdk,storages,stripe,templated_email,tqdm,versatileimagefield
++known_third_party = PIL,babel,braintree,celery,dj_database_url,dj_email_url,django,django_cache_url,django_countries,django_filters,django_measurement,django_prices,django_prices_openexchangerates,django_prices_vatlayer,draftjs_sanitizer,faker,freezegun,geolite2,google_measurement_protocol,graphene,graphene_django,graphene_federation,graphql,graphql_relay,html_to_draftjs,i18naddress,jaeger_client,jwt,markdown,measurement,mptt,oauthlib,opentracing,phonenumber_field,phonenumbers,pkg_resources,prices,promise,pytest,pytimeparse,pytz,razorpay,requests,sentry_sdk,storages,stripe,templated_email,tqdm,versatileimagefield,weasyprint
diff --cc CHANGELOG.md
index c69d28caab,c3d91e65fc..4d6b859275
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -4,10 -4,14 +4,15 @@@ All notable, unreleased changes to thi
## [Unreleased]
+- Invoices backend - #5732 by @tomaszszymanski129
- Add our implementation of UUID scalar - #5646 by @koradon
- - Add AppTokenVerify mutation - #5716 by @korycins
+ - Add AppTokenVerify mutation - #5716 by @korycins
- Fix specific product voucher in draft orders - #5727 by @fowczarek
+ - Explicit country assignment in default shipping zones - #5736 by @maarcingebala
+ - Drop `json_content` field from the `Menu` model - #5761 by @maarcingebala
+ - Refactor JWT support - #5734 by @korycins
+ - Strip warehouse name in mutations - #5766 by @koradon
+ - Add missing OrderEvents during checkout flow - #5684 by @koradon
## 2.10.1
diff --cc saleor/graphql/api.py
index 9ae14e6421,c2877afa1a..d7fcb72ea0
--- a/saleor/graphql/api.py
+++ b/saleor/graphql/api.py
@@@ -3,10 -3,9 +3,10 @@@ from graphene_federation import build_s
from .account.schema import AccountMutations, AccountQueries
from .app.schema import AppMutations, AppQueries
from .checkout.schema import CheckoutMutations, CheckoutQueries
- from .core.schema import CoreMutations, CoreQueries
+ from .core.schema import CoreQueries
from .discount.schema import DiscountMutations, DiscountQueries
from .giftcard.schema import GiftCardMutations, GiftCardQueries
+from .invoice.schema import InvoiceMutations
from .menu.schema import MenuMutations, MenuQueries
from .meta.schema import MetaMutations
from .order.schema import OrderMutations, OrderQueries
diff --cc saleor/graphql/order/types.py
index 14bf470152,8dbd0d363c..5a21d82db5
--- a/saleor/graphql/order/types.py
+++ b/saleor/graphql/order/types.py
@@@ -1,11 -1,10 +1,11 @@@
import graphene
from django.core.exceptions import ValidationError
from graphene import relay
- from graphql_jwt.exceptions import PermissionDenied
+ from ...core.exceptions import PermissionDenied
from ...core.permissions import AccountPermissions, OrderPermissions
from ...core.taxes import display_gross_prices
+from ...graphql.utils import get_user_or_app_from_context
from ...order import OrderStatus, models
from ...order.models import FulfillmentStatus
from ...order.utils import get_order_country, get_valid_shipping_methods_for_order
diff --cc saleor/graphql/schema.graphql
index d6e2e2e096,666357f91b..d8fab5f820
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@@ -1442,22 -1447,13 +1447,24 @@@ type CountryDisplay
vat: VAT
}
+type CreateInvoice {
+ errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")
+ invoiceErrors: [InvoiceError!]!
+ invoice: Invoice
+}
+
+input CreateInvoiceInput {
+ number: String!
+ url: String!
+}
+
type CreateToken {
- token: String
errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")
- accountErrors: [AccountError!]!
+ token: String
+ refreshToken: String
+ csrfToken: String
user: User
+ accountErrors: [AccountError!]!
}
type CreditCard {
@@@ -1551,14 -1547,13 +1558,19 @@@ input DateTimeRangeInput
lte: DateTime
}
+ type DeactivateAllUserTokens {
+ errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")
+ accountErrors: [AccountError!]!
+ }
+
scalar Decimal
+type DeleteInvoice {
+ errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")
+ invoiceErrors: [InvoiceError!]!
+ invoice: Invoice
+}
+
type DeleteMetadata {
errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")
metadataErrors: [MetadataError!]!
diff --cc saleor/invoice/migrations/0001_initial.py
index baa4bb1902,0000000000..6661c3a502
mode 100644,000000..100644
--- a/saleor/invoice/migrations/0001_initial.py
+++ b/saleor/invoice/migrations/0001_initial.py
@@@ -1,157 -1,0 +1,157 @@@
- # Generated by Django 3.0.6 on 2020-06-02 07:32
++# Generated by Django 3.0.6 on 2020-06-22 10:25
+
+import django.contrib.postgres.fields.jsonb
+import django.db.models.deletion
+import django.utils.timezone
+from django.conf import settings
+from django.db import migrations, models
+
+import saleor.core.utils.json_serializer
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ("order", "0085_delete_invoice"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="Invoice",
+ fields=[
+ (
+ "id",
+ models.AutoField(
+ auto_created=True,
+ primary_key=True,
+ serialize=False,
+ verbose_name="ID",
+ ),
+ ),
+ (
+ "private_metadata",
+ django.contrib.postgres.fields.jsonb.JSONField(
+ blank=True,
+ default=dict,
+ encoder=saleor.core.utils.json_serializer.CustomJsonEncoder,
+ null=True,
+ ),
+ ),
+ (
+ "metadata",
+ django.contrib.postgres.fields.jsonb.JSONField(
+ blank=True,
+ default=dict,
+ encoder=saleor.core.utils.json_serializer.CustomJsonEncoder,
+ null=True,
+ ),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("pending", "Pending"),
+ ("success", "Success"),
+ ("failed", "Failed"),
+ ("deleted", "Deleted"),
+ ],
+ default="pending",
+ max_length=50,
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("number", models.CharField(max_length=255, null=True)),
+ ("created", models.DateTimeField(null=True)),
+ ("external_url", models.URLField(max_length=2048, null=True)),
+ ("invoice_file", models.FileField(upload_to="invoices")),
+ (
+ "order",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="invoices",
+ to="order.Order",
+ ),
+ ),
+ ],
+ options={"abstract": False,}, # noqa: E231
+ ),
+ migrations.CreateModel(
+ name="InvoiceEvent",
+ fields=[
+ (
+ "id",
+ models.AutoField(
+ auto_created=True,
+ primary_key=True,
+ serialize=False,
+ verbose_name="ID",
+ ),
+ ),
+ (
+ "date",
+ models.DateTimeField(
+ default=django.utils.timezone.now, editable=False
+ ),
+ ),
+ (
+ "type",
+ models.CharField(
+ choices=[
+ ("requested", "The invoice was requested"),
+ (
+ "requested_deletion",
+ "The invoice was requested for deletion",
+ ),
+ ("created", "The invoice was created"),
+ ("deleted", "The invoice was deleted"),
+ ("sent", "The invoice has been sent"),
+ ],
+ max_length=255,
+ ),
+ ),
+ (
+ "parameters",
+ django.contrib.postgres.fields.jsonb.JSONField(
+ blank=True,
+ default=dict,
+ encoder=saleor.core.utils.json_serializer.CustomJsonEncoder,
+ ),
+ ),
+ (
+ "invoice",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="events",
+ to="invoice.Invoice",
+ ),
+ ),
+ (
+ "order",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="invoice_events",
+ to="order.Order",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={"ordering": ("date",),}, # noqa: E231
+ ),
+ ]
diff --cc saleor/order/migrations/0085_delete_invoice.py
index c9369bbeef,0000000000..302e1c5cdb
mode 100644,000000..100644
--- a/saleor/order/migrations/0085_delete_invoice.py
+++ b/saleor/order/migrations/0085_delete_invoice.py
@@@ -1,14 -1,0 +1,14 @@@
- # Generated by Django 3.0.6 on 2020-05-25 09:33
++# Generated by Django 3.0.6 on 2020-06-22 10:24
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
- ("order", "0084_auto_20200426_0647"),
++ ("order", "0084_auto_20200522_0522"),
+ ]
+
+ operations = [
+ migrations.DeleteModel(name="Invoice",),
+ ]
diff --cc saleor/tests/fixtures.py
index 10341be3bd,a6c77323e3..63b6ad1868
--- a/saleor/tests/fixtures.py
+++ b/saleor/tests/fixtures.py
@@@ -37,9 -35,7 +37,8 @@@ from ..discount.models import
VoucherTranslation,
)
from ..giftcard.models import GiftCard
+from ..invoice.models import Invoice
from ..menu.models import Menu, MenuItem, MenuItemTranslation
- from ..menu.utils import update_menu
from ..order import OrderStatus
from ..order.actions import cancel_fulfillment, fulfill_order_line
from ..order.events import OrderEvents