Compare commits

...

99 Commits

Author SHA1 Message Date
Deepesh Garg
0ca433fd56 fix: Multiple fixes in payment entry 2021-08-05 13:00:07 +05:30
Deepesh Garg
80d0f432a3 fix: Multiple fixes in payment entry 2021-08-05 12:59:52 +05:30
Deepesh Garg
4c6398665b Merge branch 'version-13' of https://github.com/frappe/erpnext into enterprise-staging 2021-08-05 12:55:46 +05:30
Deepesh Garg
1cd2f36b23 fix: GL Entries for discount amount with item qty greater than 1 2021-07-28 16:41:20 +05:30
Deepesh Garg
f46f25ba53 fix: Test Cases 2021-07-22 10:44:41 +05:30
Deepesh Garg
21d918c194 fix: Tests 2021-07-22 10:44:41 +05:30
Deepesh Garg
bad69f6c39 fix: GL For taxes if discount applied on Grand Total 2021-07-22 10:44:41 +05:30
Deepesh Garg
71642c3172 fix: Syntax Error 2021-07-22 10:44:41 +05:30
GangaManoj
bf91fe985e fix: Add mandatory_depends_on property for Discount Account 2021-07-22 10:44:08 +05:30
GangaManoj
f229e62703 fix: Tests 2021-07-22 10:44:08 +05:30
GangaManoj
da72b9b840 fix: Make discount_account mandatory if discount accounting is enabled 2021-07-22 10:44:08 +05:30
GangaManoj
94c492c085 fix: Create GL Entries for Additional Discount Account 2021-07-22 10:44:08 +05:30
Ganga Manoj
bc187c4b84 fix: Filter for additional_discount_account
Co-authored-by: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com>
2021-07-22 10:44:08 +05:30
Ganga Manoj
8e108473c2 fix: Filter for additional_discount_account
Co-authored-by: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com>
2021-07-22 10:44:08 +05:30
Ganga Manoj
b965bcc6e8 fix: GL Entry creation
Co-authored-by: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com>
2021-07-22 10:44:08 +05:30
Ganga Manoj
8387613fdf fix: Use the item's project instead of the invoice's
Co-authored-by: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com>
2021-07-22 10:44:08 +05:30
Ganga Manoj
c03f8c9e3f fix: Use the item's cost centre instead of the Invoice's
Co-authored-by: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com>
2021-07-22 10:44:08 +05:30
GangaManoj
20691f0ba2 fix: Add test for additional discount applied on taxes 2021-07-22 10:44:08 +05:30
GangaManoj
3c83691353 fix: Switch debit and credit for ledger entries for discount applied on taxes for Purchase Invoice 2021-07-22 10:44:08 +05:30
GangaManoj
f1ebe4ef8b fix: Add test for additional discount applied on taxes 2021-07-22 10:44:08 +05:30
GangaManoj
86c2cf5ab9 fix: Remove unnecessary condition 2021-07-22 10:44:08 +05:30
GangaManoj
2725e61087 fix: Only display Additional Discount Account if Enable Discount Accounting is checked 2021-07-22 10:44:08 +05:30
GangaManoj
d1f1345a7f fix: Create ledger entries for discount applied on taxes in make_tax_gl_entries 2021-07-22 10:44:08 +05:30
GangaManoj
d82fd8ded1 fix: Filter options for Additional Discount Account 2021-07-22 10:44:08 +05:30
GangaManoj
def7183979 fix: Add Additional Discount Account field 2021-07-22 10:44:08 +05:30
GangaManoj
d2541caded fix: Check all expected GL Entries 2021-07-22 10:44:08 +05:30
GangaManoj
fe515321f2 fix: Sider issues 2021-07-22 10:44:08 +05:30
GangaManoj
02e7de0e45 fix: Make additional GL Entries for discount applied on taxes 2021-07-22 10:44:08 +05:30
GangaManoj
4a294bead2 fix: Only display Additional Discount Account if Enable Discount Accounting is checked 2021-07-22 10:44:08 +05:30
GangaManoj
f7c73a3069 fix: Filter options for Additional Discount Account 2021-07-22 10:44:08 +05:30
GangaManoj
e042ed69a1 fix: Add Additional Discount Account field 2021-07-22 10:44:08 +05:30
GangaManoj
8635d39865 fix: Add tests for discount accounting 2021-07-22 10:44:08 +05:30
GangaManoj
beeaf0b04a fix: Create common function for discount accounting 2021-07-22 10:44:08 +05:30
GangaManoj
96812893f1 fix: Filter options for Discount Account 2021-07-22 10:44:08 +05:30
GangaManoj
a2595a0931 fix: Copy Discount Account from first row 2021-07-22 10:44:08 +05:30
GangaManoj
509d507d6e fix: Display Discount Account only if Enable Discount Accounting is checked 2021-07-22 10:44:08 +05:30
GangaManoj
e33be287b9 fix: Add Discount Account field 2021-07-22 10:44:08 +05:30
GangaManoj
31256698a9 fix: Filter options for Default Discount Account 2021-07-22 10:44:08 +05:30
GangaManoj
78f7c92549 fix: Move Default Discount Account field to Item Defaults 2021-07-22 10:44:08 +05:30
GangaManoj
9e1de9c206 fix: Copy discount account from first row to all Items 2021-07-22 10:44:08 +05:30
GangaManoj
6fab603a23 fix: Filter Discount Account list 2021-07-22 10:44:08 +05:30
GangaManoj
fa4d314f7b fix: Add description for Enable Discount Accounting checkbox 2021-07-22 10:44:08 +05:30
GangaManoj
55690c8165 feat: Toggle display for discount accounting fields according to enable_discount_accounting 2021-07-22 10:44:08 +05:30
GangaManoj
cb65c6ce64 feat: Assign Item's Default Discount Account if present 2021-07-22 10:44:08 +05:30
GangaManoj
9871e124d0 feat: Add Default Discount Account field 2021-07-22 10:44:08 +05:30
GangaManoj
08fddac884 feat: Filter list for Discount Account field in Items table 2021-07-22 10:44:08 +05:30
GangaManoj
d1b396637c feat: Create GL Entries for discount accounting 2021-07-22 10:44:08 +05:30
GangaManoj
27bbb7002d feat(Sales Invoice): Add 'Discount Account' field in Items table 2021-07-22 10:44:08 +05:30
GangaManoj
2d7f04dd1a feat(Accounts Settings): Add 'Enable Discount Accounting' checkbox 2021-07-22 10:44:08 +05:30
Deepesh Garg
d99d56b0e8 Merge branch 'version-13' of https://github.com/frappe/erpnext into enterprise-staging 2021-07-20 11:36:36 +05:30
Deepesh Garg
958edc7b83 fix: Use update flag for company dependant fixtures 2021-07-15 19:18:54 +05:30
Deepesh Garg
2ac0a1a1a0 fix: Error on creation of company for India 2021-07-15 19:17:55 +05:30
Deepesh Garg
fd197a3aab fix: Remove unwanted changes 2021-07-14 19:50:28 +05:30
Deepesh Garg
ec5f6c78d0 fix: Add fixes in payment entry 2021-07-13 15:00:00 +05:30
Deepesh Garg
c76b4430cf fix: Unallocated amount for inclusive charges 2021-07-13 12:54:11 +05:30
Deepesh Garg
d9b6fe0d0f fix: Deduct included taxes from unallocated amount 2021-07-13 12:54:04 +05:30
Deepesh Garg
53fb5f778d Merge branch 'version-13' of https://github.com/frappe/erpnext into enterprise-staging 2021-07-13 12:17:21 +05:30
Deepesh Garg
24a25cd834 fix: Remove unintentional changes 2021-07-09 22:53:53 +05:30
Deepesh Garg
14a9ec0592 fix: Remove unintentional changes 2021-07-09 22:53:53 +05:30
Deepesh Garg
034ad28387 fix: Hide amount after tax fields 2021-07-09 22:53:52 +05:30
Deepesh Garg
904b8481cf fix: Unallocated amount in Payment Entry after taxes 2021-07-09 18:24:24 +05:30
Deepesh Garg
8230569f23 Merge pull request #26038 from deepeshgarg007/enterprise-staging-fixes
fix: Auto tax calculations in Payment Entry
2021-06-14 11:24:30 +05:30
Deepesh Garg
098a833424 fix: Auto tax calculations in Payment Entry 2021-06-14 11:21:27 +05:30
Deepesh Garg
dad6a596eb Merge pull request #26002 from deepeshgarg007/update_staging_v2
Update staging v2
2021-06-10 13:29:28 +05:30
Deepesh Garg
bcbb1c68b4 fix: GL Entry ordering 2021-06-10 13:17:55 +05:30
Deepesh Garg
1e898c0f5b fix: Failing test case 2021-06-10 13:17:55 +05:30
Deepesh Garg
88c0cd6f7a fix: Add multiple fixes 2021-06-10 13:17:55 +05:30
Deepesh Garg
2924ff830e fix: Test case 2021-06-10 13:17:55 +05:30
Deepesh Garg
bc490e246e fix: Debug tests 2021-06-10 13:17:27 +05:30
Deepesh Garg
60de73b904 fix: Debug test 2021-06-10 13:17:27 +05:30
Deepesh Garg
af13348817 refactor: Advance taxes and charges calculation 2021-06-10 13:17:02 +05:30
Deepesh Garg
16b309e66e fix: Labeling and other fixes 2021-06-10 13:16:52 +05:30
Deepesh Garg
12fb02ed2a fix: Remove GL Entry from print 2021-06-10 13:16:51 +05:30
Deepesh Garg
223efec26e fix: Split GL Entry 2021-06-10 13:16:51 +05:30
Deepesh Garg
10e8316240 fix: Debug Test 2021-06-10 13:16:51 +05:30
Deepesh Garg
8106d70e70 fix: Update GL Entry ordering 2021-06-10 13:16:51 +05:30
Deepesh Garg
c368c5b20b fix: Create new supplier for test case 2021-06-10 13:16:51 +05:30
Deepesh Garg
b45d90153c fix: Add non group filter for account 2021-06-10 13:16:51 +05:30
Deepesh Garg
bb22972708 Merge pull request #25843 from anupamvs/enterprise-timesheet-changes
refactor: timesheet
2021-05-26 15:28:37 +05:30
Rucha Mahabal
6ac69672f2 refactor: timesheet 2021-05-26 13:55:44 +05:30
Deepesh Garg
34997ae7c5 Merge pull request #25835 from deepeshgarg007/tax_advance_staging
feat: Tax application on advances
2021-05-25 23:01:46 +05:30
Deepesh Garg
3e29361549 fix: Update TDS rate for test 2021-05-25 22:44:57 +05:30
Deepesh Garg
39a7a4f0ea fix: Remove unwanted commits 2021-05-25 22:44:57 +05:30
Deepesh Garg
f9656ed790 fix: Linting Issues 2021-05-25 22:44:56 +05:30
Deepesh Garg
c5a43a59e0 fix: Linting issues 2021-05-25 22:44:56 +05:30
Deepesh Garg
f5f883b6a0 fix: Uncommentt test 2021-05-25 22:44:55 +05:30
Deepesh Garg
390bafef08 fix: Linting and other fixes 2021-05-25 22:44:55 +05:30
Deepesh Garg
342d0d1bbb chore: Test case for adance TDS allocation 2021-05-25 22:44:54 +05:30
Deepesh Garg
e6be20a94d fix: Allocate advance taxes only for payment entry 2021-05-25 22:44:54 +05:30
Deepesh Garg
25b3507809 fix: Linting fixes and other checks 2021-05-25 22:44:53 +05:30
Deepesh Garg
0a9a4d5f88 fix: Test Cases 2021-05-25 22:44:53 +05:30
Deepesh Garg
d66559b6e4 fix: Linting errors 2021-05-25 22:44:53 +05:30
Deepesh Garg
e16a632edb fix: TDS report cleanup 2021-05-25 22:44:52 +05:30
Deepesh Garg
ccd0237ae8 fix: Advance TDS in TDS payable monthly report 2021-05-25 22:44:52 +05:30
Deepesh Garg
e93ed7d324 fix: Add tds in PO and code cleanup 2021-05-25 22:44:51 +05:30
Deepesh Garg
ec2d4c41d6 fix: TDS against Purhase Orders 2021-05-25 22:44:51 +05:30
Deepesh Garg
15a89f83c3 feat: Tax deduction against advance payments 2021-05-25 22:44:50 +05:30
Deepesh Garg
de03bc2cb3 feat: Tax deduction against advance payments 2021-05-25 22:44:50 +05:30
Deepesh Garg
4367f1c4b6 Merge pull request #25820 from deepeshgarg007/update-staging
chore: Update branch
2021-05-25 11:28:28 +05:30
21 changed files with 936 additions and 629 deletions

