Skip to content

Commit

Permalink
Merge pull request #30740 from frappe/version-13-hotfix
Browse files Browse the repository at this point in the history
chore: Pre-release for v13.27.0
  • Loading branch information
deepeshgarg007 authored Apr 19, 2022
2 parents 08e2b91 + 38002e3 commit 381e9d2
Show file tree
Hide file tree
Showing 29 changed files with 286 additions and 149 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Generate Semantic Release
on:
push:
branches:
- version-13
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Entire Repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js v14
uses: actions/setup-node@v2
with:
node-version: 14
- name: Setup dependencies
run: |
npm install @semantic-release/git @semantic-release/exec --no-save
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
24 changes: 24 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"branches": ["version-13"],
"plugins": [
"@semantic-release/commit-analyzer", {
"preset": "angular",
"releaseRules": [
{"breaking": true, "release": false}
]
},
"@semantic-release/release-notes-generator",
[
"@semantic-release/exec", {
"prepareCmd": 'sed -ir "s/[0-9]*\.[0-9]*\.[0-9]*/${nextRelease.version}/" erpnext/__init__.py'
}
],
[
"@semantic-release/git", {
"assets": ["erpnext/__init__.py"],
"message": "chore(release): Bumped to Version ${nextRelease.version}\n\n${nextRelease.notes}"
}
],
"@semantic-release/github"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,16 @@ def get_doctypes_with_dimensions():
return frappe.get_hooks("accounting_dimension_doctypes")


def get_accounting_dimensions(as_list=True):
def get_accounting_dimensions(as_list=True, filters=None):

if not filters:
filters = {"disabled": 0}

if frappe.flags.accounting_dimensions is None:
frappe.flags.accounting_dimensions = frappe.get_all(
"Accounting Dimension", fields=["label", "fieldname", "disabled", "document_type"]
"Accounting Dimension",
fields=["label", "fieldname", "disabled", "document_type"],
filters=filters,
)

if as_list:
Expand Down
4 changes: 0 additions & 4 deletions erpnext/accounts/doctype/journal_entry/journal_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
)
from erpnext.accounts.party import get_party_account
from erpnext.accounts.utils import (
check_if_stock_and_account_balance_synced,
get_account_currency,
get_balance_on,
get_stock_accounts,
Expand Down Expand Up @@ -88,9 +87,6 @@ def on_submit(self):
self.update_expense_claim()
self.update_inter_company_jv()
self.update_invoice_discounting()
check_if_stock_and_account_balance_synced(
self.posting_date, self.company, self.doctype, self.name
)

def on_cancel(self):
from erpnext.accounts.utils import unlink_ref_doc_from_payment_entries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,13 @@ def get_conditions(self, get_invoices=False, get_payments=False, get_return_invo
)

if self.minimum_invoice_amount:
condition += " and `{0}` >= {1}".format(dr_or_cr, flt(self.minimum_invoice_amount))
condition += " and {dr_or_cr} >= {amount}".format(
dr_or_cr=dr_or_cr, amount=flt(self.minimum_invoice_amount)
)
if self.maximum_invoice_amount:
condition += " and `{0}` <= {1}".format(dr_or_cr, flt(self.maximum_invoice_amount))
condition += " and {dr_or_cr} <= {amount}".format(
dr_or_cr=dr_or_cr, amount=flt(self.maximum_invoice_amount)
)

elif get_return_invoices:
condition = " and doc.company = '{0}' ".format(self.company)
Expand All @@ -367,15 +371,19 @@ def get_conditions(self, get_invoices=False, get_payments=False, get_return_invo
else ""
)
dr_or_cr = (
"gl.debit_in_account_currency"
"debit_in_account_currency"
if erpnext.get_party_account_type(self.party_type) == "Receivable"
else "gl.credit_in_account_currency"
else "credit_in_account_currency"
)

if self.minimum_invoice_amount:
condition += " and `{0}` >= {1}".format(dr_or_cr, flt(self.minimum_payment_amount))
condition += " and gl.{dr_or_cr} >= {amount}".format(
dr_or_cr=dr_or_cr, amount=flt(self.minimum_payment_amount)
)
if self.maximum_invoice_amount:
condition += " and `{0}` <= {1}".format(dr_or_cr, flt(self.maximum_payment_amount))
condition += " and gl.{dr_or_cr} <= {amount}".format(
dr_or_cr=dr_or_cr, amount=flt(self.maximum_payment_amount)
)

else:
condition += (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ def validate(self):
frappe.throw(_("Customers not selected."))

if self.enable_auto_email:
self.to_date = self.start_date
self.from_date = add_months(self.to_date, -1 * self.filter_duration)
if self.start_date and getdate(self.start_date) >= getdate(today()):
self.to_date = self.start_date
self.from_date = add_months(self.to_date, -1 * self.filter_duration)


def get_report_pdf(doc, consolidated=True):
Expand Down
3 changes: 3 additions & 0 deletions erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
onload: function() {
this._super();

// Ignore linked advances
this.frm.ignore_doctypes_on_cancel_all = ['Journal Entry', 'Payment Entry'];

if(!this.frm.doc.__islocal) {
// show credit_to in print format
if(!this.frm.doc.supplier && this.frm.doc.credit_to) {
Expand Down
6 changes: 4 additions & 2 deletions erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,9 @@ def make_item_gl_entries(self, gl_entries):

if provisional_accounting_for_non_stock_items:
if item.purchase_receipt:
provisional_account = self.get_company_default("default_provisional_account")
provisional_account = frappe.db.get_value(
"Purchase Receipt Item", item.pr_detail, "provisional_expense_account"
) or self.get_company_default("default_provisional_account")
purchase_receipt_doc = purchase_receipt_doc_map.get(item.purchase_receipt)

if not purchase_receipt_doc:
Expand All @@ -824,7 +826,7 @@ def make_item_gl_entries(self, gl_entries):
if expense_booked_in_pr:
# Intentionally passing purchase invoice item to handle partial billing
purchase_receipt_doc.add_provisional_gl_entry(
item, gl_entries, self.posting_date, reverse=1
item, gl_entries, self.posting_date, provisional_account, reverse=1
)

if not self.is_internal_transfer():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1449,7 +1449,8 @@ def test_purchase_invoice_advance_taxes(self):
self.assertEqual(payment_entry.taxes[0].allocated_amount, 0)

def test_provisional_accounting_entry(self):
item = create_item("_Test Non Stock Item", is_stock_item=0)
create_item("_Test Non Stock Item", is_stock_item=0)

provisional_account = create_account(
account_name="Provision Account",
parent_account="Current Liabilities - _TC",
Expand All @@ -1472,6 +1473,8 @@ def test_provisional_accounting_entry(self):
pi.save()
pi.submit()

self.assertEquals(pr.items[0].provisional_expense_account, "Provision Account - _TC")

# Check GLE for Purchase Invoice
expected_gle = [
["Cost of Goods Sold - _TC", 250, 0, add_days(pr.posting_date, -1)],
Expand Down
4 changes: 3 additions & 1 deletion erpnext/accounts/doctype/sales_invoice/sales_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
var me = this;
this._super();

this.frm.ignore_doctypes_on_cancel_all = ['POS Invoice', 'Timesheet', 'POS Invoice Merge Log', 'POS Closing Entry'];
this.frm.ignore_doctypes_on_cancel_all = ['POS Invoice', 'Timesheet', 'POS Invoice Merge Log',
'POS Closing Entry', 'Journal Entry', 'Payment Entry'];

if(!this.frm.doc.__islocal && !this.frm.doc.customer && this.frm.doc.debit_to) {
// show debit_to in print format
this.frm.set_df_property("debit_to", "print_hide", 0);
Expand Down
56 changes: 56 additions & 0 deletions erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -3062,6 +3062,62 @@ def test_standalone_serial_no_return(self):
si.reload()
self.assertTrue(si.items[0].serial_no)

def test_gain_loss_with_advance_entry(self):
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry

unlink_enabled = frappe.db.get_value(
"Accounts Settings", "Accounts Settings", "unlink_payment_on_cancel_of_invoice"
)

frappe.db.set_value(
"Accounts Settings", "Accounts Settings", "unlink_payment_on_cancel_of_invoice", 1
)

jv = make_journal_entry("_Test Receivable USD - _TC", "_Test Bank - _TC", -7000, save=False)

jv.accounts[0].exchange_rate = 70
jv.accounts[0].credit_in_account_currency = 100
jv.accounts[0].party_type = "Customer"
jv.accounts[0].party = "_Test Customer USD"

jv.save()
jv.submit()

si = create_sales_invoice(
customer="_Test Customer USD",
debit_to="_Test Receivable USD - _TC",
currency="USD",
conversion_rate=75,
do_not_save=1,
rate=100,
)

si.append(
"advances",
{
"reference_type": "Journal Entry",
"reference_name": jv.name,
"reference_row": jv.accounts[0].name,
"advance_amount": 100,
"allocated_amount": 100,
"ref_exchange_rate": 70,
},
)
si.save()
si.submit()

expected_gle = [
["_Test Receivable USD - _TC", 7500.0, 500],
["Exchange Gain/Loss - _TC", 500.0, 0.0],
["Sales - _TC", 0.0, 7500.0],
]

check_gl_entries(self, si.name, expected_gle, nowdate())

frappe.db.set_value(
"Accounts Settings", "Accounts Settings", "unlink_payment_on_cancel_of_invoice", unlink_enabled
)


def get_sales_invoice_for_e_invoice():
si = make_sales_invoice_for_ewaybill()
Expand Down
45 changes: 0 additions & 45 deletions erpnext/accounts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
from erpnext.stock.utils import get_stock_value_on


class StockValueAndAccountBalanceOutOfSync(frappe.ValidationError):
pass


class FiscalYearError(frappe.ValidationError):
pass

Expand Down Expand Up @@ -1247,47 +1243,6 @@ def compare_existing_and_expected_gle(existing_gle, expected_gle, precision):
return matched


def check_if_stock_and_account_balance_synced(
posting_date, company, voucher_type=None, voucher_no=None
):
if not cint(erpnext.is_perpetual_inventory_enabled(company)):
return

accounts = get_stock_accounts(company, voucher_type, voucher_no)
stock_adjustment_account = frappe.db.get_value("Company", company, "stock_adjustment_account")

for account in accounts:
account_bal, stock_bal, warehouse_list = get_stock_and_account_balance(
account, posting_date, company
)

if abs(account_bal - stock_bal) > 0.1:
precision = get_field_precision(
frappe.get_meta("GL Entry").get_field("debit"),
currency=frappe.get_cached_value("Company", company, "default_currency"),
)

diff = flt(stock_bal - account_bal, precision)

error_reason = _(
"Stock Value ({0}) and Account Balance ({1}) are out of sync for account {2} and it's linked warehouses as on {3}."
).format(stock_bal, account_bal, frappe.bold(account), posting_date)
error_resolution = _("Please create an adjustment Journal Entry for amount {0} on {1}").format(
frappe.bold(diff), frappe.bold(posting_date)
)

frappe.msgprint(
msg="""{0}<br></br>{1}<br></br>""".format(error_reason, error_resolution),
raise_exception=StockValueAndAccountBalanceOutOfSync,
title=_("Values Out Of Sync"),
primary_action={
"label": _("Make Journal Entry"),
"client_action": "erpnext.route_to_adjustment_jv",
"args": get_journal_entry(account, stock_adjustment_account, diff),
},
)


def get_stock_accounts(company, voucher_type=None, voucher_no=None):
stock_accounts = [
d.name
Expand Down
2 changes: 1 addition & 1 deletion erpnext/assets/doctype/asset/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def make_depreciation_schedule(self, date_of_sale):
if has_pro_rata and n == 0:
# For first entry of monthly depr
if r == 0:
days_until_first_depr = date_diff(monthly_schedule_date, self.available_for_use_date)
days_until_first_depr = date_diff(monthly_schedule_date, self.available_for_use_date) + 1
per_day_amt = depreciation_amount / days
depreciation_amount_for_current_month = per_day_amt * days_until_first_depr
depreciation_amount -= depreciation_amount_for_current_month
Expand Down
3 changes: 2 additions & 1 deletion erpnext/controllers/accounts_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -2000,12 +2000,13 @@ def get_advance_journal_entries(

reference_condition = " and (" + " or ".join(conditions) + ")" if conditions else ""

# nosemgrep
journal_entries = frappe.db.sql(
"""
select
"Journal Entry" as reference_type, t1.name as reference_name,
t1.remark as remarks, t2.{0} as amount, t2.name as reference_row,
t2.reference_name as against_order
t2.reference_name as against_order, t2.exchange_rate
from
`tabJournal Entry` t1, `tabJournal Entry Account` t2
where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ def make_work_order_for_subassembly_items(self, wo_list, subcontracted_po, defau
work_order_data = {
"wip_warehouse": default_warehouses.get("wip_warehouse"),
"fg_warehouse": default_warehouses.get("fg_warehouse"),
"company": self.get("company"),
}

self.prepare_data_for_sub_assembly_items(row, work_order_data)
Expand Down Expand Up @@ -499,6 +500,7 @@ def make_subcontracted_purchase_order(self, subcontracted_po, purchase_orders):

for supplier, po_list in subcontracted_po.items():
po = frappe.new_doc("Purchase Order")
po.company = self.company
po.supplier = supplier
po.schedule_date = getdate(po_list[0].schedule_date) if po_list[0].schedule_date else nowdate()
po.is_subcontracted = "Yes"
Expand Down
1 change: 1 addition & 0 deletions erpnext/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ erpnext.patches.v13_0.enable_provisional_accounting
erpnext.patches.v13_0.update_disbursement_account
erpnext.patches.v13_0.update_reserved_qty_closed_wo
erpnext.patches.v13_0.amazon_mws_deprecation_warning
erpnext.patches.v13_0.datev_deprecation_warning
erpnext.patches.v13_0.set_work_order_qty_in_so_from_mr
erpnext.patches.v13_0.update_accounts_in_loan_docs
erpnext.patches.v13_0.remove_unknown_links_to_prod_plan_items # 24-03-2022
Expand Down
9 changes: 9 additions & 0 deletions erpnext/patches/v13_0/datev_deprecation_warning.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import click


def execute():
click.secho(
"DATEV reports are moved to a separate app and will be removed from ERPNext in version-14.\n"
"Please install the app to continue using them: https://github.com/alyf-de/erpnext_datev",
fg="yellow",
)
Loading

0 comments on commit 381e9d2

Please sign in to comment.