def setUp(self): frappe.db.set_value("Healthcare Settings", None, "enable_free_follow_ups", 0) frappe.db.set_value("Healthcare Settings", None, "automate_appointment_invoicing", 1) frappe.db.sql("delete from `tabPatient Appointment`") make_pos_profile()
def test_pos_gl_entry_with_perpetual_inventory(self): set_perpetual_inventory() make_pos_profile() self._insert_purchase_receipt() pos = copy.deepcopy(test_records[1]) pos["is_pos"] = 1 pos["update_stock"] = 1 pos["payments"] = [{ 'mode_of_payment': 'Bank Draft', 'account': '_Test Bank - _TC', 'amount': 300 }, { 'mode_of_payment': 'Cash', 'account': 'Cash - _TC', 'amount': 300 }] si = frappe.copy_doc(pos) si.insert() si.submit() self.assertEquals(si.paid_amount, 600.0) self.pos_gl_entry(si, pos, 300)
def test_pos_change_amount(self): set_perpetual_inventory() make_pos_profile() self._insert_purchase_receipt() pos = copy.deepcopy(test_records[1]) pos["is_pos"] = 1 pos["update_stock"] = 1 pos["payments"] = [{ 'mode_of_payment': 'Bank Draft', 'account': '_Test Bank - _TC', 'amount': 300 }, { 'mode_of_payment': 'Cash', 'account': 'Cash - _TC', 'amount': 340 }] si = frappe.copy_doc(pos) si.change_amount = 5.0 si.insert() si.submit() self.assertEquals(si.grand_total, 630.0) self.assertEquals(si.write_off_amount, -5)
def test_make_pos_invoice(self): from erpnext.accounts.doctype.sales_invoice.pos import make_invoice set_perpetual_inventory() make_pos_profile() self._insert_purchase_receipt() pos = copy.deepcopy(test_records[1]) pos["is_pos"] = 1 pos["update_stock"] = 1 pos["payments"] = [{ 'mode_of_payment': 'Bank Draft', 'account': '_Test Bank - _TC', 'amount': 300 }, { 'mode_of_payment': 'Cash', 'account': 'Cash - _TC', 'amount': 330 }] invoice_data = [{'09052016142': pos}] si = make_invoice(invoice_data).get('invoice') self.assertEquals(si[0], '09052016142') sales_invoice = frappe.get_all('Sales Invoice', fields=["*"], filters={ 'offline_pos_name': '09052016142', 'docstatus': 1 }) si = frappe.get_doc('Sales Invoice', sales_invoice[0].name) self.assertEquals(si.grand_total, 630.0) self.pos_gl_entry(si, pos, 330)
def setUp(self): frappe.db.sql("""delete from `tabPatient Appointment`""") frappe.db.sql("""delete from `tabFee Validity`""") frappe.db.sql("""delete from `tabPatient Encounter`""") make_pos_profile() frappe.db.sql( """delete from `tabHealthcare Service Unit` where name like '_Test %'""" ) frappe.db.sql( """delete from `tabHealthcare Service Unit` where name like '_Test Service Unit Type%'""" )
def test_pos_change_amount(self): set_perpetual_inventory() make_pos_profile() self._insert_purchase_receipt() pos = copy.deepcopy(test_records[1]) pos["is_pos"] = 1 pos["update_stock"] = 1 pos["payments"] = [{'mode_of_payment': 'Bank Draft', 'account': '_Test Bank - _TC', 'amount': 300}, {'mode_of_payment': 'Cash', 'account': 'Cash - _TC', 'amount': 340}] si = frappe.copy_doc(pos) si.change_amount = 5.0 si.insert() si.submit() self.assertEquals(si.grand_total, 630.0) self.assertEquals(si.write_off_amount, -5)
def test_pos_gl_entry_with_perpetual_inventory(self): set_perpetual_inventory() make_pos_profile() self._insert_purchase_receipt() pos = copy.deepcopy(test_records[1]) pos["is_pos"] = 1 pos["update_stock"] = 1 pos["payments"] = [{'mode_of_payment': 'Bank Draft', 'account': '_Test Bank - _TC', 'amount': 300}, {'mode_of_payment': 'Cash', 'account': 'Cash - _TC', 'amount': 300}] si = frappe.copy_doc(pos) si.insert() si.submit() self.assertEquals(si.paid_amount, 600.0) self.pos_gl_entry(si, pos, 300)
def test_pos_closing_voucher(self): old_user = frappe.session.user user = '******' test_user = frappe.get_doc('User', user) roles = ("Accounts Manager", "Accounts User", "Sales Manager") test_user.add_roles(*roles) frappe.set_user(user) pos_profile = make_pos_profile() pos_profile.append('applicable_for_users', { 'default': 1, 'user': user }) pos_profile.save() si1 = create_sales_invoice(is_pos=1, rate=3500, do_not_submit=1) si1.append('payments', { 'mode_of_payment': 'Cash', 'account': 'Cash - _TC', 'amount': 3500 }) si1.submit() si2 = create_sales_invoice(is_pos=1, rate=3200, do_not_submit=1) si2.append('payments', { 'mode_of_payment': 'Cash', 'account': 'Cash - _TC', 'amount': 3200 }) si2.submit() pcv_doc = create_pos_closing_voucher(user=user, pos_profile=pos_profile.name, collected_amount=6700) pcv_doc.get_closing_voucher_details() self.assertEqual(pcv_doc.total_quantity, 2) self.assertEqual(pcv_doc.net_total, 6700) payment = pcv_doc.payment_reconciliation[0] self.assertEqual(payment.mode_of_payment, 'Cash') si1.load_from_db() si1.cancel() si2.load_from_db() si2.cancel() test_user.load_from_db() test_user.remove_roles(*roles) frappe.set_user(old_user) frappe.db.sql("delete from `tabPOS Profile`")
def test_make_pos_invoice_in_draft(self): from erpnext.accounts.doctype.sales_invoice.pos import make_invoice from erpnext.stock.doctype.item.test_item import make_item set_perpetual_inventory() allow_negative_stock = frappe.db.get_single_value('Stock Settings', 'allow_negative_stock') if allow_negative_stock: frappe.db.set_value('Stock Settings', None, 'allow_negative_stock', 0) make_pos_profile() timestamp = cint(time.time()) item = make_item("_Test POS Item") pos = copy.deepcopy(test_records[1]) pos['items'][0]['item_code'] = item.name pos['items'][0]['warehouse'] = "_Test Warehouse - _TC" pos["is_pos"] = 1 pos["offline_pos_name"] = timestamp pos["update_stock"] = 1 pos["payments"] = [{'mode_of_payment': 'Bank Draft', 'account': '_Test Bank - _TC', 'amount': 300}, {'mode_of_payment': 'Cash', 'account': 'Cash - _TC', 'amount': 330}] invoice_data = [{timestamp: pos}] si = make_invoice(invoice_data).get('invoice') self.assertEqual(si[0], timestamp) sales_invoice = frappe.get_all('Sales Invoice', fields =["*"], filters = {'offline_pos_name': timestamp}) self.assertEqual(sales_invoice[0].docstatus, 0) timestamp = cint(time.time()) pos["offline_pos_name"] = timestamp invoice_data = [{timestamp: pos}] si1 = make_invoice(invoice_data).get('invoice') self.assertEqual(si1[0], timestamp) sales_invoice1 = frappe.get_all('Sales Invoice', fields =["*"], filters = {'offline_pos_name': timestamp}) self.assertEqual(sales_invoice1[0].docstatus, 0) if allow_negative_stock: frappe.db.set_value('Stock Settings', None, 'allow_negative_stock', 1)
def create_pos_invoice(**args): args = frappe._dict(args) pos_profile = None if not args.pos_profile: pos_profile = make_pos_profile() pos_profile.save() pos_inv = frappe.new_doc("POS Invoice") pos_inv.update(args) pos_inv.update_stock = 1 pos_inv.is_pos = 1 pos_inv.pos_profile = args.pos_profile or pos_profile.name if args.posting_date: pos_inv.set_posting_time = 1 pos_inv.posting_date = args.posting_date or frappe.utils.nowdate() pos_inv.company = args.company or "_Test Company" pos_inv.customer = args.customer or "_Test Customer" pos_inv.debit_to = args.debit_to or "Debtors - _TC" pos_inv.is_return = args.is_return pos_inv.return_against = args.return_against pos_inv.currency = args.currency or "INR" pos_inv.conversion_rate = args.conversion_rate or 1 pos_inv.account_for_change_amount = args.account_for_change_amount or "Cash - _TC" pos_inv.set_missing_values() pos_inv.append( "items", { "item_code": args.item or args.item_code or "_Test Item", "warehouse": args.warehouse or "_Test Warehouse - _TC", "qty": args.qty or 1, "rate": args.rate if args.get("rate") is not None else 100, "income_account": args.income_account or "Sales - _TC", "expense_account": args.expense_account or "Cost of Goods Sold - _TC", "cost_center": args.cost_center or "_Test Cost Center - _TC", "serial_no": args.serial_no, "batch_no": args.batch_no, }, ) if not args.do_not_save: pos_inv.insert() if not args.do_not_submit: pos_inv.submit() else: pos_inv.payment_schedule = [] else: pos_inv.payment_schedule = [] return pos_inv
def test_make_pos_invoice_in_draft(self): from erpnext.accounts.doctype.sales_invoice.pos import make_invoice from erpnext.stock.doctype.item.test_item import make_item set_perpetual_inventory() allow_negative_stock = frappe.db.get_single_value('Stock Settings', 'allow_negative_stock') if allow_negative_stock: frappe.db.set_value('Stock Settings', None, 'allow_negative_stock', 0) make_pos_profile() timestamp = cint(time.time()) item = make_item("_Test POS Item") pos = copy.deepcopy(test_records[1]) pos['items'][0]['item_code'] = item.name pos["is_pos"] = 1 pos["offline_pos_name"] = timestamp pos["update_stock"] = 1 pos["payments"] = [{'mode_of_payment': 'Bank Draft', 'account': '_Test Bank - _TC', 'amount': 300}, {'mode_of_payment': 'Cash', 'account': 'Cash - _TC', 'amount': 330}] invoice_data = [{timestamp: pos}] si = make_invoice(invoice_data).get('invoice') self.assertEquals(si[0], timestamp) sales_invoice = frappe.get_all('Sales Invoice', fields =["*"], filters = {'offline_pos_name': timestamp}) self.assertEquals(sales_invoice[0].docstatus, 0) timestamp = cint(time.time()) pos["offline_pos_name"] = timestamp invoice_data = [{timestamp: pos}] si1 = make_invoice(invoice_data).get('invoice') self.assertEquals(si1[0], timestamp) sales_invoice1 = frappe.get_all('Sales Invoice', fields =["*"], filters = {'offline_pos_name': timestamp}) self.assertEquals(sales_invoice1[0].docstatus, 0) if allow_negative_stock: frappe.db.set_value('Stock Settings', None, 'allow_negative_stock', 1)
def test_pos_closing_voucher(self): old_user = frappe.session.user user = '******' test_user = frappe.get_doc('User', user) roles = ("Accounts Manager", "Accounts User", "Sales Manager") test_user.add_roles(*roles) frappe.set_user(user) pos_profile = make_pos_profile() pos_profile.append('applicable_for_users', { 'default': 1, 'user': user }) pos_profile.save() si1 = create_sales_invoice(is_pos=1, rate=3500, do_not_submit=1) si1.append('payments', { 'mode_of_payment': 'Cash', 'account': 'Cash - _TC', 'amount': 3500 }) si1.submit() si2 = create_sales_invoice(is_pos=1, rate=3200, do_not_submit=1) si2.append('payments', { 'mode_of_payment': 'Cash', 'account': 'Cash - _TC', 'amount': 3200 }) si2.submit() pcv_doc = create_pos_closing_voucher(user=user, pos_profile=pos_profile.name, collected_amount=6700) pcv_doc.get_closing_voucher_details() self.assertEqual(pcv_doc.total_quantity, 2) self.assertEqual(pcv_doc.net_total, 6700) payment = pcv_doc.payment_reconciliation[0] self.assertEqual(payment.mode_of_payment, 'Cash') si1.load_from_db() si1.cancel() si2.load_from_db() si2.cancel() test_user.load_from_db() test_user.remove_roles(*roles) frappe.set_user(old_user) frappe.db.sql("delete from `tabPOS Profile`")
def init_user_and_profile(**args): user = '******' test_user = frappe.get_doc('User', user) roles = ("Accounts Manager", "Accounts User", "Sales Manager") test_user.add_roles(*roles) frappe.set_user(user) pos_profile = make_pos_profile(**args) pos_profile.append('applicable_for_users', {'default': 1, 'user': user}) pos_profile.save() return test_user, pos_profile
def test_make_pos_invoice(self): from erpnext.accounts.doctype.sales_invoice.pos import make_invoice set_perpetual_inventory() make_pos_profile() self._insert_purchase_receipt() pos = copy.deepcopy(test_records[1]) pos["is_pos"] = 1 pos["update_stock"] = 1 pos["payments"] = [{'mode_of_payment': 'Bank Draft', 'account': '_Test Bank - _TC', 'amount': 300}, {'mode_of_payment': 'Cash', 'account': 'Cash - _TC', 'amount': 330}] invoice_data = [{'09052016142': pos}] si = make_invoice(invoice_data).get('invoice') self.assertEquals(si[0], '09052016142') sales_invoice = frappe.get_all('Sales Invoice', fields =["*"], filters = {'offline_pos_name': '09052016142', 'docstatus': 1}) si = frappe.get_doc('Sales Invoice', sales_invoice[0].name) self.assertEquals(si.grand_total, 630.0) self.pos_gl_entry(si, pos, 330)
def init_user_and_profile(**args): user = "******" test_user = frappe.get_doc("User", user) roles = ("Accounts Manager", "Accounts User", "Sales Manager") test_user.add_roles(*roles) frappe.set_user(user) pos_profile = make_pos_profile(**args) pos_profile.append("applicable_for_users", {"default": 1, "user": user}) pos_profile.save() return test_user, pos_profile
def test_item_search(self): """ Test Stock and Service Item Search. """ pos_profile = make_pos_profile(name="Test POS Profile for Search") item1 = make_item("Test Search Stock Item", {"is_stock_item": 1}) make_stock_entry( item_code="Test Search Stock Item", qty=10, to_warehouse="_Test Warehouse - _TC", rate=500, ) result = get_items( start=0, page_length=20, price_list=None, item_group=item1.item_group, pos_profile=pos_profile.name, search_term="Test Search Stock Item", ) filtered_items = result.get("items") self.assertEqual(len(filtered_items), 1) self.assertEqual(filtered_items[0]["item_code"], item1.item_code) self.assertEqual(filtered_items[0]["actual_qty"], 10) item2 = make_item("Test Search Service Item", {"is_stock_item": 0}) result = get_items( start=0, page_length=20, price_list=None, item_group=item2.item_group, pos_profile=pos_profile.name, search_term="Test Search Service Item", ) filtered_items = result.get("items") self.assertEqual(len(filtered_items), 1) self.assertEqual(filtered_items[0]["item_code"], item2.item_code)
def setUp(self): frappe.db.set_value('Healthcare Settings', None, 'enable_free_follow_ups', 0) frappe.db.set_value('Healthcare Settings', None, 'automate_appointment_invoicing', 1) make_pos_profile()
def setUp(self): make_pos_profile() add_transactions() add_vouchers()
def setUp(self): make_pos_profile() add_transactions() add_payments()
def setUp(self): frappe.db.sql("""delete from `tabPatient Appointment`""") frappe.db.sql("""delete from `tabFee Validity`""") frappe.db.sql("""delete from `tabPatient`""") make_pos_profile()
def setUpClass(cls): make_pos_profile() add_transactions() add_vouchers()