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

Port recent version-13 changes #50

Merged
merged 3 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 11 additions & 5 deletions .github/helper/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
cd ~ || exit

pip install frappe-bench
git clone https://github.com/frappe/frappe --branch version-13 --depth 1
git clone https://github.com/frappe/frappe --branch version-14 --depth 1
bench init --skip-assets --frappe-path ~/frappe --python "$(which python)" frappe-bench

mkdir ~/frappe-bench/sites/test_site
cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config.json" ~/frappe-bench/sites/test_site
cp -r "${{GITHUB_WORKSPACE}}/.github/helper/site_config.json" ~/frappe-bench/sites/test_site

mysql --host 127.0.0.1 --port 3306 -u root -e "SET GLOBAL character_set_server = 'utf8mb4'"
mysql --host 127.0.0.1 --port 3306 -u root -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'"
Expand All @@ -34,9 +34,15 @@ cd ./apps/frappe || exit
yarn add [email protected]
cd ../..

bench get-app erpnext --branch version-13
bench get-app check_run "${GITHUB_WORKSPACE}"
bench get-app https://github.com/frappe/payments
bench get-app https://github.com/frappe/erpnext --branch version-14
bench get-app https://github.com/frappe/hrms
bench setup requirements --dev

bench start &> bench_run_logs.txt &
CI=Yes bench build --app frappe &
bench --site test_site reinstall --yes
CI=Yes bench build

bench get-app check_run "${{GITHUB_WORKSPACE}}"
bench --site test_site install-app check_run
bench setup requirements --dev
4 changes: 2 additions & 2 deletions .github/helper/install_dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

# Check for merge conflicts before proceeding
python -m compileall -f "${GITHUB_WORKSPACE}"
if grep -lr --exclude-dir=node_modules "^<<<<<<< " "${GITHUB_WORKSPACE}"
python -m compileall -f "${{GITHUB_WORKSPACE}}"
if grep -lr --exclude-dir=node_modules "^<<<<<<< " "${{GITHUB_WORKSPACE}}"
then echo "Found merge conflicts"
exit 1
fi
Expand Down
File renamed without changes.
22 changes: 10 additions & 12 deletions .github/workflows/ui_test.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: UI
name: UI Tests

on:
push:
branches: [ version-14 ]
pull_request:
workflow_dispatch:
branches: [ version-14 ]

jobs:
cypress-run:
Expand All @@ -21,16 +23,16 @@ jobs:

steps:
- name: Clone
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.10'

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: '12'
node-version: '16'
check-latest: true

- name: Add to Hosts
Expand Down Expand Up @@ -79,15 +81,11 @@ jobs:
${{ runner.os }}-

- name: Install Dependencies
run: bash ${GITHUB_WORKSPACE}/.github/helper/install_dependencies.sh
run: bash ${{GITHUB_WORKSPACE}}/.github/helper/install_dependencies.sh

- name: Install
run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh

- name: Check Run Setup
run: |
cd ~/frappe-bench
bench --site test_site execute 'check_run.test_setup.before_test'
bash ${{GITHUB_WORKSPACE}}/.github/helper/install.sh

- name: Cypress run
uses: cypress-io/github-action@v4
Expand Down
36 changes: 27 additions & 9 deletions check_run/check_run/doctype/check_run/check_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
from frappe.permissions import has_permission
from frappe.utils.file_manager import save_file, remove_all, download_file
from frappe.utils.password import get_decrypted_password
from frappe.contacts.doctype.address.address import get_default_address
from frappe.query_builder.custom import ConstantColumn
from frappe.query_builder.functions import Coalesce

from erpnext.accounts.utils import get_balance_on
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_dimensions


from atnacha import ACHEntry, ACHBatch, NACHAFile

class CheckRun(Document):
Expand All @@ -41,8 +41,8 @@ def validate(self):
self.beg_balance = get_balance_on(gl_account, self.posting_date)
if self.flags.in_insert:
if self.initial_check_number is None:
self.get_last_check_number()
self.get_default_payable_account()
self.set_last_check_number()
self.set_default_payable_account()
self.set_default_dates()
else:
self.validate_last_check_number()
Expand Down Expand Up @@ -74,13 +74,13 @@ def set_status(self, status=None):
elif self.docstatus == 1:
self.status = 'Submitted'

def get_last_check_number(self):
def set_last_check_number(self):
if self.ach_only().ach_only:
return
check_number = frappe.get_value('Bank Account', self.bank_account, "check_number")
self.initial_check_number = int(check_number or 0) + 1

def get_default_payable_account(self):
def set_default_payable_account(self):
if not self.pay_to_account:
self.pay_to_account = frappe.get_value('Company', self.company, "default_payable_account")

