Merge pull request #7324 from nabinhait/lcv_testcase
[test] Fixed test cases for LCV
This commit is contained in:
commit
0d49cdf024
@ -5,6 +5,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import unittest
|
import unittest
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.utils import flt
|
||||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt \
|
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt \
|
||||||
import set_perpetual_inventory, get_gl_entries, test_records as pr_test_records
|
import set_perpetual_inventory, get_gl_entries, test_records as pr_test_records
|
||||||
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice
|
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice
|
||||||
@ -23,7 +24,7 @@ class TestLandedCostVoucher(unittest.TestCase):
|
|||||||
},
|
},
|
||||||
fieldname=["qty_after_transaction", "stock_value"], as_dict=1)
|
fieldname=["qty_after_transaction", "stock_value"], as_dict=1)
|
||||||
|
|
||||||
self.submit_landed_cost_voucher("Purchase Receipt", pr.name)
|
submit_landed_cost_voucher("Purchase Receipt", pr.name)
|
||||||
|
|
||||||
pr_lc_value = frappe.db.get_value("Purchase Receipt Item", {"parent": pr.name}, "landed_cost_voucher_amount")
|
pr_lc_value = frappe.db.get_value("Purchase Receipt Item", {"parent": pr.name}, "landed_cost_voucher_amount")
|
||||||
self.assertEquals(pr_lc_value, 25.0)
|
self.assertEquals(pr_lc_value, 25.0)
|
||||||
@ -75,7 +76,7 @@ class TestLandedCostVoucher(unittest.TestCase):
|
|||||||
},
|
},
|
||||||
fieldname=["qty_after_transaction", "stock_value"], as_dict=1)
|
fieldname=["qty_after_transaction", "stock_value"], as_dict=1)
|
||||||
|
|
||||||
self.submit_landed_cost_voucher("Purchase Invoice", pi.name)
|
submit_landed_cost_voucher("Purchase Invoice", pi.name)
|
||||||
|
|
||||||
pi_lc_value = frappe.db.get_value("Purchase Invoice Item", {"parent": pi.name},
|
pi_lc_value = frappe.db.get_value("Purchase Invoice Item", {"parent": pi.name},
|
||||||
"landed_cost_voucher_amount")
|
"landed_cost_voucher_amount")
|
||||||
@ -121,7 +122,7 @@ class TestLandedCostVoucher(unittest.TestCase):
|
|||||||
|
|
||||||
serial_no_rate = frappe.db.get_value("Serial No", "SN001", "purchase_rate")
|
serial_no_rate = frappe.db.get_value("Serial No", "SN001", "purchase_rate")
|
||||||
|
|
||||||
self.submit_landed_cost_voucher("Purchase Receipt", pr.name)
|
submit_landed_cost_voucher("Purchase Receipt", pr.name)
|
||||||
|
|
||||||
serial_no = frappe.db.get_value("Serial No", "SN001",
|
serial_no = frappe.db.get_value("Serial No", "SN001",
|
||||||
["warehouse", "purchase_rate"], as_dict=1)
|
["warehouse", "purchase_rate"], as_dict=1)
|
||||||
@ -131,11 +132,13 @@ class TestLandedCostVoucher(unittest.TestCase):
|
|||||||
|
|
||||||
set_perpetual_inventory(0)
|
set_perpetual_inventory(0)
|
||||||
|
|
||||||
def submit_landed_cost_voucher(self, receipt_document_type, receipt_document):
|
def submit_landed_cost_voucher(receipt_document_type, receipt_document):
|
||||||
ref_doc = frappe.get_doc(receipt_document_type, receipt_document)
|
ref_doc = frappe.get_doc(receipt_document_type, receipt_document)
|
||||||
|
|
||||||
lcv = frappe.new_doc("Landed Cost Voucher")
|
lcv = frappe.new_doc("Landed Cost Voucher")
|
||||||
lcv.company = "_Test Company"
|
lcv.company = "_Test Company"
|
||||||
|
lcv.distribute_charges_based_on = 'Amount'
|
||||||
|
|
||||||
lcv.set("purchase_receipts", [{
|
lcv.set("purchase_receipts", [{
|
||||||
"receipt_document_type": receipt_document_type,
|
"receipt_document_type": receipt_document_type,
|
||||||
"receipt_document": receipt_document,
|
"receipt_document": receipt_document,
|
||||||
@ -151,7 +154,15 @@ class TestLandedCostVoucher(unittest.TestCase):
|
|||||||
}])
|
}])
|
||||||
|
|
||||||
lcv.insert()
|
lcv.insert()
|
||||||
|
|
||||||
|
distribute_landed_cost_on_items(lcv)
|
||||||
|
|
||||||
lcv.submit()
|
lcv.submit()
|
||||||
|
|
||||||
|
def distribute_landed_cost_on_items(lcv):
|
||||||
|
based_on = lcv.distribute_charges_based_on.lower()
|
||||||
|
total = sum([flt(d.get(based_on)) for d in lcv.get("items")])
|
||||||
|
for item in lcv.get("items"):
|
||||||
|
item.applicable_charges = flt(item.get(based_on)) * flt(lcv.total_taxes_and_charges) / flt(total)
|
||||||
|
|
||||||
test_records = frappe.get_test_records('Landed Cost Voucher')
|
test_records = frappe.get_test_records('Landed Cost Voucher')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user