Exemplo n.º 1
0
	def test_auto_batch(self):
		item_code = dataent.db.get_value('Item',
			{'has_batch_no': 1, 'create_new_batch':1}, 'name')

		if not item_code:
			doc = dataent.get_doc({
				'doctype': 'Item',
				'is_stock_item': 1,
				'item_code': 'test batch item',
				'item_group': 'Products',
				'has_batch_no': 1,
				'create_new_batch': 1
			}).insert(ignore_permissions=True)
			item_code = doc.name

		pi = make_purchase_invoice(update_stock=1, posting_date=dataent.utils.nowdate(),
			posting_time=dataent.utils.nowtime(), item_code=item_code)

		self.assertTrue(dataent.db.get_value('Batch',
			{'item': item_code, 'reference_name': pi.name}))
Exemplo n.º 2
0
	def test_payment_entry_unlink_against_purchase_invoice(self):
		from epaas.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry
		unlink_payment_on_cancel_of_invoice(0)

		pi_doc = make_purchase_invoice()

		pe = get_payment_entry("Purchase Invoice", pi_doc.name, bank_account="_Test Bank - _TC")
		pe.reference_no = "1"
		pe.reference_date = nowdate()
		pe.paid_from_account_currency = pi_doc.currency
		pe.paid_to_account_currency = pi_doc.currency
		pe.source_exchange_rate = 1
		pe.target_exchange_rate = 1
		pe.paid_amount = pi_doc.grand_total
		pe.save(ignore_permissions=True)
		pe.submit()

		pi_doc = dataent.get_doc('Purchase Invoice', pi_doc.name)

		self.assertRaises(dataent.LinkExistsError, pi_doc.cancel)
Exemplo n.º 3
0
def execute():
	dataent.reload_doc("core", "doctype", "print_settings")
	print_settings = dataent.get_doc("Print Settings")
	print_settings.print_style = "Modern"

	try:
		import pdfkit
	except ImportError:
		pass
	else:
		# if someone has already configured in Outgoing Email Settings
		outgoing_email_settings = dataent.db.get_singles_dict("Outgoing Email Settings")
		if "send_print_as_pdf" in outgoing_email_settings:
			print_settings.send_print_as_pdf = outgoing_email_settings.send_print_as_pdf
			print_settings.pdf_page_size = outgoing_email_settings.pdf_page_size

		else:
			print_settings.send_print_as_pdf = 1

	print_settings.save()
Exemplo n.º 4
0
 def folio_no_validation(self):
     shareholders = ['from_shareholder', 'to_shareholder']
     shareholders = [
         shareholder for shareholder in shareholders
         if self.get(shareholder) is not ''
     ]
     for shareholder in shareholders:
         doc = dataent.get_doc('Shareholder', self.get(shareholder))
         if doc.company != self.company:
             dataent.throw(
                 _('The shareholder does not belong to this company'))
         if doc.folio_no is '' or doc.folio_no is None:
             doc.folio_no = self.from_folio_no \
              if (shareholder == 'from_shareholder') else self.to_folio_no
             doc.save()
         else:
             if doc.folio_no and doc.folio_no != (
                     self.from_folio_no if
                 (shareholder == 'from_shareholder') else self.to_folio_no):
                 dataent.throw(_('The folio numbers are not matching'))
Exemplo n.º 5
0
    def test_default_bom(self):
        def _get_default_bom_in_item():
            return cstr(
                dataent.db.get_value("Item", "_Test FG Item 2", "default_bom"))

        bom = dataent.get_doc("BOM", {
            "item": "_Test FG Item 2",
            "is_default": 1
        })
        self.assertEqual(_get_default_bom_in_item(), bom.name)

        bom.is_active = 0
        bom.save()
        self.assertEqual(_get_default_bom_in_item(), "")

        bom.is_active = 1
        bom.is_default = 1
        bom.save()

        self.assertTrue(_get_default_bom_in_item(), bom.name)
Exemplo n.º 6
0
    def test_duplicate_terms(self):
        template = dataent.get_doc({
            'doctype':
            'Payment Terms Template',
            'template_name':
            '_Test Payment Terms Template For Test',
            'terms': [{
                'doctype': 'Payment Terms Template Detail',
                'invoice_portion': 50.00,
                'credit_days_based_on': 'Day(s) after invoice date',
                'credit_days': 30
            }, {
                'doctype': 'Payment Terms Template Detail',
                'invoice_portion': 50.00,
                'credit_days_based_on': 'Day(s) after invoice date',
                'credit_days': 30
            }]
        })

        self.assertRaises(dataent.ValidationError, template.insert)
