From 149c6927b595398a47c28f60e1653e1ebc62c570 Mon Sep 17 00:00:00 2001 From: Kalle Norrestam Date: Thu, 5 Jan 2023 11:35:44 +0100 Subject: [PATCH] add nested complexity Change-Id: I9eda989f7f0f13210bc66932a50455345c02eb7a --- test/js-example.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/js-example.js b/test/js-example.js index f1329e6..bef470e 100644 --- a/test/js-example.js +++ b/test/js-example.js @@ -165,3 +165,23 @@ function extractEvents( } } + +function mark_purchased(transaction) { + transaction.state = TransactionState.PURCHASED + for (item in transaction.items) { + if (item.mtb_product_ids) { + if (item.mtb_product_ids) { + for (mp_id in item.mtb_product_ids) { + try { + mtb_prod = get_db_mtb_product(None, mp_id, all=True, refresh=False) + mtb_prod.purchased = True + mtb_prod.save() + } + catch(exc) { + logger.error("Failed to mark mtb_product {mp_id} as purchase", exc_info=exc) + } + } + } + } + } + } \ No newline at end of file