Merge branch 'develop' into auto_tax_gst

This commit is contained in:
Deepesh Garg 2022-03-31 13:52:10 +05:30 committed by GitHub
commit e0631474c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 173 additions and 160 deletions

View File

@ -1,117 +0,0 @@
name: UI
on:
pull_request:
paths-ignore:
- '**.md'
workflow_dispatch:
concurrency:
group: ui-develop-${{ github.event.number }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
name: UI Tests (Cypress)
services:
mysql:
image: mariadb:10.3
env:
MYSQL_ALLOW_EMPTY_PASSWORD: YES
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
steps:
- name: Clone
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions/setup-node@v2
with:
node-version: 14
check-latest: true
- name: Add to Hosts
run: |
echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Cache cypress binary
uses: actions/cache@v2
with:
path: ~/.cache
key: ${{ runner.os }}-cypress-
restore-keys: |
${{ runner.os }}-cypress-
${{ runner.os }}-
- name: Install
run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
env:
DB: mariadb
TYPE: ui
- name: Site Setup
run: cd ~/frappe-bench/ && bench --site test_site execute erpnext.setup.utils.before_tests
- name: cypress pre-requisites
run: cd ~/frappe-bench/apps/frappe && yarn add cypress-file-upload@^5 @testing-library/cypress@^8 --no-lockfile
- name: Build Assets
run: cd ~/frappe-bench/ && bench build
env:
CI: Yes
- name: UI Tests
run: cd ~/frappe-bench/ && bench --site test_site run-ui-tests erpnext --headless
env:
CYPRESS_RECORD_KEY: 60a8e3bf-08f5-45b1-9269-2b207d7d30cd
- name: Show bench console if tests failed
if: ${{ failure() }}
run: cat ~/frappe-bench/bench_run_logs.txt

View File

@ -204,7 +204,9 @@ class Account(NestedSet):
if not self.account_currency: if not self.account_currency:
self.account_currency = frappe.get_cached_value("Company", self.company, "default_currency") self.account_currency = frappe.get_cached_value("Company", self.company, "default_currency")
elif self.account_currency != frappe.db.get_value("Account", self.name, "account_currency"): gl_currency = frappe.db.get_value("GL Entry", {"account": self.name}, "account_currency")
if gl_currency and self.account_currency != gl_currency:
if frappe.db.get_value("GL Entry", {"account": self.name}): if frappe.db.get_value("GL Entry", {"account": self.name}):
frappe.throw(_("Currency can not be changed after making entries using some other currency")) frappe.throw(_("Currency can not be changed after making entries using some other currency"))

View File

@ -241,6 +241,28 @@ class TestAccount(unittest.TestCase):
for doc in to_delete: for doc in to_delete:
frappe.delete_doc("Account", doc) frappe.delete_doc("Account", doc)
def test_validate_account_currency(self):
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
if not frappe.db.get_value("Account", "Test Currency Account - _TC"):
acc = frappe.new_doc("Account")
acc.account_name = "Test Currency Account"
acc.parent_account = "Tax Assets - _TC"
acc.company = "_Test Company"
acc.insert()
else:
acc = frappe.get_doc("Account", "Test Currency Account - _TC")
self.assertEqual(acc.account_currency, "INR")
# Make a JV against this account
make_journal_entry(
"Test Currency Account - _TC", "Miscellaneous Expenses - _TC", 100, submit=True
)
acc.account_currency = "USD"
self.assertRaises(frappe.ValidationError, acc.save)
def _make_test_records(verbose=None): def _make_test_records(verbose=None):
from frappe.test_runner import make_test_objects from frappe.test_runner import make_test_objects

View File

@ -12,7 +12,6 @@ frappe.ui.form.on('Payment Order', {
}); });
frm.set_df_property('references', 'cannot_add_rows', true); frm.set_df_property('references', 'cannot_add_rows', true);
frm.set_df_property('references', 'cannot_delete_rows', true);
}, },
refresh: function(frm) { refresh: function(frm) {
if (frm.doc.docstatus == 0) { if (frm.doc.docstatus == 0) {

View File

@ -375,12 +375,12 @@ def get_pricing_rule_for_item(args, price_list_rate=0, doc=None, for_validate=Fa
def update_args_for_pricing_rule(args): def update_args_for_pricing_rule(args):
if not (args.item_group and args.brand): if not (args.item_group and args.brand):
try: item = frappe.get_cached_value("Item", args.item_code, ("item_group", "brand"))
args.item_group, args.brand = frappe.get_cached_value( if not item:
"Item", args.item_code, ["item_group", "brand"]
)
except frappe.DoesNotExistError:
return return
args.item_group, args.brand = item
if not args.item_group: if not args.item_group:
frappe.throw(_("Item Group not mentioned in item master for item {0}").format(args.item_code)) frappe.throw(_("Item Group not mentioned in item master for item {0}").format(args.item_code))

View File

@ -53,6 +53,22 @@ frappe.query_reports["Accounts Payable"] = {
} }
} }
}, },
{
"fieldname": "party_account",
"label": __("Payable Account"),
"fieldtype": "Link",
"options": "Account",
get_query: () => {
var company = frappe.query_report.get_filter_value('company');
return {
filters: {
'company': company,
'account_type': 'Payable',
'is_group': 0
}
};
}
},
{ {
"fieldname": "ageing_based_on", "fieldname": "ageing_based_on",
"label": __("Ageing Based On"), "label": __("Ageing Based On"),

View File

@ -66,6 +66,22 @@ frappe.query_reports["Accounts Receivable"] = {
} }
} }
}, },
{
"fieldname": "party_account",
"label": __("Receivable Account"),
"fieldtype": "Link",
"options": "Account",
get_query: () => {
var company = frappe.query_report.get_filter_value('company');
return {
filters: {
'company': company,
'account_type': 'Receivable',
'is_group': 0
}
};
}
},
{ {
"fieldname": "ageing_based_on", "fieldname": "ageing_based_on",
"label": __("Ageing Based On"), "label": __("Ageing Based On"),

View File

@ -111,6 +111,7 @@ class ReceivablePayableReport(object):
voucher_type=gle.voucher_type, voucher_type=gle.voucher_type,
voucher_no=gle.voucher_no, voucher_no=gle.voucher_no,
party=gle.party, party=gle.party,
party_account=gle.account,
posting_date=gle.posting_date, posting_date=gle.posting_date,
account_currency=gle.account_currency, account_currency=gle.account_currency,
remarks=gle.remarks if self.filters.get("show_remarks") else None, remarks=gle.remarks if self.filters.get("show_remarks") else None,
@ -777,18 +778,22 @@ class ReceivablePayableReport(object):
conditions.append("party=%s") conditions.append("party=%s")
values.append(self.filters.get(party_type_field)) values.append(self.filters.get(party_type_field))
# get GL with "receivable" or "payable" account_type if self.filters.party_account:
account_type = "Receivable" if self.party_type == "Customer" else "Payable" conditions.append("account =%s")
accounts = [ values.append(self.filters.party_account)
d.name else:
for d in frappe.get_all( # get GL with "receivable" or "payable" account_type
"Account", filters={"account_type": account_type, "company": self.filters.company} account_type = "Receivable" if self.party_type == "Customer" else "Payable"
) accounts = [
] d.name
for d in frappe.get_all(
"Account", filters={"account_type": account_type, "company": self.filters.company}
)
]
if accounts: if accounts:
conditions.append("account in (%s)" % ",".join(["%s"] * len(accounts))) conditions.append("account in (%s)" % ",".join(["%s"] * len(accounts)))
values += accounts values += accounts
def add_customer_filters(self, conditions, values): def add_customer_filters(self, conditions, values):
if self.filters.get("customer_group"): if self.filters.get("customer_group"):
@ -888,6 +893,13 @@ class ReceivablePayableReport(object):
options=self.party_type, options=self.party_type,
width=180, width=180,
) )
self.add_column(
label="Receivable Account" if self.party_type == "Customer" else "Payable Account",
fieldname="party_account",
fieldtype="Link",
options="Account",
width=180,
)
if self.party_naming_by == "Naming Series": if self.party_naming_by == "Naming Series":
self.add_column( self.add_column(

View File

@ -50,12 +50,19 @@ class TestAccountsReceivable(unittest.TestCase):
make_credit_note(name) make_credit_note(name)
report = execute(filters) report = execute(filters)
expected_data_after_credit_note = [100, 0, 0, 40, -40] expected_data_after_credit_note = [100, 0, 0, 40, -40, "Debtors - _TC2"]
row = report[1][0] row = report[1][0]
self.assertEqual( self.assertEqual(
expected_data_after_credit_note, expected_data_after_credit_note,
[row.invoice_grand_total, row.invoiced, row.paid, row.credit_note, row.outstanding], [
row.invoice_grand_total,
row.invoiced,
row.paid,
row.credit_note,
row.outstanding,
row.party_account,
],
) )

View File

@ -1327,7 +1327,7 @@ def get_serial_nos_for_job_card(row, wo_doc):
used_serial_nos.extend(get_serial_nos(d.serial_no)) used_serial_nos.extend(get_serial_nos(d.serial_no))
serial_nos = sorted(list(set(serial_nos) - set(used_serial_nos))) serial_nos = sorted(list(set(serial_nos) - set(used_serial_nos)))
row.serial_no = "\n".join(serial_nos[0 : row.job_card_qty]) row.serial_no = "\n".join(serial_nos[0 : cint(row.job_card_qty)])
def validate_operation_data(row): def validate_operation_data(row):

View File

@ -147,6 +147,8 @@ class AdditionalSalary(Document):
@frappe.whitelist() @frappe.whitelist()
def get_additional_salaries(employee, start_date, end_date, component_type): def get_additional_salaries(employee, start_date, end_date, component_type):
from frappe.query_builder import Criterion
comp_type = "Earning" if component_type == "earnings" else "Deduction" comp_type = "Earning" if component_type == "earnings" else "Deduction"
additional_sal = frappe.qb.DocType("Additional Salary") additional_sal = frappe.qb.DocType("Additional Salary")
@ -170,8 +172,23 @@ def get_additional_salaries(employee, start_date, end_date, component_type):
& (additional_sal.type == comp_type) & (additional_sal.type == comp_type)
) )
.where( .where(
additional_sal.payroll_date[start_date:end_date] Criterion.any(
| ((additional_sal.from_date <= end_date) & (additional_sal.to_date >= end_date)) [
Criterion.all(
[ # is recurring and additional salary dates fall within the payroll period
additional_sal.is_recurring == 1,
additional_sal.from_date <= end_date,
additional_sal.to_date >= end_date,
]
),
Criterion.all(
[ # is not recurring and additional salary's payroll date falls within the payroll period
additional_sal.is_recurring == 0,
additional_sal.payroll_date[start_date:end_date],
]
),
]
)
) )
.run(as_dict=True) .run(as_dict=True)
) )

