Esempio n. 1
0
    def test_add_and_get_item_reviews_from_customer(self):
        "Add / Get Reviews from a User that is a valid customer (has added to cart or purchased in the past)"
        # create user
        web_item = frappe.db.get_value("Website Item",
                                       {"item_code": "Test Mobile Phone"})
        test_user = create_user("*****@*****.**", "Customer")
        frappe.set_user(test_user.name)

        # create customer and contact against user
        customer = get_party()

        # post review on "Test Mobile Phone"
        try:
            add_item_review(web_item, "Great Product", 3,
                            "Would recommend this product")
            review_name = frappe.db.get_value("Item Review",
                                              {"website_item": web_item})
        except Exception:
            self.fail(f"Error while publishing review for {web_item}")

        review_data = get_item_reviews(web_item, 0, 10)

        self.assertEqual(len(review_data.reviews), 1)
        self.assertEqual(review_data.average_rating, 3)
        self.assertEqual(review_data.reviews_per_rating[2], 100)

        # tear down
        frappe.set_user("Administrator")
        frappe.delete_doc("Item Review", review_name)
        customer.delete()
Esempio n. 2
0
	def create_quotation(self):
		quotation = frappe.new_doc("Quotation")

		values = {
			"doctype": "Quotation",
			"quotation_to": "Customer",
			"order_type": "Shopping Cart",
			"party_name": get_party(frappe.session.user).name,
			"docstatus": 0,
			"contact_email": frappe.session.user,
			"selling_price_list": "_Test Price List Rest of the World",
			"currency": "USD",
			"taxes_and_charges" : "_Test Tax 1 - _TC",
			"conversion_rate":1,
			"transaction_date" : nowdate(),
			"valid_till" : add_months(nowdate(), 1),
			"items": [{
				"item_code": "_Test Item",
				"qty": 1
			}],
			"taxes": frappe.get_doc("Sales Taxes and Charges Template", "_Test Tax 1 - _TC").taxes,
			"company": "_Test Company"
		}

		quotation.update(values)

		quotation.insert(ignore_permissions=True)

		return quotation
Esempio n. 3
0
	def clear_existing_quotations(self):
		quotations = frappe.get_all("Quotation", filters={
			"party_name": get_party().name,
			"order_type": "Shopping Cart",
			"docstatus": 0
		}, order_by="modified desc", pluck="name")

		for quotation in quotations:
			frappe.delete_doc("Quotation", quotation, ignore_permissions=True, force=True)