コード例 #1
0
ファイル: amazon.py プロジェクト: garrettmk/colander2
 def perform(self, vendor_id=None, docs=None):
     for group_doc in docs:
         dqc.pipeline([
             mws.ListFinancialEvents.message(group_id=group_doc['group_id'],
                                             vendor_id=vendor_id),
             ProcessFinancialEvents.message(vendor_id, group_doc)
         ]).run()
コード例 #2
0
ファイル: amazon.py プロジェクト: garrettmk/colander2
    def perform(self, vendor_id, orders):
        amazon = Vendor.query.filter_by(name='Amazon').one()

        for cust_doc, order_doc in orders:
            if 'name' in cust_doc:
                customer = Customer.query.filter_by(
                    name=cust_doc['name']).first() or Customer()
                customer.update(cust_doc)
                db.session.add(customer)
            else:
                customer = None

            order = Order.query.filter_by(source_id=amazon.id, order_number=order_doc['order_number']).first() \
                    or Order()

            order.update(order_doc)
            order.source = amazon
            order.destination = customer
            order.date = dt.datetime.strptime(
                order_doc['date'].replace('Z', ''), ISO_8601)

            db.session.add(order)
            db.session.commit()

            dqc.pipeline([
                mws.ListOrderItems.message(order.order_number),
                ProcessOrderItems.message(vendor_id, order.id),
            ]).run()
コード例 #3
0
ファイル: amazon.py プロジェクト: garrettmk/colander2
 def perform(self, vendor_id=None, docs=None):
     for doc in docs:
         order_id = ImportInboundOrder(doc, vendor_id=vendor_id)
         dqc.pipeline([
             mws.ListInboundShipmentItems.message(doc, vendor_id=vendor_id),
             ProcessInboundOrderItems.message(vendor_id=vendor_id),
             mws.GetTransportContent.message(doc),
             ProcessInboundShipments.message(order_id=order_id)
         ]).run()
コード例 #4
0
ファイル: amazon.py プロジェクト: garrettmk/colander2
    def perform(self, docs=None, vendor_id=None):
        vendor = Vendor.query.filter_by(id=vendor_id).one()

        for doc in docs:
            # Import the Amazon
            amz_doc = {'sku': doc['sku'], 'fnsku': doc['fnsku']}
            amz_id = ImportListing(amz_doc)

            # Import the vendor listing
            vnd_doc = {'vendor_id': vendor_id, 'sku': doc['msku']}
            try:
                vnd_id = vendor.ext.call('ImportListing', **vnd_doc)
            except (ValueError, AttributeError):
                vnd_id = coreops.listings.ImportListing(doc=vnd_doc)

            # Update or create the inventory relationship
            inventory = Inventory.query.filter_by(
                owner_id=vendor_id, listing_id=amz_id).first() or Inventory(
                    owner_id=vendor_id, listing_id=amz_id)

            inventory.update(
                fnsku=doc['fnsku'],
                fulfillable=doc['fulfillable'],
            )

            db.session.add(inventory)
            db.session.commit()

            # Get updated info for the Amazon listing
            dqc.pipeline([
                mws.GetCompetitivePricingForASIN.message(amz_doc,
                                                         vendor_id=vendor_id),
                pa.ItemLookup.message(vendor_id=vendor_id),
                mws.GetMyFeesEstimate.message(vendor_id=vendor_id),
                ImportListing.message(),
                CopyToListing.message(vnd_id)
            ]).run()
コード例 #5
0
ファイル: amazon.py プロジェクト: garrettmk/colander2
 def perform(self, vendor_id=None):
     dqc.pipeline([
         mws.ListFinancialEventGroups.message(vendor_id=vendor_id),
         ProcessFinancialEventGroups.message(vendor_id)
     ]).run()
コード例 #6
0
ファイル: amazon.py プロジェクト: garrettmk/colander2
 def perform(self, vendor_id=None):
     dqc.pipeline([
         mws.ListOrders.message(vendor_id=vendor_id),
         ProcessOrders.message(vendor_id=vendor_id)
     ]).run()
コード例 #7
0
ファイル: amazon.py プロジェクト: garrettmk/colander2
 def perform(self, vendor_id):
     dqc.pipeline([
         mws.ListInboundShipments.message(vendor_id=vendor_id),
         ProcessInboundOrders.message(vendor_id=vendor_id)
     ]).run()
コード例 #8
0
ファイル: amazon.py プロジェクト: garrettmk/colander2
 def perform(self, vendor_id=None):
     """Import any ASINs that have had inventory activity in the last 90 days."""
     dqc.pipeline([
         mws.ListInventorySupply.message(vendor_id=vendor_id),
         ProcessInventory.message(vendor_id=vendor_id)
     ]).run()