Exemplo n.º 7
0
    def test_image_parsing(self):
        import re
        email_account = dataent.get_doc('Email Account',
                                        '_Test Email Account 1')

        dataent.db.sql(
            '''delete from `tabCommunication` where sender = '*****@*****.**' '''
        )

        with open(
                dataent.get_app_path('dataent', 'tests', 'data',
                                     'email_with_image.txt'), 'r') as raw:
            communication = email_account.insert_communication(raw.read())

        self.assertTrue(
            re.search('''<img[^>]*src=["']/private/files/rtco1.png[^>]*>''',
                      communication.content))
        self.assertTrue(
            re.search('''<img[^>]*src=["']/private/files/rtco2.png[^>]*>''',
                      communication.content))
Exemplo n.º 8
0
def execute():
	si_list = dataent.db.sql("""
		select distinct parent
		from `tabSales Invoice Payment`
		where docstatus!=2 and parenttype = 'Sales Invoice'
		and amount != 0 and base_amount = 0
	""")

	count = 0
	for d in si_list:
		si = dataent.get_doc("Sales Invoice", d[0])
		for p in si.get("payments"):
			if p.amount and not p.base_amount:
				base_amount = flt(p.amount*si.conversion_rate, si.precision("base_paid_amount"))
				dataent.db.set_value("Sales Invoice Payment", p.name, "base_amount", base_amount, update_modified=False)

		count +=1
			
		if count % 200 == 0:
			dataent.db.commit()
Exemplo n.º 9
0
def create_request_log(data, integration_type, service_name, name=None):
	if isinstance(data, string_types):
		data = json.loads(data)

	integration_request = dataent.get_doc({
		"doctype": "Integration Request",
		"integration_type": integration_type,
		"integration_request_service": service_name,
		"reference_doctype": data.get("reference_doctype"),
		"reference_docname": data.get("reference_docname"),
		"data": json.dumps(data, default=json_handler)
	})

	if name:
		integration_request.flags._name = name

	integration_request.insert(ignore_permissions=True)
	dataent.db.commit()

	return integration_request
Exemplo n.º 10
0
def create_variant(item, args):
    if isinstance(args, string_types):
        args = json.loads(args)

    template = dataent.get_doc("Item", item)
    variant = dataent.new_doc("Item")
    variant.variant_based_on = 'Item Attribute'
    variant_attributes = []

    for d in template.attributes:
        variant_attributes.append({
            "attribute": d.attribute,
            "attribute_value": args.get(d.attribute)
        })

    variant.set("attributes", variant_attributes)
    copy_attributes_to_variant(template, variant)
    make_variant_item_code(template.item_code, template.item_name, variant)

    return variant
Exemplo n.º 11
0
def execute():
    je_list = dataent.db.sql_list(
        """select distinct parent from `tabJournal Entry Account` je
		where docstatus=1 and ifnull(reference_name, '') !='' and creation > '2015-03-01'
			and not exists(select name from `tabGL Entry` 
				where voucher_type='Journal Entry' and voucher_no=je.parent 
				and against_voucher_type=je.reference_type 
				and against_voucher=je.reference_name)""")

    for d in je_list:
        print(d)

        # delete existing gle
        dataent.db.sql(
            "delete from `tabGL Entry` where voucher_type='Journal Entry' and voucher_no=%s",
            d)

        # repost gl entries
        je = dataent.get_doc("Journal Entry", d)
        je.make_gl_entries()
Exemplo n.º 12
0
    def on_update(self):
        """update all email accounts using this domain"""
        for email_account in dataent.get_all("Email Account",
                                             filters={"domain": self.name}):

            try:
                email_account = dataent.get_doc("Email Account",
                                                email_account.name)
                email_account.set("email_server", self.email_server)
                email_account.set("use_imap", self.use_imap)
                email_account.set("use_ssl", self.use_ssl)
                email_account.set("use_tls", self.use_tls)
                email_account.set("attachment_limit", self.attachment_limit)
                email_account.set("smtp_server", self.smtp_server)
                email_account.set("smtp_port", self.smtp_port)
                email_account.save()
            except Exception as e:
                dataent.msgprint(email_account.name)
                dataent.throw(e)
                return None
