Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: release v15 beta #36961

Merged
merged 45 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
d066b5c
fix(startup): coa drill down
blaggacao Jul 24, 2023
0d22fe0
refactor!: Lower all perm to `Desk User`
ankush Aug 28, 2023
de433d8
fix: added ignore_user_permissions to parent field of tree doctypes
RitvikSardana Aug 29, 2023
4856e11
chore: update integrations workspace
ankush Aug 29, 2023
dea802d
fix: added valuation field type (Float/Currency) in the filter (#36866)
rohitwaghchaure Aug 29, 2023
92e503f
fix: Sales/Purchase register showing duplicate records
deepeshgarg007 Aug 29, 2023
e75b72a
Merge pull request #36856 from frappe/desk_user
ankush Aug 29, 2023
5e38109
Merge pull request #36872 from deepeshgarg007/sales_purchase_register…
deepeshgarg007 Aug 29, 2023
e92d4e9
Merge branch 'develop' into develop-ritvik-ignore-perm-tree-doctype
surajshetty3416 Aug 30, 2023
f032476
Merge pull request #36869 from RitvikSardana/develop-ritvik-ignore-pe…
surajshetty3416 Aug 30, 2023
283c0a1
chore: remove patch
deepeshgarg007 Aug 30, 2023
cd74c6c
Merge pull request #36881 from deepeshgarg007/patch_revert
deepeshgarg007 Aug 30, 2023
d73daaf
fix: tax accounts in sales register
GursheenK Aug 31, 2023
2537f56
Merge pull request #36886 from GursheenK/sales-register-tax-accounts
deepeshgarg007 Aug 31, 2023
112cfe6
fix: fetch discount amount for gle in base currency
GursheenK Aug 31, 2023
64d8353
fix: calcuate received/paid amount on rate change in PE
ruthra-kumar Aug 31, 2023
0d26f67
Merge pull request #36888 from ruthra-kumar/gain_loss_refactor_issue_…
ruthra-kumar Aug 31, 2023
3e1065a
fix: `company` is ambiguous
rtdany10 Sep 1, 2023
a7e0709
fix: difference amount in UI should not be calculated
ruthra-kumar Aug 31, 2023
b6e6f2e
fix: reduce threshold for bg job fn
GursheenK Sep 1, 2023
39b598e
Merge pull request #36898 from rtdany10/company-ambiguous
deepeshgarg007 Sep 1, 2023
1e72a43
Merge pull request #36889 from GursheenK/discount-accounting-multi-cu…
deepeshgarg007 Sep 1, 2023
0e51722
Merge pull request #36899 from ruthra-kumar/use_own_exchange_rate_on_…
ruthra-kumar Sep 1, 2023
91e5746
fix: only show "Unreconcile" if reconciled
barredterra Jun 15, 2023
2d8363a
feat: Serial and Batch reservation (#35946)
s-aga-r Sep 2, 2023
e599f75
fix: account payable currency and value (#36859)
RitvikSardana Sep 2, 2023
79c6f01
fix: deduplicate gain/loss JE creation for journals as payment
ruthra-kumar Sep 1, 2023
cb6da6e
test: deduplicate gain/loss JE on reconciling journals against inv
ruthra-kumar Sep 2, 2023
79fa562
test: extend test to cancellation
ruthra-kumar Sep 2, 2023
30aba94
Merge pull request #36900 from GursheenK/pcv-request-timeout
deepeshgarg007 Sep 2, 2023
f3282b1
Merge pull request #36908 from barredterra/unreconcile-bank-transaction
deepeshgarg007 Sep 2, 2023
2e75484
Merge pull request #36895 from blaggacao/fix-coa-dill-down-on-startup
deepeshgarg007 Sep 2, 2023
4f0bb45
chore: patch to correct asset values if je has workflow [dev] (#36914)
anandbaburajan Sep 2, 2023
d6a3b9a
refactor: use payment's CC for gain/loss if company default is unset
ruthra-kumar Sep 3, 2023
0366928
test: cost center inheritance from payment
ruthra-kumar Sep 3, 2023
27e0dd9
Merge pull request #36911 from ruthra-kumar/deduplicate_gain_loss_jou…
ruthra-kumar Sep 3, 2023
24e1144
fix: when create doc from item dashboard default uom (buying or selli…
FHenry Sep 3, 2023
22cf155
feat: Service Item and Finished Good Map (#36647)
s-aga-r Sep 3, 2023
cd8ddae
refactor: remove `Recalculate Rate` from SCR Item (#36929)
s-aga-r Sep 3, 2023
75d95ac
fix: invalid gain/loss JE created on base currency Expense Claim
ruthra-kumar Sep 4, 2023
04bc353
Merge pull request #36940 from ruthra-kumar/invalid_gain_loss_in_expe…
ruthra-kumar Sep 4, 2023
6a7bdef
fix: auto refresh serial and batch bundle field (#36943)
rohitwaghchaure Sep 4, 2023
f7865da
refactor: gain/loss should use same posting date as payment
ruthra-kumar Sep 4, 2023
13ca474
Merge pull request #36950 from ruthra-kumar/use_reference_posting_dat…
ruthra-kumar Sep 5, 2023
d2f03c8
fix: payment recon not showing payment entry when party_type is Stude…
RitvikSardana Sep 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions erpnext/accounts/doctype/bank_transaction/bank_transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ frappe.ui.form.on("Bank Transaction", {
});
},
refresh(frm) {
frm.add_custom_button(__('Unreconcile Transaction'), () => {
frm.call('remove_payment_entries')
.then( () => frm.refresh() );
});
if (!frm.is_dirty() && frm.doc.payment_entries.length > 0) {
frm.add_custom_button(__("Unreconcile Transaction"), () => {
frm.call("remove_payment_entries").then(() => frm.refresh());
});
}
},
bank_account: function (frm) {
set_bank_statement_filter(frm);
Expand Down
24 changes: 21 additions & 3 deletions erpnext/accounts/doctype/payment_entry/payment_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,15 +535,21 @@ frappe.ui.form.on('Payment Entry', {
},

source_exchange_rate: function(frm) {
let company_currency = frappe.get_doc(":Company", frm.doc.company).default_currency;
if (frm.doc.paid_amount) {
frm.set_value("base_paid_amount", flt(frm.doc.paid_amount) * flt(frm.doc.source_exchange_rate));
// 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);
} else if (company_currency == frm.doc.paid_to_account_currency) {
frm.set_value("received_amount", frm.doc.base_paid_amount);
frm.set_value("base_received_amount", frm.doc.base_paid_amount);
}

frm.events.set_unallocated_amount(frm);
// set_unallocated_amount is called by below method,
// no need trigger separately
frm.events.set_total_allocated_amount(frm);
}

// Make read only if Accounts Settings doesn't allow stale rates
Expand All @@ -552,6 +558,7 @@ frappe.ui.form.on('Payment Entry', {

target_exchange_rate: function(frm) {
frm.set_paid_amount_based_on_received_amount = true;
let company_currency = frappe.get_doc(":Company", frm.doc.company).default_currency;

if (frm.doc.received_amount) {
frm.set_value("base_received_amount",
Expand All @@ -561,9 +568,14 @@ frappe.ui.form.on('Payment Entry', {
(frm.doc.paid_from_account_currency == frm.doc.paid_to_account_currency)) {
frm.set_value("source_exchange_rate", frm.doc.target_exchange_rate);
frm.set_value("base_paid_amount", frm.doc.base_received_amount);
} else if (company_currency == frm.doc.paid_from_account_currency) {
frm.set_value("paid_amount", frm.doc.base_received_amount);
frm.set_value("base_paid_amount", frm.doc.base_received_amount);
}

frm.events.set_unallocated_amount(frm);
// set_unallocated_amount is called by below method,
// no need trigger separately
frm.events.set_total_allocated_amount(frm);
}
frm.set_paid_amount_based_on_received_amount = false;

Expand Down Expand Up @@ -879,12 +891,18 @@ frappe.ui.form.on('Payment Entry', {
},

set_total_allocated_amount: function(frm) {
let exchange_rate = 1;
if (frm.doc.payment_type == "Receive") {
exchange_rate = frm.doc.source_exchange_rate;
} else if (frm.doc.payment_type == "Pay") {
exchange_rate = frm.doc.target_exchange_rate;
}
var total_allocated_amount = 0.0;
var base_total_allocated_amount = 0.0;
$.each(frm.doc.references || [], function(i, row) {
if (row.allocated_amount) {
total_allocated_amount += flt(row.allocated_amount);
base_total_allocated_amount += flt(flt(row.allocated_amount)*flt(row.exchange_rate),
base_total_allocated_amount += flt(flt(row.allocated_amount)*flt(exchange_rate),
precision("base_paid_amount"));
}
});
Expand Down
9 changes: 7 additions & 2 deletions erpnext/accounts/doctype/payment_entry/payment_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,11 @@ def calculate_base_allocated_amount_for_reference(self, d) -> float:
flt(d.allocated_amount) * flt(exchange_rate), self.precision("base_paid_amount")
)

# on rare case, when `exchange_rate` is unset, gain/loss amount is incorrectly calculated
# for base currency transactions
if d.exchange_rate is None:
d.exchange_rate = 1

allocated_amount_in_pe_exchange_rate = flt(
flt(d.allocated_amount) * flt(d.exchange_rate), self.precision("base_paid_amount")
)
Expand Down Expand Up @@ -2300,7 +2305,7 @@ def set_paid_amount_and_received_amount(
if bank_amount:
received_amount = bank_amount
else:
if company_currency != bank.account_currency:
if bank and company_currency != bank.account_currency:
received_amount = paid_amount / doc.get("conversion_rate", 1)
else:
received_amount = paid_amount * doc.get("conversion_rate", 1)
Expand All @@ -2309,7 +2314,7 @@ def set_paid_amount_and_received_amount(
if bank_amount:
paid_amount = bank_amount
else:
if company_currency != bank.account_currency:
if bank and company_currency != bank.account_currency:
paid_amount = received_amount / doc.get("conversion_rate", 1)
else:
# if party account currency and bank currency is different then populate paid amount as well
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def get_jv_entries(self):
"Journal Entry" as reference_type, t1.name as reference_name,
t1.posting_date, t1.remark as remarks, t2.name as reference_row,
{dr_or_cr} as amount, t2.is_advance, t2.exchange_rate,
t2.account_currency as currency
t2.account_currency as currency, t2.cost_center as cost_center
from
`tabJournal Entry` t1, `tabJournal Entry Account` t2
where
Expand Down Expand Up @@ -209,6 +209,7 @@ def get_dr_or_cr_notes(self):
"amount": -(inv.outstanding_in_account_currency),
"posting_date": inv.posting_date,
"currency": inv.currency,
"cost_center": inv.cost_center,
}
)
)
Expand Down Expand Up @@ -357,6 +358,7 @@ def get_allocated_entry(self, pay, inv, allocated_amount):
"allocated_amount": allocated_amount,
"difference_amount": pay.get("difference_amount"),
"currency": inv.get("currency"),
"cost_center": pay.get("cost_center"),
}
)

Expand Down Expand Up @@ -431,6 +433,7 @@ def get_payment_details(self, row, dr_or_cr):
"allocated_amount": flt(row.get("allocated_amount")),
"difference_amount": flt(row.get("difference_amount")),
"difference_account": row.get("difference_account"),
"cost_center": row.get("cost_center"),
}
)

Expand Down Expand Up @@ -603,7 +606,7 @@ def reconcile_dr_cr_note(dr_cr_notes, company):
inv.dr_or_cr: abs(inv.allocated_amount),
"reference_type": inv.against_voucher_type,
"reference_name": inv.against_voucher,
"cost_center": erpnext.get_default_cost_center(company),
"cost_center": inv.cost_center or erpnext.get_default_cost_center(company),
"exchange_rate": inv.exchange_rate,
"user_remark": f"{fmt_money(flt(inv.allocated_amount), currency=company_currency)} against {inv.against_voucher}",
},
Expand All @@ -618,7 +621,7 @@ def reconcile_dr_cr_note(dr_cr_notes, company):
),
"reference_type": inv.voucher_type,
"reference_name": inv.voucher_no,
"cost_center": erpnext.get_default_cost_center(company),
"cost_center": inv.cost_center or erpnext.get_default_cost_center(company),
"exchange_rate": inv.exchange_rate,
"user_remark": f"{fmt_money(flt(inv.allocated_amount), currency=company_currency)} from {inv.voucher_no}",
},
Expand All @@ -644,6 +647,7 @@ def reconcile_dr_cr_note(dr_cr_notes, company):

create_gain_loss_journal(
company,
today(),
inv.party_type,
inv.party,
inv.account,
Expand All @@ -657,4 +661,5 @@ def reconcile_dr_cr_note(dr_cr_notes, company):
inv.against_voucher_type,
inv.against_voucher,
None,
inv.cost_center,
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"column_break_7",
"difference_account",
"exchange_rate",
"currency"
"currency",
"cost_center"
],
"fields": [
{
Expand Down Expand Up @@ -144,11 +145,17 @@
"fieldtype": "Float",
"label": "Exchange Rate",
"read_only": 1
},
{
"fieldname": "cost_center",
"fieldtype": "Link",
"label": "Cost Center",
"options": "Cost Center"
}
],
"istable": 1,
"links": [],
"modified": "2022-12-24 21:01:14.882747",
"modified": "2023-09-03 07:52:33.684217",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Payment Reconciliation Allocation",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"sec_break1",
"remark",
"currency",
"exchange_rate"
"exchange_rate",
"cost_center"
],
"fields": [
{
Expand Down Expand Up @@ -98,11 +99,17 @@
"fieldtype": "Float",
"hidden": 1,
"label": "Exchange Rate"
},
{
"fieldname": "cost_center",
"fieldtype": "Link",
"label": "Cost Center",
"options": "Cost Center"
}
],
"istable": 1,
"links": [],
"modified": "2022-11-08 18:18:36.268760",
"modified": "2023-09-03 07:43:29.965353",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Payment Reconciliation Payment",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def check_if_previous_year_closed(self):
def make_gl_entries(self, get_opening_entries=False):
gl_entries = self.get_gl_entries()
closing_entries = self.get_grouped_gl_entries(get_opening_entries=get_opening_entries)
if len(gl_entries) > 5000:
if len(gl_entries + closing_entries) > 3000:
frappe.enqueue(
process_gl_entries,
gl_entries=gl_entries,
Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/party.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def get_party_account(party_type, party=None, company=None, include_advance=Fals
if (account and account_currency != existing_gle_currency) or not account:
account = get_party_gle_account(party_type, party, company)

if include_advance and party_type in ["Customer", "Supplier"]:
if include_advance and party_type in ["Customer", "Supplier", "Student"]:
advance_account = get_party_advance_account(party_type, party, company)
if advance_account:
return [account, advance_account]
Expand Down
53 changes: 28 additions & 25 deletions erpnext/accounts/report/accounts_payable/accounts_payable.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,6 @@ frappe.query_reports["Accounts Payable"] = {
}
}
},
{
"fieldname": "supplier",
"label": __("Supplier"),
"fieldtype": "Link",
"options": "Supplier",
on_change: () => {
var supplier = frappe.query_report.get_filter_value('supplier');
if (supplier) {
frappe.db.get_value('Supplier', supplier, "tax_id", function(value) {
frappe.query_report.set_filter_value('tax_id', value["tax_id"]);
});
} else {
frappe.query_report.set_filter_value('tax_id', "");
}

frappe.query_report.refresh();
}
},
{
"fieldname": "party_account",
"label": __("Payable Account"),
Expand Down Expand Up @@ -112,11 +94,38 @@ frappe.query_reports["Accounts Payable"] = {
"fieldtype": "Link",
"options": "Payment Terms Template"
},
{
"fieldname": "party_type",
"label": __("Party Type"),
"fieldtype": "Link",
"options": "Party Type",
get_query: () => {
return {
filters: {
'account_type': 'Payable'
}
};
},
on_change: () => {
frappe.query_report.set_filter_value('party', "");
let party_type = frappe.query_report.get_filter_value('party_type');
frappe.query_report.toggle_filter_display('supplier_group', frappe.query_report.get_filter_value('party_type') !== "Supplier");

}

},
{
"fieldname":"party",
"label": __("Party"),
"fieldtype": "Dynamic Link",
"options": "party_type",
},
{
"fieldname": "supplier_group",
"label": __("Supplier Group"),
"fieldtype": "Link",
"options": "Supplier Group"
"options": "Supplier Group",
"hidden": 1
},
{
"fieldname": "group_by_party",
Expand All @@ -133,12 +142,6 @@ frappe.query_reports["Accounts Payable"] = {
"label": __("Show Remarks"),
"fieldtype": "Check",
},
{
"fieldname": "tax_id",
"label": __("Tax Id"),
"fieldtype": "Data",
"hidden": 1
},
{
"fieldname": "show_future_payments",
"label": __("Show Future Payments"),
Expand Down
67 changes: 67 additions & 0 deletions erpnext/accounts/report/accounts_payable/test_accounts_payable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import unittest

import frappe
from frappe.tests.utils import FrappeTestCase, change_settings
from frappe.utils import add_days, flt, getdate, today

from erpnext import get_default_cost_center
from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
from erpnext.accounts.report.accounts_payable.accounts_payable import execute
from erpnext.accounts.test.accounts_mixin import AccountsTestMixin
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order


class TestAccountsReceivable(AccountsTestMixin, FrappeTestCase):
def setUp(self):
self.create_company()
self.create_customer()
self.create_item()
self.create_supplier(currency="USD", supplier_name="Test Supplier2")
self.create_usd_payable_account()

def tearDown(self):
frappe.db.rollback()

def test_accounts_receivable_with_supplier(self):
pi = self.create_purchase_invoice(do_not_submit=True)
pi.currency = "USD"
pi.conversion_rate = 80
pi.credit_to = self.creditors_usd
pi = pi.save().submit()

filters = {
"company": self.company,
"party_type": "Supplier",
"party": self.supplier,
"report_date": today(),
"range1": 30,
"range2": 60,
"range3": 90,
"range4": 120,
}

data = execute(filters)
self.assertEqual(data[1][0].get("outstanding"), 300)
self.assertEqual(data[1][0].get("currency"), "USD")

def create_purchase_invoice(self, do_not_submit=False):
frappe.set_user("Administrator")
pi = make_purchase_invoice(
item=self.item,
company=self.company,
supplier=self.supplier,
is_return=False,
update_stock=False,
posting_date=frappe.utils.datetime.date(2021, 5, 1),
do_not_save=1,
rate=300,
price_list_rate=300,
qty=1,
)

pi = pi.save()
if not do_not_submit:
pi = pi.submit()
return pi
Loading
Loading