mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-09 00:01:18 +00:00
fix: Debug travis
This commit is contained in:
@@ -1771,82 +1771,82 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
self.assertEqual(target_doc.company, "_Test Company 1")
|
||||
self.assertEqual(target_doc.supplier, "_Test Internal Supplier")
|
||||
|
||||
# def test_internal_transfer_gl_entry(self):
|
||||
# ## Create internal transfer account
|
||||
# account = create_account(account_name="Unrealized Profit",
|
||||
# parent_account="Current Liabilities - TCP1", company="_Test Company with perpetual inventory")
|
||||
def test_internal_transfer_gl_entry(self):
|
||||
## Create internal transfer account
|
||||
account = create_account(account_name="Unrealized Profit",
|
||||
parent_account="Current Liabilities - TCP1", company="_Test Company with perpetual inventory")
|
||||
|
||||
# frappe.db.set_value('Company', '_Test Company with perpetual inventory',
|
||||
# 'unrealized_profit_loss_account', account)
|
||||
frappe.db.set_value('Company', '_Test Company with perpetual inventory',
|
||||
'unrealized_profit_loss_account', account)
|
||||
|
||||
# customer = create_internal_customer("_Test Internal Customer 2", "_Test Company with perpetual inventory",
|
||||
# "_Test Company with perpetual inventory")
|
||||
customer = create_internal_customer("_Test Internal Customer 2", "_Test Company with perpetual inventory",
|
||||
"_Test Company with perpetual inventory")
|
||||
|
||||
# create_internal_supplier("_Test Internal Supplier 2", "_Test Company with perpetual inventory",
|
||||
# "_Test Company with perpetual inventory")
|
||||
create_internal_supplier("_Test Internal Supplier 2", "_Test Company with perpetual inventory",
|
||||
"_Test Company with perpetual inventory")
|
||||
|
||||
# si = create_sales_invoice(
|
||||
# company = "_Test Company with perpetual inventory",
|
||||
# customer = customer,
|
||||
# debit_to = "Debtors - TCP1",
|
||||
# warehouse = "Stores - TCP1",
|
||||
# income_account = "Sales - TCP1",
|
||||
# expense_account = "Cost of Goods Sold - TCP1",
|
||||
# cost_center = "Main - TCP1",
|
||||
# currency = "INR",
|
||||
# do_not_save = 1
|
||||
# )
|
||||
si = create_sales_invoice(
|
||||
company = "_Test Company with perpetual inventory",
|
||||
customer = customer,
|
||||
debit_to = "Debtors - TCP1",
|
||||
warehouse = "Stores - TCP1",
|
||||
income_account = "Sales - TCP1",
|
||||
expense_account = "Cost of Goods Sold - TCP1",
|
||||
cost_center = "Main - TCP1",
|
||||
currency = "INR",
|
||||
do_not_save = 1
|
||||
)
|
||||
|
||||
# si.selling_price_list = "_Test Price List Rest of the World"
|
||||
# si.update_stock = 1
|
||||
# si.items[0].target_warehouse = 'Work In Progress - TCP1'
|
||||
# add_taxes(si)
|
||||
# si.save()
|
||||
si.selling_price_list = "_Test Price List Rest of the World"
|
||||
si.update_stock = 1
|
||||
si.items[0].target_warehouse = 'Work In Progress - TCP1'
|
||||
add_taxes(si)
|
||||
si.save()
|
||||
|
||||
# rate = 0.0
|
||||
# for d in si.get('items'):
|
||||
# rate = get_incoming_rate({
|
||||
# "item_code": d.item_code,
|
||||
# "warehouse": d.warehouse,
|
||||
# "posting_date": si.posting_date,
|
||||
# "posting_time": si.posting_time,
|
||||
# "qty": -1 * flt(d.get('stock_qty')),
|
||||
# "serial_no": d.serial_no,
|
||||
# "company": si.company,
|
||||
# "voucher_type": 'Sales Invoice',
|
||||
# "voucher_no": si.name,
|
||||
# "allow_zero_valuation": d.get("allow_zero_valuation")
|
||||
# }, raise_error_if_no_rate=False)
|
||||
rate = 0.0
|
||||
for d in si.get('items'):
|
||||
rate = get_incoming_rate({
|
||||
"item_code": d.item_code,
|
||||
"warehouse": d.warehouse,
|
||||
"posting_date": si.posting_date,
|
||||
"posting_time": si.posting_time,
|
||||
"qty": -1 * flt(d.get('stock_qty')),
|
||||
"serial_no": d.serial_no,
|
||||
"company": si.company,
|
||||
"voucher_type": 'Sales Invoice',
|
||||
"voucher_no": si.name,
|
||||
"allow_zero_valuation": d.get("allow_zero_valuation")
|
||||
}, raise_error_if_no_rate=False)
|
||||
|
||||
# rate = flt(rate, 2)
|
||||
rate = flt(rate, 2)
|
||||
|
||||
# si.submit()
|
||||
si.submit()
|
||||
|
||||
# target_doc = make_inter_company_transaction("Sales Invoice", si.name)
|
||||
# target_doc.company = '_Test Company with perpetual inventory'
|
||||
# target_doc.items[0].warehouse = 'Finished Goods - TCP1'
|
||||
# add_taxes(target_doc)
|
||||
# target_doc.save()
|
||||
# target_doc.submit()
|
||||
target_doc = make_inter_company_transaction("Sales Invoice", si.name)
|
||||
target_doc.company = '_Test Company with perpetual inventory'
|
||||
target_doc.items[0].warehouse = 'Finished Goods - TCP1'
|
||||
add_taxes(target_doc)
|
||||
target_doc.save()
|
||||
target_doc.submit()
|
||||
|
||||
# tax_amount = flt(rate * (12/100), 2)
|
||||
# si_gl_entries = [
|
||||
# ["_Test Account Excise Duty - TCP1", 0.0, tax_amount, nowdate()],
|
||||
# ["Unrealized Profit - TCP1", tax_amount, 0.0, nowdate()]
|
||||
# ]
|
||||
tax_amount = flt(rate * (12/100), 2)
|
||||
si_gl_entries = [
|
||||
["_Test Account Excise Duty - TCP1", 0.0, tax_amount, nowdate()],
|
||||
["Unrealized Profit - TCP1", tax_amount, 0.0, nowdate()]
|
||||
]
|
||||
|
||||
# check_gl_entries(self, si.name, si_gl_entries, add_days(nowdate(), -1))
|
||||
check_gl_entries(self, si.name, si_gl_entries, add_days(nowdate(), -1))
|
||||
|
||||
# pi_gl_entries = [
|
||||
# ["_Test Account Excise Duty - TCP1", tax_amount , 0.0, nowdate()],
|
||||
# ["Unrealized Profit - TCP1", 0.0, tax_amount, nowdate()]
|
||||
# ]
|
||||
pi_gl_entries = [
|
||||
["_Test Account Excise Duty - TCP1", tax_amount , 0.0, nowdate()],
|
||||
["Unrealized Profit - TCP1", 0.0, tax_amount, nowdate()]
|
||||
]
|
||||
|
||||
# # Sale and Purchase both should be at valuation rate
|
||||
# self.assertEqual(si.items[0].rate, rate)
|
||||
# self.assertEqual(target_doc.items[0].rate, rate)
|
||||
# Sale and Purchase both should be at valuation rate
|
||||
self.assertEqual(si.items[0].rate, rate)
|
||||
self.assertEqual(target_doc.items[0].rate, rate)
|
||||
|
||||
# check_gl_entries(self, target_doc.name, pi_gl_entries, add_days(nowdate(), -1))
|
||||
check_gl_entries(self, target_doc.name, pi_gl_entries, add_days(nowdate(), -1))
|
||||
|
||||
def test_eway_bill_json(self):
|
||||
si = make_sales_invoice_for_ewaybill()
|
||||
|
||||
@@ -376,19 +376,19 @@ class update_entries_after(object):
|
||||
d.db_update()
|
||||
|
||||
def update_rate_on_delivery_and_sales_return(self, sle, outgoing_rate):
|
||||
if frappe.db.get_value(sle.voucher_type, sle.voucher_no, 'is_internal_customer'):
|
||||
frappe.db.set_value(sle.voucher_type + " Item", sle.voucher_detail_no, "rate", outgoing_rate)
|
||||
update_taxes_and_totals(sle.voucher_type, sle.voucher_no, outgoing_rate)
|
||||
# if frappe.db.get_value(sle.voucher_type, sle.voucher_no, 'is_internal_customer'):
|
||||
# frappe.db.set_value(sle.voucher_type + " Item", sle.voucher_detail_no, "rate", outgoing_rate)
|
||||
# update_taxes_and_totals(sle.voucher_type, sle.voucher_no, outgoing_rate)
|
||||
|
||||
purchase_doctype = 'Purchase Invoice' if sle.voucher_type == 'Sales Invoice' else 'Purchase Receipt'
|
||||
ref_doc_field = frappe.scrub(sle.voucher_type + ' Item')
|
||||
# purchase_doctype = 'Purchase Invoice' if sle.voucher_type == 'Sales Invoice' else 'Purchase Receipt'
|
||||
# ref_doc_field = frappe.scrub(sle.voucher_type + ' Item')
|
||||
|
||||
reference_field = 'inter_company_invoice_reference' if purchase_doctype == 'Purchase Invoice' else 'inter_company_reference'
|
||||
purchase_document_list = frappe.db.get_all(purchase_doctype, {reference_field: sle.voucher_no}, ['name'])
|
||||
# reference_field = 'inter_company_invoice_reference' if purchase_doctype == 'Purchase Invoice' else 'inter_company_reference'
|
||||
# purchase_document_list = frappe.db.get_all(purchase_doctype, {reference_field: sle.voucher_no}, ['name'])
|
||||
|
||||
for d in purchase_document_list:
|
||||
frappe.db.set_value(purchase_doctype + ' Item', {ref_doc_field: sle.voucher_detail_no}, 'rate', outgoing_rate)
|
||||
update_taxes_and_totals(purchase_doctype, d.name, outgoing_rate)
|
||||
# for d in purchase_document_list:
|
||||
# frappe.db.set_value(purchase_doctype + ' Item', {ref_doc_field: sle.voucher_detail_no}, 'rate', outgoing_rate)
|
||||
# update_taxes_and_totals(purchase_doctype, d.name, outgoing_rate)
|
||||
|
||||
# Update item's incoming rate on transaction
|
||||
item_code = frappe.db.get_value(sle.voucher_type + " Item", sle.voucher_detail_no, "item_code")
|
||||
@@ -658,12 +658,12 @@ class update_entries_after(object):
|
||||
bin_doc.flags.via_stock_ledger_entry = True
|
||||
bin_doc.save(ignore_permissions=True)
|
||||
|
||||
def update_taxes_and_totals(doctype, docname, rate):
|
||||
ref_doc = frappe.get_doc(doctype, docname)
|
||||
ref_doc.calculate_taxes_and_totals()
|
||||
ref_doc.db_update()
|
||||
for d in ref_doc.items:
|
||||
d.db_update()
|
||||
# def update_taxes_and_totals(doctype, docname, rate):
|
||||
# ref_doc = frappe.get_doc(doctype, docname)
|
||||
# ref_doc.calculate_taxes_and_totals()
|
||||
# ref_doc.db_update()
|
||||
# for d in ref_doc.items:
|
||||
# d.db_update()
|
||||
|
||||
def get_previous_sle(args, for_update=False):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user