Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #93 from Purplship/improve-customs-declaration
Browse files Browse the repository at this point in the history
[release-candidate] Improve customs declaration
  • Loading branch information
danh91 committed May 4, 2021
2 parents d61a3db + ff3bb42 commit 7c18d04
Show file tree
Hide file tree
Showing 42 changed files with 5,826 additions and 357 deletions.
20 changes: 10 additions & 10 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
FROM python:3.8

LABEL [email protected]
LABEL org.opencontainers.image.title="Purplship Server"
LABEL org.opencontainers.image.description="Purplship Server runtime image"
LABEL org.opencontainers.image.url="https://purplship.com"
LABEL org.opencontainers.image.documentation="https://docs.purplship.com"
LABEL org.opencontainers.image.source="https://github.com/purplship/purplship-server"
LABEL org.opencontainers.image.vendor="Purplship Team."
LABEL org.opencontainers.image.authors="[email protected]"

ENV DEBUG_MODE True
ENV USE_HTTPS False
ENV ALLOWED_HOSTS *
Expand All @@ -13,6 +22,7 @@ ENV DATABASE_PORT 5432
ENV DATABASE_NAME postgres
ENV DATABASE_USERNAME postgres
ENV DATABASE_PASSWORD postgres
ENV SECRET_KEY "w;l5kj65lk6j;lj56kl56jk5l656j5k6jl5"
ENV WORK_DIR /app
ENV LOG_DIR /log

Expand All @@ -30,13 +40,3 @@ RUN pip install --upgrade pip \
RUN chmod +x entrypoint.sh

ENTRYPOINT ["/bin/bash", "./entrypoint.sh"]


LABEL [email protected]
LABEL org.opencontainers.image.title="Purplship Server"
LABEL org.opencontainers.image.description="Purplship Server runtime image"
LABEL org.opencontainers.image.url="https://purplship.com"
LABEL org.opencontainers.image.documentation="https://docs.purplship.com"
LABEL org.opencontainers.image.source="https://github.com/purplship/purplship-server"
LABEL org.opencontainers.image.vendor="Purplship Team."
LABEL org.opencontainers.image.authors="[email protected]"

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/client/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='purplship-server.client',
version='2021.3.3',
version='2021.4',
description='Multi-carrier shipping API client module',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
4 changes: 3 additions & 1 deletion apps/core/purpleserver/core/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ class Duty(Serializer):
paid_by = ChoiceField(required=False, choices=PAYMENT_TYPES, allow_blank=True, allow_null=True, help_text="The duty payer")
currency = ChoiceField(required=False, choices=CURRENCIES, allow_blank=True, allow_null=True, help_text="The declared value currency")
declared_value = FloatField(required=False, allow_null=True, help_text="The package declared value")
account_number = CharField(required=False, allow_blank=True, allow_null=True, help_text="The duty payor account number")
account_number = CharField(required=False, allow_blank=True, allow_null=True, help_text="The duty payment account number")
bill_to = Address(required=False, allow_null=True, help_text="The duty billing address")