View File

@@ -19,6 +19,7 @@
"book_asset_depreciation_entry_automatically",
"unlink_advance_payment_on_cancelation_of_order",
"post_change_gl_entries",
"enable_discount_accounting",
"tax_settings_section",
"determine_address_tax_category_from",
"column_break_19",
@@ -261,6 +262,13 @@
"fieldname": "post_change_gl_entries",
"fieldtype": "Check",
"label": "Create Ledger Entries for Change Amount"
},
{
"default": "0",
"description": "If enabled, additional ledger entries will be made for discounts in a separate Discount Account",
"fieldname": "enable_discount_accounting",
"fieldtype": "Check",
"label": "Enable Discount Accounting"
}
],
"icon": "icon-cog",
@@ -268,7 +276,7 @@
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2021-06-17 20:26:03.721202",
"modified": "2021-07-12 18:54:29.084958",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Accounts Settings",

View File

@@ -21,6 +21,7 @@ class AccountsSettings(Document):
self.validate_stale_days()
self.enable_payment_schedule_in_print()
self.toggle_discount_accounting_fields()
def validate_stale_days(self):
if not self.allow_stale and cint(self.stale_days) <= 0:
@@ -33,3 +34,22 @@ class AccountsSettings(Document):
for doctype in ("Sales Order", "Sales Invoice", "Purchase Order", "Purchase Invoice"):
make_property_setter(doctype, "due_date", "print_hide", show_in_print, "Check", validate_fields_for_doctype=False)
make_property_setter(doctype, "payment_schedule", "print_hide", 0 if show_in_print else 1, "Check", validate_fields_for_doctype=False)
def toggle_discount_accounting_fields(self):
enable_discount_accounting = cint(self.enable_discount_accounting)
for doctype in ["Sales Invoice Item", "Purchase Invoice Item"]:
make_property_setter(doctype, "discount_account", "hidden", not(enable_discount_accounting), "Check", validate_fields_for_doctype=False)
if enable_discount_accounting:
make_property_setter(doctype, "discount_account", "mandatory_depends_on", "eval: doc.discount_amount", "Code", validate_fields_for_doctype=False)
else:
make_property_setter(doctype, "discount_account", "mandatory_depends_on", "", "Code", validate_fields_for_doctype=False)
for doctype in ["Sales Invoice", "Purchase Invoice"]:
make_property_setter(doctype, "additional_discount_account", "hidden", not(enable_discount_accounting), "Check", validate_fields_for_doctype=False)
if enable_discount_accounting:
make_property_setter(doctype, "additional_discount_account", "mandatory_depends_on", "eval: doc.discount_amount", "Code", validate_fields_for_doctype=False)
else:
make_property_setter(doctype, "additional_discount_account", "mandatory_depends_on", "", "Code", validate_fields_for_doctype=False)
make_property_setter("Item", "default_discount_account", "hidden", not(enable_discount_accounting), "Check", validate_fields_for_doctype=False)

