diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml new file mode 100644 index 00000000..971e8a65 --- /dev/null +++ b/.github/workflows/backport.yml @@ -0,0 +1,26 @@ +name: Backport +on: + pull_request_target: + types: + - closed + - labeled + +jobs: + backport: + name: Backport + runs-on: ubuntu-latest + # Only react to merged PRs for security reasons. + # See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target. + if: > + github.event.pull_request.merged + && ( + github.event.action == 'closed' + || ( + github.event.action == 'labeled' + && contains(github.event.label.name, 'backport') + ) + ) + steps: + - uses: tibdex/backport@v2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index f5302c88..b5eadb1a 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -15,7 +15,6 @@ env: jobs: mypy: - needs: [ py_json_merge ] runs-on: ubuntu-latest steps: - name: Checkout @@ -40,7 +39,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} black: - needs: [ py_json_merge ] runs-on: ubuntu-latest steps: - name: Checkout @@ -53,12 +51,11 @@ jobs: - name: Install Black (Frappe) run: pip install git+https://github.com/frappe/black.git - + - name: Run Black (Frappe) run: black --check . prettier: - needs: [ py_json_merge ] runs-on: ubuntu-latest steps: - name: Checkout @@ -76,4 +73,3 @@ jobs: run: | echo "The following files are not formatted:" echo "${{steps.prettier-run.outputs.prettier_output}}" >> $GITHUB_OUTPUT - diff --git a/CHANGELOG.md b/CHANGELOG.md index c129b342..d38d3b47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,76 @@ # CHANGELOG +## v15.1.2 (2024-07-18) +### Fix + +* fix: serialize null transactions(v15) (#262) + +* fix: serialize null transactions(v15) + +* fix: remove ci jobs dependency ([`5e13ec7`](https://github.com/agritheory/check_run/commit/5e13ec7514b78ce6d2596ed5c640e4f2c1d9bada)) + +### Unknown + +* Allow or Disallow stand-alone debit note in check run -- Version 15 (#257) + +* allow or disallow standalone debit note + +* test cases changes' ([`e0707df`](https://github.com/agritheory/check_run/commit/e0707df4fba64ac63e9fd4d36627c792748db292)) + +* Fix payment schedule outstanding v15 (#254) + +* fix: fix payment schedule outstanding + +* test: assert parent doc amount matches + +* tests: fix matching error message + +* feat: on_cancel hook and tests + +* feat: minor changes, add precision (#253) + +* fix: isort, JE generation issue + +--------- + +Co-authored-by: Francisco Roldán <franciscoproldan@gmail.com> ([`624f36e`](https://github.com/agritheory/check_run/commit/624f36ebf195e734795216cdc790b0b1112ee802)) + +## v15.1.1 (2024-05-29) + +### Ci + +* ci: add conftest file updated for json (#228) ([`dc306c3`](https://github.com/agritheory/check_run/commit/dc306c3364ac9ecb2d02003137284a138340ef42)) + +* ci: remove cypress, fix hrms install, conform (#221) + +* ci: remove cypress, fix hrms install, conform + +* ci: fix mypy error ([`f6b629b`](https://github.com/agritheory/check_run/commit/f6b629b7876a14795f39dc6d853ea5b7f8722098)) + +### Fix + +* fix: bankaccount => bank typing (#247) ([`da77cc3`](https://github.com/agritheory/check_run/commit/da77cc329e28d95f84783d98dbd204addb39d0e8)) + +### Test + +* test: add tests, remove cypress (#238) ([`c20ed6e`](https://github.com/agritheory/check_run/commit/c20ed6e23fc744f0718dd85665f407c134bb7a56)) + +### Unknown + +* Grant file download access for multiple downloads only to specific roles (#237) + +* ach file download access + +* replace super class validate + +* chore: prettier + +* ci: remove old linters + +--------- + +Co-authored-by: Tyler Matteson <tyler@agritheory.com> ([`160f609`](https://github.com/agritheory/check_run/commit/160f6090b3e3061f12c8f9649c4755bb358a8f70)) ## v15.1.0 (2024-03-18) @@ -14,25 +84,23 @@ * feat: version-15 ([`0f2cd0a`](https://github.com/agritheory/check_run/commit/0f2cd0ada07d1cb3e13ebe5325a0b9d6ab2e3876)) - ## v15.0.0 (2024-03-05) ### Ci * ci: add frappe black to CI (#214) -* ci: add frappe black to CI - +* ci: add frappe black to CI + * chore: black, flake8 ([`771e57c`](https://github.com/agritheory/check_run/commit/771e57c166f6516c4a518d5960ff1371b254b038)) ### Unknown * Add Progress Bar for "Process Check Run" and "Rendering Checks" (#212) -* feat: progress bar in check run processing - -* feat: improvement and progress in print ([`d98f198`](https://github.com/agritheory/check_run/commit/d98f1985e853d68b9e7bb3661b370b6b0b194e82)) +* feat: progress bar in check run processing +* feat: improvement and progress in print ([`d98f198`](https://github.com/agritheory/check_run/commit/d98f1985e853d68b9e7bb3661b370b6b0b194e82)) ## v14.11.5 (2024-02-06) @@ -48,43 +116,41 @@ Co-authored-by: viralpatel15 <viralkansodiya167@gmail.com> ([`0b4bff0`](ht * Override a function to improve error msg (#205) -* Allocated ammount validation override for msg improvement - -* comment add - -* add a comment on function - -* Refactor: Rename 'uniq_vouchers' to 'unique_vouchers' in payment_entry.py - ---------- - +* Allocated ammount validation override for msg improvement + +* comment add + +* add a comment on function + +* Refactor: Rename 'uniq_vouchers' to 'unique_vouchers' in payment_entry.py + +--------- + Co-authored-by: viralpatel15 <viralkansodiya167@gmail.com> ([`80fa4cf`](https://github.com/agritheory/check_run/commit/80fa4cf564b8f437eaccfc042af10c23b54b895b)) * Remove paid document on Process check run (#202) -* class name has been change - -* fix: remove paid invoice and changes related to manually paid case - +* class name has been change + +* fix: remove paid invoice and changes related to manually paid case + * changes to remove class name changes ([`43cc33e`](https://github.com/agritheory/check_run/commit/43cc33ee6f192271b5c10b5c1efea7c09b17375f)) * class name has been changed (#201) ([`8d46b53`](https://github.com/agritheory/check_run/commit/8d46b535748949e1d5467b05f69abc6d68dc077b)) - ## v14.11.4 (2024-01-22) ### Fix * fix: always include payment term for purchase invoice (#197) -* ci: update app name in path string check - -* fix: add PI payment term in Pmt Entry outside a Check Run - -* tests: add manual payment entry to test payment term - -* docs: update for Payment Entry payment term customizations ([`1156621`](https://github.com/agritheory/check_run/commit/1156621b4b80f0e7a5cc3f7c10076910305ad29b)) +* ci: update app name in path string check + +* fix: add PI payment term in Pmt Entry outside a Check Run + +* tests: add manual payment entry to test payment term +* docs: update for Payment Entry payment term customizations ([`1156621`](https://github.com/agritheory/check_run/commit/1156621b4b80f0e7a5cc3f7c10076910305ad29b)) ## v14.11.3 (2024-01-18) @@ -92,14 +158,12 @@ Co-authored-by: viralpatel15 <viralkansodiya167@gmail.com> ([`80fa4cf`](ht * fix: add docstatus check first before fetching supplier MOP (#195) ([`9691364`](https://github.com/agritheory/check_run/commit/9691364f52248e4dfd2c79eaa89bdaba41c5d148)) - ## v14.11.2 (2024-01-18) ### Fix * fix: remove validation (#194) ([`efda8ae`](https://github.com/agritheory/check_run/commit/efda8ae0f58ce272eae7888a0dd867a7ede4c792)) - ## v14.11.1 (2024-01-18) ### Fix @@ -110,67 +174,66 @@ Co-authored-by: viralpatel15 <viralkansodiya167@gmail.com> ([`80fa4cf`](ht * Optionally validate if check number has been used already (#189) -* feat: add "validate unique check number" setting - -* feat: Optionally validate if check number has been used already - -* feat: Optionally validate if check number has been used already - +* feat: add "validate unique check number" setting + +* feat: Optionally validate if check number has been used already + +* feat: Optionally validate if check number has been used already + * fix: tabulation ([`e374b97`](https://github.com/agritheory/check_run/commit/e374b9797985a9842541335cba3bfb40f9e74bfd)) * File preview in check run (#182) -* feat: file preview - -* feat: improvement - -* feat: file preview treshold - -* fix: refactor filters to work with prettier, also fix rendering bug - ---------- - +* feat: file preview + +* feat: improvement + +* feat: file preview treshold + +* fix: refactor filters to work with prettier, also fix rendering bug + +--------- + Co-authored-by: Tyler Matteson <tyler@agritheory.com> ([`1e8cd26`](https://github.com/agritheory/check_run/commit/1e8cd268786cb8dcea94bb7f279643a48570aa77)) * Validate customizations (#166) -* fix: validate customizations - -* Per supplier invoices per voucher (#165) - -* feat: allow per-supplier override for number of invoices per voucher - -* docs: add docs for per supplier invoices per voucher - -* Quick Check (#172) - -* feat: quick check poc - -* fix: add additional filters in check run settings and also in check run quick entry - -* docs: quick check and payment entry customization docs - -* fix: validate customizations - +* fix: validate customizations + +* Per supplier invoices per voucher (#165) + +* feat: allow per-supplier override for number of invoices per voucher + +* docs: add docs for per supplier invoices per voucher + +* Quick Check (#172) + +* feat: quick check poc + +* fix: add additional filters in check run settings and also in check run quick entry + +* docs: quick check and payment entry customization docs + +* fix: validate customizations + * chore: prettier ([`6fd59cb`](https://github.com/agritheory/check_run/commit/6fd59cb5dea2f7b7e84387796c18ebd83ad18442)) * Add workflow for voided check (#187) -* feat: voided check - -* style: prettify code - -* fix: rename workflow - -* chore: remove list JS, use workflow instead - -* chore: tab spacing - ---------- - -Co-authored-by: fproldan <fproldan@users.noreply.github.com> -Co-authored-by: Tyler Matteson <tyler@agritheory.com> ([`a84c566`](https://github.com/agritheory/check_run/commit/a84c5667edafa09b876a17f80661f0ced65a796e)) +* feat: voided check + +* style: prettify code + +* fix: rename workflow +* chore: remove list JS, use workflow instead + +* chore: tab spacing + +--------- + +Co-authored-by: fproldan <fproldan@users.noreply.github.com> +Co-authored-by: Tyler Matteson <tyler@agritheory.com> ([`a84c566`](https://github.com/agritheory/check_run/commit/a84c5667edafa09b876a17f80661f0ced65a796e)) ## v14.11.0 (2024-01-08) @@ -182,14 +245,12 @@ Co-authored-by: Tyler Matteson <tyler@agritheory.com> ([`a84c566`](https:/ * patch: update outsanting in old payment schedule entries (#183) ([`a9e3e8b`](https://github.com/agritheory/check_run/commit/a9e3e8b1685cdad2c243e6c383ad0563f31f5c27)) - ## v14.10.0 (2023-12-14) ### Feature * feat: ignore PI where debit not has been issued (#181) ([`e085e96`](https://github.com/agritheory/check_run/commit/e085e9675a70c81fdc560e2341472d345c92ee70)) - ## v14.9.0 (2023-12-12) ### Documentation @@ -210,65 +271,62 @@ Co-authored-by: Tyler Matteson <tyler@agritheory.com> ([`a84c566`](https:/ feat: add fallbacks for mode of payment per source document type ([`c609603`](https://github.com/agritheory/check_run/commit/c6096038c1363e14a2ba7abb29f2cf73d25ce860)) - ## v14.8.4 (2023-12-11) ### Fix * fix: only fetch check number on "pay" payment types (#179) ([`1b6dd48`](https://github.com/agritheory/check_run/commit/1b6dd488a6cf921c4497737f47d27627f19e510f)) - ## v14.8.3 (2023-12-11) ### Fix * fix: mode of payment summary (#176) -* fix: mode of payment summary - -* wip: refactor reactivity for performance - -* feat: improved reactivity - -* style: prettify code - -* fix: move built files to dist folder / ignored by git - ---------- - -Co-authored-by: Tyler Matteson <tyler@agritheory.com> +* fix: mode of payment summary + +* wip: refactor reactivity for performance + +* feat: improved reactivity + +* style: prettify code + +* fix: move built files to dist folder / ignored by git + +--------- + +Co-authored-by: Tyler Matteson <tyler@agritheory.com> Co-authored-by: agritheory <agritheory@users.noreply.github.com> ([`40fd4ee`](https://github.com/agritheory/check_run/commit/40fd4ee3057f9808944258b9d7807522827f17a6)) ### Unknown * Draft: Paid Invoices appearing in the Check Run (#171) -* wip: add correct setup data to remove payment terms bug - -* fix: paid invoices showing in check run - -* fix: add payment schedule validation in payment entry - -* docs: add purchase invoice payment term considerations - ---------- - +* wip: add correct setup data to remove payment terms bug + +* fix: paid invoices showing in check run + +* fix: add payment schedule validation in payment entry + +* docs: add purchase invoice payment term considerations + +--------- + Co-authored-by: Heather Kusmierz <heather.kusmierz@gmail.com> ([`bbb66d6`](https://github.com/agritheory/check_run/commit/bbb66d6b79fd2719b8ba6d691f73302a58362e4d)) * Quick Check (#172) -* feat: quick check poc - -* fix: add additional filters in check run settings and also in check run quick entry - +* feat: quick check poc + +* fix: add additional filters in check run settings and also in check run quick entry + * docs: quick check and payment entry customization docs ([`37a39a1`](https://github.com/agritheory/check_run/commit/37a39a17f490e6e3d173707e36cd4467116f4e3b)) * Per supplier invoices per voucher (#165) -* feat: allow per-supplier override for number of invoices per voucher - -* docs: add docs for per supplier invoices per voucher ([`567762c`](https://github.com/agritheory/check_run/commit/567762c67c9cbbc89e57f345beca61a64e28961a)) +* feat: allow per-supplier override for number of invoices per voucher +* docs: add docs for per supplier invoices per voucher ([`567762c`](https://github.com/agritheory/check_run/commit/567762c67c9cbbc89e57f345beca61a64e28961a)) ## v14.8.2 (2023-09-22) @@ -276,10 +334,9 @@ Co-authored-by: Heather Kusmierz <heather.kusmierz@gmail.com> ([`bbb66d6`] * fix: required_apps (#162) -* fix: required_apps - -* fix: required_apps ([`31b5297`](https://github.com/agritheory/check_run/commit/31b52975839424f9a9bfbded6cc03c241dcb44cd)) +* fix: required_apps +* fix: required_apps ([`31b5297`](https://github.com/agritheory/check_run/commit/31b52975839424f9a9bfbded6cc03c241dcb44cd)) ## v14.8.1 (2023-09-14) @@ -295,54 +352,53 @@ Co-authored-by: Heather Kusmierz <heather.kusmierz@gmail.com> ([`bbb66d6`] * Port preview to V14 (#153) -* File Preview (#140) - -* wip: file preview - -* feat: preview in check run, allow to preview in non submittable documents - -* feat: WIP payables attachment report - -* feat: wip preview of attachments - -* style: prettify code - -* feat: close with space - -* fix: do not open sidebar in check run - -* wip: multiple attachments in check run - -* fix: merge - -* style: prettify code - -* fix: df-preview-wrapper-fw - -* feat: improve code - -* feat: improve code - -* feat: columns - ---------- - -Co-authored-by: Tyler Matteson <tyler@agritheory.com> -Co-authored-by: fproldan <fproldan@users.noreply.github.com> - -* feat: use query builder in payables attachments report' - -* fix: build - -* fix: add remove btn - -* style: prettify code - ---------- - -Co-authored-by: Tyler Matteson <tyler@agritheory.com> -Co-authored-by: fproldan <fproldan@users.noreply.github.com> ([`78d2666`](https://github.com/agritheory/check_run/commit/78d2666c2c9b92831b90ee1c647737ef79375a44)) +* File Preview (#140) + +* wip: file preview + +* feat: preview in check run, allow to preview in non submittable documents + +* feat: WIP payables attachment report + +* feat: wip preview of attachments + +* style: prettify code + +* feat: close with space + +* fix: do not open sidebar in check run + +* wip: multiple attachments in check run + +* fix: merge + +* style: prettify code + +* fix: df-preview-wrapper-fw + +* feat: improve code +* feat: improve code + +* feat: columns + +--------- + +Co-authored-by: Tyler Matteson <tyler@agritheory.com> +Co-authored-by: fproldan <fproldan@users.noreply.github.com> + +* feat: use query builder in payables attachments report' + +* fix: build + +* fix: add remove btn + +* style: prettify code + +--------- + +Co-authored-by: Tyler Matteson <tyler@agritheory.com> +Co-authored-by: fproldan <fproldan@users.noreply.github.com> ([`78d2666`](https://github.com/agritheory/check_run/commit/78d2666c2c9b92831b90ee1c647737ef79375a44)) ## v14.8.0 (2023-09-08) @@ -360,14 +416,13 @@ feat: add read_only decorator ([`73d459d`](https://github.com/agritheory/check_r * Setup mypy (#149) -* chore: add typing - -* ci: add mypy to pre-commit and CI - ---------- - -Co-authored-by: Heather Kusmierz <heather.kusmierz@gmail.com> ([`5831fb8`](https://github.com/agritheory/check_run/commit/5831fb85f3b08e76f486c3b01fb671b3dba06225)) +* chore: add typing + +* ci: add mypy to pre-commit and CI +--------- + +Co-authored-by: Heather Kusmierz <heather.kusmierz@gmail.com> ([`5831fb8`](https://github.com/agritheory/check_run/commit/5831fb85f3b08e76f486c3b01fb671b3dba06225)) ## v14.7.0 (2023-09-07) @@ -375,10 +430,10 @@ Co-authored-by: Heather Kusmierz <heather.kusmierz@gmail.com> ([`5831fb8`] * ci: migrate to python semantic release (#133) -* ci: migrate to python semantic release - -* ci: add version variable file - +* ci: migrate to python semantic release + +* ci: add version variable file + * ci: update remote name ([`d37bca6`](https://github.com/agritheory/check_run/commit/d37bca61505e99476e6fb857fbd36dacc932918a)) ### Feature @@ -399,62 +454,61 @@ Resolution for `TypeError: the JSON object must be str, bytes or bytearray, not * Show the quantity and amount of each Mode of Payment (#141) -* feat: mode of payment summary component - -* feat: add number_of_invoices_per_voucher to check - -* feat: currency format - -* chore: fix setup, run formatters against repo - -* fix: html formatting - -* feat: reactive - -* feat: only update when draft - -* feat: improvement - -* feat: sort mop - -* fix: slight refactor, 'account' => 'Account' - ---------- - +* feat: mode of payment summary component + +* feat: add number_of_invoices_per_voucher to check + +* feat: currency format + +* chore: fix setup, run formatters against repo + +* fix: html formatting + +* feat: reactive + +* feat: only update when draft + +* feat: improvement + +* feat: sort mop + +* fix: slight refactor, 'account' => 'Account' + +--------- + Co-authored-by: Tyler Matteson <tyler@agritheory.com> ([`a0471a3`](https://github.com/agritheory/check_run/commit/a0471a3304c9610e8be3794599561c7872209e07)) * Use payment schedule as basis for due date and amount in purchase invoice query (#144) -* feat: use payment schedule as basis for due date and amount in purchase invoices - -* docs: update setup script path - -* fix: typo, add missing query column - ---------- - +* feat: use payment schedule as basis for due date and amount in purchase invoices + +* docs: update setup script path + +* fix: typo, add missing query column + +--------- + Co-authored-by: Heather Kusmierz <heather.kusmierz@gmail.com> ([`4ccba65`](https://github.com/agritheory/check_run/commit/4ccba65818350bf256fa6d25d730ba2abfe36788)) * Query Builder fixes (#145) -* fix: refactor frappe.db.sql to query builder for outstanding - -* fix: refactor postive pay to query builder - -* chore: remove print statement - -* fix: update comparison operator - ---------- - +* fix: refactor frappe.db.sql to query builder for outstanding + +* fix: refactor postive pay to query builder + +* chore: remove print statement + +* fix: update comparison operator + +--------- + Co-authored-by: Heather Kusmierz <heather.kusmierz@gmail.com> ([`e00e476`](https://github.com/agritheory/check_run/commit/e00e4768b4634716b417c6798123b44399ef7d2d)) * Update originating dfi id (#135) -According to the NACHA Dev Guide, Originating DFI Identification is supposed to be "The routing number of the DFI originating the entries within the batch." - -Co-authored-by: Trusted Computer <75872475+trustedcomputer@users.noreply.github.com> ([`f16bb24`](https://github.com/agritheory/check_run/commit/f16bb2468231a8221e302109060dee79aa476838)) +According to the NACHA Dev Guide, Originating DFI Identification is supposed to be "The routing number of the DFI originating the entries within the batch." +Co-authored-by: Trusted Computer <75872475+trustedcomputer@users.noreply.github.com> ([`f16bb24`](https://github.com/agritheory/check_run/commit/f16bb2468231a8221e302109060dee79aa476838)) ## v14.6.0 (2023-07-28) @@ -484,26 +538,26 @@ Co-authored-by: Trusted Computer <75872475+trustedcomputer@users.noreply.gith * feat: custom immediate origin value in settings (#76) -* feat: custom immediate origin value in settings - -* style: prettify code - ---------- - +* feat: custom immediate origin value in settings + +* style: prettify code + +--------- + Co-authored-by: agritheory <agritheory@users.noreply.github.com> ([`813be9e`](https://github.com/agritheory/check_run/commit/813be9e299c2ba42f1bc0de11fabd03d1ab2f0fb)) * feat: port timeout fix to v14 (#62) -* feat: port timeout fix to v14 - -* fix: indent - -* chore: prettier formatting - -* style: prettify code - ---------- - +* feat: port timeout fix to v14 + +* fix: indent + +* chore: prettier formatting + +* style: prettify code + +--------- + Co-authored-by: agritheory <agritheory@users.noreply.github.com> ([`6f50230`](https://github.com/agritheory/check_run/commit/6f50230a8713c16f1818ba8450abc18cc2535322)) * feat: fix lookup for non-existient bank account info, improve UX ([`4ef8a91`](https://github.com/agritheory/check_run/commit/4ef8a91ed769798d9569edc770ac4bd81a709b14)) @@ -520,8 +574,8 @@ Co-authored-by: agritheory <agritheory@users.noreply.github.com> ([`6f5023 * feat: validate docstatus of selected invoices still saved/submitted (#44) -* feat: validate docstatus of selected invoices still saved/submitted - +* feat: validate docstatus of selected invoices still saved/submitted + * refactor: moved validation code for cancelled transactions to function ([`78b3e25`](https://github.com/agritheory/check_run/commit/78b3e2580e200ce60211ed44d20651f68546eeae)) ### Fix @@ -552,34 +606,34 @@ Co-authored-by: agritheory <agritheory@users.noreply.github.com> ([`6f5023 * V14 pre process validation (#113) -* feat: check payment entries for cancelled or paid invoices before submitting - +* feat: check payment entries for cancelled or paid invoices before submitting + * fix: add expense calim to pre-process validation ([`232beb7`](https://github.com/agritheory/check_run/commit/232beb78f9855ceaa3b248d246b43dc19477532f)) * V14 ports (#98) -* chore: port payement entry check number fetch/save to V14 - -* chore: port ach_post procesing hook and company disc data - -* chore: port docstatus fix for ach-only crs - -* chore: port Update effective entry date - -* chore: port large process check run fixes - -* chore: debug V14 large process check run fixes - -* The hook jenv is deprecated New variable is jinja - -* chore: port ach_post procesing hook and company disc data - -* fix: fix savepoint wierdness - -* fix: company discretionary data fix - ---------- - +* chore: port payement entry check number fetch/save to V14 + +* chore: port ach_post procesing hook and company disc data + +* chore: port docstatus fix for ach-only crs + +* chore: port Update effective entry date + +* chore: port large process check run fixes + +* chore: debug V14 large process check run fixes + +* The hook jenv is deprecated New variable is jinja + +* chore: port ach_post procesing hook and company disc data + +* fix: fix savepoint wierdness + +* fix: company discretionary data fix + +--------- + Co-authored-by: Mohammad Ali <swe.mirza.ali@gmail.com> ([`b7adf96`](https://github.com/agritheory/check_run/commit/b7adf962e0008a1d02663c84b64fba6fa6b93d03)) * Merge pull request #90 from alibaig4u/version-14 @@ -598,46 +652,45 @@ ci: fix release CI ([`997c42c`](https://github.com/agritheory/check_run/commit/9 * [v14] handle errors in background queue (#72) -* feat: handle errors in background queue - -* style: prettify code - -* feat: use process_checks instead of submit triggers to manage submission and errors - -* style: prettify code - ---------- - +* feat: handle errors in background queue + +* style: prettify code + +* feat: use process_checks instead of submit triggers to manage submission and errors + +* style: prettify code + +--------- + Co-authored-by: agritheory <agritheory@users.noreply.github.com> ([`1b9b592`](https://github.com/agritheory/check_run/commit/1b9b592deb75ed3156f5588a888e7f370158d124)) * V14 party lookup (#68) -* fix: remove check_digit argument in ACH generation - +* fix: remove check_digit argument in ACH generation + * feat: look up party on PE submission to avoid renaming problems ([`7f940f3`](https://github.com/agritheory/check_run/commit/7f940f3954d8a7d75538e2c9a1fdf8da905acb96)) * V14 timeout fix (#64) -* feat: port timeout fix to v14 - -* fix: indent - -* chore: prettier formatting - -* feat: timeout fixes + prettier for v14 - -* style: prettify code - ---------- - +* feat: port timeout fix to v14 + +* fix: indent + +* chore: prettier formatting + +* feat: timeout fixes + prettier for v14 + +* style: prettify code + +--------- + Co-authored-by: agritheory <agritheory@users.noreply.github.com> ([`825bf70`](https://github.com/agritheory/check_run/commit/825bf70ae1567a3208872baf0e582972524d536c)) * Bank account lookup fix (#61) -* feat: fix lookup for non-existient bank account info, improve UX - -* fix: don't raise exception on bank account lookup ([`c4357a8`](https://github.com/agritheory/check_run/commit/c4357a80305b4b5d2137b132553eb38b4bb6e2a7)) +* feat: fix lookup for non-existient bank account info, improve UX +* fix: don't raise exception on bank account lookup ([`c4357a8`](https://github.com/agritheory/check_run/commit/c4357a80305b4b5d2137b132553eb38b4bb6e2a7)) ## v14.0.0 (2022-12-30) @@ -807,134 +860,134 @@ Not implemented yet: * CI (#8) -* wip: json and py validate, semantic, and frappe json diff - -* test: stub UI test yaml - copied from Frappe - -* test: add helper shell files, remove job contitionals - -* test: remove producer/consumer test dbs from install script - -* test: correct install file / install dependency file - -* test: echo helper folder to debug path error - -* test: move helper folder out of workflows - -* test: remove echo - -* test: install erpnext - -* test: create site in sintall script - -* test: skip assets on erpnext install - -* test: remove frappe-path argument from bench init - -* wip: update JSON ci - -* test: remove python setup, already in ubuntu - -* test: frappe-bench needs 3.10 - -* test: python3.9 - -* test: no mariadb password - -* test: blank password - -* test: mysql password 123 - -* test: using frappe/erpnext workflow - -* test: allow empty password = yes - -* test: file wasnt saved - -* test: mariadb version 10.5 => 10.3 - -* test: various - -* test: reinsert pip install - -* test: fix typo - -* test: remove space (typo) - -* test: fix syntax - -* test: remove site setup - -* test: restore site without building frappe - -* test: remove db setup, only ui test - -* test: remove strawberry output for site setup - -* test: use check run test - -* test: cypress test data path - -* test: install apps on site - -* test: cypress path - -* test: bench restart after install, set developer mode - -* test: CI=Yes bench command - -* test: install apps - -* test: add site adn skip assets - -* test: ci=yes install-app - -* test: wildcard frappe user, remove ci bench install-app - -* test: update localhost wildcard both commands - -* text: bench execute command - -* test: revert mariadb wildcard and install-app - -* test: remove bench restart - -* test: remove CI=yes execute - -* wip: cypress testing fixup - -* wip: ach workflows - -* wip: ach generation - -* wip: check run ui tests V1 - -* test: fix cypress command path - -* test: cypress command - -* test: cypress response timeout - -* test: remove headless - -* test: cypress action - -* test: rerun - -* test: "8000" + "/" - -* test: use cypress config - -* test: add bench restart - -* test: update baseUrl to match site_config.json - -* test: no recordings - -* test: video, screenshots off - -* wip: remove unused env vars, set script clone depth, remove commented yarn run, fix spec.js typo - +* wip: json and py validate, semantic, and frappe json diff + +* test: stub UI test yaml - copied from Frappe + +* test: add helper shell files, remove job contitionals + +* test: remove producer/consumer test dbs from install script + +* test: correct install file / install dependency file + +* test: echo helper folder to debug path error + +* test: move helper folder out of workflows + +* test: remove echo + +* test: install erpnext + +* test: create site in sintall script + +* test: skip assets on erpnext install + +* test: remove frappe-path argument from bench init + +* wip: update JSON ci + +* test: remove python setup, already in ubuntu + +* test: frappe-bench needs 3.10 + +* test: python3.9 + +* test: no mariadb password + +* test: blank password + +* test: mysql password 123 + +* test: using frappe/erpnext workflow + +* test: allow empty password = yes + +* test: file wasnt saved + +* test: mariadb version 10.5 => 10.3 + +* test: various + +* test: reinsert pip install + +* test: fix typo + +* test: remove space (typo) + +* test: fix syntax + +* test: remove site setup + +* test: restore site without building frappe + +* test: remove db setup, only ui test + +* test: remove strawberry output for site setup + +* test: use check run test + +* test: cypress test data path + +* test: install apps on site + +* test: cypress path + +* test: bench restart after install, set developer mode + +* test: CI=Yes bench command + +* test: install apps + +* test: add site adn skip assets + +* test: ci=yes install-app + +* test: wildcard frappe user, remove ci bench install-app + +* test: update localhost wildcard both commands + +* text: bench execute command + +* test: revert mariadb wildcard and install-app + +* test: remove bench restart + +* test: remove CI=yes execute + +* wip: cypress testing fixup + +* wip: ach workflows + +* wip: ach generation + +* wip: check run ui tests V1 + +* test: fix cypress command path + +* test: cypress command + +* test: cypress response timeout + +* test: remove headless + +* test: cypress action + +* test: rerun + +* test: "8000" + "/" + +* test: use cypress config + +* test: add bench restart + +* test: update baseUrl to match site_config.json + +* test: no recordings + +* test: video, screenshots off + +* wip: remove unused env vars, set script clone depth, remove commented yarn run, fix spec.js typo + Co-authored-by: Robert Duncan <robirtduncan@gmail.com> ([`350bb6e`](https://github.com/agritheory/check_run/commit/350bb6e5648ed63c7086a9bd89f5acb194a5c85f)) * Merge pull request #10 from agritheory/fixbankacct @@ -969,12 +1022,14 @@ changes: spacebar checks/unchecks pay, keys a-z open MOP / starts search ([`1219 * Merge branch 'test_and_cleanup' into key-nav ([`a478f7f`](https://github.com/agritheory/check_run/commit/a478f7fe61e01b3386bf866a78742d81458c1c0a)) +* Merge branch 'version-13' of github.com:agritheory/check_run into test_and_cleanup ([`6fba403`](https://github.com/agritheory/check_run/commit/6fba403ca20fbd56f022e0af8856e09681b19ef2)) + +* wip: test stubbed and some reactivity improvements ([`d5364dc`](https://github.com/agritheory/check_run/commit/d5364dc17cac516a162f654f1637b2393b731ce1)) + * Merge branch 'key-nav' of github.com:agritheory/check_run into key-nav ([`33bc96b`](https://github.com/agritheory/check_run/commit/33bc96bee34f91eddd83b530ae638f8a0e3dcde2)) * changes: spacebar checks/unchecks pay, keys a-z open MOP / starts search ([`0873c5d`](https://github.com/agritheory/check_run/commit/0873c5d395c07891a5bffd83734918adeaa44bb1)) -* Merge branch 'version-13' of github.com:agritheory/check_run into test_and_cleanup ([`6fba403`](https://github.com/agritheory/check_run/commit/6fba403ca20fbd56f022e0af8856e09681b19ef2)) - * Merge pull request #3 from agritheory/key-nav Key nav ([`0823fc5`](https://github.com/agritheory/check_run/commit/0823fc56926e40b30060b97d661c622f06c5466e)) @@ -983,20 +1038,18 @@ Key nav ([`0823fc5`](https://github.com/agritheory/check_run/commit/0823fc56926e * update checkrun total field ([`65e10b8`](https://github.com/agritheory/check_run/commit/65e10b829267784192e815e8d2bc03830b87dcd0)) -* wip: test stubbed and some reactivity improvements ([`d5364dc`](https://github.com/agritheory/check_run/commit/d5364dc17cac516a162f654f1637b2393b731ce1)) - * Merge pull request #2 from agritheory/version-13-hotfix Check run render fixes ([`8d740bd`](https://github.com/agritheory/check_run/commit/8d740bdda360bb4d2488810e3845df53e66fb700)) * cleanup: removed default span in check_run_table, removed is_dirty function ([`bc05bde`](https://github.com/agritheory/check_run/commit/bc05bde2fdbe8feb852a8f851bf64ed2897d9d7d)) +* fixes: check run table save and render on save ([`0e1c27a`](https://github.com/agritheory/check_run/commit/0e1c27a362c6107d877a270bbe9f0a4e56ca82a8)) + * Merge pull request #1 from agritheory/positivepay feat: add positive pay report ([`df8692b`](https://github.com/agritheory/check_run/commit/df8692b91c45b8d47b2eebbd8519bee1d05314f4)) -* fixes: check run table save and render on save ([`0e1c27a`](https://github.com/agritheory/check_run/commit/0e1c27a362c6107d877a270bbe9f0a4e56ca82a8)) - * wip: table not rendering on save ([`08d48c7`](https://github.com/agritheory/check_run/commit/08d48c7836a34027fd3027c6c26dc369067be644)) * wip: test fixtures and stubbed setup ([`1f8e415`](https://github.com/agritheory/check_run/commit/1f8e415868a80cee3c38260b756d0e845c4f0c30)) diff --git a/check_run/__init__.py b/check_run/__init__.py index 9a75d436..8819e942 100644 --- a/check_run/__init__.py +++ b/check_run/__init__.py @@ -1 +1 @@ -__version__ = "15.1.0" +__version__ = "15.1.2" diff --git a/check_run/check_run/__init__.py b/check_run/check_run/__init__.py index c10c1ca3..6b52509a 100644 --- a/check_run/check_run/__init__.py +++ b/check_run/check_run/__init__.py @@ -4,9 +4,8 @@ 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 erpnext.accounts.doctype.purchase_invoice.purchase_invoice import PurchaseInvoice from hrms.hr.doctype.expense_claim.expense_claim import ExpenseClaim diff --git a/check_run/check_run/doctype/check_run/check_run.js b/check_run/check_run/doctype/check_run/check_run.js index 4a4c25c2..2801338e 100644 --- a/check_run/check_run/doctype/check_run/check_run.js +++ b/check_run/check_run/doctype/check_run/check_run.js @@ -188,6 +188,9 @@ function set_queries(frm) { function get_entries(frm) { return new Promise(function (resolve, reject) { + if (!frm.doc.transactions && check_run.transactions) { + frm.dirty() + } resolve(window.check_run.mount(frm)) }) } diff --git a/check_run/check_run/doctype/check_run/check_run.py b/check_run/check_run/doctype/check_run/check_run.py index eb32b108..6df2a4a2 100644 --- a/check_run/check_run/doctype/check_run/check_run.py +++ b/check_run/check_run/doctype/check_run/check_run.py @@ -325,9 +325,7 @@ def create_payment_entries(self: Self, transactions: list[frappe._dict]) -> list pe.bank_account = self.bank_account pe.paid_from = gl_account pe.paid_to = self.pay_to_account - pe.paid_to_account_currency = frappe.db.get_value( - "Account", self.bank_account, "account_currency" - ) + pe.paid_to_account_currency = frappe.db.get_value("Account", gl_account, "account_currency") pe.paid_from_account_currency = pe.paid_to_account_currency pe.reference_date = self.posting_date pe.party_type = group[0].party_type @@ -571,7 +569,11 @@ def get_entries(doc: CheckRun | str) -> dict: .as_("supplier_default_mode_of_payment") .where(purchase_invoices.supplier == suppliers.name) ) - + stand_alone_debit_note_filter = ( + (Coalesce(payment_schedule.outstanding, purchase_invoices.outstanding_amount) > 0) + if settings.allow_stand_alone_debit_notes == "No" + else (Coalesce(payment_schedule.outstanding, purchase_invoices.outstanding_amount) != 0) + ) pi_qb = ( frappe.qb.from_(purchase_invoices) .left_join(payment_schedule) @@ -595,6 +597,7 @@ def get_entries(doc: CheckRun | str) -> dict: ) .where(Coalesce(payment_schedule.due_date, purchase_invoices.due_date) <= end_date) .where(Coalesce(payment_schedule.outstanding, purchase_invoices.outstanding_amount) != 0) + .where(stand_alone_debit_note_filter) .where(purchase_invoices.company == company) .where(purchase_invoices.docstatus == 1) .where(purchase_invoices.credit_to == pay_to_account) diff --git a/check_run/check_run/doctype/check_run/test_check_run.py b/check_run/check_run/doctype/check_run/test_check_run.py index 3f829765..ef82f53f 100644 --- a/check_run/check_run/doctype/check_run/test_check_run.py +++ b/check_run/check_run/doctype/check_run/test_check_run.py @@ -1,9 +1,10 @@ # Copyright (c) 2022, AgriTheory and Contributors # See license.txt -import frappe import unittest +import frappe + class TestCheckRun(unittest.TestCase): pass diff --git a/check_run/check_run/doctype/check_run_settings/check_run_settings.json b/check_run/check_run/doctype/check_run_settings/check_run_settings.json index 5f04f3c8..cf1eaf35 100644 --- a/check_run/check_run/doctype/check_run_settings/check_run_settings.json +++ b/check_run/check_run/doctype/check_run_settings/check_run_settings.json @@ -311,4 +311,287 @@ "sort_order": "DESC", "states": [], "track_changes": 1 +======= + "actions": [], + "autoname": "format:ACC-CRS-{bank_account}-{pay_to_account}", + "creation": "2022-08-22 14:43:43.533105", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "company", + "bank_account", + "column_break_3", + "pay_to_account", + "print_format", + "section_break_4", + "include_purchase_invoices", + "include_journal_entries", + "include_expense_claims", + "pre_check_overdue_items", + "allow_cancellation", + "cascade_cancellation", + "validate_unique_check_number", + "column_break_9", + "number_of_invoices_per_voucher", + "split_by_address", + "automatically_release_on_hold_invoices", + "file_preview_threshold", + "allow_stand_alone_debit_notes", + "default_modes_of_payment_section_section", + "purchase_invoice", + "journal_entry", + "column_break_21", + "expense_claim", + "ach_settings_section", + "ach_file_extension", + "ach_service_class_code", + "ach_standard_class_code", + "ach_description", + "column_break_27", + "immediate_origin", + "company_discretionary_data", + "custom_post_processing_hook", + "role_allowed_to_download_ach_file_multiple_times" + ], + "fields": [ + { + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company" + }, + { + "fieldname": "bank_account", + "fieldtype": "Link", + "label": "Bank Account", + "options": "Bank Account" + }, + { + "fieldname": "section_break_4", + "fieldtype": "Section Break" + }, + { + "default": "1", + "fieldname": "include_purchase_invoices", + "fieldtype": "Check", + "label": "Include Purchase Invoices" + }, + { + "default": "1", + "fieldname": "include_journal_entries", + "fieldtype": "Check", + "label": "Include Journal Entries " + }, + { + "default": "1", + "fieldname": "include_expense_claims", + "fieldtype": "Check", + "label": "Include Expense Claims" + }, + { + "default": "0", + "description": "Payment Entries will be unlinked when Check Run is cancelled", + "fieldname": "allow_cancellation", + "fieldtype": "Check", + "label": "Allow Cancellation" + }, + { + "fieldname": "column_break_9", + "fieldtype": "Column Break" + }, + { + "default": "ach", + "description": "Common file extensions are 'ach', 'txt' and 'dat'. Your bank may require one of these.", + "fieldname": "ach_file_extension", + "fieldtype": "Data", + "label": "ACH File Extension" + }, + { + "default": "0", + "description": "Pre-Check all payables that have a due date greater than the Check Run's posting date", + "fieldname": "pre_check_overdue_items", + "fieldtype": "Check", + "label": "Pre-Check Overdue Items" + }, + { + "default": "0", + "description": "When a Check Run is cancelled, all Payment Entries linked to it will also be cancelled. This is not recommended.", + "fieldname": "cascade_cancellation", + "fieldtype": "Check", + "label": "Cascade Cancellation" + }, + { + "description": "Defaults to 5 if no value is provided", + "fieldname": "number_of_invoices_per_voucher", + "fieldtype": "Int", + "label": "Number of Invoices per Voucher", + "non_negative": 1 + }, + { + "fieldname": "column_break_3", + "fieldtype": "Column Break" + }, + { + "fieldname": "pay_to_account", + "fieldtype": "Link", + "label": "Payable Account", + "options": "Account" + }, + { + "fieldname": "ach_service_class_code", + "fieldtype": "Select", + "label": "ACH Service Class Code", + "options": "200\n220\n225" + }, + { + "description": "PPD is only supported Entry format at this time", + "fieldname": "ach_standard_class_code", + "fieldtype": "Select", + "label": "ACH Standard Class Code", + "options": "PPD" + }, + { + "fieldname": "ach_description", + "fieldtype": "Data", + "label": "ACH Description", + "length": 10 + }, + { + "fieldname": "print_format", + "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" + }, + { + "fieldname": "column_break_21", + "fieldtype": "Column Break" + }, + { + "default": "0", + "fieldname": "automatically_release_on_hold_invoices", + "fieldtype": "Check", + "label": "Automatically Release On Hold Invoices" + }, + { + "fieldname": "immediate_origin", + "fieldtype": "Data", + "label": "Immediate Origin" + }, + { + "fieldname": "company_discretionary_data", + "fieldtype": "Data", + "label": "Company Discretionary Data", + "length": 20 + }, + { + "fieldname": "custom_post_processing_hook", + "fieldtype": "Data", + "label": "Custom Post Processing Hook", + "read_only": 1 + }, + { + "fieldname": "default_modes_of_payment_section_section", + "fieldtype": "Section Break", + "label": "Default Modes of Payment Section" + }, + { + "fieldname": "purchase_invoice", + "fieldtype": "Link", + "label": "Purchase Invoice", + "options": "Mode of Payment" + }, + { + "fieldname": "journal_entry", + "fieldtype": "Link", + "label": "Journal Entry", + "options": "Mode of Payment" + }, + { + "fieldname": "expense_claim", + "fieldtype": "Link", + "label": "Expense Claim", + "options": "Mode of Payment" + }, + { + "fieldname": "column_break_27", + "fieldtype": "Column Break" + }, + { + "default": "1000", + "description": "File preview is enabled up to this number of transactions", + "fieldname": "file_preview_threshold", + "fieldtype": "Int", + "label": "File Preview Threshold" + }, + { + "default": "0", + "fieldname": "validate_unique_check_number", + "fieldtype": "Check", + "label": "Validate Unique Check Number" + }, + { + "default": "No", + "fieldname": "allow_stand_alone_debit_notes", + "fieldtype": "Select", + "label": "Allow stand-alone debit notes?", + "options": "Yes\nNo" + }, + { + "description": "Users with this role are allowed to download ACH file multiple times. Users without this role are allowed to download it only once.", + "fieldname": "role_allowed_to_download_ach_file_multiple_times", + "fieldtype": "Link", + "label": "Role Allowed to Download ACH File Multiple Times", + "options": "Role" + } + ], + "links": [], + "modified": "2024-04-29 08:51:46.252826", + "modified_by": "Administrator", + "module": "Check Run", + "name": "Check Run Settings", + "naming_rule": "Expression", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "share": 1, + "write": 1 + } + ], + "quick_entry": 1, + "sort_field": "modified", + "sort_order": "DESC", + "states": [], + "track_changes": 1 } \ No newline at end of file diff --git a/check_run/hooks.py b/check_run/hooks.py index 1def385d..a9b6fe77 100644 --- a/check_run/hooks.py +++ b/check_run/hooks.py @@ -110,9 +110,14 @@ "Payment Entry": { "validate": [ "check_run.overrides.payment_entry.validate_duplicate_check_number", - "check_run.overrides.payment_entry.validate_add_payment_term", ], - "on_submit": ["check_run.overrides.payment_entry.update_check_number"], + "on_submit": [ + "check_run.overrides.payment_entry.update_outstanding_amount", + "check_run.overrides.payment_entry.update_check_number", + ], + "on_cancel": [ + "check_run.overrides.payment_entry.update_outstanding_amount", + ], }, "Purchase Invoice": { "before_cancel": ["check_run.check_run.disallow_cancellation_if_in_check_run"] diff --git a/check_run/overrides/bank.py b/check_run/overrides/bank.py index 802f170c..6282172d 100644 --- a/check_run/overrides/bank.py +++ b/check_run/overrides/bank.py @@ -2,11 +2,11 @@ # For license information, please see license.txt import frappe -from erpnext.accounts.doctype.bank_account.bank_account import BankAccount +from erpnext.accounts.doctype.bank.bank import Bank @frappe.whitelist() -def validate(doc: BankAccount, method: str | None = None): +def validate(doc: Bank, method: str | None = None): # Canadian banking institutions limit DFI Routing Numbers to 8 characters addresses = frappe.qb.DocType("Address") dls = frappe.qb.DocType("Dynamic Link") diff --git a/check_run/overrides/payment_entry.py b/check_run/overrides/payment_entry.py index 8656185e..94b7ba09 100644 --- a/check_run/overrides/payment_entry.py +++ b/check_run/overrides/payment_entry.py @@ -2,15 +2,14 @@ # For license information, please see license.txt import frappe -from frappe.utils import get_link_to_form, comma_and, flt -from erpnext.accounts.general_ledger import make_gl_entries, process_gl_map -from frappe.utils.data import getdate from erpnext.accounts.doctype.payment_entry.payment_entry import ( PaymentEntry, get_outstanding_reference_documents, ) +from erpnext.accounts.general_ledger import make_gl_entries, process_gl_map from frappe import _ -import json +from frappe.utils import flt, get_link_to_form +from frappe.utils.data import getdate class CheckRunPaymentEntry(PaymentEntry): @@ -60,7 +59,7 @@ def get_valid_reference_doctypes(self): """ Because Check Run processes multiple payment entries in a background queue, errors generally do not include enough data to identify the problem since there were written and remain appropriate for the context of an individual - Payment Entry. This code is copied from: + Payment Entry. This code is copied from: https://github.com/frappe/erpnext/blob/version-14/erpnext/accounts/doctype/payment_entry/payment_entry.py#L164 @@ -248,28 +247,53 @@ def validate_duplicate_check_number(doc: PaymentEntry, method: str | None = None @frappe.whitelist() -def validate_add_payment_term(doc: PaymentEntry, method: str | None = None): - doc = frappe._dict(json.loads(doc)) if isinstance(doc, str) else doc - if doc.check_run: - return - adjusted_refs = [] +def update_outstanding_amount(doc: PaymentEntry, method: str | None = None): + paid_amount = doc.paid_amount if method == "on_submit" else 0.0 for r in doc.get("references"): - if r.reference_doctype == "Purchase Invoice" and not r.payment_term: - pmt_term = frappe.get_all( - "Payment Schedule", - {"parent": r.reference_name, "outstanding": [">", 0.0]}, - ["payment_term"], - order_by="due_date ASC", - limit=1, - ) - if pmt_term: - r.payment_term = pmt_term[0].get("payment_term") - adjusted_refs.append(r.reference_name) - if adjusted_refs: - frappe.msgprint( - msg=frappe._( - f"An outstanding Payment Schedule term was detected and added for {comma_and(adjusted_refs)} in the references table.
Please review - " - "this field must be filled in for the Payment Schedule to synchronize and to prevent a paid invoice portion from showing up in a Check Run." - ), - title=frappe._("Payment Schedule Term Added"), + if r.reference_doctype != "Purchase Invoice": + continue + payment_schedules = frappe.get_all( + "Payment Schedule", + {"parent": r.reference_name}, + ["name", "outstanding", "payment_term", "payment_amount"], + order_by="due_date ASC", ) + if not payment_schedules: + continue + + payment_schedule = frappe.get_doc("Payment Schedule", payment_schedules[0]["name"]) + precision = payment_schedule.precision("outstanding") + payment_schedules = payment_schedules if method == "on_submit" else reversed(payment_schedules) + + for term in payment_schedules: + if r.payment_term and term.payment_term != r.payment_term: + continue + + if method == "on_submit": + if term.outstanding > 0.0 and paid_amount > 0.0: + if term.outstanding > paid_amount: + frappe.db.set_value( + "Payment Schedule", + term.name, + "outstanding", + flt(term.outstanding - paid_amount, precision), + ) + break + else: + paid_amount = flt(paid_amount - term.outstanding, precision) + frappe.db.set_value("Payment Schedule", term.name, "outstanding", 0) + if paid_amount <= 0.0: + break + + if method == "on_cancel": + if term.outstanding != term.payment_amount: + # if this payment term had previously been allocated against + paid_amount += flt(paid_amount + (term.payment_amount - term.outstanding), precision) + reverse = ( + flt(paid_amount + term.outstanding, precision) + if paid_amount < term.payment_amount + else term.payment_amount + ) + frappe.db.set_value("Payment Schedule", term.name, "outstanding", reverse) + if paid_amount >= doc.paid_amount: + break diff --git a/check_run/tests/fixtures.py b/check_run/tests/fixtures.py index de3c47fe..28fd688f 100644 --- a/check_run/tests/fixtures.py +++ b/check_run/tests/fixtures.py @@ -74,7 +74,7 @@ "Phone Services", "ACH/EFT", 250.00, - "Net 30", + "", { "address_line1": "1198 Carpenter Road", "city": "Rolla", diff --git a/check_run/tests/setup.py b/check_run/tests/setup.py index eec63c2d..be9379db 100644 --- a/check_run/tests/setup.py +++ b/check_run/tests/setup.py @@ -7,7 +7,6 @@ from erpnext.setup.utils import enable_all_roles_and_domains, set_defaults_for_tests from frappe.desk.page.setup_wizard.setup_wizard import setup_complete from frappe.utils.data import add_days, flt - from check_run.tests.fixtures import employees, sepa_supplier, suppliers, tax_authority @@ -40,7 +39,6 @@ def before_test(): for modu in frappe.get_all("Module Onboarding"): frappe.db.set_value("Module Onboarding", modu, "is_complete", 1) frappe.set_value("Website Settings", "Website Settings", "home_page", "login") - frappe.db.commit() def create_test_data(): @@ -70,8 +68,8 @@ def create_test_data(): create_employees(settings) create_expense_claim(settings) for month in range(1, 13): - create_payroll_journal_entry(settings) settings.day = settings.day.replace(month=month) + create_payroll_journal_entry(settings) create_manual_payment_entry(settings) @@ -477,6 +475,8 @@ def create_invoices(settings): "qty": 1, }, ) + if supplier[0].startswith("Sphere"): + pi.payment_terms_template = None pi.save() pi.submit() # two electric meters / test invoice aggregation @@ -729,8 +729,7 @@ def create_payroll_journal_entry(settings): je = frappe.new_doc("Journal Entry") je.entry_type = "Journal Entry" je.company = settings.company - je.posting_date = settings.day - je.due_date = settings.day + je.due_date = je.posting_date = settings.day total_payroll = 0.0 for idx, emp in enumerate(emps): employee_name = frappe.get_value( @@ -795,6 +794,7 @@ def create_payroll_journal_entry(settings): ) je.save() je.submit() + print(je.posting_date, je.due_date) """ diff --git a/check_run/tests/test_check_run.py b/check_run/tests/test_check_run.py index 1cb593b1..3631a476 100644 --- a/check_run/tests/test_check_run.py +++ b/check_run/tests/test_check_run.py @@ -4,23 +4,24 @@ import frappe import pytest -from check_run.check_run.doctype.check_run.check_run import get_check_run_settings, get_entries +from check_run.check_run.doctype.check_run.check_run import ( + check_for_draft_check_run, + get_check_run_settings, + get_entries, +) year = datetime.date.today().year @pytest.fixture def cr(): # return draft check run - if ( - frappe.db.exists("Check Run", f"ACC-CR-{year}-00001") - and frappe.get_value("Check Run", f"ACC-CR-{year}-00001", "docstatus") == 0 - ): - return frappe.get_doc("Check Run", f"ACC-CR-{year}-00001") - cr = frappe.new_doc("Check Run") + cr_name = check_for_draft_check_run( + company="Chelsea Fruit Co", + bank_account="Primary Checking - Local Bank", + payable_account="2110 - Accounts Payable - CFC", + ) + cr = frappe.get_doc("Check Run", cr_name) cr.flags.in_test = True - cr.company = "Chelsea Fruit Co" - cr.bank_account = "Primary Checking - Local Bank" - cr.pay_to_account = "2110 - Accounts Payable - CFC" cr.posting_date = cr.end_date = datetime.date(year, 12, 31) cr.set_last_check_number() cr.set_default_payable_account() @@ -89,12 +90,19 @@ def test_process_check_run_on_hold_invoice_auto_release(cr): def test_return_included_in_check_run_error(cr): - # Test for ValidationError when Check Run only includes a return transaction - cr.transactions = frappe.utils.safe_json_loads(cr.transactions) - for row in cr.transactions: + _transactions = get_entries(cr).get("transactions") + settings = get_check_run_settings(cr) + assert settings.allow_stand_alone_debit_notes == "No" + settings.allow_stand_alone_debit_notes = "Yes" + settings.save() + cr.posting_date = cr.end_date = datetime.date(year, 12, 30) + cr.transactions = "" + transactions = get_entries(cr).get("transactions") + assert transactions != _transactions + for row in transactions: if row.get("party") == "Cooperative Ag Finance" and row.get("amount") < 0: row["pay"] = True - cr.transactions = frappe.as_json(cr.transactions) + cr.transactions = frappe.as_json(transactions) cr.flags.in_test = True cr.save() diff --git a/check_run/tests/test_payment_entry.py b/check_run/tests/test_payment_entry.py new file mode 100644 index 00000000..389f0cbe --- /dev/null +++ b/check_run/tests/test_payment_entry.py @@ -0,0 +1,190 @@ +import datetime + +import frappe +import pytest +from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry + +from check_run.check_run.doctype.check_run.check_run import ( + check_for_draft_check_run, + get_check_run_settings, + get_entries, +) +from check_run.tests.test_check_run import cr + +year = datetime.date.today().year + + +def test_partial_payment_payment_entry_with_terms(): + pi_name = frappe.get_all( + "Purchase Invoice", + {"supplier": "Exceptional Grid"}, + pluck="name", + order_by="posting_date ASC", + limit=1, + )[0] + pe0 = get_payment_entry("Purchase Invoice", pi_name) + pe0.mode_of_payment = "Check" + pe0.paid_amount = 30.00 + pe0.bank_account = "Primary Checking - Local Bank" + pe0.reference_no = frappe.get_value("Bank Account", pe0.bank_account, "check_number") + pe0.references[0].allocated_amount = 30.00 + pe0.save() + pe0.submit() + + pi = frappe.get_doc("Purchase Invoice", pi_name) + assert pi.payment_schedule[0].outstanding == 120.00 + assert pi.outstanding_amount == 120.00 + + pe1 = get_payment_entry("Purchase Invoice", pi_name) + pe1.mode_of_payment = "Check" + pe1.paid_amount = 120.00 + pe1.bank_account = "Primary Checking - Local Bank" + pe1.reference_no = frappe.get_value("Bank Account", pe1.bank_account, "check_number") + pe1.references[0].allocated_amount = 120.00 + pe1.save() + pe1.submit() + + pi = frappe.get_doc("Purchase Invoice", pi_name) + assert pi.payment_schedule[0].outstanding == 0.00 + assert pi.outstanding_amount == 0.0 + + +def test_payment_payment_entry_of_multiple_terms(): + pi_name = frappe.get_all( + "Purchase Invoice", + {"supplier": "Tireless Equipment Rental, Inc"}, + pluck="name", + order_by="posting_date ASC", + limit=1, + )[0] + pe0 = get_payment_entry("Purchase Invoice", pi_name) + pe0.mode_of_payment = "Check" + pe0.paid_amount = 4500.00 + pe0.bank_account = "Primary Checking - Local Bank" + pe0.reference_no = frappe.get_value("Bank Account", pe0.bank_account, "check_number") + pe0.references[0].allocated_amount = 4500 + pe0.save() + pe0.submit() + + pi = frappe.get_doc("Purchase Invoice", pi_name) + assert pi.payment_schedule[0].outstanding == 0.0 + assert pi.payment_schedule[1].outstanding == 0.0 + assert pi.payment_schedule[2].outstanding == 500.01 + + pe0.cancel() + pi.reload() + assert pi.payment_schedule[2].outstanding == 1666.67 + assert pi.payment_schedule[1].outstanding == 1666.67 + assert pi.payment_schedule[0].outstanding == 1666.67 + + +def test_partial_payment_payment_entry_without_terms(): + pi_name = frappe.get_all( + "Purchase Invoice", + {"supplier": "Sphere Cellular"}, + pluck="name", + order_by="posting_date ASC", + limit=1, + )[0] + pi = frappe.get_doc("Purchase Invoice", pi_name) + assert pi.payment_schedule[0].outstanding == 250.00 + assert pi.outstanding_amount == 250.00 + + pe0 = get_payment_entry("Purchase Invoice", pi_name) + pe0.mode_of_payment = "Check" + pe0.paid_amount = 100.00 + pe0.bank_account = "Primary Checking - Local Bank" + pe0.reference_no = frappe.get_value("Bank Account", pe0.bank_account, "check_number") + pe0.references[0].allocated_amount = 100.00 + pe0.save() + pe0.submit() + + pi.reload() + assert pi.payment_schedule[0].outstanding == 150.00 + assert pi.outstanding_amount == 150 + + pe1 = get_payment_entry("Purchase Invoice", pi_name) + pe1.mode_of_payment = "Check" + pe1.paid_amount = 100.00 + pe1.bank_account = "Primary Checking - Local Bank" + pe1.reference_no = frappe.get_value("Bank Account", pe1.bank_account, "check_number") + pe1.references[0].allocated_amount = 100.00 + pe1.save() + pe1.submit() + + pi = frappe.get_doc("Purchase Invoice", pi_name) + assert pi.payment_schedule[0].outstanding == 50.00 + assert pi.outstanding_amount == 50.00 + + pe2 = get_payment_entry("Purchase Invoice", pi_name) + pe2.mode_of_payment = "Check" + pe2.paid_amount = 100.00 + pe2.bank_account = "Primary Checking - Local Bank" + pe2.reference_no = frappe.get_value("Bank Account", pe2.bank_account, "check_number") + pe2.references[0].allocated_amount = 100.00 + + pi = frappe.get_doc("Purchase Invoice", pi_name) + with pytest.raises( + frappe.exceptions.ValidationError, + # match='Allocated Amount of 100.0 cannot be greater than outstanding amount of 50.0', + ): + pe2.save() + + pe2.paid_amount = 50.00 + pe2.references[0].allocated_amount = 50.00 + pe2.save() + pe2.submit() + + pi.reload() + assert pi.payment_schedule[0].outstanding == 00.00 + assert pi.outstanding_amount == 0.00 + + +def test_outstanding_amount_in_check_run(cr): + pi_name = frappe.get_all( + "Purchase Invoice", + {"supplier": "Mare Digitalis"}, + pluck="name", + order_by="posting_date ASC", + limit=1, + )[0] + pi = frappe.get_doc("Purchase Invoice", pi_name) + assert pi.outstanding_amount == 200.00 + assert pi.payment_schedule[0].outstanding == 200.00 + + pe0 = get_payment_entry("Purchase Invoice", pi_name) + pe0.mode_of_payment = "Check" + pe0.paid_amount = 110.00 + pe0.bank_account = "Primary Checking - Local Bank" + pe0.reference_no = frappe.get_value("Bank Account", pe0.bank_account, "check_number") + pe0.references[0].allocated_amount = 110.00 + pe0.save() + pe0.submit() + pi.reload() + assert pi.payment_schedule[0].outstanding == 90.00 + assert pi.outstanding_amount == 90.00 + + cr.transactions = None + cr.save() + entries = get_entries(cr) + for row in entries.get("transactions"): + row["pay"] = False + transactions = frappe.utils.safe_json_loads(entries.get("transactions")) + + t = list(filter(lambda x: x.get("name") == f"ACC-PINV-{year}-00004", transactions)) + assert t[0].get("amount") == 90.00 + + pe0.cancel() + pi.reload() + assert pi.payment_schedule[0].outstanding == 200.00 + assert pi.outstanding_amount == 200.00 + + cr.transactions = None + cr.save() + entries = get_entries(cr) + for row in entries.get("transactions"): + row["pay"] = False + transactions = frappe.utils.safe_json_loads(entries.get("transactions")) + + t = list(filter(lambda x: x.get("name") == f"ACC-PINV-{year}-00004", transactions)) + assert t[0].get("amount") == 200.00