Prepare Bambu EU orders and split actual discounted cart totals
This commit is contained in:
1 parent
59cb69609b
commit
8806fc85e5
9 files changed
+755
-595
No files matched your search
+53
-118
@@ -1,110 +1,86 @@
|
||||
import hashlib
|
||||
import json
|
||||
from collections import Counter, defaultdict
|
||||
from dataclasses import dataclass
|
||||
from http.cookiejar import CookieJar
|
||||
from urllib.error import URLError
|
||||
from urllib.parse import urlsplit
|
||||
from urllib.request import HTTPCookieProcessor, HTTPRedirectHandler, Request, build_opener
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
from .bambu_eu_variant_ids import BAMBU_EU_PRODUCT_SLUGS, BAMBU_SHOPIFY_VARIANT_IDS
|
||||
from .bambu_eu_variant_ids import BAMBU_EU_PRODUCTS
|
||||
from .models import OrderItem
|
||||
|
||||
SHOP_HOST = "bambulab-eu.myshopify.com"
|
||||
SHOP_URL = f"https://{SHOP_HOST}"
|
||||
SHOP_VARIANTS = {
|
||||
(product.casefold(), code, spool, grams, diameter): shop_id
|
||||
for product, rows in BAMBU_SHOPIFY_VARIANT_IDS.items()
|
||||
for code, spool, grams, diameter, shop_id in rows
|
||||
SHOP_URL = "https://eu.store.bambulab.com"
|
||||
SHOP_PRODUCTS = {
|
||||
name.casefold(): (slug, {row[:4]: row[4] for row in variants})
|
||||
for name, (slug, variants) in BAMBU_EU_PRODUCTS.items()
|
||||
}
|
||||
SHOP_PRODUCT_NAMES = {"pla silk dual color": "pla silk multi-color"}
|
||||
|
||||
|
||||
class CartQuoteError(Exception):
|
||||
pass
|
||||
@dataclass
|
||||
class CartLine:
|
||||
key: str
|
||||
product_url: str
|
||||
exact_link: bool
|
||||
entries: list[OrderItem] = field(default_factory=list)
|
||||
|
||||
@property
|
||||
def variant(self):
|
||||
return self.entries[0].variant
|
||||
|
||||
@property
|
||||
def quantity(self):
|
||||
return sum(entry.quantity for entry in self.entries)
|
||||
|
||||
|
||||
@dataclass
|
||||
class CartPlan:
|
||||
entries: dict
|
||||
excluded: list
|
||||
|
||||
@property
|
||||
def quantities(self):
|
||||
return {
|
||||
shop_id: sum(entry.quantity for entry in rows) for shop_id, rows in self.entries.items()
|
||||
}
|
||||
lines: list[CartLine]
|
||||
|
||||
@property
|
||||
def signature(self):
|
||||
rows = [
|
||||
(shop_id, entry.pk, entry.variant_id, entry.quantity)
|
||||
for shop_id, entries in self.entries.items()
|
||||
for entry in entries
|
||||
(line.key, entry.pk, entry.variant_id, entry.quantity)
|
||||
for line in self.lines
|
||||
for entry in line.entries
|
||||
]
|
||||
return hashlib.sha256(json.dumps(sorted(rows)).encode()).hexdigest()
|
||||
|
||||
@property
|
||||
def url(self):
|
||||
if not self.entries:
|
||||
return ""
|
||||
items = ",".join(f"{shop_id}:{qty}" for shop_id, qty in sorted(self.quantities.items()))
|
||||
return f"{SHOP_URL}/cart/{items}?storefront=true"
|
||||
prefix = OrderItem.EU_CART_QUOTE_PREFIX
|
||||
digest = hashlib.sha256(json.dumps(sorted(rows)).encode()).hexdigest()
|
||||
return prefix + digest[: 64 - len(prefix)]
|
||||
|
||||
|
||||
def plan_cart(entries):
|
||||
mapped = defaultdict(list)
|
||||
excluded = []
|
||||
lines = {}
|
||||
for entry in entries:
|
||||
variant = entry.variant
|
||||
if (
|
||||
entry.status != OrderItem.Status.OPEN
|
||||
or variant.manufacturer.name.casefold() != "bambu lab"
|
||||
or not variant.is_active
|
||||
):
|
||||
continue
|
||||
product = variant.product_type.name.strip().casefold()
|
||||
product = SHOP_PRODUCT_NAMES.get(product, product)
|
||||
shop_id = SHOP_VARIANTS.get(
|
||||
slug, variants = SHOP_PRODUCTS.get(SHOP_PRODUCT_NAMES.get(product, product), ("", {}))
|
||||
shop_id = variants.get(
|
||||
(
|
||||
product,
|
||||
variant.manufacturer_color_code.strip(),
|
||||
variant.spool_type,
|
||||
variant.net_weight_g,
|
||||
str(variant.diameter_mm),
|
||||
)
|
||||
)
|
||||
if shop_id and variant.is_active:
|
||||
mapped[shop_id].append(entry)
|
||||
continue
|
||||
reason = (
|
||||
"Keine eindeutige Shop-Variante" if variant.is_active else "Katalogvariante deaktiviert"
|
||||
key = f"shop_{shop_id}" if shop_id else f"local_{variant.pk}"
|
||||
product_url = f"{SHOP_URL}/products/{slug}" if slug else ""
|
||||
if shop_id:
|
||||
product_url += f"?id={shop_id}"
|
||||
line = lines.setdefault(key, CartLine(key, product_url, bool(shop_id)))
|
||||
line.entries.append(entry)
|
||||
return CartPlan(
|
||||
sorted(
|
||||
lines.values(),
|
||||
key=lambda line: (
|
||||
line.variant.product_type.name.casefold(),
|
||||
line.variant.color_label.casefold(),
|
||||
line.key,
|
||||
),
|
||||
)
|
||||
slug = BAMBU_EU_PRODUCT_SLUGS.get(product) if variant.is_active else None
|
||||
product_url = f"https://eu.store.bambulab.com/products/{slug}" if slug else ""
|
||||
excluded.append((entry, reason, product_url))
|
||||
return CartPlan(dict(mapped), excluded)
|
||||
|
||||
|
||||
class CartRedirectHandler(HTTPRedirectHandler):
|
||||
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
||||
target = urlsplit(newurl)
|
||||
if (target.scheme, target.netloc, target.path) != ("https", SHOP_HOST, "/cart"):
|
||||
raise CartQuoteError("Der Shop hat auf eine andere Seite weitergeleitet.")
|
||||
return super().redirect_request(req, fp, code, msg, headers, newurl)
|
||||
|
||||
|
||||
def fetch_cart(plan):
|
||||
browser = build_opener(HTTPCookieProcessor(CookieJar()), CartRedirectHandler())
|
||||
headers = {"User-Agent": "Mozilla/5.0", "Cache-Control": "no-cache"}
|
||||
try:
|
||||
with browser.open(Request(plan.url, headers=headers), timeout=8):
|
||||
pass
|
||||
with browser.open(Request(f"{SHOP_URL}/cart.js", headers=headers), timeout=8) as response:
|
||||
return json.loads(response.read(1024 * 1024))
|
||||
except (URLError, OSError, ValueError) as error:
|
||||
raise CartQuoteError(
|
||||
"Die Warenkorbpreise konnten beim Shop nicht abgerufen werden."
|
||||
) from error
|
||||
)
|
||||
|
||||
|
||||
def _allocate_cents(total, weights):
|
||||
@@ -119,53 +95,12 @@ def _allocate_cents(total, weights):
|
||||
return allocations
|
||||
|
||||
|
||||
def quote_cart(plan, cart):
|
||||
if not isinstance(cart, dict) or cart.get("currency") != "EUR":
|
||||
raise CartQuoteError("Der Shop hat keinen Warenkorb in Euro geliefert.")
|
||||
if not isinstance(cart.get("items"), list) or type(cart.get("total_price")) is not int:
|
||||
raise CartQuoteError("Der Shop hat unvollständige Preisdaten geliefert.")
|
||||
quantities = Counter()
|
||||
prices = Counter()
|
||||
for line in cart["items"]:
|
||||
if not isinstance(line, dict):
|
||||
raise CartQuoteError("Der Shop hat unvollständige Preisdaten geliefert.")
|
||||
shop_id, quantity, cents = (
|
||||
line.get(key) for key in ("variant_id", "quantity", "final_line_price")
|
||||
)
|
||||
if (
|
||||
any(type(value) is not int for value in (shop_id, quantity, cents))
|
||||
or quantity < 1
|
||||
or cents < 0
|
||||
):
|
||||
raise CartQuoteError("Der Shop hat unvollständige Preisdaten geliefert.")
|
||||
quantities[shop_id] += quantity
|
||||
prices[shop_id] += cents
|
||||
requested = plan.quantities
|
||||
if quantities != requested:
|
||||
missing = []
|
||||
for shop_id, entries in plan.entries.items():
|
||||
if quantities[shop_id] != requested[shop_id]:
|
||||
missing.append(
|
||||
f"{entries[0].variant} ({quantities[shop_id]} von {requested[shop_id]} im Shop)"
|
||||
)
|
||||
extra = (
|
||||
" Der Shop hat weitere Artikel hinzugefügt."
|
||||
if quantities.keys() - plan.entries.keys()
|
||||
else ""
|
||||
)
|
||||
raise CartQuoteError(
|
||||
"Der Inhalt des Shop-Warenkorbs weicht von der Liste ab. " + ", ".join(missing) + extra
|
||||
)
|
||||
|
||||
shop_ids = sorted(prices)
|
||||
total = cart["total_price"]
|
||||
if not 0 <= total <= sum(prices.values()) or total > 2_147_483_647:
|
||||
raise CartQuoteError("Die Warensumme aus dem Shop konnte nicht abgeglichen werden.")
|
||||
# Some discounts are applied to the whole cart and not included in the line prices.
|
||||
shop_totals = _allocate_cents(total, [prices[shop_id] for shop_id in shop_ids])
|
||||
def allocate_prices(plan, line_cents, total_cents):
|
||||
# Distribute any discount on the whole cart proportionally, keeping the sum exact.
|
||||
totals = _allocate_cents(total_cents, line_cents)
|
||||
result = {}
|
||||
for shop_id, cents in zip(shop_ids, shop_totals, strict=True):
|
||||
entries = sorted(plan.entries[shop_id], key=lambda entry: entry.pk)
|
||||
per_order = _allocate_cents(cents, [entry.quantity for entry in entries])
|
||||
result.update((entry.pk, price) for entry, price in zip(entries, per_order, strict=True))
|
||||
for line, cents in zip(plan.lines, totals, strict=True):
|
||||
entries = sorted(line.entries, key=lambda entry: entry.pk)
|
||||
shares = _allocate_cents(cents, [entry.quantity for entry in entries])
|
||||
result.update((entry.pk, share) for entry, share in zip(entries, shares, strict=True))
|
||||
return result
|
||||
+494
-320
@@ -1,377 +1,551 @@
|
||||
"""Bambu Lab EU Shopify variant IDs and EU product links."""
|
||||
"""Variant links in the Bambu Lab EU Store structured catalog."""
|
||||
|
||||
# Shopify catalog verified against the Bambu Lab EU filament collection products.json.
|
||||
# Product, then (colour code, spool type, grams, diameter in mm, Shopify variant ID).
|
||||
BAMBU_SHOPIFY_VARIANT_IDS = {
|
||||
# Product, product page slug, and (colour code, spool type, grams, diameter, shop ID).
|
||||
BAMBU_EU_PRODUCTS = {
|
||||
"ABS": (
|
||||
("40100", "refill", 1000, "1.75", 42917259083995),
|
||||
("40100", "spool", 1000, "1.75", 46963746046300),
|
||||
("40101", "refill", 1000, "1.75", 42917259051227),
|
||||
("40101", "spool", 1000, "1.75", 46963744145756),
|
||||
("40102", "refill", 1000, "1.75", 49503790596444),
|
||||
("40102", "spool", 1000, "1.75", 46841277022556),
|
||||
("40200", "refill", 1000, "1.75", 42917259116763),
|
||||
("40300", "refill", 1000, "1.75", 48953684394332),
|
||||
("40402", "refill", 1000, "1.75", 49130709418332),
|
||||
("40500", "refill", 1000, "1.75", 48953688850780),
|
||||
("40502", "refill", 1000, "1.75", 49037506216284),
|
||||
("40600", "refill", 1000, "1.75", 42917259182299),
|
||||
("40601", "refill", 1000, "1.75", 49130708730204),
|
||||
("40602", "refill", 1000, "1.75", 49130708009308),
|
||||
"abs-filament",
|
||||
(
|
||||
("40100", "refill", 1000, "1.75", "42917259083995"),
|
||||
("40100", "spool", 1000, "1.75", "46963746046300"),
|
||||
("40101", "refill", 1000, "1.75", "42917259051227"),
|
||||
("40101", "spool", 1000, "1.75", "46963744145756"),
|
||||
("40102", "refill", 1000, "1.75", "49503790596444"),
|
||||
("40102", "spool", 1000, "1.75", "46841277022556"),
|
||||
("40200", "refill", 1000, "1.75", "42917259116763"),
|
||||
("40300", "refill", 1000, "1.75", "48953684394332"),
|
||||
("40402", "refill", 1000, "1.75", "49130709418332"),
|
||||
("40500", "refill", 1000, "1.75", "48953688850780"),
|
||||
("40502", "refill", 1000, "1.75", "49037506216284"),
|
||||
("40600", "refill", 1000, "1.75", "42917259182299"),
|
||||
("40601", "refill", 1000, "1.75", "49130708730204"),
|
||||
("40602", "refill", 1000, "1.75", "49130708009308"),
|
||||
),
|
||||
),
|
||||
"ABS-GF": (
|
||||
("41100", "spool", 1000, "1.75", 48011475845468),
|
||||
("41101", "spool", 1000, "1.75", 48011475911004),
|
||||
("41102", "spool", 1000, "1.75", 48011475878236),
|
||||
("41200", "spool", 1000, "1.75", 48011475779932),
|
||||
("41300", "spool", 1000, "1.75", 48011475714396),
|
||||
("41400", "spool", 1000, "1.75", 48011475812700),
|
||||
("41500", "spool", 1000, "1.75", 48011475747164),
|
||||
("41600", "spool", 1000, "1.75", 48725868872028),
|
||||
"abs-gf",
|
||||
(
|
||||
("41100", "spool", 1000, "1.75", "48011475845468"),
|
||||
("41101", "spool", 1000, "1.75", "48011475911004"),
|
||||
("41102", "spool", 1000, "1.75", "48011475878236"),
|
||||
("41200", "spool", 1000, "1.75", "48011475779932"),
|
||||
("41300", "spool", 1000, "1.75", "48011475714396"),
|
||||
("41600", "spool", 1000, "1.75", "48725868872028"),
|
||||
),
|
||||
),
|
||||
"ASA": (
|
||||
("45100", "spool", 1000, "1.75", 46930444353884),
|
||||
("45101", "spool", 1000, "1.75", 46930444222812),
|
||||
("45102", "spool", 1000, "1.75", 46930444255580),
|
||||
("45200", "spool", 1000, "1.75", 46930444288348),
|
||||
("45500", "spool", 1000, "1.75", 46930444386652),
|
||||
("45600", "spool", 1000, "1.75", 46930444321116),
|
||||
"asa-filament",
|
||||
(
|
||||
("45100", "spool", 1000, "1.75", "46930444353884"),
|
||||
("45101", "spool", 1000, "1.75", "46930444222812"),
|
||||
("45102", "spool", 1000, "1.75", "46930444255580"),
|
||||
("45200", "spool", 1000, "1.75", "46930444288348"),
|
||||
("45500", "spool", 1000, "1.75", "46930444386652"),
|
||||
("45600", "spool", 1000, "1.75", "46930444321116"),
|
||||
),
|
||||
),
|
||||
"ASA Aero": (
|
||||
"asa-aero",
|
||||
(("46100", "spool", 1000, "1.75", "47966894096732"),),
|
||||
),
|
||||
"ASA-CF": (
|
||||
"asa-cf",
|
||||
(("46101", "spool", 1000, "1.75", "49410590409052"),),
|
||||
),
|
||||
"PA6-CF (1 kg)": (
|
||||
"pa6-cf",
|
||||
(("72100", "spool", 1000, "1.75", "47023571534172"),),
|
||||
),
|
||||
"PA6-CF (500 g)": (
|
||||
"pa6-cf",
|
||||
(("72100", "spool", 500, "1.75", "47023571468636"),),
|
||||
),
|
||||
"ASA Aero": (("46100", "spool", 1000, "1.75", 47966894096732),),
|
||||
"ASA-CF": (("46101", "spool", 1000, "1.75", 49410590409052),),
|
||||
"PA6-CF (1 kg)": (("72100", "spool", 1000, "1.75", 47023571534172),),
|
||||
"PA6-CF (500 g)": (("72100", "spool", 500, "1.75", 47023571468636),),
|
||||
"PA6-GF": (
|
||||
("72102", "spool", 1000, "1.75", 47833416270172),
|
||||
("72103", "spool", 1000, "1.75", 47833416302940),
|
||||
("72104", "spool", 1000, "1.75", 47833416335708),
|
||||
("72200", "spool", 1000, "1.75", 47833416139100),
|
||||
("72400", "spool", 1000, "1.75", 47833416171868),
|
||||
("72500", "spool", 1000, "1.75", 47833416204636),
|
||||
("72600", "spool", 1000, "1.75", 47833416106332),
|
||||
("72800", "spool", 1000, "1.75", 47833416237404),
|
||||
"pa6-gf",
|
||||
(
|
||||
("72102", "spool", 1000, "1.75", "47833416270172"),
|
||||
("72103", "spool", 1000, "1.75", "47833416302940"),
|
||||
("72104", "spool", 1000, "1.75", "47833416335708"),
|
||||
("72200", "spool", 1000, "1.75", "47833416139100"),
|
||||
("72400", "spool", 1000, "1.75", "47833416171868"),
|
||||
("72500", "spool", 1000, "1.75", "47833416204636"),
|
||||
("72600", "spool", 1000, "1.75", "47833416106332"),
|
||||
("72800", "spool", 1000, "1.75", "47833416237404"),
|
||||
),
|
||||
),
|
||||
"PAHT-CF (1 kg)": (
|
||||
"paht-cf",
|
||||
(("70100", "spool", 1000, "1.75", "43923846889691"),),
|
||||
),
|
||||
"PAHT-CF (500 g)": (
|
||||
"paht-cf",
|
||||
(("70100", "spool", 500, "1.75", "43923846856923"),),
|
||||
),
|
||||
"PAHT-CF (1 kg)": (("70100", "spool", 1000, "1.75", 43923846889691),),
|
||||
"PAHT-CF (500 g)": (("70100", "spool", 500, "1.75", 43923846856923),),
|
||||
"PC": (
|
||||
("60100", "spool", 1000, "1.75", 43408627138779),
|
||||
("60101", "spool", 1000, "1.75", 46673173807452),
|
||||
("60102", "spool", 1000, "1.75", 43408627106011),
|
||||
("60103", "spool", 1000, "1.75", 46673173774684),
|
||||
"pc-filament",
|
||||
(
|
||||
("60100", "spool", 1000, "1.75", "43408627138779"),
|
||||
("60101", "spool", 1000, "1.75", "46673173807452"),
|
||||
("60102", "spool", 1000, "1.75", "43408627106011"),
|
||||
("60103", "spool", 1000, "1.75", "46673173774684"),
|
||||
),
|
||||
),
|
||||
"PC FR": (
|
||||
("63100", "spool", 1000, "1.75", 53649920950620),
|
||||
("63101", "spool", 1000, "1.75", 53649920983388),
|
||||
("63102", "spool", 1000, "1.75", 53649921016156),
|
||||
"pc-fr",
|
||||
(
|
||||
("63100", "spool", 1000, "1.75", "53649920950620"),
|
||||
("63101", "spool", 1000, "1.75", "53649920983388"),
|
||||
("63102", "spool", 1000, "1.75", "53649921016156"),
|
||||
),
|
||||
),
|
||||
"PET-CF (1 kg)": (("71100", "spool", 1000, "1.75", 44012072763611),),
|
||||
"PET-CF (500 g)": (("71100", "spool", 500, "1.75", 44012072730843),),
|
||||
"PETG HF": (
|
||||
("33100", "refill", 1000, "1.75", 49068714623324),
|
||||
("33100", "spool", 1000, "1.75", 49068714787164),
|
||||
("33101", "refill", 1000, "1.75", 49068714688860),
|
||||
("33101", "spool", 1000, "1.75", 49068714852700),
|
||||
("33102", "refill", 1000, "1.75", 49068714590556),
|
||||
("33102", "spool", 1000, "1.75", 49068714754396),
|
||||
("33103", "refill", 1000, "1.75", 49503342920028),
|
||||
("33200", "refill", 1000, "1.75", 49068714557788),
|
||||
("33200", "spool", 1000, "1.75", 49068714721628),
|
||||
("33300", "refill", 1000, "1.75", 49068714492252),
|
||||
("33400", "refill", 1000, "1.75", 49068714459484),
|
||||
("33401", "refill", 1000, "1.75", 49503344034140),
|
||||
("33500", "refill", 1000, "1.75", 49068714525020),
|
||||
("33501", "refill", 1000, "1.75", 49503344427356),
|
||||
("33502", "refill", 1000, "1.75", 49503341511004),
|
||||
("33600", "refill", 1000, "1.75", 49068714656092),
|
||||
("33600", "spool", 1000, "1.75", 49068714819932),
|
||||
("33601", "refill", 1000, "1.75", 49503345246556),
|
||||
("33801", "refill", 1000, "1.75", 49503342625116),
|
||||
"PET-CF (1 kg)": (
|
||||
"pet-cf",
|
||||
(("71100", "spool", 1000, "1.75", "44012072763611"),),
|
||||
),
|
||||
"PET-CF (500 g)": (
|
||||
"pet-cf",
|
||||
(("71100", "spool", 500, "1.75", "44012072730843"),),
|
||||
),
|
||||
"PETG Basic": (
|
||||
"petg-basic",
|
||||
(
|
||||
("30105", "refill", 1000, "1.75", "703100873995440140"),
|
||||
("30105", "spool", 1000, "1.75", "703100873995440146"),
|
||||
("30106", "refill", 1000, "1.75", "703100873995440152"),
|
||||
("30106", "spool", 1000, "1.75", "703100873995440158"),
|
||||
("30107", "refill", 1000, "1.75", "703100873995440164"),
|
||||
("30107", "spool", 1000, "1.75", "703100873995440170"),
|
||||
("30108", "refill", 1000, "1.75", "738173299117862983"),
|
||||
("30108", "spool", 1000, "1.75", "738173299117862991"),
|
||||
("30201", "refill", 1000, "1.75", "703100873995440176"),
|
||||
("30201", "spool", 1000, "1.75", "703100873995440182"),
|
||||
("30301", "refill", 1000, "1.75", "738173299117862919"),
|
||||
("30301", "spool", 1000, "1.75", "738173299117862927"),
|
||||
("30402", "refill", 1000, "1.75", "703100873995440188"),
|
||||
("30402", "spool", 1000, "1.75", "703100873995440194"),
|
||||
("30403", "refill", 1000, "1.75", "738173299117862967"),
|
||||
("30403", "spool", 1000, "1.75", "738173299117862975"),
|
||||
("30502", "refill", 1000, "1.75", "738173299117862935"),
|
||||
("30502", "spool", 1000, "1.75", "738173299117862943"),
|
||||
("30503", "refill", 1000, "1.75", "738173299117862999"),
|
||||
("30503", "spool", 1000, "1.75", "738173299117863007"),
|
||||
("30603", "refill", 1000, "1.75", "703100873995440200"),
|
||||
("30603", "spool", 1000, "1.75", "703100873995440206"),
|
||||
("30604", "refill", 1000, "1.75", "738173299117862951"),
|
||||
("30604", "spool", 1000, "1.75", "738173299117862959"),
|
||||
("30800", "refill", 1000, "1.75", "703100873995440212"),
|
||||
("30800", "spool", 1000, "1.75", "703100873995440218"),
|
||||
),
|
||||
),
|
||||
"PETG Matte": (
|
||||
"petg-matte",
|
||||
(
|
||||
("35100", "refill", 1000, "1.75", "775952393450868750"),
|
||||
("35100", "spool", 1000, "1.75", "775952393450868758"),
|
||||
("35101", "refill", 1000, "1.75", "775952393450868766"),
|
||||
("35101", "spool", 1000, "1.75", "775952393450868774"),
|
||||
("35102", "refill", 1000, "1.75", "775952393450868798"),
|
||||
("35102", "spool", 1000, "1.75", "775952393450868806"),
|
||||
("35500", "refill", 1000, "1.75", "775952393450868782"),
|
||||
("35500", "spool", 1000, "1.75", "775952393450868790"),
|
||||
("35501", "refill", 1000, "1.75", "775952393450868862"),
|
||||
("35501", "spool", 1000, "1.75", "775952393450868870"),
|
||||
("35600", "refill", 1000, "1.75", "775952393450868830"),
|
||||
("35600", "spool", 1000, "1.75", "775952393450868838"),
|
||||
("35700", "refill", 1000, "1.75", "775952393450868814"),
|
||||
("35700", "spool", 1000, "1.75", "775952393450868822"),
|
||||
("35702", "refill", 1000, "1.75", "775952393450868846"),
|
||||
("35702", "spool", 1000, "1.75", "775952393450868854"),
|
||||
),
|
||||
),
|
||||
"PETG Translucent": (
|
||||
("32100", "refill", 1000, "1.75", 49271784472924),
|
||||
("32101", "refill", 1000, "1.75", 48786708922716),
|
||||
("32101", "spool", 1000, "1.75", 48055896047964),
|
||||
("32200", "refill", 1000, "1.75", 49074123145564),
|
||||
("32300", "refill", 1000, "1.75", 49130706469212),
|
||||
("32500", "refill", 1000, "1.75", 49130705977692),
|
||||
("32501", "refill", 1000, "1.75", 49074122162524),
|
||||
("32501", "spool", 1000, "1.75", 47502089290076),
|
||||
("32600", "refill", 1000, "1.75", 49192018149724),
|
||||
("32600", "spool", 1000, "1.75", 47502089191772),
|
||||
("32700", "refill", 1000, "1.75", 49130706829660),
|
||||
("32800", "refill", 1000, "1.75", 49192019788124),
|
||||
"petg-translucent",
|
||||
(
|
||||
("32100", "refill", 1000, "1.75", "49271784472924"),
|
||||
("32101", "refill", 1000, "1.75", "48786708922716"),
|
||||
("32101", "spool", 1000, "1.75", "48055896047964"),
|
||||
("32200", "refill", 1000, "1.75", "49074123145564"),
|
||||
("32300", "refill", 1000, "1.75", "49130706469212"),
|
||||
("32500", "refill", 1000, "1.75", "49130705977692"),
|
||||
("32501", "refill", 1000, "1.75", "49074122162524"),
|
||||
("32501", "spool", 1000, "1.75", "47502089290076"),
|
||||
("32600", "refill", 1000, "1.75", "49192018149724"),
|
||||
("32600", "spool", 1000, "1.75", "47502089191772"),
|
||||
("32700", "refill", 1000, "1.75", "49130706829660"),
|
||||
("32800", "refill", 1000, "1.75", "49192019788124"),
|
||||
),
|
||||
),
|
||||
"PETG-CF": (
|
||||
("31100", "refill", 1000, "1.75", 49238020686172),
|
||||
("31100", "spool", 1000, "1.75", 43982559412443),
|
||||
("31101", "spool", 1000, "1.75", 47228683714908),
|
||||
("31200", "spool", 1000, "1.75", 46935828300124),
|
||||
("31500", "spool", 1000, "1.75", 46935828365660),
|
||||
("31600", "spool", 1000, "1.75", 46935828332892),
|
||||
("31700", "spool", 1000, "1.75", 46935828267356),
|
||||
"petg-cf",
|
||||
(
|
||||
("31100", "refill", 1000, "1.75", "49238020686172"),
|
||||
("31100", "spool", 1000, "1.75", "43982559412443"),
|
||||
("31101", "refill", 1000, "1.75", "785030589559357440"),
|
||||
("31101", "spool", 1000, "1.75", "47228683714908"),
|
||||
("31200", "spool", 1000, "1.75", "46935828300124"),
|
||||
("31500", "spool", 1000, "1.75", "46935828365660"),
|
||||
("31600", "spool", 1000, "1.75", "46935828332892"),
|
||||
("31700", "spool", 1000, "1.75", "46935828267356"),
|
||||
),
|
||||
),
|
||||
"PLA Aero": (
|
||||
("14102", "spool", 1000, "1.75", 46953506505052),
|
||||
("14104", "spool", 1000, "1.75", 49078101279068),
|
||||
"pla-aero",
|
||||
(
|
||||
("14102", "spool", 1000, "1.75", "46953506505052"),
|
||||
("14104", "spool", 1000, "1.75", "49078101279068"),
|
||||
),
|
||||
),
|
||||
"PLA Basic": (
|
||||
("10100", "refill", 1000, "1.75", 42911327846619),
|
||||
("10100", "spool", 1000, "1.75", 43992829919451),
|
||||
("10101", "refill", 1000, "1.75", 43923829129435),
|
||||
("10101", "spool", 1000, "1.75", 43992830017755),
|
||||
("10102", "refill", 1000, "1.75", 42911328010459),
|
||||
("10103", "refill", 1000, "1.75", 42911327944923),
|
||||
("10103", "spool", 1000, "1.75", 46956524241244),
|
||||
("10104", "refill", 1000, "1.75", 49299256148316),
|
||||
("10105", "refill", 1000, "1.75", 49299261423964),
|
||||
("10200", "refill", 1000, "1.75", 42911328239835),
|
||||
("10200", "spool", 1000, "1.75", 43992829952219),
|
||||
("10201", "refill", 1000, "1.75", 42911327977691),
|
||||
("10202", "refill", 1000, "1.75", 47794655068508),
|
||||
("10203", "refill", 1000, "1.75", 42911328141531),
|
||||
("10204", "refill", 1000, "1.75", 49636028285276),
|
||||
("10204", "spool", 1000, "1.75", 53951742509404),
|
||||
("10205", "refill", 1000, "1.75", 49636008395100),
|
||||
("10300", "refill", 1000, "1.75", 42911327879387),
|
||||
("10301", "refill", 1000, "1.75", 49636029530460),
|
||||
("10301", "spool", 1000, "1.75", 53951744213340),
|
||||
("10400", "refill", 1000, "1.75", 42911328043227),
|
||||
("10401", "refill", 1000, "1.75", 47794656706908),
|
||||
("10402", "refill", 1000, "1.75", 49636014031196),
|
||||
("10402", "spool", 1000, "1.75", 53951741002076),
|
||||
("10501", "refill", 1000, "1.75", 47794655461724),
|
||||
("10501", "spool", 1000, "1.75", 46673378607452),
|
||||
("10502", "refill", 1000, "1.75", 47794656477532),
|
||||
("10502", "spool", 1000, "1.75", 54004770537820),
|
||||
("10503", "refill", 1000, "1.75", 49636024353116),
|
||||
("10601", "refill", 1000, "1.75", 42911327912155),
|
||||
("10601", "spool", 1000, "1.75", 46738546622812),
|
||||
("10602", "refill", 1000, "1.75", 42911328075995),
|
||||
("10603", "refill", 1000, "1.75", 47794657329500),
|
||||
("10603", "spool", 1000, "1.75", 54004785217884),
|
||||
("10604", "refill", 1000, "1.75", 49636029006172),
|
||||
("10605", "refill", 1000, "1.75", 49636016783708),
|
||||
("10700", "refill", 1000, "1.75", 47794657362268),
|
||||
("10701", "refill", 1000, "1.75", 49636021436764),
|
||||
("10701", "spool", 1000, "1.75", 53951741821276),
|
||||
("10800", "refill", 1000, "1.75", 42911328207067),
|
||||
("10801", "refill", 1000, "1.75", 47794655101276),
|
||||
("10802", "refill", 1000, "1.75", 49636027236700),
|
||||
("10802", "spool", 1000, "1.75", 53951748702556),
|
||||
"pla-basic-filament",
|
||||
(
|
||||
("10100", "refill", 1000, "1.75", "42911327846619"),
|
||||
("10100", "spool", 1000, "1.75", "43992829919451"),
|
||||
("10101", "refill", 1000, "1.75", "43923829129435"),
|
||||
("10101", "spool", 1000, "1.75", "43992830017755"),
|
||||
("10102", "refill", 1000, "1.75", "42911328010459"),
|
||||
("10103", "refill", 1000, "1.75", "42911327944923"),
|
||||
("10103", "spool", 1000, "1.75", "46956524241244"),
|
||||
("10104", "refill", 1000, "1.75", "49299256148316"),
|
||||
("10105", "refill", 1000, "1.75", "49299261423964"),
|
||||
("10200", "refill", 1000, "1.75", "42911328239835"),
|
||||
("10200", "spool", 1000, "1.75", "43992829952219"),
|
||||
("10201", "refill", 1000, "1.75", "42911327977691"),
|
||||
("10202", "refill", 1000, "1.75", "47794655068508"),
|
||||
("10203", "refill", 1000, "1.75", "42911328141531"),
|
||||
("10204", "refill", 1000, "1.75", "49636028285276"),
|
||||
("10204", "spool", 1000, "1.75", "53951742509404"),
|
||||
("10205", "refill", 1000, "1.75", "49636008395100"),
|
||||
("10300", "refill", 1000, "1.75", "42911327879387"),
|
||||
("10301", "refill", 1000, "1.75", "49636029530460"),
|
||||
("10301", "spool", 1000, "1.75", "53951744213340"),
|
||||
("10400", "refill", 1000, "1.75", "42911328043227"),
|
||||
("10401", "refill", 1000, "1.75", "47794656706908"),
|
||||
("10402", "refill", 1000, "1.75", "49636014031196"),
|
||||
("10402", "spool", 1000, "1.75", "53951741002076"),
|
||||
("10501", "refill", 1000, "1.75", "47794655461724"),
|
||||
("10501", "spool", 1000, "1.75", "46673378607452"),
|
||||
("10502", "refill", 1000, "1.75", "47794656477532"),
|
||||
("10502", "spool", 1000, "1.75", "599083438524203008"),
|
||||
("10503", "refill", 1000, "1.75", "49636024353116"),
|
||||
("10601", "refill", 1000, "1.75", "42911327912155"),
|
||||
("10601", "spool", 1000, "1.75", "46738546622812"),
|
||||
("10602", "refill", 1000, "1.75", "42911328075995"),
|
||||
("10603", "refill", 1000, "1.75", "47794657329500"),
|
||||
("10603", "spool", 1000, "1.75", "54004785217884"),
|
||||
("10604", "refill", 1000, "1.75", "49636029006172"),
|
||||
("10605", "refill", 1000, "1.75", "49636016783708"),
|
||||
("10700", "refill", 1000, "1.75", "47794657362268"),
|
||||
("10701", "refill", 1000, "1.75", "49636021436764"),
|
||||
("10701", "spool", 1000, "1.75", "53951741821276"),
|
||||
("10800", "refill", 1000, "1.75", "42911328207067"),
|
||||
("10801", "refill", 1000, "1.75", "47794655101276"),
|
||||
("10802", "refill", 1000, "1.75", "49636027236700"),
|
||||
("10802", "spool", 1000, "1.75", "53951748702556"),
|
||||
),
|
||||
),
|
||||
"PLA Basic Gradient": (
|
||||
("10900", "spool", 1000, "1.75", 46901930492252),
|
||||
("10901", "spool", 1000, "1.75", 46901930525020),
|
||||
("10902", "spool", 1000, "1.75", 46901930557788),
|
||||
("10903", "spool", 1000, "1.75", 53638219071836),
|
||||
("10904", "spool", 1000, "1.75", 53638219104604),
|
||||
("10905", "spool", 1000, "1.75", 53638219006300),
|
||||
("10906", "spool", 1000, "1.75", 53687078420828),
|
||||
("10907", "spool", 1000, "1.75", 53638219039068),
|
||||
"pla-basic-gradient",
|
||||
(
|
||||
("10900", "spool", 1000, "1.75", "46901930492252"),
|
||||
("10901", "spool", 1000, "1.75", "46901930525020"),
|
||||
("10902", "spool", 1000, "1.75", "46901930557788"),
|
||||
("10903", "spool", 1000, "1.75", "53638219071836"),
|
||||
("10904", "spool", 1000, "1.75", "53638219104604"),
|
||||
("10905", "spool", 1000, "1.75", "53638219006300"),
|
||||
("10906", "spool", 1000, "1.75", "53687078420828"),
|
||||
("10907", "spool", 1000, "1.75", "53638219039068"),
|
||||
),
|
||||
),
|
||||
"PLA Galaxy": (
|
||||
("13203", "spool", 1000, "1.75", 47730388074844),
|
||||
("13503", "spool", 1000, "1.75", 47730388107612),
|
||||
("13504", "spool", 1000, "1.75", 47730388140380),
|
||||
("13602", "spool", 1000, "1.75", 47730388173148),
|
||||
"pla-galaxy",
|
||||
(
|
||||
("13203", "spool", 1000, "1.75", "47730388074844"),
|
||||
("13503", "spool", 1000, "1.75", "47730388107612"),
|
||||
("13504", "spool", 1000, "1.75", "47730388140380"),
|
||||
("13602", "spool", 1000, "1.75", "47730388173148"),
|
||||
),
|
||||
),
|
||||
"PLA Glow": (
|
||||
("15200", "spool", 1000, "1.75", 47396823630172),
|
||||
("15300", "spool", 1000, "1.75", 47396823531868),
|
||||
("15400", "spool", 1000, "1.75", 47396823662940),
|
||||
("15500", "spool", 1000, "1.75", 47396823597404),
|
||||
("15600", "spool", 1000, "1.75", 47396823564636),
|
||||
"pla-glow",
|
||||
(
|
||||
("15200", "spool", 1000, "1.75", "47396823630172"),
|
||||
("15300", "spool", 1000, "1.75", "47396823531868"),
|
||||
("15400", "spool", 1000, "1.75", "47396823662940"),
|
||||
("15500", "spool", 1000, "1.75", "47396823597404"),
|
||||
("15600", "spool", 1000, "1.75", "47396823564636"),
|
||||
),
|
||||
),
|
||||
"PLA Marble": (
|
||||
("13103", "spool", 1000, "1.75", 43964050964699),
|
||||
("13201", "spool", 1000, "1.75", 46756997333340),
|
||||
"pla-marble",
|
||||
(
|
||||
("13103", "spool", 1000, "1.75", "43964050964699"),
|
||||
("13201", "spool", 1000, "1.75", "46756997333340"),
|
||||
),
|
||||
),
|
||||
"PLA Matte": (
|
||||
("11100", "refill", 1000, "1.75", 42996742586587),
|
||||
("11100", "spool", 1000, "1.75", 43992833229019),
|
||||
("11101", "refill", 1000, "1.75", 42996742750427),
|
||||
("11101", "spool", 1000, "1.75", 43992833261787),
|
||||
("11102", "refill", 1000, "1.75", 42996742619355),
|
||||
("11102", "spool", 1000, "1.75", 43992833327323),
|
||||
("11103", "refill", 1000, "1.75", 53926028607836),
|
||||
("11104", "refill", 1000, "1.75", 53926028837212),
|
||||
("11200", "refill", 1000, "1.75", 42996742848731),
|
||||
("11200", "spool", 1000, "1.75", 43992833294555),
|
||||
("11201", "refill", 1000, "1.75", 42996742684891),
|
||||
("11202", "refill", 1000, "1.75", 47794659164508),
|
||||
("11203", "refill", 1000, "1.75", 53926028804444),
|
||||
("11204", "refill", 1000, "1.75", 53926028640604),
|
||||
("11300", "refill", 1000, "1.75", 42996742652123),
|
||||
("11300", "spool", 1000, "1.75", 46893218038108),
|
||||
("11400", "refill", 1000, "1.75", 42996742717659),
|
||||
("11401", "refill", 1000, "1.75", 48612736401756),
|
||||
("11500", "refill", 1000, "1.75", 42996742783195),
|
||||
("11501", "refill", 1000, "1.75", 47794659656028),
|
||||
("11502", "refill", 1000, "1.75", 53926028706140),
|
||||
("11600", "refill", 1000, "1.75", 42996751073499),
|
||||
("11600", "spool", 1000, "1.75", 43992833360091),
|
||||
("11601", "refill", 1000, "1.75", 42996742881499),
|
||||
("11602", "refill", 1000, "1.75", 47794659688796),
|
||||
("11603", "refill", 1000, "1.75", 53926028673372),
|
||||
("11700", "refill", 1000, "1.75", 42996742914267),
|
||||
("11800", "refill", 1000, "1.75", 42996742815963),
|
||||
("11801", "refill", 1000, "1.75", 47794659426652),
|
||||
("11802", "refill", 1000, "1.75", 53926028738908),
|
||||
("11803", "refill", 1000, "1.75", 53926028771676),
|
||||
"pla-matte",
|
||||
(
|
||||
("11100", "refill", 1000, "1.75", "42996742586587"),
|
||||
("11100", "spool", 1000, "1.75", "43992833229019"),
|
||||
("11101", "refill", 1000, "1.75", "42996742750427"),
|
||||
("11101", "spool", 1000, "1.75", "43992833261787"),
|
||||
("11102", "refill", 1000, "1.75", "42996742619355"),
|
||||
("11102", "spool", 1000, "1.75", "43992833327323"),
|
||||
("11103", "refill", 1000, "1.75", "53926028607836"),
|
||||
("11104", "refill", 1000, "1.75", "53926028837212"),
|
||||
("11200", "refill", 1000, "1.75", "42996742848731"),
|
||||
("11200", "spool", 1000, "1.75", "43992833294555"),
|
||||
("11201", "refill", 1000, "1.75", "42996742684891"),
|
||||
("11202", "refill", 1000, "1.75", "47794659164508"),
|
||||
("11203", "refill", 1000, "1.75", "53926028804444"),
|
||||
("11204", "refill", 1000, "1.75", "53926028640604"),
|
||||
("11300", "refill", 1000, "1.75", "42996742652123"),
|
||||
("11300", "spool", 1000, "1.75", "46893218038108"),
|
||||
("11400", "refill", 1000, "1.75", "42996742717659"),
|
||||
("11401", "refill", 1000, "1.75", "48612736401756"),
|
||||
("11500", "refill", 1000, "1.75", "42996742783195"),
|
||||
("11501", "refill", 1000, "1.75", "47794659656028"),
|
||||
("11502", "refill", 1000, "1.75", "53926028706140"),
|
||||
("11600", "refill", 1000, "1.75", "42996751073499"),
|
||||
("11600", "spool", 1000, "1.75", "43992833360091"),
|
||||
("11601", "refill", 1000, "1.75", "42996742881499"),
|
||||
("11602", "refill", 1000, "1.75", "47794659688796"),
|
||||
("11603", "refill", 1000, "1.75", "53926028673372"),
|
||||
("11700", "refill", 1000, "1.75", "42996742914267"),
|
||||
("11800", "refill", 1000, "1.75", "42996742815963"),
|
||||
("11801", "refill", 1000, "1.75", "47794659426652"),
|
||||
("11802", "refill", 1000, "1.75", "53926028738908"),
|
||||
("11803", "refill", 1000, "1.75", "53926028771676"),
|
||||
),
|
||||
),
|
||||
"PLA Metal": (
|
||||
("13100", "spool", 1000, "1.75", 46797850902876),
|
||||
("13400", "spool", 1000, "1.75", 46797851099484),
|
||||
("13500", "spool", 1000, "1.75", 43959185277147),
|
||||
("13600", "spool", 1000, "1.75", 43959185244379),
|
||||
("13800", "spool", 1000, "1.75", 43959185015003),
|
||||
"pla-metal",
|
||||
(
|
||||
("13100", "spool", 1000, "1.75", "46797850902876"),
|
||||
("13400", "spool", 1000, "1.75", "46797851099484"),
|
||||
("13500", "spool", 1000, "1.75", "43959185277147"),
|
||||
("13600", "spool", 1000, "1.75", "43959185244379"),
|
||||
("13800", "spool", 1000, "1.75", "43959185015003"),
|
||||
),
|
||||
),
|
||||
"PLA Palette": (
|
||||
"pla-palette",
|
||||
(
|
||||
("18100", "spool", 1000, "1.75", "792649782224003114"),
|
||||
("18101", "spool", 1000, "1.75", "792649782224003106"),
|
||||
("18200", "spool", 1000, "1.75", "792649782224003090"),
|
||||
("18400", "spool", 1000, "1.75", "792649782224003098"),
|
||||
("18600", "spool", 1000, "1.75", "792649782224003082"),
|
||||
),
|
||||
),
|
||||
"PLA Pure": (
|
||||
"pla-pure",
|
||||
(
|
||||
("17100", "refill", 1000, "1.75", "738891519803023418"),
|
||||
("17100", "spool", 1000, "1.75", "738891519803023426"),
|
||||
("17101", "refill", 1000, "1.75", "738891519803023434"),
|
||||
("17101", "spool", 1000, "1.75", "738891519803023442"),
|
||||
("17200", "refill", 1000, "1.75", "738891519803023370"),
|
||||
("17200", "spool", 1000, "1.75", "738891519803023378"),
|
||||
("17300", "refill", 1000, "1.75", "738891519803023402"),
|
||||
("17300", "spool", 1000, "1.75", "738891519803023410"),
|
||||
("17600", "refill", 1000, "1.75", "738891519803023386"),
|
||||
("17600", "spool", 1000, "1.75", "738891519803023394"),
|
||||
),
|
||||
),
|
||||
"PLA Silk Multi-Color": (
|
||||
("13901", "spool", 1000, "1.75", 47489270776156),
|
||||
("13902", "spool", 1000, "1.75", 47489270808924),
|
||||
("13903", "spool", 1000, "1.75", 47489270841692),
|
||||
("13904", "spool", 1000, "1.75", 47489270874460),
|
||||
("13905", "spool", 1000, "1.75", 53515458085212),
|
||||
"pla-silk-multi-color",
|
||||
(
|
||||
("13901", "spool", 1000, "1.75", "47489270776156"),
|
||||
("13902", "spool", 1000, "1.75", "47489270808924"),
|
||||
("13903", "spool", 1000, "1.75", "47489270841692"),
|
||||
("13904", "spool", 1000, "1.75", "47489270874460"),
|
||||
("13905", "spool", 1000, "1.75", "53515458085212"),
|
||||
("13906", "spool", 1000, "1.75", "601314264425144336"),
|
||||
("13909", "spool", 1000, "1.75", "601314264425144330"),
|
||||
("13912", "spool", 1000, "1.75", "601314264425144324"),
|
||||
("13913", "spool", 1000, "1.75", "665320335394844675"),
|
||||
("13916", "spool", 1000, "1.75", "665320335394844681"),
|
||||
),
|
||||
),
|
||||
"PLA Silk+": (
|
||||
("13108", "spool", 1000, "1.75", 53583205925212),
|
||||
("13109", "spool", 1000, "1.75", 53583205826908),
|
||||
("13110", "spool", 1000, "1.75", 53583205794140),
|
||||
("13205", "spool", 1000, "1.75", 53583205663068),
|
||||
("13206", "spool", 1000, "1.75", 53583205957980),
|
||||
("13207", "spool", 1000, "1.75", 53583205761372),
|
||||
("13404", "spool", 1000, "1.75", 53583205990748),
|
||||
("13405", "spool", 1000, "1.75", 53583205859676),
|
||||
("13506", "spool", 1000, "1.75", 53583205630300),
|
||||
("13507", "spool", 1000, "1.75", 53583205892444),
|
||||
("13603", "spool", 1000, "1.75", 53583206023516),
|
||||
("13604", "spool", 1000, "1.75", 53583205695836),
|
||||
("13702", "spool", 1000, "1.75", 53583205728604),
|
||||
"pla-silk-upgrade",
|
||||
(
|
||||
("13108", "refill", 1000, "1.75", "678380546391728130"),
|
||||
("13108", "spool", 1000, "1.75", "53583205925212"),
|
||||
("13109", "refill", 1000, "1.75", "678380546395922438"),
|
||||
("13109", "spool", 1000, "1.75", "53583205826908"),
|
||||
("13110", "refill", 1000, "1.75", "678380546395922432"),
|
||||
("13110", "spool", 1000, "1.75", "53583205794140"),
|
||||
("13205", "spool", 1000, "1.75", "53583205663068"),
|
||||
("13206", "spool", 1000, "1.75", "53583205957980"),
|
||||
("13207", "spool", 1000, "1.75", "53583205761372"),
|
||||
("13404", "spool", 1000, "1.75", "53583205990748"),
|
||||
("13405", "refill", 1000, "1.75", "678380546395922444"),
|
||||
("13405", "spool", 1000, "1.75", "53583205859676"),
|
||||
("13506", "spool", 1000, "1.75", "53583205630300"),
|
||||
("13507", "spool", 1000, "1.75", "53583205892444"),
|
||||
("13603", "spool", 1000, "1.75", "53583206023516"),
|
||||
("13604", "spool", 1000, "1.75", "53583205695836"),
|
||||
("13702", "spool", 1000, "1.75", "53583205728604"),
|
||||
),
|
||||
),
|
||||
"PLA Sparkle": (
|
||||
("13101", "spool", 1000, "1.75", 43959190946011),
|
||||
("13102", "spool", 1000, "1.75", 46797853163868),
|
||||
("13200", "spool", 1000, "1.75", 43959190913243),
|
||||
("13402", "spool", 1000, "1.75", 48725896266076),
|
||||
("13501", "spool", 1000, "1.75", 43959190880475),
|
||||
("13700", "spool", 1000, "1.75", 46797853032796),
|
||||
"pla-sparkle",
|
||||
(
|
||||
("13101", "spool", 1000, "1.75", "43959190946011"),
|
||||
("13102", "spool", 1000, "1.75", "46797853163868"),
|
||||
("13200", "spool", 1000, "1.75", "43959190913243"),
|
||||
("13402", "spool", 1000, "1.75", "48725896266076"),
|
||||
("13501", "spool", 1000, "1.75", "43959190880475"),
|
||||
("13700", "spool", 1000, "1.75", "46797853032796"),
|
||||
),
|
||||
),
|
||||
"PLA Tough+": (
|
||||
"pla-tough-upgrade",
|
||||
(
|
||||
("12104", "refill", 1000, "1.75", "661695156312956942"),
|
||||
("12104", "spool", 1000, "1.75", "624496486489088048"),
|
||||
("12105", "refill", 1000, "1.75", "661695156312956936"),
|
||||
("12105", "spool", 1000, "1.75", "624496486489088030"),
|
||||
("12106", "spool", 1000, "1.75", "624496486489088036"),
|
||||
("12107", "refill", 1000, "1.75", "661695156312956930"),
|
||||
("12107", "spool", 1000, "1.75", "624496486489088012"),
|
||||
("12301", "spool", 1000, "1.75", "624496486489088024"),
|
||||
("12401", "spool", 1000, "1.75", "624496486489088018"),
|
||||
("12601", "spool", 1000, "1.75", "624496486489088042"),
|
||||
),
|
||||
),
|
||||
"PLA Translucent": (
|
||||
("13210", "spool", 1000, "1.75", 54345716695388),
|
||||
("13211", "spool", 1000, "1.75", 54407223050588),
|
||||
("13301", "spool", 1000, "1.75", 54345716662620),
|
||||
("13410", "spool", 1000, "1.75", 54407223017820),
|
||||
("13510", "spool", 1000, "1.75", 54407222985052),
|
||||
("13610", "spool", 1000, "1.75", 54407223083356),
|
||||
("13611", "spool", 1000, "1.75", 54345716597084),
|
||||
("13612", "spool", 1000, "1.75", 54345716564316),
|
||||
("13710", "spool", 1000, "1.75", 54345716629852),
|
||||
("13711", "spool", 1000, "1.75", 54407223116124),
|
||||
"pla-translucent",
|
||||
(
|
||||
("13210", "spool", 1000, "1.75", "54345716695388"),
|
||||
("13211", "spool", 1000, "1.75", "54407223050588"),
|
||||
("13301", "spool", 1000, "1.75", "54345716662620"),
|
||||
("13410", "spool", 1000, "1.75", "54407223017820"),
|
||||
("13510", "spool", 1000, "1.75", "54407222985052"),
|
||||
("13610", "spool", 1000, "1.75", "54407223083356"),
|
||||
("13611", "spool", 1000, "1.75", "54345716597084"),
|
||||
("13612", "spool", 1000, "1.75", "54345716564316"),
|
||||
("13710", "spool", 1000, "1.75", "54345716629852"),
|
||||
("13711", "spool", 1000, "1.75", "54407223116124"),
|
||||
),
|
||||
),
|
||||
"PLA Wood": (
|
||||
("13106", "spool", 1000, "1.75", 53441583186268),
|
||||
("13107", "spool", 1000, "1.75", 53441583055196),
|
||||
("13204", "spool", 1000, "1.75", 53441583087964),
|
||||
("13403", "spool", 1000, "1.75", 53441583219036),
|
||||
("13505", "spool", 1000, "1.75", 53441583153500),
|
||||
("13801", "spool", 1000, "1.75", 53441583120732),
|
||||
"pla-wood",
|
||||
(
|
||||
("13106", "spool", 1000, "1.75", "53441583186268"),
|
||||
("13107", "spool", 1000, "1.75", "53441583055196"),
|
||||
("13204", "spool", 1000, "1.75", "53441583087964"),
|
||||
("13403", "spool", 1000, "1.75", "53441583219036"),
|
||||
("13505", "spool", 1000, "1.75", "53441583153500"),
|
||||
("13801", "spool", 1000, "1.75", "53441583120732"),
|
||||
),
|
||||
),
|
||||
"PLA-CF": (
|
||||
("14100", "refill", 1000, "1.75", 49200517448028),
|
||||
("14100", "spool", 1000, "1.75", 43944001994971),
|
||||
("14101", "refill", 1000, "1.75", 49238028845404),
|
||||
("14101", "spool", 1000, "1.75", 46702306296156),
|
||||
("14200", "spool", 1000, "1.75", 46702306230620),
|
||||
("14500", "spool", 1000, "1.75", 46797856342364),
|
||||
("14600", "spool", 1000, "1.75", 46702306263388),
|
||||
("14601", "spool", 1000, "1.75", 47068316565852),
|
||||
("14700", "spool", 1000, "1.75", 47068316598620),
|
||||
"pla-cf",
|
||||
(
|
||||
("14100", "refill", 1000, "1.75", "49200517448028"),
|
||||
("14100", "spool", 1000, "1.75", "43944001994971"),
|
||||
("14101", "refill", 1000, "1.75", "49238028845404"),
|
||||
("14101", "spool", 1000, "1.75", "46702306296156"),
|
||||
("14200", "spool", 1000, "1.75", "46702306230620"),
|
||||
("14500", "spool", 1000, "1.75", "46797856342364"),
|
||||
("14600", "spool", 1000, "1.75", "46702306263388"),
|
||||
("14601", "spool", 1000, "1.75", "47068316565852"),
|
||||
("14700", "spool", 1000, "1.75", "47068316598620"),
|
||||
),
|
||||
),
|
||||
"PPA-CF": (
|
||||
"ppa-cf",
|
||||
(("73100", "spool", 750, "1.75", "49237640642908"),),
|
||||
),
|
||||
"PPS-CF": (
|
||||
"pps-cf",
|
||||
(("76100", "spool", 750, "1.75", "49259815731548"),),
|
||||
),
|
||||
"PVA": (
|
||||
"pva",
|
||||
(("66400", "spool", 500, "1.75", "47790189281628"),),
|
||||
),
|
||||
"Support for ABS": (
|
||||
"support-for-abs",
|
||||
(("66100", "spool", 500, "1.75", "49063577420124"),),
|
||||
),
|
||||
"Support for PA/PET": (
|
||||
"support-for-pa-pet",
|
||||
(("65500", "spool", 500, "1.75", "43050119364827"),),
|
||||
),
|
||||
"Support for PLA (New Version)": (
|
||||
"support-for-pla-new",
|
||||
(("65104", "spool", 500, "1.75", "54200625725788"),),
|
||||
),
|
||||
"PPA-CF": (("73100", "spool", 750, "1.75", 49237640642908),),
|
||||
"PPS-CF": (("76100", "spool", 750, "1.75", 49259815731548),),
|
||||
"PVA": (("66400", "spool", 500, "1.75", 47790189281628),),
|
||||
"Support for ABS": (("66100", "spool", 500, "1.75", 49063577420124),),
|
||||
"Support for PA/PET": (("65500", "spool", 500, "1.75", 43050119364827),),
|
||||
"Support for PLA (New Version)": (("65104", "spool", 500, "1.75", 54200625725788),),
|
||||
"Support for PLA/PETG": (
|
||||
("65102", "spool", 500, "1.75", 48921550553436),
|
||||
("65103", "spool", 500, "1.75", 53534477320540),
|
||||
"support-for-pla-petg",
|
||||
(
|
||||
("65102", "spool", 500, "1.75", "48921550553436"),
|
||||
("65103", "spool", 500, "1.75", "53534477320540"),
|
||||
),
|
||||
),
|
||||
"TPU 75A (2.85mm)": (
|
||||
"tpu-75a-2-85mm",
|
||||
(
|
||||
("56100", "spool", 1000, "2.85", "788659415745044543"),
|
||||
("56200", "spool", 1000, "2.85", "788659415740850191"),
|
||||
("56300", "spool", 1000, "2.85", "788659415745044503"),
|
||||
("56400", "spool", 1000, "2.85", "788659415745044535"),
|
||||
("56401", "spool", 1000, "2.85", "788659415745044527"),
|
||||
("56500", "spool", 1000, "2.85", "788659415745044519"),
|
||||
("56501", "spool", 1000, "2.85", "788659415745044511"),
|
||||
("56600", "spool", 1000, "2.85", "788659415745044551"),
|
||||
("56700", "spool", 1000, "2.85", "788659415745044495"),
|
||||
("56701", "spool", 1000, "2.85", "788659415745044487"),
|
||||
),
|
||||
),
|
||||
"TPU 85A": (
|
||||
("51305", "spool", 1000, "1.75", 54085774410076),
|
||||
("51500", "spool", 1000, "1.75", 54085774442844),
|
||||
"tpu-85a-tpu-90a",
|
||||
(
|
||||
("51107", "spool", 1000, "1.75", "682714606946189336"),
|
||||
("51201", "spool", 1000, "1.75", "682714606946189342"),
|
||||
("51305", "spool", 1000, "1.75", "669790315686178817"),
|
||||
("51500", "spool", 1000, "1.75", "54085774442844"),
|
||||
("51501", "spool", 1000, "1.75", "682714606946189348"),
|
||||
),
|
||||
),
|
||||
"TPU 90A": (
|
||||
("51103", "spool", 1000, "1.75", 54085774541148),
|
||||
("51105", "spool", 1000, "1.75", 54085774475612),
|
||||
("51900", "spool", 1000, "1.75", 54085774508380),
|
||||
("51901", "spool", 1000, "1.75", 54084062511452),
|
||||
"tpu-85a-tpu-90a",
|
||||
(
|
||||
("51103", "spool", 1000, "1.75", "54085774541148"),
|
||||
("51105", "spool", 1000, "1.75", "664621573916450817"),
|
||||
("51106", "spool", 1000, "1.75", "697574082204368897"),
|
||||
("51601", "spool", 1000, "1.75", "682714606946189324"),
|
||||
("51700", "spool", 1000, "1.75", "682714606946189318"),
|
||||
("51800", "spool", 1000, "1.75", "682714606946189330"),
|
||||
("51900", "spool", 1000, "1.75", "54085774508380"),
|
||||
("51901", "spool", 1000, "1.75", "54084062511452"),
|
||||
),
|
||||
),
|
||||
"TPU 95A HF": (
|
||||
("51100", "spool", 1000, "1.75", 47305218687324),
|
||||
("51101", "spool", 1000, "1.75", 47305218785628),
|
||||
("51102", "spool", 1000, "1.75", 47305218752860),
|
||||
("51200", "spool", 1000, "1.75", 47305218883932),
|
||||
("51400", "spool", 1000, "1.75", 47305218818396),
|
||||
("51600", "spool", 1000, "1.75", 47305218851164),
|
||||
"tpu-95a-hf",
|
||||
(
|
||||
("51100", "spool", 1000, "1.75", "47305218687324"),
|
||||
("51101", "spool", 1000, "1.75", "47305218785628"),
|
||||
("51102", "spool", 1000, "1.75", "47305218752860"),
|
||||
("51200", "spool", 1000, "1.75", "47305218883932"),
|
||||
("51400", "spool", 1000, "1.75", "47305218818396"),
|
||||
("51600", "spool", 1000, "1.75", "47305218851164"),
|
||||
),
|
||||
),
|
||||
"TPU for AMS": (
|
||||
("53100", "spool", 1000, "1.75", 53421837320540),
|
||||
("53101", "spool", 1000, "1.75", 53421837386076),
|
||||
("53102", "spool", 1000, "1.75", 53421837353308),
|
||||
("53200", "spool", 1000, "1.75", 53421837189468),
|
||||
("53400", "spool", 1000, "1.75", 53421837222236),
|
||||
("53500", "spool", 1000, "1.75", 53421837287772),
|
||||
("53600", "spool", 1000, "1.75", 53421837255004),
|
||||
"tpu-for-ams",
|
||||
(
|
||||
("53100", "spool", 1000, "1.75", "53421837320540"),
|
||||
("53101", "refill", 1000, "1.75", "680212034153209858"),
|
||||
("53101", "spool", 1000, "1.75", "53421837386076"),
|
||||
("53102", "spool", 1000, "1.75", "53421837353308"),
|
||||
("53200", "spool", 1000, "1.75", "53421837189468"),
|
||||
("53400", "spool", 1000, "1.75", "53421837222236"),
|
||||
("53500", "spool", 1000, "1.75", "53421837287772"),
|
||||
("53600", "spool", 1000, "1.75", "53421837255004"),
|
||||
),
|
||||
),
|
||||
}
|
||||
|
||||
BAMBU_EU_PRODUCT_SLUGS = {
|
||||
"abs": "abs-filament",
|
||||
"abs-gf": "abs-gf",
|
||||
"asa": "asa-filament",
|
||||
"asa aero": "asa-aero",
|
||||
"asa-cf": "asa-cf",
|
||||
"pa6-cf (1 kg)": "pa6-cf",
|
||||
"pa6-cf (500 g)": "pa6-cf",
|
||||
"pa6-gf": "pa6-gf",
|
||||
"paht-cf (1 kg)": "paht-cf",
|
||||
"paht-cf (500 g)": "paht-cf",
|
||||
"pc": "pc-filament",
|
||||
"pc fr": "pc-fr",
|
||||
"pet-cf (1 kg)": "pet-cf",
|
||||
"pet-cf (500 g)": "pet-cf",
|
||||
"petg basic": "petg-basic",
|
||||
"petg matte": "petg-matte",
|
||||
"petg translucent": "petg-translucent",
|
||||
"petg-cf": "petg-cf",
|
||||
"pla aero": "pla-aero",
|
||||
"pla basic": "pla-basic-filament",
|
||||
"pla basic gradient": "pla-basic-gradient",
|
||||
"pla galaxy": "pla-galaxy",
|
||||
"pla glow": "pla-glow",
|
||||
"pla marble": "pla-marble",
|
||||
"pla matte": "pla-matte",
|
||||
"pla metal": "pla-metal",
|
||||
"pla palette": "pla-palette",
|
||||
"pla pure": "pla-pure",
|
||||
"pla silk multi-color": "pla-silk-multi-color",
|
||||
"pla silk+": "pla-silk-upgrade",
|
||||
"pla sparkle": "pla-sparkle",
|
||||
"pla tough+": "pla-tough-upgrade",
|
||||
"pla translucent": "pla-translucent",
|
||||
"pla wood": "pla-wood",
|
||||
"pla-cf": "pla-cf",
|
||||
"ppa-cf": "ppa-cf",
|
||||
"pps-cf": "pps-cf",
|
||||
"pva": "pva",
|
||||
"support for abs": "support-for-abs",
|
||||
"support for pa/pet": "support-for-pa-pet",
|
||||
"support for pla (new version)": "support-for-pla-new",
|
||||
"support for pla/petg": "support-for-pla-petg",
|
||||
"tpu 75a (2.85mm)": "tpu-75a-2-85mm",
|
||||
"tpu 85a": "tpu-85a-tpu-90a",
|
||||
"tpu 90a": "tpu-85a-tpu-90a",
|
||||
"tpu 95a hf": "tpu-95a-hf",
|
||||
"tpu for ams": "tpu-for-ams",
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
from decimal import Decimal
|
||||
|
||||
from django import forms
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db.models import Q
|
||||
@@ -45,6 +47,45 @@ class MarketplaceOfferForm(forms.ModelForm):
|
||||
return quantity
|
||||
|
||||
|
||||
class BambuCartPricesForm(forms.Form):
|
||||
signature = forms.CharField(widget=forms.HiddenInput)
|
||||
cart_total = forms.DecimalField(
|
||||
label="Warensumme nach allen Rabatten (€)",
|
||||
min_value=0,
|
||||
max_value=Decimal("21474836.47"),
|
||||
decimal_places=2,
|
||||
localize=True,
|
||||
widget=forms.TextInput(attrs={"inputmode": "decimal"}),
|
||||
)
|
||||
|
||||
def __init__(self, *args, plan, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.plan = plan
|
||||
self.initial["signature"] = plan.signature
|
||||
for line in plan.lines:
|
||||
self.fields[line.key] = forms.DecimalField(
|
||||
label=f"Preis für {line.quantity} Stück · {line.variant}",
|
||||
min_value=0,
|
||||
max_value=Decimal("21474836.47"),
|
||||
decimal_places=2,
|
||||
localize=True,
|
||||
widget=forms.TextInput(attrs={"inputmode": "decimal"}),
|
||||
)
|
||||
|
||||
def clean(self):
|
||||
cleaned = super().clean()
|
||||
if cleaned.get("signature") != self.plan.signature:
|
||||
raise forms.ValidationError("Die Bestellliste hat sich geändert. Lade die Seite neu.")
|
||||
total = cleaned.get("cart_total")
|
||||
if total is not None and all(line.key in cleaned for line in self.plan.lines):
|
||||
if total > sum(cleaned[line.key] for line in self.plan.lines):
|
||||
self.add_error(
|
||||
"cart_total",
|
||||
"Die Warensumme darf die Summe der Positionen nicht übersteigen. Prüfe Versand und weitere Artikel.",
|
||||
)
|
||||
return cleaned
|
||||
|
||||
|
||||
def selection_id(value):
|
||||
text = str(value or "")
|
||||
return int(text) if text.isascii() and text.isdecimal() and len(text) < 19 else None
|
||||
|
||||
+7
-1
@@ -405,6 +405,8 @@ class StockMovement(models.Model):
|
||||
|
||||
|
||||
class OrderItem(QuantityPosition):
|
||||
EU_CART_QUOTE_PREFIX = "eu-cart:"
|
||||
|
||||
class Status(models.TextChoices):
|
||||
OPEN = "open", "Offen"
|
||||
UNAVAILABLE = "unavailable", "Aktuell nicht verfügbar"
|
||||
@@ -454,7 +456,11 @@ class OrderItem(QuantityPosition):
|
||||
|
||||
@property
|
||||
def bambu_line_total(self):
|
||||
if self.bambu_quote_cents is not None and self.quantity == self.bambu_quote_quantity:
|
||||
if (
|
||||
self.bambu_quote_cents is not None
|
||||
and self.quantity == self.bambu_quote_quantity
|
||||
and self.bambu_quote_signature.startswith(self.EU_CART_QUOTE_PREFIX)
|
||||
):
|
||||
return Decimal(self.bambu_quote_cents) / 100
|
||||
return None
|
||||
|
||||
|
||||
@@ -738,10 +738,9 @@ td.quantity {
|
||||
.actions a + a {
|
||||
margin-left: 14px;
|
||||
}
|
||||
.order-cart-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
.order-cart-price {
|
||||
margin: 0;
|
||||
min-width: 110px;
|
||||
}
|
||||
.order-person-total {
|
||||
display: flex;
|
||||
|
||||
@@ -1,20 +1,11 @@
|
||||
from unittest.mock import patch
|
||||
|
||||
from django.test import Client
|
||||
from django.urls import reverse
|
||||
|
||||
from filament.bambu_cart import plan_cart
|
||||
from filament.models import OrderItem
|
||||
from filament.models import Color, OrderItem, ProductType, Variant
|
||||
|
||||
from .base import CatalogTestCase
|
||||
|
||||
WHITE_SPOOL = 43992829919451
|
||||
COBALT_REFILL = 49636029006172
|
||||
|
||||
|
||||
def shop_line(shop_id, quantity, cents):
|
||||
return {"variant_id": shop_id, "quantity": quantity, "final_line_price": cents}
|
||||
|
||||
|
||||
class BambuCartTests(CatalogTestCase):
|
||||
def setUp(self):
|
||||
@@ -31,32 +22,72 @@ class BambuCartTests(CatalogTestCase):
|
||||
self.third = OrderItem.objects.create(owner=self.bob, variant=self.refill, quantity=1)
|
||||
self.client.force_login(self.alice)
|
||||
self.url = reverse("bambu_order_cart")
|
||||
self.cart = {
|
||||
"currency": "EUR",
|
||||
"items": [shop_line(WHITE_SPOOL, 3, 7797), shop_line(COBALT_REFILL, 1, 2299)],
|
||||
"total_price": 10096,
|
||||
}
|
||||
|
||||
@patch("filament.views.fetch_cart")
|
||||
def test_open_cart_aggregates_open_wishes_and_persists_prices_per_person(self, fetch):
|
||||
fetch.return_value = self.cart | {"total_price": 9501}
|
||||
def price_data(self, **values):
|
||||
form = self.client.get(self.url).context["form"]
|
||||
return {
|
||||
"signature": form.initial["signature"],
|
||||
"shop_43992829919451": "77,97",
|
||||
"shop_49636029006172": "22,99",
|
||||
"cart_total": "95,01",
|
||||
} | values
|
||||
|
||||
def test_cart_preparation_displays_aggregated_quantities_without_saving_prices(self):
|
||||
page = self.client.get(self.url)
|
||||
rows = {line.key: line for line, _ in page.context["rows"]}
|
||||
self.assertEqual(rows["shop_43992829919451"].quantity, 3)
|
||||
self.assertEqual(rows["shop_49636029006172"].quantity, 1)
|
||||
self.assertContains(page, "https://eu.store.bambulab.com/cart")
|
||||
self.assertContains(page, "/products/pla-basic-filament?id=43992829919451")
|
||||
self.assertNotContains(page, "myshopify.com")
|
||||
self.assertFalse(OrderItem.objects.filter(bambu_quoted_at__isnull=False).exists())
|
||||
self.assertEqual(self.client.post(self.url, {"action": "prices"}).status_code, 200)
|
||||
self.assertFalse(OrderItem.objects.filter(bambu_quoted_at__isnull=False).exists())
|
||||
|
||||
def test_old_shopify_prices_do_not_count_towards_amount_due(self):
|
||||
OrderItem.objects.filter(pk=self.first.pk).update(
|
||||
bambu_quote_cents=2599,
|
||||
bambu_quote_quantity=1,
|
||||
bambu_quote_signature="0" * 64,
|
||||
)
|
||||
response = self.client.get(reverse("orders"))
|
||||
self.assertContains(response, "Gesamtbetrag offen")
|
||||
self.assertNotContains(response, "25,99 €")
|
||||
|
||||
def test_all_five_reported_variants_open_on_the_current_eu_shop(self):
|
||||
cases = (
|
||||
("PETG Basic", "petg-basic", "30403", "spool", "738173299117862975"),
|
||||
("PETG Basic", "petg-basic", "30108", "refill", "738173299117862983"),
|
||||
("PETG Basic", "petg-basic", "30106", "refill", "703100873995440152"),
|
||||
("PLA Pure", "pla-pure", "17300", "spool", "738891519803023410"),
|
||||
("PLA Pure", "pla-pure", "17600", "spool", "738891519803023394"),
|
||||
)
|
||||
for name, _, code, spool, _ in cases:
|
||||
product, _ = ProductType.objects.get_or_create(name=name, manufacturer=self.maker)
|
||||
variant = Variant.objects.create(
|
||||
product_type=product,
|
||||
color=Color.objects.create(name=code),
|
||||
manufacturer_color_code=code,
|
||||
spool_type=spool,
|
||||
net_weight_g=1000,
|
||||
diameter_mm="1.75",
|
||||
)
|
||||
OrderItem.objects.create(owner=self.bob, variant=variant, quantity=1)
|
||||
|
||||
page = self.client.get(self.url)
|
||||
for _, slug, _, _, shop_id in cases:
|
||||
self.assertContains(page, f"https://eu.store.bambulab.com/products/{slug}?id={shop_id}")
|
||||
|
||||
def test_import_distributes_actual_cart_total_including_discount_and_rounding(self):
|
||||
ordered = OrderItem.objects.create(
|
||||
owner=self.alice, variant=self.refill, quantity=2, status=OrderItem.Status.ORDERED
|
||||
)
|
||||
unavailable = OrderItem.objects.create(
|
||||
owner=self.alice, variant=self.refill, quantity=4, status=OrderItem.Status.UNAVAILABLE
|
||||
)
|
||||
response = self.client.post(self.url)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(
|
||||
response["Location"],
|
||||
f"https://bambulab-eu.myshopify.com/cart/{WHITE_SPOOL}:3,{COBALT_REFILL}:1?storefront=true",
|
||||
)
|
||||
self.assertRedirects(self.client.post(self.url, self.price_data()), reverse("orders"))
|
||||
for entry in (self.first, self.second, self.third, ordered, unavailable):
|
||||
entry.refresh_from_db()
|
||||
self.assertEqual(
|
||||
sum(entry.bambu_quote_cents for entry in (self.first, self.second, self.third)), 9501
|
||||
)
|
||||
self.assertEqual(self.first.bambu_quote_cents, 2446)
|
||||
self.assertEqual(self.second.bambu_quote_cents, 4891)
|
||||
self.assertEqual(self.third.bambu_quote_cents, 2164)
|
||||
@@ -71,10 +102,29 @@ class BambuCartTests(CatalogTestCase):
|
||||
self.assertContains(
|
||||
page, "<div><span>Gesamtbetrag</span> <strong>70,55 €</strong></div>", html=True
|
||||
)
|
||||
self.assertContains(page, 'class="order-person-total"', count=2)
|
||||
self.assertContains(page, "Für 1 Position fehlt der Preis.", count=1)
|
||||
for section in page.content.decode().split('class="order-table"')[1:]:
|
||||
self.assertIn('class="order-person-total"', section.split("</table>", 1)[1])
|
||||
|
||||
def test_import_rejects_incomplete_amounts_or_a_total_including_shipping(self):
|
||||
for values in (
|
||||
{"cart_total": "102,00"},
|
||||
{"shop_49636029006172": ""},
|
||||
{"shop_49636029006172": "-1,50"},
|
||||
):
|
||||
response = self.client.post(self.url, self.price_data(**values))
|
||||
self.assertTrue(response.context["form"].errors)
|
||||
self.assertFalse(OrderItem.objects.filter(bambu_quoted_at__isnull=False).exists())
|
||||
|
||||
def test_quantity_change_rejects_import_prepared_for_another_cart(self):
|
||||
data = self.price_data()
|
||||
self.second.quantity = 1
|
||||
self.second.save(update_fields=["quantity"])
|
||||
response = self.client.post(self.url, data)
|
||||
self.assertContains(response, "Die Bestellliste hat sich geändert.")
|
||||
self.assertFalse(OrderItem.objects.filter(bambu_quoted_at__isnull=False).exists())
|
||||
|
||||
def test_existing_price_is_marked_stale_after_cart_changes(self):
|
||||
self.client.post(self.url, self.price_data())
|
||||
self.third.status = OrderItem.Status.UNAVAILABLE
|
||||
self.third.save(update_fields=["status"])
|
||||
page = self.client.get(reverse("orders"))
|
||||
@@ -84,74 +134,27 @@ class BambuCartTests(CatalogTestCase):
|
||||
self.assertNotContains(page, "70,55 €")
|
||||
self.assertContains(page, "Preise vor der letzten Listenänderung.")
|
||||
|
||||
@patch("filament.views.fetch_cart")
|
||||
def test_preview_warns_about_unmapped_variants_and_keeps_price_for_mapped_rows(self, fetch):
|
||||
OrderItem.objects.create(owner=self.bob, variant=self.black_spool, quantity=5)
|
||||
fetch.return_value = self.cart
|
||||
page = self.client.post(self.url)
|
||||
self.assertContains(page, "Keine eindeutige Shop-Variante")
|
||||
self.assertContains(page, "Warenkorb im Shop prüfen")
|
||||
self.first.refresh_from_db()
|
||||
self.assertEqual(self.first.bambu_quote_cents, 2599)
|
||||
|
||||
@patch("filament.views.fetch_cart")
|
||||
def test_stock_shortage_leaves_existing_prices_intact(self, fetch):
|
||||
fetch.return_value = self.cart
|
||||
self.assertRedirects(self.client.post(self.url, {"action": "prices"}), reverse("orders"))
|
||||
fetch.return_value = self.cart | {
|
||||
"items": [shop_line(WHITE_SPOOL, 2, 4000), shop_line(COBALT_REFILL, 1, 1000)],
|
||||
"total_price": 5000,
|
||||
}
|
||||
page = self.client.post(self.url)
|
||||
self.assertContains(page, "2 von 3 im Shop")
|
||||
self.first.refresh_from_db()
|
||||
self.assertEqual(self.first.bambu_quote_cents, 2599)
|
||||
|
||||
@patch("filament.views.fetch_cart")
|
||||
def test_concurrent_change_prevents_overwriting_prices_or_opening_old_cart(self, fetch):
|
||||
def shop_response(plan):
|
||||
OrderItem.objects.filter(pk=self.second.pk).update(quantity=1)
|
||||
return self.cart
|
||||
|
||||
fetch.side_effect = shop_response
|
||||
page = self.client.post(self.url)
|
||||
self.assertContains(page, "Die Bestellliste hat sich geändert")
|
||||
self.assertNotContains(page, "Warenkorb im Shop prüfen")
|
||||
self.first.refresh_from_db()
|
||||
self.assertIsNone(self.first.bambu_quote_cents)
|
||||
|
||||
@patch("filament.views.fetch_cart")
|
||||
def test_a_changed_cart_marks_other_open_prices_as_stale(self, fetch):
|
||||
fetch.return_value = self.cart
|
||||
self.client.post(self.url)
|
||||
OrderItem.objects.filter(pk=self.second.pk).update(quantity=1)
|
||||
page = self.client.get(reverse("orders"))
|
||||
self.assertContains(page, "Bestellliste geändert", count=2)
|
||||
self.assertNotContains(page, "51,98 €")
|
||||
|
||||
@patch("filament.views.fetch_cart")
|
||||
def test_cart_action_requires_login_post_and_csrf(self, fetch):
|
||||
self.assertEqual(self.client.get(self.url).status_code, 405)
|
||||
def test_cart_action_requires_login_and_import_requires_csrf(self):
|
||||
self.client.logout()
|
||||
self.assertEqual(self.client.get(self.url).status_code, 302)
|
||||
self.assertEqual(self.client.post(self.url).status_code, 302)
|
||||
csrf = Client(enforce_csrf_checks=True)
|
||||
csrf.force_login(self.alice)
|
||||
self.assertEqual(csrf.post(self.url).status_code, 403)
|
||||
fetch.assert_not_called()
|
||||
|
||||
def test_silk_dual_uses_the_shop_multi_color_listing(self):
|
||||
def test_silk_dual_uses_current_shop_multi_color_listing(self):
|
||||
self.product.name = "PLA Silk Dual Color"
|
||||
self.product.save(update_fields=["name"])
|
||||
self.spool.manufacturer_color_code = "13901"
|
||||
self.spool.save(update_fields=["manufacturer_color_code"])
|
||||
plan = plan_cart(OrderItem.objects.filter(pk=self.first.pk))
|
||||
self.assertEqual(len(plan.entries), 1)
|
||||
self.assertEqual(plan.excluded, [])
|
||||
|
||||
self.spool.manufacturer_color_code = "13909"
|
||||
self.spool.save(update_fields=["manufacturer_color_code"])
|
||||
plan = plan_cart(OrderItem.objects.filter(pk=self.first.pk))
|
||||
self.assertFalse(plan.entries)
|
||||
self.assertEqual(
|
||||
plan.excluded[0][2], "https://eu.store.bambulab.com/products/pla-silk-multi-color"
|
||||
plan.lines[0].product_url,
|
||||
"https://eu.store.bambulab.com/products/pla-silk-multi-color?id=601314264425144330",
|
||||
)
|
||||
|
||||
def test_a_custom_catalog_variant_stays_on_the_shopping_list(self):
|
||||
OrderItem.objects.create(owner=self.bob, variant=self.black_spool, quantity=1)
|
||||
page = self.client.get(self.url)
|
||||
self.assertContains(page, "Ausführung im Shop prüfen")
|
||||
self.assertContains(page, f'id="id_local_{self.black_spool.pk}"')
|
||||
+23
-37
@@ -17,10 +17,11 @@ from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from django.views.decorators.http import require_http_methods
|
||||
|
||||
from .bambu_cart import CartQuoteError, fetch_cart, plan_cart, quote_cart
|
||||
from .bambu_cart import SHOP_URL, allocate_prices, plan_cart
|
||||
from .forms import (
|
||||
ArticleLookupForm,
|
||||
AssignEmptySpoolForm,
|
||||
BambuCartPricesForm,
|
||||
ConsumeSpoolForm,
|
||||
EmptySpoolForm,
|
||||
FeedbackForm,
|
||||
@@ -958,7 +959,7 @@ def orders(request):
|
||||
"total": sum(entry.quantity for entry in entries),
|
||||
"variant_count": len({entry.variant_id for entry in entries}),
|
||||
"status_choices": OrderItem.Status.choices,
|
||||
"has_bambu_cart": bool(plan.entries or plan.excluded),
|
||||
"has_bambu_cart": bool(plan.lines),
|
||||
"has_bambu_prices": any(entry.bambu_line_total is not None for entry in entries),
|
||||
},
|
||||
)
|
||||
@@ -971,24 +972,24 @@ def _open_bambu_orders():
|
||||
|
||||
|
||||
@login_required
|
||||
@require_http_methods(["POST"])
|
||||
@require_http_methods(["GET", "POST"])
|
||||
def bambu_order_cart(request):
|
||||
plan = plan_cart(_open_bambu_orders())
|
||||
cart_url = plan.url
|
||||
error = ""
|
||||
prices_saved = False
|
||||
if cart_url:
|
||||
try:
|
||||
prices = quote_cart(plan, fetch_cart(plan))
|
||||
signature = plan.signature
|
||||
with transaction.atomic():
|
||||
current = plan_cart(_open_bambu_orders())
|
||||
if current.signature != signature:
|
||||
raise CartQuoteError(
|
||||
"Die Bestellliste hat sich geändert. Erstelle den Warenkorb erneut."
|
||||
)
|
||||
form = BambuCartPricesForm(request.POST if request.method == "POST" else None, plan=plan)
|
||||
if plan.lines and request.method == "POST" and form.is_valid():
|
||||
signature = plan.signature
|
||||
prices = allocate_prices(
|
||||
plan,
|
||||
[int(form.cleaned_data[line.key] * 100) for line in plan.lines],
|
||||
int(form.cleaned_data["cart_total"] * 100),
|
||||
)
|
||||
with transaction.atomic():
|
||||
current = plan_cart(_open_bambu_orders())
|
||||
if current.signature != signature:
|
||||
form.add_error(None, "Die Bestellliste hat sich geändert. Lade die Seite neu.")
|
||||
else:
|
||||
now = timezone.now()
|
||||
positions = [entry for rows in current.entries.values() for entry in rows]
|
||||
positions = [entry for line in current.lines for entry in line.entries]
|
||||
for entry in positions:
|
||||
entry.bambu_quote_cents = prices[entry.pk]
|
||||
entry.bambu_quote_quantity = entry.quantity
|
||||
@@ -1003,30 +1004,15 @@ def bambu_order_cart(request):
|
||||
"bambu_quoted_at",
|
||||
),
|
||||
)
|
||||
prices_saved = True
|
||||
except CartQuoteError as exc:
|
||||
error = str(exc)
|
||||
current = plan_cart(_open_bambu_orders())
|
||||
if current.signature != plan.signature:
|
||||
cart_url = ""
|
||||
prices_saved = False
|
||||
error = "Die Bestellliste hat sich geändert. Erstelle den Warenkorb erneut."
|
||||
plan = current
|
||||
|
||||
prices_only = request.POST.get("action") == "prices"
|
||||
if prices_saved and not plan.excluded:
|
||||
messages.success(
|
||||
request, "Bambu-Lab-Warenkorbpreise wurden für die Sammelbestellung gespeichert."
|
||||
)
|
||||
return redirect("orders" if prices_only else cart_url)
|
||||
messages.success(request, "Warensumme mit Rabatt auf die Bestellwünsche verteilt.")
|
||||
return redirect("orders")
|
||||
return render(
|
||||
request,
|
||||
"filament/bambu_order_cart.html",
|
||||
{
|
||||
"cart_url": "" if prices_only else cart_url,
|
||||
"excluded": plan.excluded,
|
||||
"error": error,
|
||||
"prices_saved": prices_saved,
|
||||
"cart_url": f"{SHOP_URL}/cart",
|
||||
"rows": [(line, form[line.key]) for line in plan.lines],
|
||||
"form": form,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -2,23 +2,45 @@
|
||||
{% block title %}Bambu-Lab-Warenkorb · Fil-A-Management{% endblock %}
|
||||
{% block content %}
|
||||
<a class="back-link" href="{% url 'orders' %}">← Zur Sammelbestellung</a>
|
||||
<div class="page-heading"><h1>Bambu-Lab-Warenkorb</h1></div>
|
||||
<section class="panel form-panel">
|
||||
{% if error %}<p class="warning">{{ error }}</p>{% endif %}
|
||||
{% if prices_saved %}<p>Die Preise für die zugeordneten Rollen stehen in der Sammelbestellung.</p>{% endif %}
|
||||
{% if excluded %}
|
||||
<h2>Positionen ohne Übernahme</h2>
|
||||
<ul>
|
||||
{% for entry, reason, product_url in excluded %}
|
||||
<li>{{ entry.owner.username }} · {{ entry.quantity }} × {{ entry.variant }} · {{ reason }}{% if product_url %} · <a href="{{ product_url }}" target="_blank" rel="noreferrer">Im aktuellen EU-Shop ansehen</a>{% endif %}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% elif not error and not prices_saved %}
|
||||
<p>Es gibt keine offenen Bambu-Lab-Wünsche für den Warenkorb.</p>
|
||||
{% endif %}
|
||||
<div class="order-cart-actions">
|
||||
{% if cart_url %}<a class="button" href="{{ cart_url }}" rel="noreferrer">{% if excluded or error %}Warenkorb im Shop prüfen{% else %}Warenkorb im Shop öffnen{% endif %}</a>{% endif %}
|
||||
<a class="button secondary" href="{% url 'orders' %}">Zur Sammelbestellung</a>
|
||||
</div>
|
||||
</section>
|
||||
<div class="page-heading">
|
||||
<div><h1>Bambu-Lab-Warenkorb</h1><p class="muted">Lege die aufgeführten Varianten und Mengen im EU-Shop in den Warenkorb.</p></div>
|
||||
<a class="button secondary" href="{{ cart_url }}" target="_blank" rel="noreferrer">Warenkorb im EU-Shop ansehen ↗</a>
|
||||
</div>
|
||||
{% if rows %}
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.signature }}
|
||||
{{ form.signature.errors }}
|
||||
{{ form.non_field_errors }}
|
||||
<section class="panel">
|
||||
<div class="panel-heading"><h2>Offene Bambu-Lab-Wünsche</h2></div>
|
||||
<div class="table-wrap">
|
||||
<table>
|
||||
<thead><tr><th scope="col">Stück</th><th scope="col">Filament</th><th scope="col">Artikelnr.</th><th scope="col">Produktseite</th><th scope="col">Betrag für die Position (€)</th></tr></thead>
|
||||
<tbody>
|
||||
{% for line, price in rows %}
|
||||
<tr>
|
||||
<td class="quantity">{{ line.quantity }}</td>
|
||||
<td>{{ line.variant.product_type.name }} · {{ line.variant.color_label }}<small>{{ line.variant.get_spool_type_display }}</small></td>
|
||||
<td>{{ line.variant.manufacturer_color_code|default:"–" }}</td>
|
||||
<td>{% if line.product_url %}<a href="{{ line.product_url }}" target="_blank" rel="noreferrer">{% if line.exact_link %}Variante öffnen ↗{% else %}Produkt öffnen ↗{% endif %}</a>{% else %}<a href="https://eu.store.bambulab.com/collections/bambu-lab-3d-printer-filament" target="_blank" rel="noreferrer">Im Shop suchen ↗</a>{% endif %}{% if not line.exact_link %}<small>Ausführung im Shop prüfen</small>{% endif %}</td>
|
||||
<td><div class="field order-cart-price"><label class="sr-only" for="{{ price.id_for_label }}">{{ price.label }}</label>{{ price }}{{ price.errors }}</div></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
<section class="panel form-panel">
|
||||
<h2>Beträge aus dem gefüllten Warenkorb übernehmen</h2>
|
||||
<p class="hint">Trage oben die Beträge für die angezeigten Stückzahlen ein. Übernimm unten die Warenzwischensumme für diese Filamente nach Rabatt. Versand und andere Artikel bleiben außen vor.</p>
|
||||
<div class="field">
|
||||
{{ form.cart_total.label_tag }}{{ form.cart_total }}{{ form.cart_total.errors }}
|
||||
</div>
|
||||
<button class="button" type="submit">Warenkorbbeträge übernehmen</button>
|
||||
</section>
|
||||
</form>
|
||||
{% else %}
|
||||
<section class="panel"><div class="empty"><p>Es gibt keine offenen Bambu-Lab-Wünsche für den Warenkorb.</p></div></section>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
@@ -7,14 +7,8 @@
|
||||
</div>
|
||||
{% if has_bambu_cart %}
|
||||
<section class="panel form-panel" aria-label="Bambu-Lab-Warenkorb">
|
||||
<form method="post" action="{% url 'bambu_order_cart' %}">
|
||||
{% csrf_token %}
|
||||
<div class="order-cart-actions">
|
||||
<button class="button" type="submit">Bambu-Lab-Warenkorb öffnen</button>
|
||||
<button class="button secondary" type="submit" name="action" value="prices">Nur Shoppreise aktualisieren</button>
|
||||
</div>
|
||||
<p class="hint">Für offene Bambu-Lab-Wünsche aller Personen. Beim Öffnen wird ein vorhandener Warenkorb im Shopify-Shop ersetzt.</p>
|
||||
</form>
|
||||
<a class="button" href="{% url 'bambu_order_cart' %}">Bambu-Lab-Warenkorb vorbereiten</a>
|
||||
<p class="hint">Öffne die passenden Varianten im EU-Shop und übernimm anschließend die rabattierte Warensumme.</p>
|
||||
</section>
|
||||
{% endif %}
|
||||
<div class="stats">
|
||||
@@ -22,7 +16,7 @@
|
||||
<section class="stat"><span>Verschiedene Varianten</span><strong>{{ variant_count }}</strong></section>
|
||||
<section class="stat"><span>Personen mit Bestellwünschen</span><strong>{{ groups|length }}</strong></section>
|
||||
</div>
|
||||
{% if has_bambu_prices %}<p class="hint">Shoppreise stammen aus dem Warenkorb zum angegebenen Zeitpunkt. Der Rollenpreis ist der gerundete Durchschnitt je Position. Versand und Preisänderungen beim Bezahlen können den Endbetrag verändern.</p>{% endif %}
|
||||
{% if has_bambu_prices %}<p class="hint">Die Beträge stammen aus den übernommenen Warenkorbpreisen. Der Rollenpreis ist der gerundete Durchschnitt je Position. Versand und Preisänderungen beim Bezahlen können den Endbetrag verändern.</p>{% endif %}
|
||||
{% for group in groups %}
|
||||
{% with username=group.username entries=group.entries %}
|
||||
<section class="panel">
|
||||
|
||||
Reference in new issue
Block a user