frappe/frappe#478, frappe tests pass, .txt renamed to .json
This commit is contained in:
parent
0e13cd5ac9
commit
0a0f2495a2
@ -1,49 +1,6 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
test_records = [
|
||||
{
|
||||
"doctype": "Budget Distribution",
|
||||
"distribution_id": "_Test Distribution",
|
||||
"fiscal_year": "_Test Fiscal Year 2013",
|
||||
"budget_distribution_details": [
|
||||
{
|
||||
"month": "January",
|
||||
"percentage_allocation": "8"
|
||||
}, {
|
||||
"month": "February",
|
||||
"percentage_allocation": "8"
|
||||
}, {
|
||||
"month": "March",
|
||||
"percentage_allocation": "8"
|
||||
}, {
|
||||
"month": "April",
|
||||
"percentage_allocation": "8"
|
||||
}, {
|
||||
"month": "May",
|
||||
"percentage_allocation": "8"
|
||||
}, {
|
||||
"month": "June",
|
||||
"percentage_allocation": "8"
|
||||
}, {
|
||||
"month": "July",
|
||||
"percentage_allocation": "8"
|
||||
}, {
|
||||
"month": "August",
|
||||
"percentage_allocation": "8"
|
||||
}, {
|
||||
"month": "September",
|
||||
"percentage_allocation": "8"
|
||||
}, {
|
||||
"month": "October",
|
||||
"percentage_allocation": "8"
|
||||
}, {
|
||||
"month": "November",
|
||||
"percentage_allocation": "10"
|
||||
}, {
|
||||
"month": "December",
|
||||
"percentage_allocation": "10"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
import frappe
|
||||
test_records = frappe.get_test_records('Budget Distribution')
|
@ -1,19 +1,6 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
test_records = [
|
||||
[{
|
||||
"doctype": "Cost Center",
|
||||
"cost_center_name": "_Test Cost Center",
|
||||
"parent_cost_center": "_Test Company - _TC",
|
||||
"company": "_Test Company",
|
||||
"group_or_ledger": "Ledger",
|
||||
"distribution_id": "_Test Distribution",
|
||||
}, {
|
||||
"doctype": "Budget Detail",
|
||||
"parentfield": "budget_details",
|
||||
"account": "_Test Account Cost for Goods Sold - _TC",
|
||||
"budget_allocated": 100000,
|
||||
"fiscal_year": "_Test Fiscal Year 2013"
|
||||
}],
|
||||
]
|
||||
|
||||
import frappe
|
||||
test_records = frappe.get_test_records('Cost Center')
|
@ -12,7 +12,7 @@ class FiscalYear(Document):
|
||||
|
||||
def set_as_default(self):
|
||||
frappe.db.set_value("Global Defaults", None, "current_fiscal_year", self.name)
|
||||
frappe.get_obj("Global Defaults").on_update()
|
||||
frappe.get_doc("Global Defaults").on_update()
|
||||
|
||||
# clear cache
|
||||
frappe.clear_cache()
|
||||
|
@ -3,35 +3,4 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
test_records = [
|
||||
[{
|
||||
"doctype": "Fiscal Year",
|
||||
"year": "_Test Fiscal Year 2012",
|
||||
"year_start_date": "2012-01-01",
|
||||
"year_end_date": "2012-12-31"
|
||||
}],
|
||||
[{
|
||||
"doctype": "Fiscal Year",
|
||||
"year": "_Test Fiscal Year 2013",
|
||||
"year_start_date": "2013-01-01",
|
||||
"year_end_date": "2013-12-31"
|
||||
}],
|
||||
[{
|
||||
"doctype": "Fiscal Year",
|
||||
"year": "_Test Fiscal Year 2014",
|
||||
"year_start_date": "2014-01-01",
|
||||
"year_end_date": "2014-12-31"
|
||||
}],
|
||||
[{
|
||||
"doctype": "Fiscal Year",
|
||||
"year": "_Test Fiscal Year 2015",
|
||||
"year_start_date": "2015-01-01",
|
||||
"year_end_date": "2015-12-31"
|
||||
}],
|
||||
[{
|
||||
"doctype": "Fiscal Year",
|
||||
"year": "_Test Fiscal Year 2016",
|
||||
"year_start_date": "2016-01-01",
|
||||
"year_end_date": "2016-12-31"
|
||||
}],
|
||||
]
|
||||
test_records = frappe.get_test_records('Fiscal Year')
|
@ -9,14 +9,14 @@ import frappe
|
||||
class TestJournalVoucher(unittest.TestCase):
|
||||
def test_journal_voucher_with_against_jv(self):
|
||||
self.clear_account_balance()
|
||||
jv_invoice = frappe.get_doc(copy=test_records[2])
|
||||
jv_invoice = frappe.copy_doc(test_records[2])
|
||||
jv_invoice.insert()
|
||||
jv_invoice.submit()
|
||||
|
||||
self.assertTrue(not frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
||||
where against_jv=%s""", jv_invoice.name))
|
||||
|
||||
jv_payment = frappe.get_doc(copy=test_records[0])
|
||||
jv_payment = frappe.copy_doc(test_records[0])
|
||||
jv_payment.doclist[1].against_jv = jv_invoice.name
|
||||
jv_payment.insert()
|
||||
jv_payment.submit()
|
||||
@ -37,7 +37,7 @@ class TestJournalVoucher(unittest.TestCase):
|
||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
|
||||
set_perpetual_inventory()
|
||||
|
||||
jv = frappe.get_doc(copy=test_records[0])
|
||||
jv = frappe.copy_doc(test_records[0])
|
||||
jv.doclist[1].account = "_Test Warehouse - _TC"
|
||||
jv.insert()
|
||||
|
||||
@ -50,7 +50,7 @@ class TestJournalVoucher(unittest.TestCase):
|
||||
frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore")
|
||||
self.clear_account_balance()
|
||||
|
||||
jv = frappe.get_doc(copy=test_records[0])
|
||||
jv = frappe.copy_doc(test_records[0])
|
||||
jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
|
||||
jv.doclist[2].cost_center = "_Test Cost Center - _TC"
|
||||
jv.doclist[2].debit = 20000.0
|
||||
@ -65,7 +65,7 @@ class TestJournalVoucher(unittest.TestCase):
|
||||
frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop")
|
||||
self.clear_account_balance()
|
||||
|
||||
jv = frappe.get_doc(copy=test_records[0])
|
||||
jv = frappe.copy_doc(test_records[0])
|
||||
jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
|
||||
jv.doclist[2].cost_center = "_Test Cost Center - _TC"
|
||||
jv.doclist[2].debit = 20000.0
|
||||
@ -83,7 +83,7 @@ class TestJournalVoucher(unittest.TestCase):
|
||||
|
||||
frappe.db.set_value("Company", "_Test Company", "yearly_bgt_flag", "Stop")
|
||||
|
||||
jv = frappe.get_doc(copy=test_records[0])
|
||||
jv = frappe.copy_doc(test_records[0])
|
||||
jv.posting_date = "2013-08-12"
|
||||
jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
|
||||
jv.doclist[2].cost_center = "_Test Cost Center - _TC"
|
||||
@ -100,7 +100,7 @@ class TestJournalVoucher(unittest.TestCase):
|
||||
frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop")
|
||||
self.clear_account_balance()
|
||||
|
||||
jv = frappe.get_doc(copy=test_records[0])
|
||||
jv = frappe.copy_doc(test_records[0])
|
||||
jv.doclist[1].account = "_Test Account Cost for Goods Sold - _TC"
|
||||
jv.doclist[1].cost_center = "_Test Cost Center - _TC"
|
||||
jv.doclist[1].credit = 30000.0
|
||||
@ -110,7 +110,7 @@ class TestJournalVoucher(unittest.TestCase):
|
||||
self.assertTrue(frappe.db.get_value("GL Entry",
|
||||
{"voucher_type": "Journal Voucher", "voucher_no": jv.name}))
|
||||
|
||||
jv1 = frappe.get_doc(copy=test_records[0])
|
||||
jv1 = frappe.copy_doc(test_records[0])
|
||||
jv1.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
|
||||
jv1.doclist[2].cost_center = "_Test Cost Center - _TC"
|
||||
jv1.doclist[2].debit = 40000.0
|
||||
@ -128,81 +128,4 @@ class TestJournalVoucher(unittest.TestCase):
|
||||
frappe.db.sql("""delete from `tabGL Entry`""")
|
||||
|
||||
|
||||
test_records = [
|
||||
[{
|
||||
"company": "_Test Company",
|
||||
"doctype": "Journal Voucher",
|
||||
"fiscal_year": "_Test Fiscal Year 2013",
|
||||
"naming_series": "_T-Journal Voucher-",
|
||||
"posting_date": "2013-02-14",
|
||||
"user_remark": "test",
|
||||
"voucher_type": "Bank Voucher",
|
||||
"cheque_no": "33",
|
||||
"cheque_date": "2013-02-14"
|
||||
},
|
||||
{
|
||||
"account": "_Test Customer - _TC",
|
||||
"doctype": "Journal Voucher Detail",
|
||||
"credit": 400.0,
|
||||
"debit": 0.0,
|
||||
"parentfield": "entries"
|
||||
},
|
||||
{
|
||||
"account": "_Test Account Bank Account - _TC",
|
||||
"doctype": "Journal Voucher Detail",
|
||||
"debit": 400.0,
|
||||
"credit": 0.0,
|
||||
"parentfield": "entries"
|
||||
}],
|
||||
[{
|
||||
"company": "_Test Company",
|
||||
"doctype": "Journal Voucher",
|
||||
"fiscal_year": "_Test Fiscal Year 2013",
|
||||
"naming_series": "_T-Journal Voucher-",
|
||||
"posting_date": "2013-02-14",
|
||||
"user_remark": "test",
|
||||
"voucher_type": "Bank Voucher",
|
||||
"cheque_no": "33",
|
||||
"cheque_date": "2013-02-14"
|
||||
},
|
||||
{
|
||||
"account": "_Test Supplier - _TC",
|
||||
"doctype": "Journal Voucher Detail",
|
||||
"credit": 0.0,
|
||||
"debit": 400.0,
|
||||
"parentfield": "entries"
|
||||
},
|
||||
{
|
||||
"account": "_Test Account Bank Account - _TC",
|
||||
"doctype": "Journal Voucher Detail",
|
||||
"debit": 0.0,
|
||||
"credit": 400.0,
|
||||
"parentfield": "entries"
|
||||
}],
|
||||
[{
|
||||
"company": "_Test Company",
|
||||
"doctype": "Journal Voucher",
|
||||
"fiscal_year": "_Test Fiscal Year 2013",
|
||||
"naming_series": "_T-Journal Voucher-",
|
||||
"posting_date": "2013-02-14",
|
||||
"user_remark": "test",
|
||||
"voucher_type": "Bank Voucher",
|
||||
"cheque_no": "33",
|
||||
"cheque_date": "2013-02-14"
|
||||
},
|
||||
{
|
||||
"account": "_Test Customer - _TC",
|
||||
"doctype": "Journal Voucher Detail",
|
||||
"credit": 0.0,
|
||||
"debit": 400.0,
|
||||
"parentfield": "entries"
|
||||
},
|
||||
{
|
||||
"account": "Sales - _TC",
|
||||
"doctype": "Journal Voucher Detail",
|
||||
"credit": 400.0,
|
||||
"debit": 0.0,
|
||||
"parentfield": "entries",
|
||||
"cost_center": "_Test Cost Center - _TC"
|
||||
}],
|
||||
]
|
||||
test_records = frappe.get_test_records('Journal Voucher')
|
@ -5,4 +5,4 @@ from __future__ import unicode_literals
|
||||
import unittest
|
||||
import frappe
|
||||
|
||||
test_records = []
|
||||
test_records = frappe.get_test_records('Payment To Invoice Matching Tool')
|
@ -12,18 +12,18 @@ class TestPeriodClosingVoucher(unittest.TestCase):
|
||||
frappe.db.sql("""delete from `tabGL Entry`""")
|
||||
|
||||
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher import test_records as jv_records
|
||||
jv = frappe.get_doc(copy=jv_records[2])
|
||||
jv = frappe.copy_doc(jv_records[2])
|
||||
jv.insert()
|
||||
jv.submit()
|
||||
|
||||
jv1 = frappe.get_doc(copy=jv_records[0])
|
||||
jv1 = frappe.copy_doc(jv_records[0])
|
||||
jv1.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
|
||||
jv1.doclist[2].debit = 600.0
|
||||
jv1.doclist[1].credit = 600.0
|
||||
jv1.insert()
|
||||
jv1.submit()
|
||||
|
||||
pcv = frappe.get_doc(copy=test_record)
|
||||
pcv = frappe.copy_doc(test_record)
|
||||
pcv.insert()
|
||||
pcv.submit()
|
||||
|
||||
|
@ -10,11 +10,7 @@ from frappe.model.document import Document
|
||||
|
||||
class PosSetting(Document):
|
||||
def get_series(self):
|
||||
import frappe.model.doctype
|
||||
docfield = frappe.model.doctype.get('Sales Invoice')
|
||||
series = [d.options for d in docfield
|
||||
if d.doctype == 'DocField' and d.fieldname == 'naming_series']
|
||||
return series and series[0] or ''
|
||||
frappe.get_meta("Sales Invoice").get_field("naming_series").options or ""
|
||||
|
||||
def validate(self):
|
||||
self.check_for_duplicate()
|
||||
|
@ -1,19 +1,6 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
test_records = [
|
||||
[{
|
||||
"doctype": "POS Setting",
|
||||
"name": "_Test POS Setting",
|
||||
"currency": "INR",
|
||||
"selling_price_list": "_Test Price List",
|
||||
"company": "_Test Company",
|
||||
"warehouse": "_Test Warehouse - _TC",
|
||||
"territory": "_Test Territory",
|
||||
"cash_bank_account": "_Test Account Bank Account - _TC",
|
||||
"income_account": "Sales - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"expense_account": "_Test Account Cost for Goods Sold - _TC",
|
||||
"naming_series": "_T-Sales Invoice-"
|
||||
}]
|
||||
]
|
||||
|
||||
import frappe
|
||||
test_records = frappe.get_test_records('Pos Setting')
|
@ -19,7 +19,7 @@ class TestPricingRule(unittest.TestCase):
|
||||
"price": 0,
|
||||
"discount_percentage": 10,
|
||||
}]
|
||||
frappe.get_doc(copy=test_record).insert()
|
||||
frappe.copy_doc(test_record).insert()
|
||||
|
||||
args = frappe._dict({
|
||||
"item_code": "_Test Item",
|
||||
@ -38,7 +38,7 @@ class TestPricingRule(unittest.TestCase):
|
||||
details = get_item_details(args)
|
||||
self.assertEquals(details.get("discount_percentage"), 10)
|
||||
|
||||
prule = frappe.get_doc(copy=test_record)
|
||||
prule = frappe.copy_doc(test_record)
|
||||
prule.applicable_for = "Customer"
|
||||
self.assertRaises(MandatoryError, prule.insert)
|
||||
prule.customer = "_Test Customer"
|
||||
@ -47,7 +47,7 @@ class TestPricingRule(unittest.TestCase):
|
||||
details = get_item_details(args)
|
||||
self.assertEquals(details.get("discount_percentage"), 20)
|
||||
|
||||
prule = frappe.get_doc(copy=test_record)
|
||||
prule = frappe.copy_doc(test_record)
|
||||
prule.apply_on = "Item Group"
|
||||
prule.item_group = "All Item Groups"
|
||||
prule.discount_percentage = 15
|
||||
@ -57,7 +57,7 @@ class TestPricingRule(unittest.TestCase):
|
||||
details = get_item_details(args)
|
||||
self.assertEquals(details.get("discount_percentage"), 10)
|
||||
|
||||
prule = frappe.get_doc(copy=test_record)
|
||||
prule = frappe.copy_doc(test_record)
|
||||
prule.applicable_for = "Campaign"
|
||||
prule.campaign = "_Test Campaign"
|
||||
prule.discount_percentage = 5
|
||||
|
@ -6,7 +6,6 @@ import frappe
|
||||
|
||||
from frappe.utils import cint, cstr, flt, formatdate
|
||||
|
||||
from frappe.model.code import get_obj
|
||||
from frappe import msgprint, _
|
||||
from erpnext.setup.utils import get_company_currency
|
||||
|
||||
@ -267,7 +266,7 @@ class PurchaseInvoice(BuyingController):
|
||||
def on_submit(self):
|
||||
self.check_prev_docstatus()
|
||||
|
||||
get_obj('Authorization Control').validate_approving_authority(self.doctype,
|
||||
frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype,
|
||||
self.company, self.grand_total)
|
||||
|
||||
# this sequence because outstanding may get -negative
|
||||
|
@ -19,7 +19,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
set_perpetual_inventory(0)
|
||||
self.assertTrue(not cint(frappe.defaults.get_global_default("auto_accounting_for_stock")))
|
||||
|
||||
wrapper = frappe.get_doc(copy=test_records[0])
|
||||
wrapper = frappe.copy_doc(test_records[0])
|
||||
wrapper.insert()
|
||||
wrapper.submit()
|
||||
wrapper.load_from_db()
|
||||
@ -45,7 +45,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
set_perpetual_inventory(1)
|
||||
self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1)
|
||||
|
||||
pi = frappe.get_doc(copy=test_records[1])
|
||||
pi = frappe.copy_doc(test_records[1])
|
||||
pi.insert()
|
||||
pi.submit()
|
||||
|
||||
@ -73,7 +73,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
set_perpetual_inventory()
|
||||
self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1)
|
||||
|
||||
pi = frappe.get_doc(copy=test_records[1])
|
||||
pi = frappe.copy_doc(test_records[1])
|
||||
pi.doclist[1].item_code = "_Test Non Stock Item"
|
||||
pi.doclist[1].expense_account = "_Test Account Cost for Goods Sold - _TC"
|
||||
pi.doclist.pop(2)
|
||||
@ -99,7 +99,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
set_perpetual_inventory(0)
|
||||
|
||||
def test_purchase_invoice_calculation(self):
|
||||
wrapper = frappe.get_doc(copy=test_records[0])
|
||||
wrapper = frappe.copy_doc(test_records[0])
|
||||
wrapper.insert()
|
||||
wrapper.load_from_db()
|
||||
|
||||
@ -132,7 +132,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
self.assertEqual(tax.total, expected_values[i][2])
|
||||
|
||||
def test_purchase_invoice_with_subcontracted_item(self):
|
||||
wrapper = frappe.get_doc(copy=test_records[0])
|
||||
wrapper = frappe.copy_doc(test_records[0])
|
||||
wrapper.doclist[1].item_code = "_Test FG Item"
|
||||
wrapper.insert()
|
||||
wrapper.load_from_db()
|
||||
@ -169,11 +169,11 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \
|
||||
import test_records as jv_test_records
|
||||
|
||||
jv = frappe.get_doc(copy=jv_test_records[1])
|
||||
jv = frappe.copy_doc(jv_test_records[1])
|
||||
jv.insert()
|
||||
jv.submit()
|
||||
|
||||
pi = frappe.get_doc(copy=test_records[0])
|
||||
pi = frappe.copy_doc(test_records[0])
|
||||
pi.append("advance_allocation_details", {
|
||||
"journal_voucher": jv.name,
|
||||
"jv_detail_no": jv.doclist[1].name,
|
||||
@ -198,212 +198,4 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
self.assertTrue(not frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
||||
where against_voucher=%s""", pi.name))
|
||||
|
||||
test_records = [
|
||||
[
|
||||
# parent
|
||||
{
|
||||
"doctype": "Purchase Invoice",
|
||||
"naming_series": "BILL",
|
||||
"supplier_name": "_Test Supplier",
|
||||
"credit_to": "_Test Supplier - _TC",
|
||||
"bill_no": "NA",
|
||||
"posting_date": "2013-02-03",
|
||||
"fiscal_year": "_Test Fiscal Year 2013",
|
||||
"company": "_Test Company",
|
||||
"currency": "INR",
|
||||
"conversion_rate": 1,
|
||||
"grand_total_import": 0, # for feed
|
||||
"buying_price_list": "_Test Price List"
|
||||
},
|
||||
# items
|
||||
{
|
||||
"doctype": "Purchase Invoice Item",
|
||||
"parentfield": "entries",
|
||||
"item_code": "_Test Item Home Desktop 100",
|
||||
"item_name": "_Test Item Home Desktop 100",
|
||||
"qty": 10,
|
||||
"rate": 50,
|
||||
"amount": 500,
|
||||
"base_rate": 50,
|
||||
"base_amount": 500,
|
||||
"uom": "_Test UOM",
|
||||
"item_tax_rate": json.dumps({"_Test Account Excise Duty - _TC": 10}),
|
||||
"expense_account": "_Test Account Cost for Goods Sold - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"conversion_factor": 1.0,
|
||||
|
||||
},
|
||||
{
|
||||
"doctype": "Purchase Invoice Item",
|
||||
"parentfield": "entries",
|
||||
"item_code": "_Test Item Home Desktop 200",
|
||||
"item_name": "_Test Item Home Desktop 200",
|
||||
"qty": 5,
|
||||
"rate": 150,
|
||||
"amount": 750,
|
||||
"base_rate": 150,
|
||||
"base_amount": 750,
|
||||
"uom": "_Test UOM",
|
||||
"expense_account": "_Test Account Cost for Goods Sold - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"conversion_factor": 1.0,
|
||||
},
|
||||
# taxes
|
||||
{
|
||||
"doctype": "Purchase Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "Actual",
|
||||
"account_head": "_Test Account Shipping Charges - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Shipping Charges",
|
||||
"category": "Valuation and Total",
|
||||
"add_deduct_tax": "Add",
|
||||
"rate": 100
|
||||
},
|
||||
{
|
||||
"doctype": "Purchase Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Net Total",
|
||||
"account_head": "_Test Account Customs Duty - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Customs Duty",
|
||||
"category": "Valuation",
|
||||
"add_deduct_tax": "Add",
|
||||
"rate": 10
|
||||
},
|
||||
{
|
||||
"doctype": "Purchase Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Net Total",
|
||||
"account_head": "_Test Account Excise Duty - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Excise Duty",
|
||||
"category": "Total",
|
||||
"add_deduct_tax": "Add",
|
||||
"rate": 12
|
||||
},
|
||||
{
|
||||
"doctype": "Purchase Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Previous Row Amount",
|
||||
"account_head": "_Test Account Education Cess - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Education Cess",
|
||||
"category": "Total",
|
||||
"add_deduct_tax": "Add",
|
||||
"rate": 2,
|
||||
"row_id": 3
|
||||
},
|
||||
{
|
||||
"doctype": "Purchase Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Previous Row Amount",
|
||||
"account_head": "_Test Account S&H Education Cess - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "S&H Education Cess",
|
||||
"category": "Total",
|
||||
"add_deduct_tax": "Add",
|
||||
"rate": 1,
|
||||
"row_id": 3
|
||||
},
|
||||
{
|
||||
"doctype": "Purchase Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Previous Row Total",
|
||||
"account_head": "_Test Account CST - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "CST",
|
||||
"category": "Total",
|
||||
"add_deduct_tax": "Add",
|
||||
"rate": 2,
|
||||
"row_id": 5
|
||||
},
|
||||
{
|
||||
"doctype": "Purchase Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Net Total",
|
||||
"account_head": "_Test Account VAT - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "VAT",
|
||||
"category": "Total",
|
||||
"add_deduct_tax": "Add",
|
||||
"rate": 12.5
|
||||
},
|
||||
{
|
||||
"doctype": "Purchase Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Previous Row Total",
|
||||
"account_head": "_Test Account Discount - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Discount",
|
||||
"category": "Total",
|
||||
"add_deduct_tax": "Deduct",
|
||||
"rate": 10,
|
||||
"row_id": 7
|
||||
},
|
||||
],
|
||||
[
|
||||
# parent
|
||||
{
|
||||
"doctype": "Purchase Invoice",
|
||||
"naming_series": "_T-Purchase Invoice-",
|
||||
"supplier_name": "_Test Supplier",
|
||||
"credit_to": "_Test Supplier - _TC",
|
||||
"bill_no": "NA",
|
||||
"posting_date": "2013-02-03",
|
||||
"fiscal_year": "_Test Fiscal Year 2013",
|
||||
"company": "_Test Company",
|
||||
"currency": "INR",
|
||||
"conversion_rate": 1.0,
|
||||
"grand_total_import": 0, # for feed
|
||||
"buying_price_list": "_Test Price List"
|
||||
},
|
||||
# items
|
||||
{
|
||||
"doctype": "Purchase Invoice Item",
|
||||
"parentfield": "entries",
|
||||
"item_code": "_Test Item",
|
||||
"item_name": "_Test Item",
|
||||
"qty": 10.0,
|
||||
"rate": 50.0,
|
||||
"uom": "_Test UOM",
|
||||
"expense_account": "_Test Account Cost for Goods Sold - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"conversion_factor": 1.0,
|
||||
},
|
||||
# taxes
|
||||
{
|
||||
"doctype": "Purchase Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "Actual",
|
||||
"account_head": "_Test Account Shipping Charges - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Shipping Charges",
|
||||
"category": "Valuation and Total",
|
||||
"add_deduct_tax": "Add",
|
||||
"rate": 100.0
|
||||
},
|
||||
{
|
||||
"doctype": "Purchase Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "Actual",
|
||||
"account_head": "_Test Account VAT - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "VAT",
|
||||
"category": "Total",
|
||||
"add_deduct_tax": "Add",
|
||||
"rate": 120.0
|
||||
},
|
||||
{
|
||||
"doctype": "Purchase Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "Actual",
|
||||
"account_head": "_Test Account Customs Duty - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Customs Duty",
|
||||
"category": "Valuation",
|
||||
"add_deduct_tax": "Add",
|
||||
"rate": 150.0
|
||||
},
|
||||
]
|
||||
]
|
||||
test_records = frappe.get_test_records('Purchase Invoice')
|
@ -11,7 +11,6 @@ from frappe.utils import add_days, cint, cstr, date_diff, flt, getdate, nowdate,
|
||||
from frappe.utils import comma_and
|
||||
from frappe.model.naming import make_autoname
|
||||
|
||||
from frappe.model.code import get_obj
|
||||
from frappe import _, msgprint
|
||||
|
||||
from erpnext.accounts.party import get_party_account, get_due_date
|
||||
@ -78,7 +77,7 @@ class SalesInvoice(SellingController):
|
||||
else:
|
||||
# Check for Approving Authority
|
||||
if not self.recurring_id:
|
||||
get_obj('Authorization Control').validate_approving_authority(self.doctype,
|
||||
frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype,
|
||||
self.company, self.grand_total, self)
|
||||
|
||||
self.check_prev_docstatus()
|
||||
|
@ -10,14 +10,14 @@ from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_per
|
||||
|
||||
class TestSalesInvoice(unittest.TestCase):
|
||||
def make(self):
|
||||
w = frappe.get_doc(copy=test_records[0])
|
||||
w = frappe.copy_doc(test_records[0])
|
||||
w.is_pos = 0
|
||||
w.insert()
|
||||
w.submit()
|
||||
return w
|
||||
|
||||
def test_double_submission(self):
|
||||
w = frappe.get_doc(copy=test_records[0])
|
||||
w = frappe.copy_doc(test_records[0])
|
||||
w.docstatus = '0'
|
||||
w.insert()
|
||||
|
||||
@ -28,7 +28,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
self.assertRaises(DocstatusTransitionError, w.submit)
|
||||
|
||||
def test_timestamp_change(self):
|
||||
w = frappe.get_doc(copy=test_records[0])
|
||||
w = frappe.copy_doc(test_records[0])
|
||||
w.docstatus = '0'
|
||||
w.insert()
|
||||
|
||||
@ -43,7 +43,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
self.assertRaises(TimestampMismatchError, w2.save)
|
||||
|
||||
def test_sales_invoice_calculation_base_currency(self):
|
||||
si = frappe.get_doc(copy=test_records[2])
|
||||
si = frappe.copy_doc(test_records[2])
|
||||
si.insert()
|
||||
|
||||
expected_values = {
|
||||
@ -87,7 +87,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
self.assertEquals(si.grand_total_export, 1627.05)
|
||||
|
||||
def test_sales_invoice_calculation_export_currency(self):
|
||||
si = frappe.get_doc(copy=test_records[2])
|
||||
si = frappe.copy_doc(test_records[2])
|
||||
si.currency = "USD"
|
||||
si.conversion_rate = 50
|
||||
si.doclist[1].rate = 1
|
||||
@ -137,7 +137,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
self.assertEquals(si.grand_total_export, 32.54)
|
||||
|
||||
def test_sales_invoice_discount_amount(self):
|
||||
si = frappe.get_doc(copy=test_records[3])
|
||||
si = frappe.copy_doc(test_records[3])
|
||||
si.discount_amount = 104.95
|
||||
si.append("other_charges", {
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
@ -192,7 +192,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
self.assertEquals(si.grand_total_export, 1500)
|
||||
|
||||
def test_discount_amount_gl_entry(self):
|
||||
si = frappe.get_doc(copy=test_records[3])
|
||||
si = frappe.copy_doc(test_records[3])
|
||||
si.discount_amount = 104.95
|
||||
si.append("other_charges", {
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
@ -240,7 +240,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
self.assertFalse(gle)
|
||||
|
||||
def test_inclusive_rate_validations(self):
|
||||
si = frappe.get_doc(copy=test_records[2])
|
||||
si = frappe.copy_doc(test_records[2])
|
||||
for i, tax in enumerate(si.get("other_charges")):
|
||||
tax.idx = i+1
|
||||
|
||||
@ -258,7 +258,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
|
||||
def test_sales_invoice_calculation_base_currency_with_tax_inclusive_price(self):
|
||||
# prepare
|
||||
si = frappe.get_doc(copy=test_records[3])
|
||||
si = frappe.copy_doc(test_records[3])
|
||||
si.insert()
|
||||
|
||||
expected_values = {
|
||||
@ -303,7 +303,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
|
||||
def test_sales_invoice_calculation_export_currency_with_tax_inclusive_price(self):
|
||||
# prepare
|
||||
si = frappe.get_doc(copy=test_records[3])
|
||||
si = frappe.copy_doc(test_records[3])
|
||||
si.currency = "USD"
|
||||
si.conversion_rate = 50
|
||||
si.doclist[1].price_list_rate = 55.56
|
||||
@ -403,7 +403,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
def test_sales_invoice_gl_entry_without_aii(self):
|
||||
self.clear_stock_account_balance()
|
||||
set_perpetual_inventory(0)
|
||||
si = frappe.get_doc(copy=test_records[1])
|
||||
si = frappe.copy_doc(test_records[1])
|
||||
si.insert()
|
||||
si.submit()
|
||||
|
||||
@ -447,7 +447,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
pos[0]["cash_bank_account"] = "_Test Account Bank Account - _TC"
|
||||
pos[0]["paid_amount"] = 600.0
|
||||
|
||||
si = frappe.get_doc(copy=pos)
|
||||
si = frappe.copy_doc(pos)
|
||||
si.insert()
|
||||
si.submit()
|
||||
|
||||
@ -500,7 +500,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
# insert purchase receipt
|
||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import test_records \
|
||||
as pr_test_records
|
||||
pr = frappe.get_doc(copy=pr_test_records[0])
|
||||
pr = frappe.copy_doc(pr_test_records[0])
|
||||
pr.naming_series = "_T-Purchase Receipt-"
|
||||
pr.doclist[1].warehouse = "_Test Warehouse No Account - _TC"
|
||||
pr.insert()
|
||||
@ -511,7 +511,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
si_doclist[0]["posting_time"] = "12:05"
|
||||
si_doclist[1]["warehouse"] = "_Test Warehouse No Account - _TC"
|
||||
|
||||
si = frappe.get_doc(copy=si_doclist)
|
||||
si = frappe.copy_doc(si_doclist)
|
||||
si.insert()
|
||||
si.submit()
|
||||
|
||||
@ -605,7 +605,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
def _insert_purchase_receipt(self):
|
||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import test_records \
|
||||
as pr_test_records
|
||||
pr = frappe.get_doc(copy=pr_test_records[0])
|
||||
pr = frappe.copy_doc(pr_test_records[0])
|
||||
pr.naming_series = "_T-Purchase Receipt-"
|
||||
pr.insert()
|
||||
pr.submit()
|
||||
@ -613,7 +613,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
def _insert_delivery_note(self):
|
||||
from erpnext.stock.doctype.delivery_note.test_delivery_note import test_records \
|
||||
as dn_test_records
|
||||
dn = frappe.get_doc(copy=dn_test_records[0])
|
||||
dn = frappe.copy_doc(dn_test_records[0])
|
||||
dn.naming_series = "_T-Delivery Note-"
|
||||
dn.insert()
|
||||
dn.submit()
|
||||
@ -624,18 +624,18 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
import test_records as pos_setting_test_records
|
||||
frappe.db.sql("""delete from `tabPOS Setting`""")
|
||||
|
||||
ps = frappe.get_doc(copy=pos_setting_test_records[0])
|
||||
ps = frappe.copy_doc(pos_setting_test_records[0])
|
||||
ps.insert()
|
||||
|
||||
def test_sales_invoice_with_advance(self):
|
||||
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \
|
||||
import test_records as jv_test_records
|
||||
|
||||
jv = frappe.get_doc(copy=jv_test_records[0])
|
||||
jv = frappe.copy_doc(jv_test_records[0])
|
||||
jv.insert()
|
||||
jv.submit()
|
||||
|
||||
si = frappe.get_doc(copy=test_records[0])
|
||||
si = frappe.copy_doc(test_records[0])
|
||||
si.append("advance_adjustment_details", {
|
||||
"doctype": "Sales Invoice Advance",
|
||||
"journal_voucher": jv.name,
|
||||
@ -665,7 +665,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
from frappe.utils import get_first_day, get_last_day, add_to_date, nowdate, getdate
|
||||
from erpnext.accounts.utils import get_fiscal_year
|
||||
today = nowdate()
|
||||
base_si = frappe.get_doc(copy=test_records[0])
|
||||
base_si = frappe.copy_doc(test_records[0])
|
||||
base_si.update({
|
||||
"convert_into_recurring_invoice": 1,
|
||||
"recurring_type": "Monthly",
|
||||
@ -678,13 +678,13 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
})
|
||||
|
||||
# monthly
|
||||
si1 = frappe.get_doc(copy=base_si.doclist)
|
||||
si1 = frappe.copy_doc(base_si.doclist)
|
||||
si1.insert()
|
||||
si1.submit()
|
||||
self._test_recurring_invoice(si1, True)
|
||||
|
||||
# monthly without a first and last day period
|
||||
si2 = frappe.get_doc(copy=base_si.doclist)
|
||||
si2 = frappe.copy_doc(base_si.doclist)
|
||||
si2.update({
|
||||
"invoice_period_from_date": today,
|
||||
"invoice_period_to_date": add_to_date(today, days=30)
|
||||
@ -694,7 +694,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
self._test_recurring_invoice(si2, False)
|
||||
|
||||
# quarterly
|
||||
si3 = frappe.get_doc(copy=base_si.doclist)
|
||||
si3 = frappe.copy_doc(base_si.doclist)
|
||||
si3.update({
|
||||
"recurring_type": "Quarterly",
|
||||
"invoice_period_from_date": get_first_day(today),
|
||||
@ -705,7 +705,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
self._test_recurring_invoice(si3, True)
|
||||
|
||||
# quarterly without a first and last day period
|
||||
si4 = frappe.get_doc(copy=base_si.doclist)
|
||||
si4 = frappe.copy_doc(base_si.doclist)
|
||||
si4.update({
|
||||
"recurring_type": "Quarterly",
|
||||
"invoice_period_from_date": today,
|
||||
@ -716,7 +716,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
self._test_recurring_invoice(si4, False)
|
||||
|
||||
# yearly
|
||||
si5 = frappe.get_doc(copy=base_si.doclist)
|
||||
si5 = frappe.copy_doc(base_si.doclist)
|
||||
si5.update({
|
||||
"recurring_type": "Yearly",
|
||||
"invoice_period_from_date": get_first_day(today),
|
||||
@ -727,7 +727,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
self._test_recurring_invoice(si5, True)
|
||||
|
||||
# yearly without a first and last day period
|
||||
si6 = frappe.get_doc(copy=base_si.doclist)
|
||||
si6 = frappe.copy_doc(base_si.doclist)
|
||||
si6.update({
|
||||
"recurring_type": "Yearly",
|
||||
"invoice_period_from_date": today,
|
||||
@ -738,7 +738,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
self._test_recurring_invoice(si6, False)
|
||||
|
||||
# change posting date but keep recuring day to be today
|
||||
si7 = frappe.get_doc(copy=base_si.doclist)
|
||||
si7 = frappe.copy_doc(base_si.doclist)
|
||||
si7.update({
|
||||
"posting_date": add_to_date(today, days=-1)
|
||||
})
|
||||
@ -811,7 +811,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
se = make_serialized_item()
|
||||
serial_nos = get_serial_nos(se.doclist[1].serial_no)
|
||||
|
||||
si = frappe.get_doc(copy=test_records[0])
|
||||
si = frappe.copy_doc(test_records[0])
|
||||
si.update_stock = 1
|
||||
si.doclist[1].item_code = "_Test Serialized Item With Series"
|
||||
si.doclist[1].qty = 1
|
||||
@ -849,7 +849,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
sr.status = "Not Available"
|
||||
sr.save()
|
||||
|
||||
si = frappe.get_doc(copy=test_records[0])
|
||||
si = frappe.copy_doc(test_records[0])
|
||||
si.update_stock = 1
|
||||
si.doclist[1].item_code = "_Test Serialized Item With Series"
|
||||
si.doclist[1].qty = 1
|
||||
@ -860,386 +860,4 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
|
||||
test_dependencies = ["Journal Voucher", "POS Setting", "Contact", "Address"]
|
||||
|
||||
test_records = [
|
||||
[
|
||||
{
|
||||
"naming_series": "_T-Sales Invoice-",
|
||||
"company": "_Test Company",
|
||||
"is_pos": 0,
|
||||
"conversion_rate": 1.0,
|
||||
"currency": "INR",
|
||||
"debit_to": "_Test Customer - _TC",
|
||||
"customer": "_Test Customer",
|
||||
"customer_name": "_Test Customer",
|
||||
"doctype": "Sales Invoice",
|
||||
"due_date": "2013-01-23",
|
||||
"fiscal_year": "_Test Fiscal Year 2013",
|
||||
"grand_total": 561.8,
|
||||
"grand_total_export": 561.8,
|
||||
"net_total": 500.0,
|
||||
"plc_conversion_rate": 1.0,
|
||||
"posting_date": "2013-01-23",
|
||||
"price_list_currency": "INR",
|
||||
"selling_price_list": "_Test Price List",
|
||||
"territory": "_Test Territory"
|
||||
},
|
||||
{
|
||||
"base_amount": 500.0,
|
||||
"base_rate": 500.0,
|
||||
"description": "138-CMS Shoe",
|
||||
"doctype": "Sales Invoice Item",
|
||||
"amount": 500.0,
|
||||
"rate": 500.0,
|
||||
"income_account": "Sales - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"item_name": "138-CMS Shoe",
|
||||
"parentfield": "entries",
|
||||
"qty": 1.0
|
||||
},
|
||||
{
|
||||
"account_head": "_Test Account VAT - _TC",
|
||||
"charge_type": "On Net Total",
|
||||
"description": "VAT",
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"rate": 6,
|
||||
},
|
||||
{
|
||||
"account_head": "_Test Account Service Tax - _TC",
|
||||
"charge_type": "On Net Total",
|
||||
"description": "Service Tax",
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"rate": 6.36,
|
||||
},
|
||||
{
|
||||
"parentfield": "sales_team",
|
||||
"doctype": "Sales Team",
|
||||
"sales_person": "_Test Sales Person 1",
|
||||
"allocated_percentage": 65.5,
|
||||
},
|
||||
{
|
||||
"parentfield": "sales_team",
|
||||
"doctype": "Sales Team",
|
||||
"sales_person": "_Test Sales Person 2",
|
||||
"allocated_percentage": 34.5,
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
"naming_series": "_T-Sales Invoice-",
|
||||
"company": "_Test Company",
|
||||
"is_pos": 0,
|
||||
"conversion_rate": 1.0,
|
||||
"currency": "INR",
|
||||
"debit_to": "_Test Customer - _TC",
|
||||
"customer": "_Test Customer",
|
||||
"customer_name": "_Test Customer",
|
||||
"doctype": "Sales Invoice",
|
||||
"due_date": "2013-01-23",
|
||||
"fiscal_year": "_Test Fiscal Year 2013",
|
||||
"grand_total": 630.0,
|
||||
"grand_total_export": 630.0,
|
||||
"net_total": 500.0,
|
||||
"plc_conversion_rate": 1.0,
|
||||
"posting_date": "2013-03-07",
|
||||
"price_list_currency": "INR",
|
||||
"selling_price_list": "_Test Price List",
|
||||
"territory": "_Test Territory"
|
||||
},
|
||||
{
|
||||
"item_code": "_Test Item",
|
||||
"item_name": "_Test Item",
|
||||
"description": "_Test Item",
|
||||
"doctype": "Sales Invoice Item",
|
||||
"parentfield": "entries",
|
||||
"qty": 1.0,
|
||||
"base_rate": 500.0,
|
||||
"base_amount": 500.0,
|
||||
"price_list_rate": 500.0,
|
||||
"amount": 500.0,
|
||||
"income_account": "Sales - _TC",
|
||||
"expense_account": "_Test Account Cost for Goods Sold - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
},
|
||||
{
|
||||
"account_head": "_Test Account VAT - _TC",
|
||||
"charge_type": "On Net Total",
|
||||
"description": "VAT",
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"rate": 16,
|
||||
},
|
||||
{
|
||||
"account_head": "_Test Account Service Tax - _TC",
|
||||
"charge_type": "On Net Total",
|
||||
"description": "Service Tax",
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"rate": 10
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"naming_series": "_T-Sales Invoice-",
|
||||
"company": "_Test Company",
|
||||
"is_pos": 0,
|
||||
"conversion_rate": 1.0,
|
||||
"currency": "INR",
|
||||
"debit_to": "_Test Customer - _TC",
|
||||
"customer": "_Test Customer",
|
||||
"customer_name": "_Test Customer",
|
||||
"doctype": "Sales Invoice",
|
||||
"due_date": "2013-01-23",
|
||||
"fiscal_year": "_Test Fiscal Year 2013",
|
||||
"grand_total_export": 0,
|
||||
"plc_conversion_rate": 1.0,
|
||||
"posting_date": "2013-01-23",
|
||||
"price_list_currency": "INR",
|
||||
"selling_price_list": "_Test Price List",
|
||||
"territory": "_Test Territory",
|
||||
},
|
||||
# items
|
||||
{
|
||||
"doctype": "Sales Invoice Item",
|
||||
"parentfield": "entries",
|
||||
"item_code": "_Test Item Home Desktop 100",
|
||||
"item_name": "_Test Item Home Desktop 100",
|
||||
"qty": 10,
|
||||
"price_list_rate": 50,
|
||||
"rate": 50,
|
||||
"stock_uom": "_Test UOM",
|
||||
"item_tax_rate": json.dumps({"_Test Account Excise Duty - _TC": 10}),
|
||||
"income_account": "Sales - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Invoice Item",
|
||||
"parentfield": "entries",
|
||||
"item_code": "_Test Item Home Desktop 200",
|
||||
"item_name": "_Test Item Home Desktop 200",
|
||||
"qty": 5,
|
||||
"price_list_rate": 150,
|
||||
"rate": 150,
|
||||
"stock_uom": "_Test UOM",
|
||||
"income_account": "Sales - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
|
||||
},
|
||||
# taxes
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "Actual",
|
||||
"account_head": "_Test Account Shipping Charges - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Shipping Charges",
|
||||
"rate": 100
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Net Total",
|
||||
"account_head": "_Test Account Customs Duty - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Customs Duty",
|
||||
"rate": 10
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Net Total",
|
||||
"account_head": "_Test Account Excise Duty - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Excise Duty",
|
||||
"rate": 12
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Previous Row Amount",
|
||||
"account_head": "_Test Account Education Cess - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Education Cess",
|
||||
"rate": 2,
|
||||
"row_id": 3
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Previous Row Amount",
|
||||
"account_head": "_Test Account S&H Education Cess - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "S&H Education Cess",
|
||||
"rate": 1,
|
||||
"row_id": 3
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Previous Row Total",
|
||||
"account_head": "_Test Account CST - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "CST",
|
||||
"rate": 2,
|
||||
"row_id": 5
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Net Total",
|
||||
"account_head": "_Test Account VAT - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "VAT",
|
||||
"rate": 12.5
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Previous Row Total",
|
||||
"account_head": "_Test Account Discount - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Discount",
|
||||
"rate": -10,
|
||||
"row_id": 7
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
"naming_series": "_T-Sales Invoice-",
|
||||
"company": "_Test Company",
|
||||
"is_pos": 0,
|
||||
"conversion_rate": 1.0,
|
||||
"currency": "INR",
|
||||
"debit_to": "_Test Customer - _TC",
|
||||
"customer": "_Test Customer",
|
||||
"customer_name": "_Test Customer",
|
||||
"doctype": "Sales Invoice",
|
||||
"due_date": "2013-01-23",
|
||||
"fiscal_year": "_Test Fiscal Year 2013",
|
||||
"grand_total_export": 0,
|
||||
"plc_conversion_rate": 1.0,
|
||||
"posting_date": "2013-01-23",
|
||||
"price_list_currency": "INR",
|
||||
"selling_price_list": "_Test Price List",
|
||||
"territory": "_Test Territory",
|
||||
},
|
||||
# items
|
||||
{
|
||||
"doctype": "Sales Invoice Item",
|
||||
"parentfield": "entries",
|
||||
"item_code": "_Test Item Home Desktop 100",
|
||||
"item_name": "_Test Item Home Desktop 100",
|
||||
"qty": 10,
|
||||
"price_list_rate": 62.5,
|
||||
"stock_uom": "_Test UOM",
|
||||
"item_tax_rate": json.dumps({"_Test Account Excise Duty - _TC": 10}),
|
||||
"income_account": "Sales - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Invoice Item",
|
||||
"parentfield": "entries",
|
||||
"item_code": "_Test Item Home Desktop 200",
|
||||
"item_name": "_Test Item Home Desktop 200",
|
||||
"qty": 5,
|
||||
"price_list_rate": 190.66,
|
||||
"stock_uom": "_Test UOM",
|
||||
"income_account": "Sales - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
|
||||
},
|
||||
# taxes
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Net Total",
|
||||
"account_head": "_Test Account Excise Duty - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Excise Duty",
|
||||
"rate": 12,
|
||||
"included_in_print_rate": 1,
|
||||
"idx": 1
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Previous Row Amount",
|
||||
"account_head": "_Test Account Education Cess - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Education Cess",
|
||||
"rate": 2,
|
||||
"row_id": 1,
|
||||
"included_in_print_rate": 1,
|
||||
"idx": 2
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Previous Row Amount",
|
||||
"account_head": "_Test Account S&H Education Cess - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "S&H Education Cess",
|
||||
"rate": 1,
|
||||
"row_id": 1,
|
||||
"included_in_print_rate": 1,
|
||||
"idx": 3
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Previous Row Total",
|
||||
"account_head": "_Test Account CST - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "CST",
|
||||
"rate": 2,
|
||||
"row_id": 3,
|
||||
"included_in_print_rate": 1,
|
||||
"idx": 4
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Net Total",
|
||||
"account_head": "_Test Account VAT - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "VAT",
|
||||
"rate": 12.5,
|
||||
"included_in_print_rate": 1,
|
||||
"idx": 5
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Net Total",
|
||||
"account_head": "_Test Account Customs Duty - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Customs Duty",
|
||||
"rate": 10,
|
||||
"idx": 6
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "Actual",
|
||||
"account_head": "_Test Account Shipping Charges - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Shipping Charges",
|
||||
"rate": 100,
|
||||
"idx": 7
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Previous Row Total",
|
||||
"account_head": "_Test Account Discount - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Discount",
|
||||
"rate": -10,
|
||||
"row_id": 7,
|
||||
"idx": 8
|
||||
},
|
||||
],
|
||||
]
|
||||
test_records = frappe.get_test_records('Sales Invoice')
|
@ -1,154 +1,6 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
test_records = [
|
||||
[
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges Master",
|
||||
"title": "_Test Sales Taxes and Charges Master",
|
||||
"company": "_Test Company"
|
||||
},
|
||||
{
|
||||
"account_head": "_Test Account VAT - _TC",
|
||||
"charge_type": "On Net Total",
|
||||
"description": "VAT",
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"rate": 6,
|
||||
},
|
||||
{
|
||||
"account_head": "_Test Account Service Tax - _TC",
|
||||
"charge_type": "On Net Total",
|
||||
"description": "Service Tax",
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"rate": 6.36,
|
||||
},
|
||||
{
|
||||
"doctype": "Applicable Territory",
|
||||
"parentfield": "valid_for_territories",
|
||||
"territory": "All Territories"
|
||||
},
|
||||
{
|
||||
"doctype": "Applicable Territory",
|
||||
"parentfield": "valid_for_territories",
|
||||
"territory": "_Test Territory Rest Of The World"
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges Master",
|
||||
"title": "_Test India Tax Master",
|
||||
"company": "_Test Company"
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "Actual",
|
||||
"account_head": "_Test Account Shipping Charges - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Shipping Charges",
|
||||
"rate": 100
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Net Total",
|
||||
"account_head": "_Test Account Customs Duty - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Customs Duty",
|
||||
"rate": 10
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Net Total",
|
||||
"account_head": "_Test Account Excise Duty - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Excise Duty",
|
||||
"rate": 12
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Previous Row Amount",
|
||||
"account_head": "_Test Account Education Cess - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Education Cess",
|
||||
"rate": 2,
|
||||
"row_id": 3
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Previous Row Amount",
|
||||
"account_head": "_Test Account S&H Education Cess - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "S&H Education Cess",
|
||||
"rate": 1,
|
||||
"row_id": 3
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Previous Row Total",
|
||||
"account_head": "_Test Account CST - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "CST",
|
||||
"rate": 2,
|
||||
"row_id": 5
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Net Total",
|
||||
"account_head": "_Test Account VAT - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "VAT",
|
||||
"rate": 12.5
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Previous Row Total",
|
||||
"account_head": "_Test Account Discount - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Discount",
|
||||
"rate": -10,
|
||||
"row_id": 7
|
||||
},
|
||||
{
|
||||
"doctype": "Applicable Territory",
|
||||
"parentfield": "valid_for_territories",
|
||||
"territory": "_Test Territory India"
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"doctype": "Sales Taxes and Charges Master",
|
||||
"title": "_Test Sales Taxes and Charges Master - Rest of the World",
|
||||
"company": "_Test Company"
|
||||
},
|
||||
{
|
||||
"account_head": "_Test Account VAT - _TC",
|
||||
"charge_type": "On Net Total",
|
||||
"description": "VAT",
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"rate": 12,
|
||||
},
|
||||
{
|
||||
"account_head": "_Test Account Service Tax - _TC",
|
||||
"charge_type": "On Net Total",
|
||||
"description": "Service Tax",
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"rate": 4,
|
||||
},
|
||||
{
|
||||
"doctype": "Applicable Territory",
|
||||
"parentfield": "valid_for_territories",
|
||||
"territory": "_Test Territory Rest Of The World"
|
||||
}
|
||||
],
|
||||
]
|
||||
|
||||
import frappe
|
||||
test_records = frappe.get_test_records('Sales Taxes And Charges Master')
|
@ -7,12 +7,12 @@ from erpnext.accounts.doctype.shipping_rule.shipping_rule import FromGreaterThan
|
||||
|
||||
class TestShippingRule(unittest.TestCase):
|
||||
def test_from_greater_than_to(self):
|
||||
shipping_rule = frappe.get_doc(copy=test_records[0])
|
||||
shipping_rule = frappe.copy_doc(test_records[0])
|
||||
shipping_rule.doclist[1].from_value = 101
|
||||
self.assertRaises(FromGreaterThanToError, shipping_rule.insert)
|
||||
|
||||
def test_many_zero_to_values(self):
|
||||
shipping_rule = frappe.get_doc(copy=test_records[0])
|
||||
shipping_rule = frappe.copy_doc(test_records[0])
|
||||
shipping_rule.doclist[1].to_value = 0
|
||||
self.assertRaises(ManyBlankToValuesError, shipping_rule.insert)
|
||||
|
||||
@ -24,120 +24,11 @@ class TestShippingRule(unittest.TestCase):
|
||||
((50, 150), (25, 175)),
|
||||
((50, 150), (50, 150)),
|
||||
]:
|
||||
shipping_rule = frappe.get_doc(copy=test_records[0])
|
||||
shipping_rule = frappe.copy_doc(test_records[0])
|
||||
shipping_rule.doclist[1].from_value = range_a[0]
|
||||
shipping_rule.doclist[1].to_value = range_a[1]
|
||||
shipping_rule.doclist[2].from_value = range_b[0]
|
||||
shipping_rule.doclist[2].to_value = range_b[1]
|
||||
self.assertRaises(OverlappingConditionError, shipping_rule.insert)
|
||||
|
||||
test_records = [
|
||||
[
|
||||
{
|
||||
"doctype": "Shipping Rule",
|
||||
"label": "_Test Shipping Rule",
|
||||
"name": "_Test Shipping Rule",
|
||||
"calculate_based_on": "Net Total",
|
||||
"company": "_Test Company",
|
||||
"account": "_Test Account Shipping Charges - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC"
|
||||
},
|
||||
{
|
||||
"doctype": "Shipping Rule Condition",
|
||||
"parentfield": "shipping_rule_conditions",
|
||||
"from_value": 0,
|
||||
"to_value": 100,
|
||||
"shipping_amount": 50.0
|
||||
},
|
||||
{
|
||||
"doctype": "Shipping Rule Condition",
|
||||
"parentfield": "shipping_rule_conditions",
|
||||
"from_value": 101,
|
||||
"to_value": 200,
|
||||
"shipping_amount": 100.0
|
||||
},
|
||||
{
|
||||
"doctype": "Shipping Rule Condition",
|
||||
"parentfield": "shipping_rule_conditions",
|
||||
"from_value": 201,
|
||||
"shipping_amount": 0.0
|
||||
},
|
||||
{
|
||||
"doctype": "Applicable Territory",
|
||||
"parentfield": "valid_for_territories",
|
||||
"territory": "_Test Territory"
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"doctype": "Shipping Rule",
|
||||
"name": "_Test Shipping Rule - India",
|
||||
"label": "_Test Shipping Rule - India",
|
||||
"calculate_based_on": "Net Total",
|
||||
"company": "_Test Company",
|
||||
"account": "_Test Account Shipping Charges - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC"
|
||||
},
|
||||
{
|
||||
"doctype": "Shipping Rule Condition",
|
||||
"parentfield": "shipping_rule_conditions",
|
||||
"from_value": 0,
|
||||
"to_value": 100,
|
||||
"shipping_amount": 50.0
|
||||
},
|
||||
{
|
||||
"doctype": "Shipping Rule Condition",
|
||||
"parentfield": "shipping_rule_conditions",
|
||||
"from_value": 101,
|
||||
"to_value": 200,
|
||||
"shipping_amount": 100.0
|
||||
},
|
||||
{
|
||||
"doctype": "Shipping Rule Condition",
|
||||
"parentfield": "shipping_rule_conditions",
|
||||
"from_value": 201,
|
||||
"shipping_amount": 0.0
|
||||
},
|
||||
{
|
||||
"doctype": "Applicable Territory",
|
||||
"parentfield": "valid_for_territories",
|
||||
"territory": "_Test Territory India"
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"doctype": "Shipping Rule",
|
||||
"name": "_Test Shipping Rule - Rest of the World",
|
||||
"label": "_Test Shipping Rule - Rest of the World",
|
||||
"calculate_based_on": "Net Total",
|
||||
"company": "_Test Company",
|
||||
"account": "_Test Account Shipping Charges - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC"
|
||||
},
|
||||
{
|
||||
"doctype": "Shipping Rule Condition",
|
||||
"parentfield": "shipping_rule_conditions",
|
||||
"from_value": 0,
|
||||
"to_value": 1000,
|
||||
"shipping_amount": 500.0
|
||||
},
|
||||
{
|
||||
"doctype": "Shipping Rule Condition",
|
||||
"parentfield": "shipping_rule_conditions",
|
||||
"from_value": 1001,
|
||||
"to_value": 2000,
|
||||
"shipping_amount": 1000.0
|
||||
},
|
||||
{
|
||||
"doctype": "Shipping Rule Condition",
|
||||
"parentfield": "shipping_rule_conditions",
|
||||
"from_value": 2001,
|
||||
"shipping_amount": 1500.0
|
||||
},
|
||||
{
|
||||
"doctype": "Applicable Territory",
|
||||
"parentfield": "valid_for_territories",
|
||||
"territory": "_Test Territory Rest Of The World"
|
||||
}
|
||||
],
|
||||
]
|
||||
test_records = frappe.get_test_records('Shipping Rule')
|
@ -138,14 +138,14 @@ def reconcile_against_document(args):
|
||||
d['against_fld'] = against_fld[d['against_voucher_type']]
|
||||
|
||||
# cancel JV
|
||||
jv_obj = frappe.get_obj('Journal Voucher', d['voucher_no'], with_children=1)
|
||||
jv_obj = frappe.get_doc('Journal Voucher', d['voucher_no'])
|
||||
jv_obj.make_gl_entries(cancel=1, adv_adj=1)
|
||||
|
||||
# update ref in JV Detail
|
||||
update_against_doc(d, jv_obj)
|
||||
|
||||
# re-submit JV
|
||||
jv_obj = frappe.get_obj('Journal Voucher', d['voucher_no'], with_children =1)
|
||||
jv_obj = frappe.get_doc('Journal Voucher', d['voucher_no'])
|
||||
jv_obj.make_gl_entries(cancel = 0, adv_adj =1)
|
||||
|
||||
|
||||
|
@ -6,7 +6,6 @@ import frappe
|
||||
|
||||
from frappe.utils import cstr, flt
|
||||
|
||||
from frappe.model.code import get_obj
|
||||
from frappe import msgprint
|
||||
|
||||
|
||||
@ -36,7 +35,7 @@ class PurchaseOrder(BuyingController):
|
||||
validate_status(self.status, ["Draft", "Submitted", "Stopped",
|
||||
"Cancelled"])
|
||||
|
||||
pc_obj = get_obj(dt='Purchase Common')
|
||||
pc_obj = frappe.get_doc(dt='Purchase Common')
|
||||
pc_obj.validate_for_items(self)
|
||||
self.check_for_stopped_status(pc_obj)
|
||||
|
||||
@ -68,7 +67,7 @@ class PurchaseOrder(BuyingController):
|
||||
d.prevdoc_detail_docname, "schedule_date")
|
||||
|
||||
def get_last_purchase_rate(self):
|
||||
get_obj('Purchase Common').get_last_purchase_rate(self)
|
||||
frappe.get_doc('Purchase Common').get_last_purchase_rate(self)
|
||||
|
||||
# Check for Stopped status
|
||||
def check_for_stopped_status(self, pc_obj):
|
||||
@ -81,7 +80,7 @@ class PurchaseOrder(BuyingController):
|
||||
|
||||
def update_bin(self, is_submit, is_stopped = 0):
|
||||
from erpnext.stock.utils import update_bin
|
||||
pc_obj = get_obj('Purchase Common')
|
||||
pc_obj = frappe.get_doc('Purchase Common')
|
||||
for d in self.get('po_details'):
|
||||
#1. Check if is_stock_item == 'Yes'
|
||||
if frappe.db.get_value("Item", d.item_code, "is_stock_item") == "Yes":
|
||||
@ -144,12 +143,12 @@ class PurchaseOrder(BuyingController):
|
||||
msgprint(self.doctype + ": " + self.name + " has been %s." % ((status == 'Submitted') and 'Unstopped' or cstr(status)))
|
||||
|
||||
def on_submit(self):
|
||||
purchase_controller = frappe.get_obj("Purchase Common")
|
||||
purchase_controller = frappe.get_doc("Purchase Common")
|
||||
|
||||
self.update_prevdoc_status()
|
||||
self.update_bin(is_submit = 1, is_stopped = 0)
|
||||
|
||||
get_obj('Authorization Control').validate_approving_authority(self.doctype,
|
||||
frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype,
|
||||
self.company, self.grand_total)
|
||||
|
||||
purchase_controller.update_last_purchase_rate(self, is_submit = 1)
|
||||
@ -157,7 +156,7 @@ class PurchaseOrder(BuyingController):
|
||||
frappe.db.set(self,'status','Submitted')
|
||||
|
||||
def on_cancel(self):
|
||||
pc_obj = get_obj(dt = 'Purchase Common')
|
||||
pc_obj = frappe.get_doc(dt = 'Purchase Common')
|
||||
self.check_for_stopped_status(pc_obj)
|
||||
|
||||
# Check if Purchase Receipt has been submitted against current Purchase Order
|
||||
|
@ -11,7 +11,7 @@ class TestPurchaseOrder(unittest.TestCase):
|
||||
def test_make_purchase_receipt(self):
|
||||
from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_receipt
|
||||
|
||||
po = frappe.get_doc(copy=test_records[0]).insert()
|
||||
po = frappe.copy_doc(test_records[0]).insert()
|
||||
|
||||
self.assertRaises(frappe.ValidationError, make_purchase_receipt,
|
||||
po.name)
|
||||
@ -34,7 +34,7 @@ class TestPurchaseOrder(unittest.TestCase):
|
||||
|
||||
from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_receipt
|
||||
|
||||
po = frappe.get_doc(copy=test_records[0]).insert()
|
||||
po = frappe.copy_doc(test_records[0]).insert()
|
||||
|
||||
self.assertRaises(frappe.ValidationError, make_purchase_receipt,
|
||||
po.name)
|
||||
@ -77,7 +77,7 @@ class TestPurchaseOrder(unittest.TestCase):
|
||||
def test_make_purchase_invoice(self):
|
||||
from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_invoice
|
||||
|
||||
po = frappe.get_doc(copy=test_records[0]).insert()
|
||||
po = frappe.copy_doc(test_records[0]).insert()
|
||||
|
||||
self.assertRaises(frappe.ValidationError, make_purchase_invoice,
|
||||
po.name)
|
||||
@ -93,58 +93,24 @@ class TestPurchaseOrder(unittest.TestCase):
|
||||
frappe.get_doc(pi).insert()
|
||||
|
||||
def test_subcontracting(self):
|
||||
po = frappe.get_doc(copy=test_records[0])
|
||||
po = frappe.copy_doc(test_records[0])
|
||||
po.insert()
|
||||
self.assertEquals(len(po.get("po_raw_material_details")), 2)
|
||||
|
||||
def test_warehouse_company_validation(self):
|
||||
from erpnext.stock.utils import InvalidWarehouseCompany
|
||||
po = frappe.get_doc(copy=test_records[0])
|
||||
po = frappe.copy_doc(test_records[0])
|
||||
po.company = "_Test Company 1"
|
||||
po.conversion_rate = 0.0167
|
||||
self.assertRaises(InvalidWarehouseCompany, po.insert)
|
||||
|
||||
def test_uom_integer_validation(self):
|
||||
from erpnext.utilities.transaction_base import UOMMustBeIntegerError
|
||||
po = frappe.get_doc(copy=test_records[0])
|
||||
po = frappe.copy_doc(test_records[0])
|
||||
po.doclist[1].qty = 3.4
|
||||
self.assertRaises(UOMMustBeIntegerError, po.insert)
|
||||
|
||||
|
||||
test_dependencies = ["BOM"]
|
||||
|
||||
test_records = [
|
||||
[
|
||||
{
|
||||
"company": "_Test Company",
|
||||
"naming_series": "_T-Purchase Order-",
|
||||
"conversion_rate": 1.0,
|
||||
"currency": "INR",
|
||||
"doctype": "Purchase Order",
|
||||
"fiscal_year": "_Test Fiscal Year 2013",
|
||||
"transaction_date": "2013-02-12",
|
||||
"is_subcontracted": "Yes",
|
||||
"supplier": "_Test Supplier",
|
||||
"supplier_name": "_Test Supplier",
|
||||
"net_total": 5000.0,
|
||||
"grand_total": 5000.0,
|
||||
"grand_total_import": 5000.0,
|
||||
"buying_price_list": "_Test Price List"
|
||||
},
|
||||
{
|
||||
"conversion_factor": 1.0,
|
||||
"description": "_Test FG Item",
|
||||
"doctype": "Purchase Order Item",
|
||||
"item_code": "_Test FG Item",
|
||||
"item_name": "_Test FG Item",
|
||||
"parentfield": "po_details",
|
||||
"qty": 10.0,
|
||||
"rate": 500.0,
|
||||
"base_amount": 5000.0,
|
||||
"warehouse": "_Test Warehouse - _TC",
|
||||
"stock_uom": "_Test UOM",
|
||||
"uom": "_Test UOM",
|
||||
"schedule_date": "2013-03-01"
|
||||
}
|
||||
],
|
||||
]
|
||||
test_records = frappe.get_test_records('Purchase Order')
|
@ -1,11 +1,6 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
test_records = [
|
||||
[{
|
||||
"doctype": "Supplier",
|
||||
"supplier_name": "_Test Supplier",
|
||||
"supplier_type": "_Test Supplier Type",
|
||||
"company": "_Test Company"
|
||||
}]
|
||||
]
|
||||
|
||||
import frappe
|
||||
test_records = frappe.get_test_records('Supplier')
|
@ -3,7 +3,6 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.code import get_obj
|
||||
|
||||
from erpnext.controllers.buying_controller import BuyingController
|
||||
class SupplierQuotation(BuyingController):
|
||||
@ -48,7 +47,7 @@ class SupplierQuotation(BuyingController):
|
||||
|
||||
|
||||
def validate_common(self):
|
||||
pc = get_obj('Purchase Common')
|
||||
pc = frappe.get_doc('Purchase Common')
|
||||
pc.validate_for_items(self)
|
||||
|
||||
@frappe.whitelist()
|
||||
|
@ -11,7 +11,7 @@ class TestPurchaseOrder(unittest.TestCase):
|
||||
def test_make_purchase_order(self):
|
||||
from erpnext.buying.doctype.supplier_quotation.supplier_quotation import make_purchase_order
|
||||
|
||||
sq = frappe.get_doc(copy=test_records[0]).insert()
|
||||
sq = frappe.copy_doc(test_records[0]).insert()
|
||||
|
||||
self.assertRaises(frappe.ValidationError, make_purchase_order,
|
||||
sq.name)
|
||||
@ -31,35 +31,4 @@ class TestPurchaseOrder(unittest.TestCase):
|
||||
|
||||
frappe.get_doc(po).insert()
|
||||
|
||||
test_records = [
|
||||
[
|
||||
{
|
||||
"company": "_Test Company",
|
||||
"conversion_rate": 1.0,
|
||||
"currency": "INR",
|
||||
"doctype": "Supplier Quotation",
|
||||
"fiscal_year": "_Test Fiscal Year 2013",
|
||||
"transaction_date": "2013-02-12",
|
||||
"is_subcontracted": "No",
|
||||
"supplier": "_Test Supplier",
|
||||
"supplier_name": "_Test Supplier",
|
||||
"net_total": 5000.0,
|
||||
"grand_total": 5000.0,
|
||||
"grand_total_import": 5000.0,
|
||||
"naming_series": "_T-Supplier Quotation-",
|
||||
"buying_price_list": "_Test Price List"
|
||||
},
|
||||
{
|
||||
"description": "_Test FG Item",
|
||||
"doctype": "Supplier Quotation Item",
|
||||
"item_code": "_Test FG Item",
|
||||
"item_name": "_Test FG Item",
|
||||
"parentfield": "quotation_items",
|
||||
"qty": 10.0,
|
||||
"rate": 500.0,
|
||||
"base_amount": 5000.0,
|
||||
"warehouse": "_Test Warehouse - _TC",
|
||||
"uom": "_Test UOM",
|
||||
}
|
||||
],
|
||||
]
|
||||
test_records = frappe.get_test_records('Supplier Quotation')
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user