View File

@ -4,7 +4,8 @@
import unittest import unittest
import frappe import frappe
from frappe.utils import add_days, nowdate from frappe.tests.utils import FrappeTestCase
from frappe.utils import add_days, add_months, nowdate
import erpnext import erpnext
from erpnext.hr.doctype.employee.test_employee import make_employee from erpnext.hr.doctype.employee.test_employee import make_employee
@ -16,19 +17,10 @@ from erpnext.payroll.doctype.salary_slip.test_salary_slip import (
from erpnext.payroll.doctype.salary_structure.test_salary_structure import make_salary_structure from erpnext.payroll.doctype.salary_structure.test_salary_structure import make_salary_structure
class TestAdditionalSalary(unittest.TestCase): class TestAdditionalSalary(FrappeTestCase):
def setUp(self): def setUp(self):
setup_test() setup_test()
def tearDown(self):
for dt in [
"Salary Slip",
"Additional Salary",
"Salary Structure Assignment",
"Salary Structure",
]:
frappe.db.sql("delete from `tab%s`" % dt)
def test_recurring_additional_salary(self): def test_recurring_additional_salary(self):
amount = 0 amount = 0
salary_component = None salary_component = None
@ -46,19 +38,66 @@ class TestAdditionalSalary(unittest.TestCase):
if earning.salary_component == "Recurring Salary Component": if earning.salary_component == "Recurring Salary Component":
amount = earning.amount amount = earning.amount
salary_component = earning.salary_component salary_component = earning.salary_component
break
self.assertEqual(amount, add_sal.amount) self.assertEqual(amount, add_sal.amount)
self.assertEqual(salary_component, add_sal.salary_component) self.assertEqual(salary_component, add_sal.salary_component)
def test_non_recurring_additional_salary(self):
amount = 0
salary_component = None
date = nowdate()
def get_additional_salary(emp_id): emp_id = make_employee("test_additional@salary.com")
frappe.db.set_value("Employee", emp_id, "relieving_date", add_days(date, 1800))
salary_structure = make_salary_structure(
"Test Salary Structure Additional Salary", "Monthly", employee=emp_id
)
add_sal = get_additional_salary(emp_id, recurring=False, payroll_date=date)
ss = make_employee_salary_slip(
"test_additional@salary.com", "Monthly", salary_structure=salary_structure.name
)
amount, salary_component = None, None
for earning in ss.earnings:
if earning.salary_component == "Recurring Salary Component":
amount = earning.amount
salary_component = earning.salary_component
break
self.assertEqual(amount, add_sal.amount)
self.assertEqual(salary_component, add_sal.salary_component)
# should not show up in next months
ss.posting_date = add_months(date, 1)
ss.start_date = ss.end_date = None
ss.earnings = []
ss.deductions = []
ss.save()
amount, salary_component = None, None
for earning in ss.earnings:
if earning.salary_component == "Recurring Salary Component":
amount = earning.amount
salary_component = earning.salary_component
break
self.assertIsNone(amount)
self.assertIsNone(salary_component)
def get_additional_salary(emp_id, recurring=True, payroll_date=None):
create_salary_component("Recurring Salary Component") create_salary_component("Recurring Salary Component")
add_sal = frappe.new_doc("Additional Salary") add_sal = frappe.new_doc("Additional Salary")
add_sal.employee = emp_id add_sal.employee = emp_id
add_sal.salary_component = "Recurring Salary Component" add_sal.salary_component = "Recurring Salary Component"
add_sal.is_recurring = 1
add_sal.is_recurring = 1 if recurring else 0
add_sal.from_date = add_days(nowdate(), -50) add_sal.from_date = add_days(nowdate(), -50)
add_sal.to_date = add_days(nowdate(), 180) add_sal.to_date = add_days(nowdate(), 180)
add_sal.payroll_date = payroll_date
add_sal.amount = 5000 add_sal.amount = 5000
add_sal.currency = erpnext.get_default_currency() add_sal.currency = erpnext.get_default_currency()
add_sal.save() add_sal.save()

View File

@ -1,4 +1,4 @@
<div> <div class="stock-levels">
<div class="result"> <div class="result">
</div> </div>
<div class="more hidden" style="padding: 15px;"> <div class="more hidden" style="padding: 15px;">

View File

@ -1,6 +1,6 @@
{ {
"actions": [], "actions": [],
"autoname": "MAT-BIN-.YYYY.-.#####", "autoname": "hash",
"creation": "2013-01-10 16:34:25", "creation": "2013-01-10 16:34:25",
"doctype": "DocType", "doctype": "DocType",
"engine": "InnoDB", "engine": "InnoDB",
@ -171,11 +171,11 @@
"idx": 1, "idx": 1,
"in_create": 1, "in_create": 1,
"links": [], "links": [],
"modified": "2022-01-30 17:04:54.715288", "modified": "2022-03-30 07:22:23.868602",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Bin", "name": "Bin",
"naming_rule": "Expression (old style)", "naming_rule": "Random",
"owner": "Administrator", "owner": "Administrator",
"permissions": [ "permissions": [
{ {

View File

@ -1,6 +1,6 @@
{ {
"actions": [], "actions": [],
"autoname": "REPOST-ITEM-VAL-.######", "autoname": "hash",
"creation": "2022-01-11 15:03:38.273179", "creation": "2022-01-11 15:03:38.273179",
"doctype": "DocType", "doctype": "DocType",
"editable_grid": 1, "editable_grid": 1,
@ -177,11 +177,11 @@
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2022-01-18 10:57:33.450907", "modified": "2022-03-30 07:22:48.520266",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Repost Item Valuation", "name": "Repost Item Valuation",
"naming_rule": "Expression (old style)", "naming_rule": "Random",
"owner": "Administrator", "owner": "Administrator",
"permissions": [ "permissions": [
{ {