View File

@@ -531,8 +531,8 @@ frappe.ui.form.on('Payment Entry', {
source_exchange_rate: function(frm) {
if (frm.doc.paid_amount) {
frm.set_value("base_paid_amount", flt(frm.doc.paid_amount) * flt(frm.doc.source_exchange_rate));
if(!frm.set_paid_amount_based_on_received_amount &&
(frm.doc.paid_from_account_currency == frm.doc.paid_to_account_currency)) {
// target exchange rate should always be same as source if both account currencies is same
if(frm.doc.paid_from_account_currency == frm.doc.paid_to_account_currency) {
frm.set_value("target_exchange_rate", frm.doc.source_exchange_rate);
frm.set_value("base_received_amount", frm.doc.base_paid_amount);
}

View File

@@ -691,7 +691,7 @@
"options": "Account"
},
{
"depends_on": "eval:doc.received_amount && doc.payment_type != 'Internal Transfer'",
"depends_on": "eval:doc.received_amount",
"fieldname": "received_amount_after_tax",
"fieldtype": "Currency",
"hidden": 1,

View File

@@ -45,7 +45,7 @@ class PaymentEntry(AccountsController):
self.party_account = self.paid_to
self.party_account_currency = self.paid_to_account_currency
def validate(self):
def validate(self, on_reference_unlink=False):
self.setup_party_account_field()
self.set_missing_values()
self.validate_payment_type()
@@ -55,16 +55,18 @@ class PaymentEntry(AccountsController):
self.validate_mandatory()
self.validate_reference_documents()
self.set_tax_withholding()
self.apply_taxes()
self.set_amounts()
self.validate_amounts()
self.apply_taxes()
self.clear_unallocated_reference_document_rows()
self.validate_payment_against_negative_invoice()
self.validate_transaction_reference()
self.set_title()
self.set_remarks()
self.validate_duplicate_entry()
self.validate_allocated_amount()
self.validate_paid_invoices()
if not on_reference_unlink:
self.validate_allocated_amount()
self.validate_paid_invoices()
self.ensure_supplier_is_not_blocked()
self.set_status()
@@ -236,7 +238,9 @@ class PaymentEntry(AccountsController):
self.company_currency, self.posting_date)
def set_target_exchange_rate(self, ref_doc=None):
if self.paid_to and not self.target_exchange_rate:
if self.paid_from_account_currency == self.paid_to_account_currency:
self.target_exchange_rate = self.source_exchange_rate
elif self.paid_to and not self.target_exchange_rate:
if ref_doc:
if self.paid_to_account_currency == ref_doc.currency:
self.target_exchange_rate = ref_doc.get("exchange_rate")
@@ -473,6 +477,14 @@ class PaymentEntry(AccountsController):
self.set_unallocated_amount()
self.set_difference_amount()
def validate_amounts(self):
self.validate_received_amount()
def validate_received_amount(self):
if self.paid_from_account_currency == self.paid_to_account_currency:
if self.paid_amount != self.received_amount:
frappe.throw(_("Received Amount cannot be greater than Paid Amount"))
def set_received_amount(self):
self.base_received_amount = self.base_paid_amount
@@ -518,8 +530,10 @@ class PaymentEntry(AccountsController):
base_total_allocated_amount += flt(flt(d.allocated_amount) * flt(d.exchange_rate),
self.precision("base_paid_amount"))
self.total_allocated_amount = abs(total_allocated_amount)
self.base_total_allocated_amount = abs(base_total_allocated_amount)
# Do not use absolute values as only credit notes could be allocated
# and total allocated should be negative in that scenario
self.total_allocated_amount = total_allocated_amount
self.base_total_allocated_amount = base_total_allocated_amount
def set_unallocated_amount(self):
self.unallocated_amount = 0

View File

@@ -365,7 +365,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
items_add: function(doc, cdt, cdn) {
var row = frappe.get_doc(cdt, cdn);
this.frm.script_manager.copy_from_first_row("items", row,
["expense_account", "cost_center", "project"]);
["expense_account", "discount_account", "cost_center", "project"]);
},
on_submit: function() {
@@ -499,6 +499,16 @@ frappe.ui.form.on("Purchase Invoice", {
'Payment Entry': 'Payment'
}
frm.set_query("additional_discount_account", function() {
return {
filters: {
company: frm.doc.company,
is_group: 0,
report_type: "Profit and Loss",
}
};
});
frm.fields_dict['items'].grid.get_field('deferred_expense_account').get_query = function(doc) {
return {
filters: {
@@ -508,6 +518,16 @@ frappe.ui.form.on("Purchase Invoice", {
}
}
}
frm.fields_dict['items'].grid.get_field('discount_account').get_query = function(doc) {
return {
filters: {
'report_type': 'Profit and Loss',
'company': doc.company,
"is_group": 0
}
}
}
},
refresh: function(frm) {

View File

@@ -446,6 +446,7 @@ class PurchaseInvoice(BuyingController):
self.make_supplier_gl_entry(gl_entries)
self.make_item_gl_entries(gl_entries)
self.make_discount_gl_entries(gl_entries)
if self.check_asset_cwip_enabled():
self.get_asset_gl_entry(gl_entries)
@@ -608,7 +609,11 @@ class PurchaseInvoice(BuyingController):
if (not item.enable_deferred_expense or self.is_return) else item.deferred_expense_account)
if not item.is_fixed_asset:
amount = flt(item.base_net_amount, item.precision("base_net_amount"))
if frappe.db.get_single_value('Accounts Settings', 'enable_discount_accounting'):
amount = flt(item.base_amount, item.precision("base_amount"))
else:
amount = flt(item.base_net_amount, item.precision("base_net_amount"))
else:
amount = flt(item.base_net_amount + item.item_tax_amount, item.precision("base_net_amount"))

View File

@@ -230,6 +230,48 @@ class TestPurchaseInvoice(unittest.TestCase):
self.assertEqual(expected_values[gle.account][1], gle.debit)
self.assertEqual(expected_values[gle.account][2], gle.credit)
def test_purchase_invoice_with_discount_accounting_enabled(self):
enable_discount_accounting()
discount_account = create_account(account_name="Discount Account",
parent_account="Indirect Expenses - _TC", company="_Test Company")
pi = make_purchase_invoice(discount_account=discount_account, discount_amount=100)
expected_gle = [
["_Test Account Cost for Goods Sold - _TC", 350.0, 0.0, nowdate()],
["Creditors - _TC", 0.0, 250.0, nowdate()],
["Discount Account - _TC", 0.0, 100.0, nowdate()]
]
check_gl_entries(self, pi.name, expected_gle, nowdate())
def test_additional_discount_for_purchase_invoice_with_discount_accounting_enabled(self):
enable_discount_accounting()
additional_discount_account = create_account(account_name="Discount Account",
parent_account="Indirect Expenses - _TC", company="_Test Company")
pi = make_purchase_invoice(qty=1, rate=100, do_not_save=1, parent_cost_center="Main - _TC")
pi.apply_discount_on = "Grand Total"
pi.additional_discount_account = additional_discount_account
pi.additional_discount_percentage = 20
pi.append("taxes", {
"charge_type": "Actual",
"account_head": "_Test Account VAT - _TC",
"cost_center": "Main - _TC",
"description": "Test",
"tax_amount": 20
})
pi.submit()
expected_gle = [
["_Test Account Cost for Goods Sold - _TC", 100.0, 0.0, nowdate()],
["_Test Account VAT - _TC", 20.0, 0.0, nowdate()],
["Creditors - _TC", 0.0, 96.0, nowdate()],
["Discount Account - _TC", 0.0, 24.0, nowdate()]
]
check_gl_entries(self, pi.name, expected_gle, nowdate())
def test_purchase_invoice_change_naming_series(self):
pi = frappe.copy_doc(test_records[1])
pi.insert()
@@ -1140,6 +1182,18 @@ class TestPurchaseInvoice(unittest.TestCase):
self.assertEqual(expected_gle[i][0], gle.account)
self.assertEqual(expected_gle[i][1], gle.amount)
def check_gl_entries(doc, voucher_no, expected_gle, posting_date):
gl_entries = frappe.db.sql("""select account, debit, credit, posting_date
from `tabGL Entry`
where voucher_type='Purchase Invoice' and voucher_no=%s and posting_date >= %s
order by posting_date asc, account asc""", (voucher_no, posting_date), as_dict=1)
for i, gle in enumerate(gl_entries):
doc.assertEqual(expected_gle[i][0], gle.account)
doc.assertEqual(expected_gle[i][1], gle.debit)
doc.assertEqual(expected_gle[i][2], gle.credit)
doc.assertEqual(getdate(expected_gle[i][3]), gle.posting_date)
def update_tax_witholding_category(company, account, date):
from erpnext.accounts.utils import get_fiscal_year
@@ -1170,6 +1224,11 @@ def unlink_payment_on_cancel_of_invoice(enable=1):
accounts_settings.unlink_payment_on_cancellation_of_invoice = enable
accounts_settings.save()
def enable_discount_accounting(enable=1):
accounts_settings = frappe.get_doc("Accounts Settings")
accounts_settings.enable_discount_accounting = enable
accounts_settings.save()
def make_purchase_invoice(**args):
pi = frappe.new_doc("Purchase Invoice")
args = frappe._dict(args)
@@ -1192,6 +1251,7 @@ def make_purchase_invoice(**args):
pi.return_against = args.return_against
pi.is_subcontracted = args.is_subcontracted or "No"
pi.supplier_warehouse = args.supplier_warehouse or "_Test Warehouse 1 - _TC"
pi.cost_center = args.parent_cost_center
pi.append("items", {
"item_code": args.item or args.item_code or "_Test Item",
@@ -1200,7 +1260,9 @@ def make_purchase_invoice(**args):
"received_qty": args.received_qty or 0,
"rejected_qty": args.rejected_qty or 0,
"rate": args.rate or 50,
'expense_account': args.expense_account or '_Test Account Cost for Goods Sold - _TC',
"expense_account": args.expense_account or '_Test Account Cost for Goods Sold - _TC',
"discount_account": args.discount_account or None,
"discount_amount": args.discount_amount or 0,
"conversion_factor": 1.0,
"serial_no": args.serial_no,
"stock_uom": args.uom or "_Test UOM",

View File

@@ -73,6 +73,7 @@
"manufacturer_part_no",
"accounting",
"expense_account",
"discount_account",
"col_break5",
"is_fixed_asset",
"asset_location",
@@ -849,12 +850,18 @@
"options": "Company:company:default_currency",
"print_hide": 1,
"read_only": 1
},
{
"fieldname": "discount_account",
"fieldtype": "Link",
"label": "Discount Account",
"options": "Account"
}
],
"idx": 1,
"istable": 1,
"links": [],
"modified": "2021-06-16 19:57:03.101571",
"modified": "2021-07-13 02:04:37.787882",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice Item",

View File

@@ -347,7 +347,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
items_add: function(doc, cdt, cdn) {
var row = frappe.get_doc(cdt, cdn);
this.frm.script_manager.copy_from_first_row("items", row, ["income_account", "cost_center"]);
this.frm.script_manager.copy_from_first_row("items", row, ["income_account", "discount_account", "cost_center"]);
},
set_dynamic_labels: function() {
@@ -510,7 +510,6 @@ cur_frm.set_query("income_account", "items", function(doc) {
}
});
// Cost Center in Details Table
// -----------------------------
cur_frm.fields_dict["items"].grid.get_field("cost_center").get_query = function(doc) {
@@ -592,6 +591,16 @@ frappe.ui.form.on('Sales Invoice', {
};
});
frm.set_query("additional_discount_account", function() {
return {
filters: {
company: frm.doc.company,
is_group: 0,
report_type: "Profit and Loss",
}
};
});
frm.custom_make_buttons = {
'Delivery Note': 'Delivery',
'Sales Invoice': 'Return / Credit Note',
@@ -618,6 +627,17 @@ frappe.ui.form.on('Sales Invoice', {
}
}
// discount account
frm.fields_dict['items'].grid.get_field('discount_account').get_query = function(doc) {
return {
filters: {
'report_type': 'Profit and Loss',
'company': doc.company,
"is_group": 0
}
}
}
frm.fields_dict['items'].grid.get_field('deferred_revenue_account').get_query = function(doc) {
return {
filters: {

View File

@@ -104,6 +104,7 @@
"section_break_49",
"apply_discount_on",
"base_discount_amount",
"additional_discount_account",
"column_break_51",
"additional_discount_percentage",
"discount_amount",
@@ -1966,6 +1967,12 @@
"fieldname": "disable_rounded_total",
"fieldtype": "Check",
"label": "Disable Rounded Total"
},
{
"fieldname": "additional_discount_account",
"fieldtype": "Link",
"label": "Additional Discount Account",
"options": "Account"
}
],
"icon": "fa fa-file-text",
@@ -1978,7 +1985,7 @@
"link_fieldname": "consolidated_invoice"
}
],
"modified": "2021-05-20 22:48:33.988881",
"modified": "2021-07-15 21:57:17.544279",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice",

View File

@@ -846,6 +846,7 @@ class SalesInvoice(SellingController):
self.allocate_advance_taxes(gl_entries)
self.make_item_gl_entries(gl_entries)
self.make_discount_gl_entries(gl_entries)
# merge gl entries before adding pos entries
gl_entries = merge_similar_entries(gl_entries)
@@ -885,18 +886,22 @@ class SalesInvoice(SellingController):
)
def make_tax_gl_entries(self, gl_entries):
enable_discount_accounting = cint(frappe.db.get_single_value('Accounts Settings', 'enable_discount_accounting'))
for tax in self.get("taxes"):
amount, base_amount = self.get_tax_amounts(tax, enable_discount_accounting)
if flt(tax.base_tax_amount_after_discount_amount):
account_currency = get_account_currency(tax.account_head)
gl_entries.append(
self.get_gl_dict({
"account": tax.account_head,
"against": self.customer,
"credit": flt(tax.base_tax_amount_after_discount_amount,
"credit": flt(base_amount,
tax.precision("tax_amount_after_discount_amount")),
"credit_in_account_currency": (flt(tax.base_tax_amount_after_discount_amount,
"credit_in_account_currency": (flt(base_amount,
tax.precision("base_tax_amount_after_discount_amount")) if account_currency==self.company_currency else
flt(tax.tax_amount_after_discount_amount, tax.precision("tax_amount_after_discount_amount"))),
flt(amount, tax.precision("tax_amount_after_discount_amount"))),
"cost_center": tax.cost_center
}, account_currency, item=tax)
)
@@ -915,6 +920,8 @@ class SalesInvoice(SellingController):
def make_item_gl_entries(self, gl_entries):
# income account gl entries
enable_discount_accounting = cint(frappe.db.get_single_value('Accounts Settings', 'enable_discount_accounting'))
for item in self.get("items"):
if flt(item.base_net_amount, item.precision("base_net_amount")):
if item.is_fixed_asset:
@@ -940,15 +947,17 @@ class SalesInvoice(SellingController):
income_account = (item.income_account
if (not item.enable_deferred_revenue or self.is_return) else item.deferred_revenue_account)
amount, base_amount = self.get_amount_and_base_amount(item, enable_discount_accounting)
account_currency = get_account_currency(income_account)
gl_entries.append(
self.get_gl_dict({
"account": income_account,
"against": self.customer,
"credit": flt(item.base_net_amount, item.precision("base_net_amount")),
"credit_in_account_currency": (flt(item.base_net_amount, item.precision("base_net_amount"))
"credit": flt(base_amount, item.precision("base_net_amount")),
"credit_in_account_currency": (flt(base_amount, item.precision("base_net_amount"))
if account_currency==self.company_currency
else flt(item.net_amount, item.precision("net_amount"))),
else flt(amount, item.precision("net_amount"))),
"cost_center": item.cost_center,
"project": item.project or self.project
}, account_currency, item=item)
@@ -959,6 +968,12 @@ class SalesInvoice(SellingController):
erpnext.is_perpetual_inventory_enabled(self.company):
gl_entries += super(SalesInvoice, self).get_gl_entries()
def set_asset_status(self, asset):
if self.is_return:
asset.set_status()
else:
asset.set_status("Sold" if self.docstatus==1 else None)
def make_loyalty_point_redemption_gle(self, gl_entries):
if cint(self.redeem_loyalty_points):
gl_entries.append(

View File

@@ -1984,6 +1984,53 @@ class TestSalesInvoice(unittest.TestCase):
sales_invoice.save()
self.assertEqual(sales_invoice.items[0].item_tax_template, "_Test Account Excise Duty @ 10 - _TC")
def test_sales_invoice_with_discount_accounting_enabled(self):
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import enable_discount_accounting
enable_discount_accounting()
discount_account = create_account(account_name="Discount Account",
parent_account="Indirect Expenses - _TC", company="_Test Company")
si = create_sales_invoice(discount_account=discount_account, discount_amount=100)
expected_gle = [
["Debtors - _TC", 100.0, 0.0, nowdate()],
["Discount Account - _TC", 100.0, 0.0, nowdate()],
["Sales - _TC", 0.0, 200.0, nowdate()]
]
check_gl_entries(self, si.name, expected_gle, add_days(nowdate(), -1))
def test_additional_discount_for_sales_invoice_with_discount_accounting_enabled(self):
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import enable_discount_accounting
enable_discount_accounting()
additional_discount_account = create_account(account_name="Discount Account",
parent_account="Indirect Expenses - _TC", company="_Test Company")
si = create_sales_invoice(rate=100, parent_cost_center='Main - _TC', do_not_save=1)
si.apply_discount_on = "Grand Total"
si.additional_discount_account = additional_discount_account
si.additional_discount_percentage = 20
si.append("taxes", {
"charge_type": "Actual",
"account_head": "_Test Account VAT - _TC",
"cost_center": "Main - _TC",
"description": "Test",
"rate": 0,
"tax_amount": 20
})
si.submit()
expected_gle = [
["_Test Account VAT - _TC", 0.0, 20.0, nowdate()],
["Debtors - _TC", 96.0, 0.0, nowdate()],
["Discount Account - _TC", 24.0, 0.0, nowdate()],
["Sales - _TC", 0.0, 100.0, nowdate()]
]
check_gl_entries(self, si.name, expected_gle, add_days(nowdate(), -1))
def get_sales_invoice_for_e_invoice():
si = make_sales_invoice_for_ewaybill()
si.naming_series = 'INV-2020-.#####'
@@ -2152,6 +2199,7 @@ def create_sales_invoice(**args):
si.currency=args.currency or "INR"
si.conversion_rate = args.conversion_rate or 1
si.naming_series = args.naming_series or "T-SINV-"
si.cost_center = args.parent_cost_center
si.append("items", {
"item_code": args.item or args.item_code or "_Test Item",
@@ -2165,6 +2213,8 @@ def create_sales_invoice(**args):
"rate": args.rate if args.get("rate") is not None else 100,
"income_account": args.income_account or "Sales - _TC",
"expense_account": args.expense_account or "Cost of Goods Sold - _TC",
"discount_account": args.discount_account or None,
"discount_amount": args.discount_amount or 0,
"cost_center": args.cost_center or "_Test Cost Center - _TC",
"serial_no": args.serial_no,
"conversion_factor": 1

View File

@@ -63,6 +63,7 @@
"finance_book",
"col_break4",
"expense_account",
"discount_account",
"deferred_revenue",
"deferred_revenue_account",
"service_stop_date",
@@ -821,12 +822,18 @@
"no_copy": 1,
"options": "currency",
"read_only": 1
},
{
"fieldname": "discount_account",
"fieldtype": "Link",
"label": "Discount Account",
"options": "Account"
}
],
"idx": 1,
"istable": 1,
"links": [],
"modified": "2021-02-23 01:05:22.123527",
"modified": "2021-07-05 15:07:22.857128",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice Item",

View File

@@ -553,10 +553,14 @@ def remove_ref_doc_link_from_pe(ref_type, ref_no):
and docstatus < 2""", (now(), frappe.session.user, ref_type, ref_no))
for pe in linked_pe:
pe_doc = frappe.get_doc("Payment Entry", pe)
pe_doc.set_total_allocated_amount()
pe_doc.set_unallocated_amount()
pe_doc.clear_unallocated_reference_document_rows()
try:
pe_doc = frappe.get_doc("Payment Entry", pe)
pe_doc.validate(on_reference_unlink=True)
except Exception as e:
msg = _("There were issues unlinking payment entry {0}.").format(pe_doc.name)
msg += '<br>'
msg += _("Please cancel payment entry manually first and then resubmit")
frappe.throw(msg, title=_("Payment Unlink Error"))
frappe.db.sql("""update `tabPayment Entry` set total_allocated_amount=%s,
base_total_allocated_amount=%s, unallocated_amount=%s, modified=%s, modified_by=%s

View File

@@ -813,6 +813,89 @@ class AccountsController(TransactionBase):
tax_map[tax.account_head] -= allocated_amount
allocated_tax_map[tax.account_head] -= allocated_amount
def get_amount_and_base_amount(self, item, enable_discount_accounting):
amount = item.net_amount
base_amount = item.base_net_amount
if enable_discount_accounting and self.get('discount_amount') and self.get('additional_discount_account'):
amount = item.amount
base_amount = item.base_amount
return amount, base_amount
def get_tax_amounts(self, tax, enable_discount_accounting):
amount = tax.tax_amount_after_discount_amount
base_amount = tax.base_tax_amount_after_discount_amount
if enable_discount_accounting and self.get('discount_amount') and self.get('additional_discount_account') \
and self.get('apply_discount_on') == 'Grand Total':
amount = tax.tax_amount
base_amount = tax.base_tax_amount
return amount, base_amount
def make_discount_gl_entries(self, gl_entries):
enable_discount_accounting = cint(frappe.db.get_single_value('Accounts Settings', 'enable_discount_accounting'))
if enable_discount_accounting:
if self.doctype == "Purchase Invoice":
dr_or_cr = "credit"
rev_dr_cr = "debit"
supplier_or_customer = self.supplier
else:
dr_or_cr = "debit"
rev_dr_cr = "credit"
supplier_or_customer = self.customer
for item in self.get("items"):
if item.get('discount_amount') and item.get('discount_account'):
discount_amount = item.discount_amount * item.qty
if self.doctype == "Purchase Invoice":
income_or_expense_account = (item.expense_account
if (not item.enable_deferred_expense or self.is_return)
else item.deferred_expense_account)
else:
income_or_expense_account = (item.income_account
if (not item.enable_deferred_revenue or self.is_return)
else item.deferred_revenue_account)
account_currency = get_account_currency(item.discount_account)
gl_entries.append(
self.get_gl_dict({
"account": item.discount_account,
"against": supplier_or_customer,
dr_or_cr: flt(discount_amount, item.precision('discount_amount')),
dr_or_cr + "_in_account_currency": flt(discount_amount * self.get('conversion_rate'),
item.precision('discount_amount')),
"cost_center": item.cost_center,
"project": item.project
}, account_currency, item=item)
)
account_currency = get_account_currency(income_or_expense_account)
gl_entries.append(
self.get_gl_dict({
"account": income_or_expense_account,
"against": supplier_or_customer,
rev_dr_cr: flt(discount_amount, item.precision('discount_amount')),
rev_dr_cr + "_in_account_currency": flt(discount_amount * self.get('conversion_rate'),
item.precision('discount_amount')),
"cost_center": item.cost_center,
"project": item.project or self.project
}, account_currency, item=item)
)
if self.get('discount_amount') and self.get('additional_discount_account'):
gl_entries.append(
self.get_gl_dict({
"account": self.additional_discount_account,
"against": supplier_or_customer,
dr_or_cr: self.discount_amount,
"cost_center": self.cost_center
}, item=self)
)
def allocate_advance_taxes(self, gl_entries):
tax_map = self.get_tax_map()
for pe in self.get("advances"):

View File

@@ -274,6 +274,17 @@ $.extend(erpnext.item, {
}
}
frm.fields_dict["item_defaults"].grid.get_field("default_discount_account").get_query = function(doc, cdt, cdn) {
const row = locals[cdt][cdn];
return {
filters: {
'report_type': 'Profit and Loss',
'company': row.company,
"is_group": 0
}
};
};
frm.fields_dict["item_defaults"].grid.get_field("buying_cost_center").get_query = function(doc, cdt, cdn) {
const row = locals[cdt][cdn];
return {

View File

@@ -1067,7 +1067,7 @@
"index_web_pages_for_search": 1,
"links": [],
"max_attachments": 1,
"modified": "2021-03-18 14:04:38.575519",
"modified": "2021-07-13 01:29:06.071827",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item",
@@ -1138,4 +1138,4 @@
"sort_order": "DESC",
"title_field": "item_name",
"track_changes": 1
}
}

View File

@@ -1,464 +1,118 @@
{
"allow_copy": 0,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
"beta": 0,
"creation": "2018-05-03 02:29:24.444341",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "",
"editable_grid": 1,
"engine": "InnoDB",
"actions": [],
"creation": "2018-05-03 02:29:24.444341",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"company",
"default_warehouse",
"column_break_3",
"default_price_list",
"default_discount_account",
"purchase_defaults",
"buying_cost_center",
"default_supplier",
"column_break_8",
"expense_account",
"selling_defaults",
"selling_cost_center",
"column_break_12",
"income_account"
],
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "company",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 1,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Company",
"length": 0,
"no_copy": 0,
"options": "Company",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "company",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"in_list_view": 1,
"label": "Company",
"options": "Company",
"reqd": 1
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "default_warehouse",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Default Warehouse",
"length": 0,
"no_copy": 0,
"options": "Warehouse",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "default_warehouse",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Default Warehouse",
"options": "Warehouse"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_3",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "column_break_3",
"fieldtype": "Column Break"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "default_price_list",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Default Price List",
"length": 0,
"no_copy": 0,
"options": "Price List",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "default_price_list",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Default Price List",
"options": "Price List"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "purchase_defaults",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Purchase Defaults",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "purchase_defaults",
"fieldtype": "Section Break",
"label": "Purchase Defaults"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "buying_cost_center",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Default Buying Cost Center",
"length": 0,
"no_copy": 0,
"options": "Cost Center",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "buying_cost_center",
"fieldtype": "Link",
"label": "Default Buying Cost Center",
"options": "Cost Center"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "default_supplier",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Default Supplier",
"length": 0,
"no_copy": 0,
"options": "Supplier",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "default_supplier",
"fieldtype": "Link",
"label": "Default Supplier",
"options": "Supplier"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_8",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "column_break_8",
"fieldtype": "Column Break"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "expense_account",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Default Expense Account",
"length": 0,
"no_copy": 0,
"options": "Account",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "expense_account",
"fieldtype": "Link",
"label": "Default Expense Account",
"options": "Account"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "selling_defaults",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Sales Defaults",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "selling_defaults",
"fieldtype": "Section Break",
"label": "Sales Defaults"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "selling_cost_center",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Default Selling Cost Center",
"length": 0,
"no_copy": 0,
"options": "Cost Center",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "selling_cost_center",
"fieldtype": "Link",
"label": "Default Selling Cost Center",
"options": "Cost Center"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_12",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "column_break_12",
"fieldtype": "Column Break"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "income_account",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Default Income Account",
"length": 0,
"no_copy": 0,
"options": "Account",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
"fieldname": "income_account",
"fieldtype": "Link",
"label": "Default Income Account",
"options": "Account"
},
{
"fieldname": "default_discount_account",
"fieldtype": "Link",
"label": "Default Discount Account",
"options": "Account"
}
],
"has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 0,
"image_view": 0,
"in_create": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2018-12-07 11:48:07.638935",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item Default",
"name_case": "",
"owner": "Administrator",
"permissions": [],
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1,
"track_seen": 0,
"track_views": 0
],
"istable": 1,
"links": [],
"modified": "2021-07-13 01:26:03.860065",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item Default",
"owner": "Administrator",
"permissions": [],
"quick_entry": 1,
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1
}

View File

@@ -287,6 +287,7 @@ def get_basic_details(args, item, overwrite_warehouse=True):
"warehouse": warehouse,
"income_account": get_default_income_account(args, item_defaults, item_group_defaults, brand_defaults),
"expense_account": expense_account or get_default_expense_account(args, item_defaults, item_group_defaults, brand_defaults) ,
"discount_account": None or get_default_discount_account(args, item_defaults),
"cost_center": get_default_cost_center(args, item_defaults, item_group_defaults, brand_defaults),
'has_serial_no': item.has_serial_no,
'has_batch_no': item.has_batch_no,
@@ -589,6 +590,10 @@ def get_default_expense_account(args, item, item_group, brand):
or brand.get("expense_account")
or args.expense_account)
def get_default_discount_account(args, item):
return (item.get("default_discount_account")
or args.discount_account)
def get_default_deferred_account(args, item, fieldname=None):
if item.get("enable_deferred_revenue") or item.get("enable_deferred_expense"):
return (item.get(fieldname)