Exemplo n.º 1
0
	def test_update_cart(self):
		# first, add to cart
		self.test_add_to_cart()

		# update first item
		update_cart("_Test Item", 5)
		quotation = self.test_get_cart_customer()
		self.assertEquals(quotation.get("items")[0].item_code, "_Test Item")
		self.assertEquals(quotation.get("items")[0].qty, 5)
		self.assertEquals(quotation.get("items")[0].amount, 50)
		self.assertEquals(quotation.net_total, 70)
		self.assertEquals(len(quotation.get("items")), 2)
Exemplo n.º 2
0
    def test_update_cart(self):
        # first, add to cart
        self.test_add_to_cart()

        # update first item
        update_cart("_Test Item", 5)
        quotation = self.test_get_cart_customer()
        self.assertEquals(quotation.get("items")[0].item_code, "_Test Item")
        self.assertEquals(quotation.get("items")[0].qty, 5)
        self.assertEquals(quotation.get("items")[0].amount, 50)
        self.assertEquals(quotation.net_total, 70)
        self.assertEquals(len(quotation.get("items")), 2)
Exemplo n.º 3
0
	def test_remove_from_cart(self):
		# first, add to cart
		self.test_add_to_cart()

		# remove first item
		update_cart("_Test Item", 0)
		quotation = self.test_get_cart_customer()

		self.assertEquals(quotation.get("items")[0].item_code, "_Test Item 2")
		self.assertEquals(quotation.get("items")[0].qty, 1)
		self.assertEquals(quotation.get("items")[0].amount, 20)
		self.assertEquals(quotation.net_total, 20)
		self.assertEquals(len(quotation.get("items")), 1)
Exemplo n.º 4
0
    def test_remove_from_cart(self):
        # first, add to cart
        self.test_add_to_cart()

        # remove first item
        update_cart("_Test Item", 0)
        quotation = self.test_get_cart_customer()

        self.assertEquals(quotation.get("items")[0].item_code, "_Test Item 2")
        self.assertEquals(quotation.get("items")[0].qty, 1)
        self.assertEquals(quotation.get("items")[0].amount, 20)
        self.assertEquals(quotation.net_total, 20)
        self.assertEquals(len(quotation.get("items")), 1)
Exemplo n.º 5
0
def shared_update_cart(item_code, qty, with_items=False):
    from erpnext.shopping_cart.cart import update_cart
    calendar_items = get_url_list_for_redirect()

    if item_code in calendar_items["items"]:
        return update_calendar_items_cart(item_code, qty, with_items)
    else:
        return update_cart(item_code, qty, with_items)
Exemplo n.º 6
0
    def test_add_to_cart(self):
        self.login_as_customer()

        # remove from cart
        self.remove_all_items_from_cart()

        # add first item
        update_cart("_Test Item", 1)

        quotation = self.test_get_cart_customer()

        self.assertEquals(quotation.get("items")[0].item_code, "_Test Item")
        self.assertEquals(quotation.get("items")[0].qty, 1)
        self.assertEquals(quotation.get("items")[0].amount, 10)

        # add second item
        update_cart("_Test Item 2", 1)
        quotation = self.test_get_cart_customer()
        self.assertEquals(quotation.get("items")[1].item_code, "_Test Item 2")
        self.assertEquals(quotation.get("items")[1].qty, 1)
        self.assertEquals(quotation.get("items")[1].amount, 20)

        self.assertEquals(len(quotation.get("items")), 2)
Exemplo n.º 7
0
	def test_add_to_cart(self):
		self.login_as_customer()

		# remove from cart
		self.remove_all_items_from_cart()

		# add first item
		update_cart("_Test Item", 1)

		quotation = self.test_get_cart_customer()

		self.assertEqual(quotation.get("items")[0].item_code, "_Test Item")
		self.assertEqual(quotation.get("items")[0].qty, 1)
		self.assertEqual(quotation.get("items")[0].amount, 10)

		# add second item
		update_cart("_Test Item 2", 1)
		quotation = self.test_get_cart_customer()
		self.assertEqual(quotation.get("items")[1].item_code, "_Test Item 2")
		self.assertEqual(quotation.get("items")[1].qty, 1)
		self.assertEqual(quotation.get("items")[1].amount, 20)

		self.assertEqual(len(quotation.get("items")), 2)
Exemplo n.º 8
0
    def test_add_to_cart(self):
        self.login_as_customer()

        # clear existing quotations
        self.clear_existing_quotations()

        # add first item
        update_cart("_Test Item", 1)

        quotation = self.test_get_cart_customer()

        self.assertEqual(quotation.get("items")[0].item_code, "_Test Item")
        self.assertEqual(quotation.get("items")[0].qty, 1)
        self.assertEqual(quotation.get("items")[0].amount, 10)

        # add second item
        update_cart("_Test Item 2", 1)
        quotation = self.test_get_cart_customer()
        self.assertEqual(quotation.get("items")[1].item_code, "_Test Item 2")
        self.assertEqual(quotation.get("items")[1].qty, 1)
        self.assertEqual(quotation.get("items")[1].amount, 20)

        self.assertEqual(len(quotation.get("items")), 2)
Exemplo n.º 9
0
def remove_linked_bookings(item):
    from erpnext.shopping_cart.cart import _get_cart_quotation, update_cart

    quotation = _get_cart_quotation()

    rooms = [
        x['name']
        for x in frappe.get_all("Shared Place Room", filters={"item": item})
    ]
    resources = [
        x['name'] for x in frappe.get_all("Shared Place Resource",
                                          filters={"item": item})
    ]

    bookings = []
    if rooms:
        bookings.extend(
            frappe.get_all("Shared Place Booking",
                           filters={
                               "booking_type": "Shared Place Room",
                               "booked_resource": ("in", (rooms)),
                               "quotation": quotation.name,
                               "docstatus": 0
                           }))
    if resources:
        bookings.extend(
            frappe.get_all("Shared Place Booking",
                           filters={
                               "booking_type": "Shared Place Resource",
                               "booked_resource": ("in", (resources)),
                               "quotation": quotation.name,
                               "docstatus": 0
                           },
                           fields=["name", "linked_booking"]))

    for booking in bookings:
        if booking.linked_booking:
            room = frappe.db.get_value("Shared Place Booking",
                                       booking.linked_booking,
                                       "booked_resource")
            item = frappe.db.get_value("Shared Place Room", room, "item")
            update_cart(item, 0)

        else:
            links = frappe.get_all("Shared Place Booking",
                                   filters={
                                       "linked_booking": booking.name,
                                       "docstatus": 0,
                                       "name": ["!=", booking.name]
                                   })
            for link in links:
                res = frappe.db.get_value("Shared Place Booking", link.name,
                                          "booked_resource")
                item = frappe.db.get_value("Shared Place Resource", res,
                                           "item")
                update_cart(item, 0)

        frappe.delete_doc("Shared Place Booking",
                          booking.name,
                          ignore_permissions=True)

    return bookings
Exemplo n.º 10
0
def update_cart_custom(item_data=[],ignore_permissions=True):
	item_list = json.loads(item_data)
	for d in item_list:
		result = update_cart(d['item_code'],flt(d['qty']))
	return result
Exemplo n.º 11
0
 def test_shared_place_order(self):
     frappe.set_user = "******"
     update_cart("Petite salle", 2)
     so = shared_place_order()
     self.assertTrue(so)