class CustomsData(Serializer):
Expand All @@ -235,6 +236,7 @@ class CustomsData(Serializer):
Note that this is required for a Dutiable parcel shipped internationally.
""")
invoice = CharField(required=False, allow_null=True, allow_blank=True, help_text="The invoice reference number")
invoice_date = CharField(required=False, allow_null=True, allow_blank=True, validators=[valid_date_format], help_text="The invoice date")
commercial_invoice = BooleanField(required=False, allow_null=True, help_text="Indicates if the shipment is commercial")
certify = BooleanField(required=False, allow_null=True, help_text="Indicate that signer certified confirmed all")
signer = CharField(required=False, allow_blank=True, allow_null=True)
Expand Down
17 changes: 15 additions & 2 deletions apps/core/purpleserver/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ def save(self, **kwargs) -> 'Decorator':
SerializerDecorator = _SerializerDecoratorInitializer()


def owned_model_serializer(serializer: Type[serializers.Serializer]):

class MetaSerializer(serializer):
def __init__(self, *args, **kwargs):
self._context_user = kwargs.pop('context_user') if 'context_user' in kwargs else None

super().__init__(*args, **kwargs)

return type(serializer.__name__, (MetaSerializer,), {})


def save_many_to_many_data(
name: str,
serializer: Type[serializers.ModelSerializer],
Expand All @@ -107,7 +118,8 @@ def save_many_to_many_data(
if item_instance is None:
item = SerializerDecorator[serializer](data=data, **kwargs).save().instance
else:
item = SerializerDecorator[serializer](instance=item_instance, data=data, **kwargs).save().instance
item = SerializerDecorator[serializer](
instance=item_instance, data=data, **{**kwargs, 'partial': True}).save().instance

getattr(parent, name).add(item)

Expand All @@ -134,4 +146,5 @@ def save_one_to_one_data(
parent and setattr(parent, name, new_instance)
return new_instance

return SerializerDecorator[serializer](instance=instance, data=data, **kwargs).save().instance
return SerializerDecorator[serializer](
instance=instance, data=data, **{**kwargs, 'partial': True}).save().instance
2 changes: 1 addition & 1 deletion apps/core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='purplship-server.core',
version='2021.3.1',
version='2021.4',
description='Multi-carrier shipping API Core module',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
66 changes: 60 additions & 6 deletions apps/graph/purpleserver/graph/schema/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,35 @@ class Meta:
exclude = ('user', )


class MessageType(graphene.ObjectType):
carrier_name = graphene.String()
carrier_id = graphene.String()
message = graphene.String()
code = graphene.String()
details = generic.GenericScalar()


class ChargeType(graphene.ObjectType):
name = graphene.String()
amount = graphene.Float()
currency = graphene.String()


class RateType(graphene.ObjectType):
carrier_name = graphene.String()
carrier_id = graphene.String()
currency = graphene.String()
transit_days = graphene.Int()
service = graphene.String()
discount = graphene.Float()
base_charge = graphene.Float()
total_charge = graphene.Float()
duties_and_taxes = graphene.Float()
extra_charges = graphene.List(ChargeType)
meta = generic.GenericScalar()
id = graphene.String()


class CommodityType(graphene_django.DjangoObjectType):
class Meta:
model = manager.Commodity
Expand All @@ -77,9 +106,18 @@ class Meta:
exclude = ('shipment_parcels', 'template', )


class DutyType(graphene.ObjectType):
paid_by = graphene.String()
currency = graphene.String()
account_number = graphene.String()
declared_value = graphene.Float()
bill_to = graphene.Field(AddressType)
id = graphene.String()


class CustomsType(graphene_django.DjangoObjectType):
commodities = graphene.List(CommodityType)
duty = generic.GenericScalar()
duty = graphene.Field(DutyType)

class Meta:
model = manager.Customs
Expand Down Expand Up @@ -132,16 +170,31 @@ class Meta:
interfaces = (CustomNode,)


class TrackingEventType(graphene.ObjectType):
description = graphene.String()
location = graphene.String()
code = graphene.String()
date = graphene.String()
time = graphene.String()


class TrackerType(graphene_django.DjangoObjectType):
tracking_carrier = graphene.Field(SystemConnectionType)
events = generic.GenericScalar()
events = graphene.List(TrackingEventType)

class Meta:
model = manager.Tracking
filter_fields = ['delivered']
interfaces = (CustomNode,)


class PaymentType(graphene.ObjectType):
paid_by = graphene.String()
currency = graphene.String()
account_number = graphene.String()
id = graphene.String()


class ShipmentType(graphene_django.DjangoObjectType):
carrier_id = graphene.String()
carrier_name = graphene.String()
Expand All @@ -150,15 +203,16 @@ class ShipmentType(graphene_django.DjangoObjectType):
recipient = graphene.Field(AddressType)
customs = graphene.Field(CustomsType)
parcels = graphene.List(ParcelType)
payment = graphene.Field(PaymentType)

services = graphene.List(graphene.String)
carrier_ids = graphene.List(graphene.String)
payment = generic.GenericScalar()
messages = graphene.List(MessageType)
selected_rate = graphene.Field(RateType)
rates = graphene.List(RateType)

options = generic.GenericScalar()
meta = generic.GenericScalar()
messages = generic.GenericScalar()
selected_rate = generic.GenericScalar()
rates = generic.GenericScalar()

class Meta:
model = manager.Shipment
Expand Down
52 changes: 49 additions & 3 deletions apps/graph/purpleserver/graph/tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,27 @@ def _create_customs_info_template(self):
commercial_invoice
certificate_number
content_description
duty
duty {
paid_by
currency
account_number
declared_value
bill_to {
company_name
person_name
address_line1
address_line2
postal_code
residential
city
state_code
country_code
email
phone_number
validation
validate_location
}
}
invoice
signer
certify
Expand Down Expand Up @@ -292,7 +312,27 @@ def test_update_customs_info_template(self):
commercial_invoice
certificate_number
content_description
duty
duty {
paid_by
currency
account_number
declared_value
bill_to {
company_name
person_name
address_line1
address_line2
postal_code
residential
city
state_code
country_code
email
phone_number
validation
validate_location
}
}
invoice
signer
certify
Expand Down Expand Up @@ -587,7 +627,13 @@ def test_delete_customs_info(self):
"commercial_invoice": None,
"certificate_number": None,
"content_description": None,
"duty": {"paid_by": "SENDER"},
"duty": {
'account_number': None,
'bill_to': None,
'currency': None,
'declared_value': None,
'paid_by': 'SENDER'
},
"invoice": None,
"signer": None,
"certify": None,
Expand Down
2 changes: 1 addition & 1 deletion apps/graph/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='purplship-server.graph',
version='2021.3.1',
version='2021.4',
description='Multi-carrier shipping API Graph module',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2 on 2021-05-03 18:41

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('manager', '0012_auto_20210427_1319'),
]

operations = [
migrations.AddField(
model_name='customs',
name='invoice_date',
field=models.DateField(blank=True, null=True),
),
]
Loading

0 comments on commit 7c18d04

Please sign in to comment.