Skip to content

Commit

Permalink
test: Purchase Invoice Received Qty
Browse files Browse the repository at this point in the history
  • Loading branch information
marination committed Nov 16, 2021
1 parent 05ec7cc commit e9c75d6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
make_purchase_receipt,
)
from erpnext.stock.doctype.stock_entry.test_stock_entry import get_qty_after_transaction
from erpnext.controllers.buying_controller import QtyMismatchError

test_dependencies = ["Item", "Cost Center", "Payment Term", "Payment Terms Template"]
test_ignore = ["Serial No"]
Expand All @@ -35,6 +36,27 @@ def setUpClass(self):
def tearDownClass(self):
unlink_payment_on_cancel_of_invoice(0)

def test_purchase_invoice_received_qty(self):
"""
1. Test if received qty is validated against accepted + rejected
2. Test if received qty is auto set on save
"""
pi = make_purchase_invoice(
qty=1,
rejected_qty=1,
received_qty=3,
item_code="_Test Item Home Desktop 200",
rejected_warehouse = "_Test Rejected Warehouse - _TC",
update_stock=True, do_not_save=True)
self.assertRaises(QtyMismatchError, pi.save)

pi.items[0].received_qty = 0
pi.save()
self.assertEqual(pi.items[0].received_qty, 2)

# teardown
pi.delete()

def test_gl_entries_without_perpetual_inventory(self):
frappe.db.set_value("Company", "_Test Company", "round_off_account", "Round Off - _TC")
pi = frappe.copy_doc(test_records[0])
Expand Down

0 comments on commit e9c75d6

Please sign in to comment.