Expand Down Expand Up @@ -126,7 +126,6 @@ def build_nacha_file(self, settings=None):
payment_entries = [frappe.get_doc('Payment Entry', pe) for pe in ach_payment_entries]
nacha_file = build_nacha_file_from_payment_entries(self, payment_entries, settings)
ach_file = StringIO(nacha_file())
print(ach_file)
ach_file.seek(0)
return ach_file

Expand Down Expand Up @@ -154,7 +153,14 @@ def create_payment_entries(self, transactions):
check_count = 0
_transactions = []
gl_account = frappe.get_value('Bank Account', self.bank_account, 'account')
for party, _group in groupby(transactions, key=lambda x: x.party):
key_lookup = lambda x: x.party
if settings and settings.split_by_address:
key_lookup = lambda x: (x.get('party'), x.get('address'))
for transaction in transactions:
transaction['address'] = get_address(
transaction.get('party'), transaction.get('party_type'), transaction.get('doctype'), transaction.get('name')
)
for party, _group in groupby(transactions, key=key_lookup):
_group = list(_group)
if frappe.db.get_value('Mode of Payment', _group[0].mode_of_payment, 'type') == 'Bank':
groups = list(zip_longest(*[iter(_group)] * split))
Expand Down Expand Up @@ -540,7 +546,7 @@ def build_nacha_file_from_payment_entries(doc, payment_entries, settings):
)
nacha_file = NACHAFile(
priority_code=1,
immediate_destination=company_bank_aba_number,
immediate_destination=company_bank_aba_number if not settings.omit_destination else "",
immediate_origin=company_bank_aba_number,
file_creation_date=getdate(),
file_creation_time=get_datetime(),
Expand All @@ -559,4 +565,16 @@ def build_nacha_file_from_payment_entries(doc, payment_entries, settings):
def get_check_run_settings(doc):
doc = frappe._dict(json.loads(doc)) if isinstance(doc, str) else doc
if frappe.db.exists('Check Run Settings', {'bank_account': doc.bank_account, 'pay_to_account': doc.pay_to_account}):
return frappe.get_doc('Check Run Settings', {'bank_account': doc.bank_account, 'pay_to_account': doc.pay_to_account})
return frappe.get_doc('Check Run Settings', {'bank_account': doc.bank_account, 'pay_to_account': doc.pay_to_account})


def get_address(party, party_type, doctype, name):
if doctype == 'Purchase Invoice':
return frappe.get_value('Purchase Invoice', name, 'supplier_address')
elif doctype == 'Expense Claim':
return frappe.get_value('Employee', name, 'permanent_address')
elif doctype == 'Journal Entry':
if party_type == 'Supplier':
return get_default_address('Supplier', party)
elif party_type == 'Employee':
return frappe.get_value('Employee', name, 'permanent_address')
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@
"cascade_cancellation",
"column_break_9",
"number_of_invoices_per_voucher",
"split_by_address",
"ach_settings_section",
"ach_file_extension",
"ach_service_class_code",
"ach_standard_class_code",
"ach_description"
"ach_description",
"column_break_21",
"omit_destination"
],
"fields": [
{
Expand Down Expand Up @@ -132,10 +136,31 @@
"fieldtype": "Link",
"label": "Print Format",
"options": "Print Format"
}
},
{
"default": "0",
"fieldname": "split_by_address",
"fieldtype": "Check",
"label": "Split Invoices by Address"
},
{
"fieldname": "ach_settings_section",
"fieldtype": "Section Break",
"label": "ACH Settings"
},
{
"default": "0",
"fieldname": "omit_destination",
"fieldtype": "Check",
"label": "Omit Destination"
},
{
"fieldname": "column_break_21",
"fieldtype": "Column Break"
}
],
"links": [],
"modified": "2022-08-26 16:54:08.327344",
"modified": "2022-02-13 15:33:15.269467",
"modified_by": "Administrator",
"module": "Check Run",
"name": "Check Run Settings",
Expand Down
5 changes: 5 additions & 0 deletions check_run/public/js/check_run/check_run.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,15 @@ check_run.mount_table = frm => {
}

check_run.keyDownHandler = e => {

if(!check_run.frm) {
return
}

if(document.activeElement.tagName == "INPUT" || document.activeElement.tagName == "TEXTAREA") {
return
}

if(e.keyCode == 40 && check_run.frm.check_run_state.selectedRow < (check_run.frm.check_run_state.transactions.length - 1)){
for(let j=0;j<check_run.frm.check_run_state.transactions.length;j++) {
if(check_run.frm.check_run_state.transactions[j].mopIsOpen) {
Expand Down
Loading