Exemplo n.º 13
0
def execute():
	je_list = dataent.db.sql_list("""
		select par.name from `tabJournal Entry` par 
		where par.docstatus=1 and par.creation > '2015-03-01'
			and (select count(distinct child.party) from `tabJournal Entry Account` child
				where par.name=child.parent and ifnull(child.party, '') != '') > 1	
	""")
	
	for d in je_list:		
		# delete existing gle
		dataent.db.sql("delete from `tabGL Entry` where voucher_type='Journal Entry' and voucher_no=%s", d)
		
		# repost gl entries
		je = dataent.get_doc("Journal Entry", d)
		je.make_gl_entries()
		
	if je_list:
		print(je_list)
		
		
Exemplo n.º 14
0
    def test_block_desktop_icons_for_user(self):
        def test_unblock():
            user = dataent.get_doc('User', '*****@*****.**')
            user.block_modules = []
            user.save(ignore_permissions=1)

            icon = self.get_icon('Desk')
            self.assertEqual(icon.hidden, 0)

        test_unblock()

        user = dataent.get_doc('User', '*****@*****.**')
        user.append('block_modules', {'module': 'Desk'})
        user.save(ignore_permissions=1)
        clear_desktop_icons_cache(user.name)

        icon = self.get_icon('Desk')
        self.assertEqual(icon.hidden, 1)

        test_unblock()
Exemplo n.º 15
0
def get_context(context):
	context.no_cache = True
	chapter = dataent.get_doc('Chapter', dataent.form_dict.name)
	if dataent.session.user!='Guest':
		if dataent.session.user in [d.user for d in chapter.members if d.enabled == 1]:
			context.already_member = True
		else:
			if dataent.request.method=='GET':
				pass
			elif dataent.request.method=='POST':
				chapter.append('members', dict(
					user=dataent.session.user,
					introduction=dataent.form_dict.introduction,
					website_url=dataent.form_dict.website_url,
					enabled=1
				))
				chapter.save(ignore_permissions=1)
				dataent.db.commit()

	context.chapter = chapter
Exemplo n.º 16
0
 def test_date_range(self):
     employee = make_employee("*****@*****.**")
     employee_doc = dataent.get_doc("Employee", employee)
     date_of_joining = "2018-01-02"
     relieving_date = "2018-01-03"
     from_date = "2018-01-01"
     to_date = "2018-01-04"
     employee_doc.date_of_joining = date_of_joining
     employee_doc.relieving_date = relieving_date
     employee_doc.save()
     args = {"from_date": from_date, "to_date": to_date}
     data = get_data(args)
     filtered_data = []
     for row in data:
         if row[1] == employee:
             filtered_data.append(row)
     for row in filtered_data:
         self.assertTrue(
             getdate(row[3]) >= getdate(date_of_joining)
             and getdate(row[3]) <= getdate(relieving_date))
Exemplo n.º 17
0
def execute():
    if dataent.db.exists("DocType", "Guardian"):

        # 'Schools' module changed to the 'Education'
        # dataent.reload_doc("schools", "doctype", "student")
        # dataent.reload_doc("schools", "doctype", "student_guardian")
        # dataent.reload_doc("schools", "doctype", "student_sibling")

        dataent.reload_doc("education", "doctype", "student")
        dataent.reload_doc("education", "doctype", "student_guardian")
        dataent.reload_doc("education", "doctype", "student_sibling")
        if "student" not in dataent.db.get_table_columns("Guardian"):
            return
        guardian = dataent.get_all("Guardian", fields=["name", "student"])
        for d in guardian:
            if d.student:
                student = dataent.get_doc("Student", d.student)
                if student:
                    student.append("guardians", {"guardian": d.name})
                    student.save()
Exemplo n.º 18
0
def validate_ipn_request(data):
	def _throw():
		dataent.throw(_("In Valid Request"), exc=dataent.InvalidStatusError)

	if not data.get("recurring_payment_id"):
		_throw()

	doc = dataent.get_doc("PayPal Settings")
	params, url = doc.get_paypal_params_and_url()

	params.update({
		"METHOD": "GetRecurringPaymentsProfileDetails",
		"PROFILEID": data.get("recurring_payment_id")
	})

	params = urlencode(params)
	res = make_post_request(url=url, data=params.encode("utf-8"))

	if res['ACK'][0] != 'Success':
		_throw()
Exemplo n.º 19
0
def make_stock_entry_from_pro(pro_id, purpose):
    from epaas.manufacturing.doctype.work_order.work_order import make_stock_entry
    from epaas.stock.stock_ledger import NegativeStockError
    from epaas.stock.doctype.stock_entry.stock_entry import IncorrectValuationRateError, \
     DuplicateEntryForWorkOrderError, OperationsNotCompleteError

    try:
        st = dataent.get_doc(make_stock_entry(pro_id, purpose))
        st.posting_date = dataent.flags.current_date
        st.fiscal_year = str(dataent.flags.current_date.year)
        for d in st.get("items"):
            d.cost_center = "Main - " + dataent.get_cached_value(
                'Company', st.company, 'abbr')
        st.insert()
        dataent.db.commit()
        st.submit()
        dataent.db.commit()
    except (NegativeStockError, IncorrectValuationRateError,
            DuplicateEntryForWorkOrderError, OperationsNotCompleteError):
        dataent.db.rollback()
Exemplo n.º 20
0
	def handle_bad_emails(self, email_server, uid, raw, reason):
		if cint(email_server.settings.use_imap):
			import email
			try:
				mail = email.message_from_string(raw)

				message_id = mail.get('Message-ID')
			except Exception:
				message_id = "can't be parsed"

			unhandled_email = dataent.get_doc({
				"raw": raw,
				"uid": uid,
				"reason":reason,
				"message_id": message_id,
				"doctype": "Unhandled Email",
				"email_account": email_server.settings.email_account
			})
			unhandled_email.insert(ignore_permissions=True)
			dataent.db.commit()
Exemplo n.º 21
0
	def test_payment_entry_for_blocked_supplier_payments_past_date(self):
		# this test is meant to fail only if something fails in the try block
		with self.assertRaises(Exception):
			try:
				supplier = dataent.get_doc('Supplier', '_Test Supplier')
				supplier.on_hold = 1
				supplier.hold_type = 'Payments'
				supplier.release_date = '2018-03-01'
				supplier.save()

				pi = make_purchase_invoice()

				get_payment_entry('Purchase Invoice', pi.name, bank_account="_Test Bank - _TC")

				supplier.on_hold = 0
				supplier.save()
			except:
				pass
			else:
				raise Exception
Exemplo n.º 22
0
def execute():
    old_formats = ("Sales Invoice", "Sales Invoice Spartan",
                   "Sales Invoice Modern", "Sales Invoice Classic",
                   "Sales Order Spartan", "Sales Order Modern",
                   "Sales Order Classic", "Purchase Order Spartan",
                   "Purchase Order Modern", "Purchase Order Classic",
                   "Quotation Spartan", "Quotation Modern",
                   "Quotation Classic", "Delivery Note Spartan",
                   "Delivery Note Modern", "Delivery Note Classic")

    for fmt in old_formats:
        # update property setter
        for ps in dataent.db.sql_list(
                """select name from `tabProperty Setter`
			where property='default_print_format' and value=%s""", fmt):
            ps = dataent.get_doc("Property Setter", ps)
            ps.value = "Standard"
            ps.save(ignore_permissions=True)

        dataent.delete_doc_if_exists("Print Format", fmt)
Exemplo n.º 23
0
def execute():
    dataent.reload_doc('accounts', 'doctype', 'mode_of_payment')
    dataent.reload_doc('accounts', 'doctype', 'mode_of_payment_account')

    mode_of_payment_list = dataent.db.sql("""select name, default_account
		from `tabMode of Payment`""",
                                          as_dict=1)

    for d in mode_of_payment_list:
        if d.get("default_account"):
            parent_doc = dataent.get_doc("Mode of Payment", d.get("name"))

            parent_doc.set("accounts", [{
                "company":
                dataent.db.get_value("Account", d.get("default_account"),
                                     "company"),
                "default_account":
                d.get("default_account")
            }])
            parent_doc.save()
Exemplo n.º 24
0
def make_quote(items, customer):
    qtn = dataent.get_doc({
        "doctype": "Quotation",
        "quotation_to": "Customer",
        "customer": customer,
        "order_type": "Sales"
    })

    add_random_children(qtn,
                        "items",
                        rows=len(items),
                        randomize={
                            "qty": (1, 5),
                            "item_code": ["Item"]
                        },
                        unique="item_code")

    qtn.insert(ignore_permissions=True)

    qtn.add_comment('Comment', text="This is a dummy record")
Exemplo n.º 25
0
	def get_documents_for_today(self):
		'''get list of documents that will be triggered today'''
		docs = []

		diff_days = self.days_in_advance
		if self.event=="Days After":
			diff_days = -diff_days

		for name in dataent.db.sql_list("""select name from `tab{0}` where
			DATE(`{1}`) = ADDDATE(DATE(%s), INTERVAL %s DAY)""".format(self.document_type,
				self.date_changed), (nowdate(), diff_days or 0)):

			doc = dataent.get_doc(self.document_type, name)

			if self.condition and not dataent.safe_eval(self.condition, None, get_context(doc)):
				continue

			docs.append(doc)

		return docs
Exemplo n.º 26
0
	def test_payment_entry_against_purchase_invoice_for_enable_allow_cost_center_in_entry_of_bs_account(self):
		from epaas.accounts.doctype.cost_center.test_cost_center import create_cost_center
		accounts_settings = dataent.get_doc('Accounts Settings', 'Accounts Settings')
		accounts_settings.allow_cost_center_in_entry_of_bs_account = 1
		accounts_settings.save()
		cost_center = "_Test Cost Center for BS Account - _TC"
		create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company")

		pi =  make_purchase_invoice_against_cost_center(cost_center=cost_center, credit_to="Creditors - _TC")

		pe = get_payment_entry("Purchase Invoice", pi.name, bank_account="_Test Bank - _TC")
		self.assertEqual(pe.cost_center, pi.cost_center)

		pe.reference_no = "112222-1"
		pe.reference_date = nowdate()
		pe.paid_from = "_Test Bank - _TC"
		pe.paid_amount = pi.grand_total
		pe.insert()
		pe.submit()

		expected_values = {
			"_Test Bank - _TC": {
				"cost_center": cost_center
			},
			"Creditors - _TC": {
				"cost_center": cost_center
			}
		}

		gl_entries = dataent.db.sql("""select account, cost_center, account_currency, debit, credit,
			debit_in_account_currency, credit_in_account_currency
			from `tabGL Entry` where voucher_type='Payment Entry' and voucher_no=%s
			order by account asc""", pe.name, as_dict=1)

		self.assertTrue(gl_entries)

		for gle in gl_entries:
			self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)

		accounts_settings.allow_cost_center_in_entry_of_bs_account = 0
		accounts_settings.save()
Exemplo n.º 27
0
def make_purchase_order_based_on_supplier(source_name, target_doc=None):
    if target_doc:
        if isinstance(target_doc, string_types):
            import json
            target_doc = dataent.get_doc(json.loads(target_doc))
        target_doc.set("items", [])

    material_requests, supplier_items = get_material_requests_based_on_supplier(
        source_name)

    def postprocess(source, target_doc):
        target_doc.supplier = source_name
        if getdate(target_doc.schedule_date) < getdate(nowdate()):
            target_doc.schedule_date = None
        target_doc.set("items", [
            d for d in target_doc.get("items")
            if d.get("item_code") in supplier_items and d.get("qty") > 0
        ])

        set_missing_values(source, target_doc)

    for mr in material_requests:
        target_doc = get_mapped_doc(
            "Material Request", mr, {
                "Material Request": {
                    "doctype": "Purchase Order",
                },
                "Material Request Item": {
                    "doctype":
                    "Purchase Order Item",
                    "field_map": [["name", "material_request_item"],
                                  ["parent", "material_request"],
                                  ["uom", "stock_uom"], ["uom", "uom"]],
                    "postprocess":
                    update_item,
                    "condition":
                    lambda doc: doc.ordered_qty < doc.qty
                }
            }, target_doc, postprocess)

    return target_doc
