Skip to content

Instantly share code, notes, and snippets.

@mario-chaves
Created February 28, 2016 01:25
Show Gist options
  • Save mario-chaves/a3aef28adc811bc932d5 to your computer and use it in GitHub Desktop.
Save mario-chaves/a3aef28adc811bc932d5 to your computer and use it in GitHub Desktop.
from decimal import Decimal
from django.utils.timezone import UTC, datetime
from model_mommy import mommy
customer = mommy.make('order.Customer', cpf='123212212-54', email='[email protected]', first_name='Carol', phone='85-988778899')
address = mommy.make('order.Address', customer=customer, address='Rua Dr.a Neyde', number='256', district='Vila Clementino', city='São Paulo', state='SP', zipcode='04022040')
seller = Seller.objects.get(name=‘sandboxintegracao’)
marketplace = mommy.make('marketplace.Marketplace', name='Magazine Luiza’, platform=‘magazineluiza’)
product = mommy.make('product.Product', name='prod_1', seller=seller)
variation = mommy.make('product.Variation', sku='123', sku_name='name_123', product=product, sku_name_complete='full_name_123')
order = mommy.make('order.Order', customer=customer, shipping_address=address, marketplace_order_id='123456', marketplace=marketplace)
Status.objects.save_on(order, Status.WAITING_PAYMENT)
sub_order = mommy.make('order.SubOrder', order=order, seller=seller)
Status.objects.save_on(sub_order, Status.CREATED)
info1 = mommy.make('order.SubOrderInfoTracking', variation=variation, price=Decimal('10.20'), seller_ship_price=Decimal('5.0'), sub_order=sub_order, quantity=2)
info2 = mommy.make('order.SubOrderInfoTracking', variation=variation, price=Decimal('5.60'), seller_ship_price=Decimal('5.0'), sub_order=sub_order, quantity=5)
info3 = mommy.make('order.SubOrderInfoTracking', variation=variation, price=Decimal('135.28'), seller_ship_price=Decimal('5.0'), sub_order=sub_order, quantity=1)
tracking1 = mommy.make('package.Tracking', send_date=None, shipping_company='FedEx', tracking_number='123', tracking_url='http://fedex.com')
pack1 = mommy.make('package.Package', sub_order=sub_order, tracking=tracking1)
Status.objects.save_on(pack1, Status.DISPATCHED)
invoice1 = mommy.make('package.Invoice', package=pack1, type='inv_type_1', number='123', value=Decimal('15.80'), date=datetime(2016, 2, 24, 0, 0, 0, 0, tzinfo=UTC()), invoice_key='321')
pack1.info_tracking.add(info1)
pack1.info_tracking.add(info2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment