Skip to content

Commit

Permalink
Merge branch 'version-14' into read_only
Browse files Browse the repository at this point in the history
  • Loading branch information
agritheory authored Sep 8, 2023
2 parents c7bb83c + 5831fb8 commit aaca764
Show file tree
Hide file tree
Showing 10 changed files with 255 additions and 137 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/main.yaml → .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
prettier:
lint:
needs: [ py_json_merge ]
runs-on: ubuntu-latest
steps:
Expand All @@ -24,6 +24,21 @@ jobs:
with:
commit_message: "style: prettify code"

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

- name: Install mypy
run: pip install mypy

- name: Run mypy
uses: sasanquaneuf/mypy-github-action@releases/v1
with:
checkName: 'mypy'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

json_diff:
needs: [ py_json_merge ]
runs-on: ubuntu-latest
Expand Down
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ repos:
- id: flake8
additional_dependencies: ['flake8-bugbear']

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
hooks:
- id: mypy
exclude: ^tests/
args: [--ignore-missing-imports]

ci:
autoupdate_schedule: weekly
skip: []
Expand Down
70 changes: 69 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,74 @@

MIT

### Installation Instructions
### Production Installation Instructions

See the [installation guide](./docs/installationguide.md) for detailed instructions for either a production or development environment.

#### Developer Setup

First, set up a new bench and substitute a path to the python version to use. Python should be 3.10 latest for V14. These instructions use [pyenv](https://github.com/pyenv/pyenv) for managing environments.
```shell
# Version 14
bench init --frappe-branch version-14 {{ bench name }} --python ~/.pyenv/versions/3.10.3/bin/python3
```

Create a new site in that bench
```shell
cd {{ bench name }}
bench new-site {{ site name }} --force --db-name {{ site name }}
```

Download the ERPNext app
```shell
# Version 14
bench get-app erpnext --branch version-14
bench get-app hrms --branch version-14
```

Download the Time and Expense application
```shell
bench get-app check_run https://github.com/agritheory/check_run
```

Install the apps to your site
```shell
bench --site {{ site name }} install-app erpnext hrms check_run

# Optional: Check that all apps installed on your site
bench --site {{ site name }} list-apps
```

Set developer mode in `site_config.json`
```shell
nano sites/{{ site name }}/site_config.json
# Add this line:
"developer_mode": 1,

```
Install pre-commit:
```
# ~/frappe-bench/apps/check_run/
pre-commit install
```

Add the site to your computer's hosts file to be able to access it via: `http://{{ site name }}:[8000]`. You'll need to enter your root password to allow your command line application to make edits to this file.
```shell
bench --site {{site name}} add-to-hosts
```

Launch your bench (note you should be using Node.js v14 for a Version 13 bench and Node.js v16 for a Version 14 bench)
```shell
bench start
```

Optional: install a [demo Company and its data](./exampledata.md) to test the Electronic Payments module's functionality
```shell
bench execute 'check_run.tests.setup.before_test'
```

To run `mypy` locally:
```shell
source env/bin/activate
mypy ./apps/check_run/check_run --ignore-missing-imports
```
13 changes: 11 additions & 2 deletions check_run/check_run/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
# Copyright (c) 2023, AgriTheory and contributors
# For license information, please see license.txt

import json

import frappe

from erpnext.accounts.doctype.purchase_invoice.purchase_invoice import PurchaseInvoice
from erpnext.accounts.doctype.journal_entry.journal_entry import JournalEntry
from hrms.hr.doctype.expense_claim.expense_claim import ExpenseClaim


@frappe.whitelist()
@frappe.read_only()
def show_bank_account_number(doctype, docname):
def show_bank_account_number(doctype: str, docname: str) -> dict:
doc = frappe.get_doc(doctype, docname)
routing_number = frappe.get_value("Bank", doc.bank, "aba_number") or ""
account_number = doc.get_password("bank_account", raise_exception=False) or ""
return {"routing_number": routing_number, "account_number": account_number}


@frappe.whitelist()
def disallow_cancellation_if_in_check_run(doc, method=None):
def disallow_cancellation_if_in_check_run(
doc: PurchaseInvoice | JournalEntry | ExpenseClaim, method: str | None = None
) -> None:
draft_check_runs = frappe.get_all("Check Run", ["name", "transactions"], {"docstatus": 0})
for draft_check_run in draft_check_runs:
if not draft_check_run.transactions:
Expand Down
Loading

0 comments on commit aaca764

Please sign in to comment.