Exemplo n.º 28
0
def update_outstanding_amt(account, party_type, party, against_voucher_type, against_voucher, on_cancel=False):
	if party_type and party:
		party_condition = " and party_type='{0}' and party='{1}'"\
			.format(dataent.db.escape(party_type), dataent.db.escape(party))
	else:
		party_condition = ""

	# get final outstanding amt
	bal = flt(dataent.db.sql("""
		select sum(debit_in_account_currency) - sum(credit_in_account_currency)
		from `tabGL Entry`
		where against_voucher_type=%s and against_voucher=%s
		and account = %s {0}""".format(party_condition),
		(against_voucher_type, against_voucher, account))[0][0] or 0.0)

	if against_voucher_type == 'Purchase Invoice':
		bal = -bal
	elif against_voucher_type == "Journal Entry":
		against_voucher_amount = flt(dataent.db.sql("""
			select sum(debit_in_account_currency) - sum(credit_in_account_currency)
			from `tabGL Entry` where voucher_type = 'Journal Entry' and voucher_no = %s
			and account = %s and (against_voucher is null or against_voucher='') {0}"""
			.format(party_condition), (against_voucher, account))[0][0])

		if not against_voucher_amount:
			dataent.throw(_("Against Journal Entry {0} is already adjusted against some other voucher")
				.format(against_voucher))

		bal = against_voucher_amount + bal
		if against_voucher_amount < 0:
			bal = -bal

		# Validation : Outstanding can not be negative for JV
		if bal < 0 and not on_cancel:
			dataent.throw(_("Outstanding for {0} cannot be less than zero ({1})").format(against_voucher, fmt_money(bal)))

	# Update outstanding amt on against voucher
	if against_voucher_type in ["Sales Invoice", "Purchase Invoice", "Fees"]:
		ref_doc = dataent.get_doc(against_voucher_type, against_voucher)
		ref_doc.db_set('outstanding_amount', bal)
		ref_doc.set_status(update=True)
Exemplo n.º 29
0
def make_subcontract():
    from epaas.buying.doctype.purchase_order.purchase_order import make_rm_stock_entry
    item_code = get_random("Item", {"is_sub_contracted_item": 1})
    if item_code:
        # make sub-contract PO
        po = dataent.new_doc("Purchase Order")
        po.is_subcontracted = "Yes"
        po.supplier = get_random("Supplier")
        po.transaction_date = dataent.flags.current_date  # added
        po.schedule_date = dataent.utils.add_days(dataent.flags.current_date,
                                                  7)

        item_code = get_random("Item", {"is_sub_contracted_item": 1})

        po.append(
            "items", {
                "item_code":
                item_code,
                "schedule_date":
                dataent.utils.add_days(dataent.flags.current_date, 7),
                "qty":
                random.randint(10, 30)
            })
        po.set_missing_values()
        try:
            po.insert()
        except InvalidCurrency:
            return

        po.submit()

        # make material request for
        make_material_request(po.items[0].item_code, po.items[0].qty)

        # transfer material for sub-contract
        rm_items = get_rm_item(po.items[0], po.supplied_items[0])
        stock_entry = dataent.get_doc(
            make_rm_stock_entry(po.name, json.dumps([rm_items])))
        stock_entry.from_warehouse = "Stores - WPL"
        stock_entry.to_warehouse = "Supplier - WPL"
        stock_entry.insert()
Exemplo n.º 30
0
    def test_schedule_for_prorated_straight_line_method(self):
        set_prorated_depreciation_schedule()
        pr = make_purchase_receipt(item_code="Macbook Pro",
                                   qty=1,
                                   rate=100000.0,
                                   location="Test Location")

        asset_name = dataent.db.get_value("Asset",
                                          {"purchase_receipt": pr.name},
                                          'name')
        asset = dataent.get_doc('Asset', asset_name)
        asset.calculate_depreciation = 1
        asset.purchase_date = '2020-01-30'
        asset.is_existing_asset = 0
        asset.available_for_use_date = "2020-01-30"
        asset.append(
            "finance_books", {
                "expected_value_after_useful_life": 10000,
                "depreciation_method": "Straight Line",
                "total_number_of_depreciations": 3,
                "frequency_of_depreciation": 10,
                "depreciation_start_date": "2020-12-31"
            })

        asset.insert()
        asset.save()

        expected_schedules = [["2020-12-31", 28000.0, 28000.0],
                              ["2021-12-31", 30000.0, 58000.0],
                              ["2022-12-31", 30000.0, 88000.0],
                              ["2023-01-30", 2000.0, 90000.0]]

        schedules = [[
            cstr(d.schedule_date),
            flt(d.depreciation_amount, 2),
            flt(d.accumulated_depreciation_amount, 2)
        ] for d in asset.get("schedules")]

        self.assertEqual(schedules, expected_schedules)

        remove_prorated_depreciation_schedule()