示例#1
0
def argos_csv_to_item(csv_row):
    sku = csv_row[42]
    sellable_id = get_sellable_id(sku)
    price_per_unit = get_price(sku)
    quantity = csv_row[47]

    return Item(sellable_id, quantity, price_per_unit, TAX_RATE)
示例#2
0
def shop_direct_csv_to_item(csv_row):
    sku = csv_row[27]
    sellable_id = get_sellable_id(sku)
    quantity = csv_row[24]
    price_per_unit = "0"

    return Item(
        sellable_id,
        quantity,
        price_per_unit,
        TAX_RATE,
    )
示例#3
0
def robert_dyas_csv_to_item(csv_row):
    sku = csv_row[15]
    sellable_id = get_sellable_id(sku)
    quantity = csv_row[12]
    price_per_unit = csv_row[16]

    return Item(
        sellable_id,
        quantity,
        price_per_unit,
        TAX_RATE,
    )
示例#4
0
def globus_xml_to_items(xml):
    items = []
    products = xml.findall('.//Product[@xrefMode="Target"]')

    for product in products:
        sku = product.find('.//Identifier[@function="ProductCode"]').text
        sellable_id = get_sellable_id(sku)

        quantity = 1
        price_per_unit = product.find('.//Value').text

        item = Item(sellable_id, quantity, price_per_unit, TAX_RATE)
        items.append(item)

    return items
示例#5
0
def range_store_csv_to_item(csv_row):
    sku = csv_row[6]
    sellable_id = get_sellable_id(sku)

    quantity = csv_row[12]
    net_cost_price = csv_row[16].replace(",", "")

    price_per_unit = str(
        float(net_cost_price) / float(quantity),
    )

    return Item(
        sellable_id,
        quantity,
        price_per_unit,
        TAX_RATE,
    )
示例#6
0
def range_json_to_items(json):
    stock = json["stock"]
    items = []

    for item_json in json["item_arr"]:
        sku = item_json["supplier_ref"]
        sellable_id = get_sellable_id(sku)
        price_per_unit = get_range_item_price(stock, item_json)
        quantity = item_json["quantity"]

        items.append(Item(
            sellable_id,
            quantity,
            price_per_unit,
            TAX_RATE,
        ))

    return items
示例#7
0
def bandq_csv_to_item(csv_row):
    sku = csv_row[29]
    sellable_id = get_sellable_id(sku)
    quantity = csv_row[31]
    price_per_unit = csv_row[35]

    billing_name = csv_row[8]
    tax_rate = TAX_RATE

    if "Jersey" in billing_name or "Guernsey" in billing_name:
        tax_rate = 0

    return Item(
        sellable_id,
        quantity,
        price_per_unit,
        tax_rate,
    )
示例#8
0
def homebase_xml_to_items(xml):
    items = []
    products = xml.findall('.//Product[@xrefMode="Target"]')

    for product in products:
        sku = product.find(
            './/Identifier[@function="ProductCode"][@owner="Company"]').text
        sellable_id = get_sellable_id(sku)

        quantity = product.find(".//UnitQuantity").text
        price_per_unit = product.find(".//Value").text

        items.append(Item(
            sellable_id,
            quantity,
            price_per_unit,
            TAX_RATE,
        ))

    return items
示例#9
0
def hornbach_pdf_to_items(pdf_pages):
    items = []

    for page_layout in pdf_pages:
        for element in page_layout:
            if isinstance(element, LTTextContainer):
                text = element.get_text()

                skus = re.findall(r"^K[A-Z]-\d{5}$", text)
                if len(skus) > 0:
                    sku = skus[0]

                    sellable_id = get_sellable_id(sku)
                    price_per_unit = get_price(sku)
                    quantity = "1"

                    item = Item(sellable_id, quantity, price_per_unit,
                                TAX_RATE)
                    items.append(item)

    return items