Skip to content

Commit

Permalink
Merge pull request #4 from agritheory/key-nav
Browse files Browse the repository at this point in the history
changes: spacebar checks/unchecks pay, keys a-z open MOP / starts search
  • Loading branch information
agritheory authored Jul 24, 2022
2 parents 0823fc5 + 1b19e30 commit 121932a
Show file tree
Hide file tree
Showing 21 changed files with 2,374 additions and 99 deletions.
196 changes: 192 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,194 @@
.DS_Store
*.pyc
*.egg-info
*.py~
*.comp.js
*.DS_Store
locale
.wnf-lang-status
*.swp
tags
check_run/docs/current
*.egg-info
dist/
# build/
frappe/docs/current
.vscode
node_modules
.kdev4/
*.kdev4
*debug.log

# Not Recommended, but will remove once webpack ready
package-lock.json

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
# build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
.static_storage/
.media/
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

# cypress
cypress/screenshots
cypress/videos

# JetBrains IDEs
.idea/
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,16 @@ In a new terminal window
```
bench update
```
### Testing
#### Running Cypress tests
To set up local Cypress tests;
```bash
cd apps/check_run
yarn
```
Additional steps may be required on WSL, use Nicky's guide:
https://nickymeuleman.netlify.app/blog/gui-on-wsl2-cypress

### Printer Server setup
```
sudo apt-get install gcc cups python3-dev libcups2-dev -y
bench pip install pycups
sudo usermod -a -G lpadmin {username} # the "frappe" user in most installations
```
Go to `{server URL or localhost}:631` to access the CUPS web interface
Configuration on a remote server will take extra steps to secure:
https://askubuntu.com/questions/23936/how-do-you-administer-cups-remotely-using-the-web-interface

```bash
yarn run cypress open
```
35 changes: 29 additions & 6 deletions check_run/check_run/doctype/check_run/check_run.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// For license information, please see license.txt
frappe.ui.form.on("Check Run", {
validate: frm => {
validate_mode_of_payment_mandatory(frm)
if(frm.check_run_state.party_filter.length > 0) {
frm.check_run_state.party_filter = ""
frm.check_run_state.show_party_filter = false
Expand Down Expand Up @@ -45,6 +46,10 @@ frappe.ui.form.on("Check Run", {
onload_post_render: frm => {
frm.page.wrapper.find('.layout-side-section').hide()
permit_first_user(frm)
frappe.xcall('check_run.check_run.doctype.check_run.check_run.get_balance', { doc: frm.doc })
.then(r => {
frm.set_value('beg_balance', r)
})
},
end_date: frm => {
get_entries(frm)
Expand Down Expand Up @@ -117,11 +122,6 @@ function get_defaults(frm){
if(!frm.is_new()){ return }
frm.set_value('start_date', moment().startOf('week').format())
frm.set_value('end_date', moment().endOf('week').format())
frappe.db.get_value('Company', frm.doc.company, ['default_bank_account', 'default_payable_account'])
.then(r => {
frm.set_value('bank_account', r.message.default_bank_account)
frm.set_value('pay_to_account', r.message.default_payable_account)
})
}

function get_last_check_number(frm){
Expand Down Expand Up @@ -198,7 +198,7 @@ function reprint_checks(frm){
{
fieldname: 'reprint_check_number',
fieldtype: 'Data',
label: "New Intial Check Number",
label: "New Initial Check Number",
}
],
minimizable: false,
Expand All @@ -212,3 +212,26 @@ function reprint_checks(frm){
})
d.show()
}


function validate_mode_of_payment_mandatory(frm){
let mode_of_payment_required = []
for(const index in frm.check_run_state.transactions){
let row = frm.check_run_state.transactions[index]
if (row.pay && row.mode_of_payment.length < 2){
mode_of_payment_required.push({ row: index + 1, party: row.party, ref_name: row.ref_number || row.name })
}
}
if (mode_of_payment_required.length == 0){ return }
let message = ''
for (const index in mode_of_payment_required) {
let row = mode_of_payment_required[index]
message += `<li>Row ${row.row}: ${row.party} - ${row.ref_name}</li>`
}
frappe.msgprint({
message: `<br><br><ul>${message}</ul>`,
indicator: 'red',
title: __('Mode of Payment Required'),
raise_exception: true,
})
}
5 changes: 4 additions & 1 deletion check_run/check_run/doctype/check_run/check_run.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
},
{
"allow_in_quick_entry": 1,
"fetch_from": "company.default_bank_account",
"fetch_if_empty": 1,
"fieldname": "bank_account",
"fieldtype": "Link",
"label": "Paid From (Bank Account)",
Expand All @@ -89,6 +91,7 @@
"reqd": 1
},
{
"default": "company.default_payable_account",
"fieldname": "pay_to_account",
"fieldtype": "Link",
"label": "Accounts Payable",
Expand Down Expand Up @@ -155,7 +158,7 @@
],
"is_submittable": 1,
"links": [],
"modified": "2022-07-08 10:10:39.971682",
"modified": "2022-07-10 16:16:03.289288",
"modified_by": "Administrator",
"module": "Check Run",
"name": "Check Run",
Expand Down
Loading

0 comments on commit 121932a

Please sign in to comment.