Skip to content

Commit

Permalink
Bump to v13.16.0 (#404)
Browse files Browse the repository at this point in the history
* feat: create party link from customer/supplier (backport frappe#28387)

* fix: Customer, Supplier heatmap data not rendering (backport frappe#28553)

* fix: Filter out cancelled and non-depreciable Assets in Asset Value Adjustment (backport frappe#28443)

* fix: allow creating Shift Assignment for same day (backport frappe#28613)

* fix: Taxes and Charges template not getting copied from Purchase Order/Receipt to Invoice

(cherry picked from commit 6a75e8d)

* fix: India utils code cleanup

(cherry picked from commit 56c626a)

* fix: dont requeue repost immediately and clear progress (backport frappe#28684)

* fix: Employee Advance paid amount not updated on PE cancellation (backport frappe#28572)

* fix: coa balance rendering bug (backport frappe#28468)

* fix(UX): combine_items checkbox to trigger get_items and sub_assembly button (backport frappe#28558)

* fix: added job_card_item link in material request (backport frappe#28222)

* fix: incorrect discount amount set when item is replaced (frappe#28556)

(cherry picked from commit c0cc72e)

* fix: cost center wise ledger posting for pcv (backport frappe#28477)

* fix(UX): Allocated Amount in Advances not updated on updating expense amount in Expense Claim (backport frappe#28497)

* fix: Employee link formatter showing incorrect value for Employee Name (backport frappe#28504)

* fix: Remove RM Cost column as cost is not retrievable from Job card (backport frappe#28123)

* fix: total stock summary UI glitch (backport frappe#28564)

* fix: (style) Warehouse Capacity Dashboard UI (backport frappe#28431)

* fix: incorrect balance in "Warehouse Wise Item Balance and Age" report (backport frappe#28583)

* refactor!: remove abbreviation renaming (backport frappe#27766)

* fix: POS Item cart only taxes with amount displayed (backport frappe#28501)

* refactor: (ux) Accepted/Rejected/Received Qty UX

(cherry picked from commit 5fb5a75)

* fix: Sider + Fields UX

- remove extra space (sider)
- PR: Bring rejected qty in grid view
- PI: Rename `Stock Qty` to `Accepted Qty in Stock UOM`
- PI: Move `Accepted Qty in Stock UOM` under Stock UOM

(cherry picked from commit afe1c45)

* test: Purchase Receipt Received Qty

(cherry picked from commit 05ec7cc)

* test: Purchase Invoice Received Qty

(cherry picked from commit e9c75d6)

* fix: Sider, Linter and Server Side Test

- Fix Server side PR test
- linter: re-arrange imports
- sider: avoid single line multi statement
- Code cleanup: Improve code readability and avoid horizontal scroll in test_purchase_receipt
- Removed unused variables in test_purchase_receipt

(cherry picked from commit 293f6cb)

* fix: Merge conflicts

* fix: fixes in work order doctype (backport frappe#28217)

* fix: (server test) Missing variable declaration

* refactor: item-wh wise reposting by default

(cherry picked from commit 6dc9b82)

* test: item-wh repost creation

(cherry picked from commit a36c249)

* refactor: reuse get_items_to_be_repost function

(cherry picked from commit d220e08)

* feat: option to select reposting method

In current implementation selecting Item-Warehouse based reposting is
better for few users, who don't use depenent SLEs but have frequent
transactions involving same items.

This change lets them switch to item-warehouse based reposting if
required.

Only use this if you understand technicalities of stock reposting. This
is experimental but will become mainstream in coming days.

(cherry picked from commit 45dd46b)

* perf: index for item-sh on repost item valuation

Item-WH based reposting requires querying existing similar repost.
Assuming there is only 1 max extra entry with same params just indexing
item-WH is sufficient to speed up the query.

(cherry picked from commit a5a8c91)

* fix: dont erase voucher_type and voucher_no for item_wh repost

kept for tracability.

(cherry picked from commit 1d3842f)

* perf: skip unnecessary item-wh reposts

Using basic idea that repost with older posting date will also take care
of subsequent posting dates...

When Item-WH reposts are queued:

1. If another repost with same item-wh but older posting date exists
    then skip current one.
2. If another repost with same item-wh but newer posting date exists
    then skip another one.

(cherry picked from commit 0d0e24a)

* test: item-wh deduplication in reposting

(cherry picked from commit 55631dd)

* refactor: deduplicate during repost background job

(cherry picked from commit ed94f0f)

* fix: ignore permissions while creating reposts

(cherry picked from commit 0a2964d)

* fix: Shipping Rule picking up old net_rate

(cherry picked from commit c78b8b7)

* fix: calling shipping rule method during net_total calculation in taxes_adn_totals.py

(cherry picked from commit 18ae03d)

* fix: check if shipping rule value exists

(cherry picked from commit af1fce0)

* fix: fixed tests, separated a  method for shipping charges

(cherry picked from commit a8e2c02)

* fix: sider issues

(cherry picked from commit e7b4204)

* fix: merge conflicts

* fix: fixes in work order doctype (backport frappe#28217)

* fix: abbr

Co-authored-by: Deepesh Garg <deepeshgarg6@gmail.com>
Co-authored-by: Saqib <nextchamp.saqib@gmail.com>
Co-authored-by: marination <maricadsouza221197@gmail.com>
Co-authored-by: Ankush Menat <ankush@frappe.io>
Co-authored-by: Subin Tom <subintom2@gmail.com>
  • Loading branch information
6 people committed Dec 13, 2022
1 parent 3c2f71b commit b7f6dca
Show file tree
Hide file tree
Showing 55 changed files with 1,012 additions and 482 deletions.
2 changes: 1 addition & 1 deletion erpnext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from erpnext.hooks import regional_overrides

__version__ = '13.14.1'
__version__ = '13.16.1'

def get_default_company(user=None):
'''Get default company for user'''
Expand Down
1 change: 1 addition & 0 deletions erpnext/accounts/doctype/account/account_tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ frappe.treeview_settings["Account"] = {
const format = (value, currency) => format_currency(Math.abs(value), currency);

if (account.balance!==undefined) {
node.parent && node.parent.find('.balance-area').remove();
$('<span class="balance-area pull-right">'
+ (account.balance_in_account_currency ?
(format(account.balance_in_account_currency, account.account_currency) + " / ") : "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def validate(self):
frappe.db.set_default("add_taxes_from_item_tax_template",
self.get("add_taxes_from_item_tax_template", 0))

frappe.db.set_default("enable_common_party_accounting",
self.get("enable_common_party_accounting", 0))

self.validate_stale_days()
self.enable_payment_schedule_in_print()
self.toggle_discount_accounting_fields()
Expand Down
13 changes: 13 additions & 0 deletions erpnext/accounts/doctype/party_link/party_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,16 @@ def validate(self):
if existing_party_link:
frappe.throw(_('{} {} is already linked with another {}')
.format(self.primary_role, self.primary_party, existing_party_link[0]))


@frappe.whitelist()
def create_party_link(primary_role, primary_party, secondary_party):
party_link = frappe.new_doc('Party Link')
party_link.primary_role = primary_role
party_link.primary_party = primary_party
party_link.secondary_role = 'Customer' if primary_role == 'Supplier' else 'Supplier'
party_link.secondary_party = secondary_party

party_link.save(ignore_permissions=True)

return party_link
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ def get_pnl_gl_entry(self, pl_accounts):

for acc in pl_accounts:
if flt(acc.bal_in_company_currency):
cost_center = acc.cost_center if self.cost_center_wise_pnl else company_cost_center
gl_entry = self.get_gl_dict({
"account": self.closing_account_head,
"cost_center": acc.cost_center or company_cost_center,
"cost_center": cost_center,
"finance_book": acc.finance_book,
"account_currency": acc.account_currency,
"debit_in_account_currency": abs(flt(acc.bal_in_account_currency)) if flt(acc.bal_in_account_currency) > 0 else 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def test_cost_center_wise_posting(self):
company = create_company()
surplus_account = create_account()

cost_center1 = create_cost_center("Test Cost Center 1")
cost_center2 = create_cost_center("Test Cost Center 2")
cost_center1 = create_cost_center("Main")
cost_center2 = create_cost_center("Western Branch")

create_sales_invoice(
company=company,
Expand All @@ -87,7 +87,10 @@ def test_cost_center_wise_posting(self):
debit_to="Debtors - TPC"
)

pcv = self.make_period_closing_voucher()
pcv = self.make_period_closing_voucher(submit=False)
pcv.cost_center_wise_pnl = 1
pcv.save()
pcv.submit()
surplus_account = pcv.closing_account_head

expected_gle = (
Expand Down Expand Up @@ -150,7 +153,7 @@ def test_period_closing_with_finance_book_entries(self):

self.assertEqual(pcv_gle, expected_gle)

def make_period_closing_voucher(self):
def make_period_closing_voucher(self, submit=True):
surplus_account = create_account()
cost_center = create_cost_center("Test Cost Center 1")
pcv = frappe.get_doc({
Expand All @@ -164,7 +167,8 @@ def make_period_closing_voucher(self):
"remarks": "test"
})
pcv.insert()
pcv.submit()
if submit:
pcv.submit()

return pcv

Expand Down
43 changes: 24 additions & 19 deletions erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry
from erpnext.buying.doctype.supplier.test_supplier import create_supplier
from erpnext.controllers.accounts_controller import get_payment_terms
from erpnext.controllers.buying_controller import QtyMismatchError
from erpnext.exceptions import InvalidCurrency
from erpnext.projects.doctype.project.test_project import make_project
from erpnext.stock.doctype.item.test_item import create_item
Expand All @@ -36,6 +37,27 @@ def setUpClass(self):
def tearDownClass(self):
unlink_payment_on_cancel_of_invoice(0)

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

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

# teardown
pi.delete()

def test_gl_entries_without_perpetual_inventory(self):
frappe.db.set_value("Company", "_Test Company", "round_off_account", "Round Off - _TC")
pi = frappe.copy_doc(test_records[0])
Expand Down Expand Up @@ -789,29 +811,12 @@ def test_purchase_invoice_with_shipping_rule(self):

pi.shipping_rule = shipping_rule.name
pi.insert()

shipping_amount = 0.0
for condition in shipping_rule.get("conditions"):
if not condition.to_value or (flt(condition.from_value) <= pi.net_total <= flt(condition.to_value)):
shipping_amount = condition.shipping_amount

shipping_charge = {
"doctype": "Purchase Taxes and Charges",
"category": "Valuation and Total",
"charge_type": "Actual",
"account_head": shipping_rule.account,
"cost_center": shipping_rule.cost_center,
"tax_amount": shipping_amount,
"description": shipping_rule.name,
"add_deduct_tax": "Add"
}
pi.append("taxes", shipping_charge)
pi.save()

self.assertEqual(pi.net_total, 1250)

self.assertEqual(pi.total_taxes_and_charges, 462.3)
self.assertEqual(pi.grand_total, 1712.3)
self.assertEqual(pi.total_taxes_and_charges, 354.1)
self.assertEqual(pi.grand_total, 1604.1)

def test_make_pi_without_terms(self):
pi = make_purchase_invoice(do_not_save=1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
"received_qty",
"qty",
"rejected_qty",
"stock_uom",
"col_break2",
"uom",
"conversion_factor",
"stock_uom",
"stock_qty",
"sec_break1",
"price_list_rate",
Expand Down Expand Up @@ -175,7 +175,8 @@
{
"fieldname": "received_qty",
"fieldtype": "Float",
"label": "Received Qty"
"label": "Received Qty",
"read_only": 1
},
{
"bold": 1,
Expand Down Expand Up @@ -223,7 +224,7 @@
{
"fieldname": "stock_qty",
"fieldtype": "Float",
"label": "Stock Qty",
"label": "Accepted Qty in Stock UOM",
"print_hide": 1,
"read_only": 1,
"reqd": 1
Expand Down Expand Up @@ -871,10 +872,11 @@
"idx": 1,
"istable": 1,
"links": [],
"modified": "2022-10-20 10:55:19.281097",
"modified": "2022-10-21 10:55:19.281097",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice Item",
"naming_rule": "Random",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
Expand Down
28 changes: 4 additions & 24 deletions erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -1626,28 +1626,12 @@ def test_sales_invoice_with_shipping_rule(self):

si.shipping_rule = shipping_rule.name
si.insert()

shipping_amount = 0.0
for condition in shipping_rule.get("conditions"):
if not condition.to_value or (flt(condition.from_value) <= si.net_total <= flt(condition.to_value)):
shipping_amount = condition.shipping_amount

shipping_charge = {
"doctype": "Sales Taxes and Charges",
"category": "Valuation and Total",
"charge_type": "Actual",
"account_head": shipping_rule.account,
"cost_center": shipping_rule.cost_center,
"tax_amount": shipping_amount,
"description": shipping_rule.name
}
si.append("taxes", shipping_charge)
si.save()

self.assertEqual(si.net_total, 1250)

self.assertEqual(si.total_taxes_and_charges, 577.05)
self.assertEqual(si.grand_total, 1827.05)
self.assertEqual(si.total_taxes_and_charges, 468.85)
self.assertEqual(si.grand_total, 1718.85)



Expand Down Expand Up @@ -2251,6 +2235,7 @@ def test_sales_invoice_against_supplier(self):
from erpnext.accounts.doctype.opening_invoice_creation_tool.test_opening_invoice_creation_tool import (
make_customer,
)
from erpnext.accounts.doctype.party_link.party_link import create_party_link
from erpnext.buying.doctype.supplier.test_supplier import create_supplier

# create a customer
Expand All @@ -2260,12 +2245,7 @@ def test_sales_invoice_against_supplier(self):

# create a party link between customer & supplier
# set primary role as supplier
party_link = frappe.new_doc("Party Link")
party_link.primary_role = "Supplier"
party_link.primary_party = supplier
party_link.secondary_role = "Customer"
party_link.secondary_party = customer
party_link.save()
party_link = create_party_link("Supplier", supplier, customer)

# enable common party accounting
frappe.db.set_value('Accounts Settings', None, 'enable_common_party_accounting', 1)
Expand Down
10 changes: 6 additions & 4 deletions erpnext/accounts/party.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ def _get_party_details(party=None, account=None, party_type="Customer", company=
party_details["tax_category"] = get_address_tax_category(party.get("tax_category"),
party_address, shipping_address if party_type != "Supplier" else party_address)

if not party_details.get("taxes_and_charges"):
party_details["taxes_and_charges"] = set_taxes(party.name, party_type, posting_date, company,
customer_group=party_details.customer_group, supplier_group=party_details.supplier_group, tax_category=party_details.tax_category,
billing_address=party_address, shipping_address=shipping_address)
tax_template = set_taxes(party.name, party_type, posting_date, company,
customer_group=party_details.customer_group, supplier_group=party_details.supplier_group, tax_category=party_details.tax_category,
billing_address=party_address, shipping_address=shipping_address)

if tax_template:
party_details['taxes_and_charges'] = tax_template

if cint(fetch_payment_terms_template):
party_details["payment_terms_template"] = get_payment_terms_template(party.name, party_type, company)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ frappe.ui.form.on('Asset Value Adjustment', {
}
}
});
frm.set_query('asset', function() {
return {
filters: {
calculate_depreciation: 1,
docstatus: 1
}
};
});
},

onload: function(frm) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
get_checks_for_pl_and_bs_accounts,
)
from erpnext.assets.doctype.asset.depreciation import get_depreciation_accounts

from erpnext.regional.india.utils import (
get_depreciation_amount as get_depreciation_amount_for_india,
)

class AssetValueAdjustment(Document):
def validate(self):
Expand Down Expand Up @@ -92,6 +94,7 @@ def make_depreciation_entry(self):

def reschedule_depreciations(self, asset_value):
asset = frappe.get_doc('Asset', self.asset)
country = frappe.get_value('Company', self.company, 'country')

for d in asset.finance_books:
d.value_after_depreciation = asset_value
Expand All @@ -113,8 +116,10 @@ def reschedule_depreciations(self, asset_value):
depreciation_amount = days * rate_per_day
from_date = data.schedule_date
else:
depreciation_amount = asset.get_depreciation_amount(value_after_depreciation,
no_of_depreciations, d)
if country == "India":
depreciation_amount = get_depreciation_amount_for_india(asset, value_after_depreciation, d)
else:
depreciation_amount = get_depreciation_amount(asset, value_after_depreciation, d)

if depreciation_amount:
value_after_depreciation -= flt(depreciation_amount)
Expand Down
44 changes: 44 additions & 0 deletions erpnext/buying/doctype/supplier/supplier.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ frappe.ui.form.on("Supplier", {
frm.trigger("get_supplier_group_details");
}, __('Actions'));

if (cint(frappe.defaults.get_default("enable_common_party_accounting"))) {
frm.add_custom_button(__('Link with Customer'), function () {
frm.trigger('show_party_link_dialog');
}, __('Actions'));
}

// indicators
erpnext.utils.set_party_dashboard_indicators(frm);
}
Expand Down Expand Up @@ -128,5 +134,43 @@ frappe.ui.form.on("Supplier", {
else {
frm.toggle_reqd("represents_company", false);
}
},

show_party_link_dialog: function(frm) {
const dialog = new frappe.ui.Dialog({
title: __('Select a Customer'),
fields: [{
fieldtype: 'Link', label: __('Customer'),
options: 'Customer', fieldname: 'customer', reqd: 1
}],
primary_action: function({ customer }) {
frappe.call({
method: 'erpnext.accounts.doctype.party_link.party_link.create_party_link',
args: {
primary_role: 'Supplier',
primary_party: frm.doc.name,
secondary_party: customer
},
freeze: true,
callback: function() {
dialog.hide();
frappe.msgprint({
message: __('Successfully linked to Customer'),
alert: true
});
},
error: function() {
dialog.hide();
frappe.msgprint({
message: __('Linking to Customer Failed. Please try again.'),
title: __('Linking Failed'),
indicator: 'red'
});
}
});
},
primary_action_label: __('Create Link')
});
dialog.show();
}
});
6 changes: 5 additions & 1 deletion erpnext/buying/doctype/supplier/supplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
)
from frappe.model.naming import set_name_by_naming_series, set_name_from_naming_options

from erpnext.accounts.party import get_dashboard_info, validate_party_accounts
from erpnext.accounts.party import ( # noqa
get_dashboard_info,
get_timeline_data,
validate_party_accounts,
)
from erpnext.utilities.transaction_base import TransactionBase


Expand Down
Loading

0 comments on commit b7f6dca

Please sign in to comment.