Skip to content

Commit

Permalink
ci: add frappe black to CI (#214)
Browse files Browse the repository at this point in the history
* ci: add frappe black to CI

* chore: black, flake8
  • Loading branch information
agritheory authored Mar 5, 2024
1 parent d98f198 commit 771e57c
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 22 deletions.
31 changes: 26 additions & 5 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,33 @@ jobs:
- name: Install mypy
run: pip install mypy

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

black:
needs: [ py_json_merge ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
checkName: 'mypy'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.head_ref }}
fetch-depth: 2

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

- name: Install Black (Frappe)
run: pip install git+https://github.com/frappe/black.git

- name: Run Black (Frappe)
run: black --check .

json_diff:
needs: [ py_json_merge ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,45 @@
def execute(filters=None):
return get_columns(filters), get_data(filters)


def get_data(filters):
PurchaseInvoice = DocType("Purchase Invoice")
data = (
frappe.qb.from_(PurchaseInvoice)
.select(
PurchaseInvoice.name, PurchaseInvoice.title, PurchaseInvoice.supplier, PurchaseInvoice.company,
PurchaseInvoice.posting_date, PurchaseInvoice.grand_total, PurchaseInvoice.status, PurchaseInvoice.currency,
PurchaseInvoice.supplier_name, PurchaseInvoice.grand_total, PurchaseInvoice.outstanding_amount,
PurchaseInvoice.due_date, PurchaseInvoice.is_return, PurchaseInvoice.release_date, PurchaseInvoice.represents_company,
PurchaseInvoice.is_internal_supplier
)
.orderby('modified', Order.desc)
.select(
PurchaseInvoice.name,
PurchaseInvoice.title,
PurchaseInvoice.supplier,
PurchaseInvoice.company,
PurchaseInvoice.posting_date,
PurchaseInvoice.grand_total,
PurchaseInvoice.status,
PurchaseInvoice.currency,
PurchaseInvoice.supplier_name,
PurchaseInvoice.grand_total,
PurchaseInvoice.outstanding_amount,
PurchaseInvoice.due_date,
PurchaseInvoice.is_return,
PurchaseInvoice.release_date,
PurchaseInvoice.represents_company,
PurchaseInvoice.is_internal_supplier,
)
.orderby("modified", Order.desc)
).run(as_dict=True)

for row in data:
row['attachments'] = " ".join([
f"""<a data-pdf-preview="{attachment.file_url}" onclick="pdf_preview('{attachment.file_url}')">{attachment.file_name}</a>"""
for attachment in get_attachments('Purchase Invoice', row['name']) if attachment.file_url.endswith('.pdf')
])
row["attachments"] = " ".join(
[
f"""<a data-pdf-preview="{attachment.file_url}" onclick="pdf_preview('{attachment.file_url}')">{attachment.file_name}</a>"""
for attachment in get_attachments("Purchase Invoice", row["name"])
if attachment.file_url.endswith(".pdf")
]
)
return data


def get_columns(filters):
return [

{
"label": frappe._("Name"),
"fieldname": "name",
Expand Down Expand Up @@ -142,4 +157,3 @@ def get_columns(filters):
"width": "400px",
},
]

3 changes: 1 addition & 2 deletions check_run/patches/patch_voided_check_workflow.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import frappe
from check_run.customize import add_workflow_for_voided_check


def execute():
add_workflow_for_voided_check()
add_workflow_for_voided_check()

0 comments on commit 771e57c

Please sign in to comment.