From fef18e52592fdcf87f2777c27c72b812624f5608 Mon Sep 17 00:00:00 2001 From: MostafaKadry Date: Wed, 12 Aug 2026 14:21:56 +0300 Subject: [PATCH 1/3] feat: implement POS authorization gate system with PIN-based authentication and rule-based workflow control --- POS/components.d.ts | 1 + POS/package.json | 1 + POS/src/App.vue | 2 + .../components/common/AuthorizationDialog.vue | 185 ++++++++++++++ .../components/sale/ReturnInvoiceDialog.vue | 44 +++- POS/src/composables/useAuthorization.js | 110 ++++++++ POS/src/index.css | 1 + pos_next/api/authorization.py | 200 +++++++++++++++ pos_next/api/bootstrap.py | 25 +- pos_next/api/invoices.py | 6 + pos_next/api/test_authorization.py | 58 +++++ pos_next/authorization/__init__.py | 21 ++ pos_next/authorization/actions/__init__.py | 5 + .../authorization/actions/sales_invoice.py | 60 +++++ pos_next/authorization/gate.py | 113 +++++++++ pos_next/authorization/grants.py | 126 ++++++++++ pos_next/authorization/log.py | 65 +++++ pos_next/authorization/pin.py | 237 ++++++++++++++++++ pos_next/authorization/policy.py | 205 +++++++++++++++ pos_next/authorization/registry.py | 108 ++++++++ pos_next/authorization/tests/__init__.py | 0 pos_next/authorization/tests/helpers.py | 90 +++++++ .../tests/test_actions_sales_invoice.py | 39 +++ pos_next/authorization/tests/test_gate.py | 73 ++++++ pos_next/authorization/tests/test_grants.py | 58 +++++ pos_next/authorization/tests/test_log.py | 45 ++++ pos_next/authorization/tests/test_pin.py | 179 +++++++++++++ pos_next/authorization/tests/test_policy.py | 140 +++++++++++ pos_next/hooks.py | 2 + pos_next/modules.txt | 3 +- pos_next/pos_next/custom/sales_invoice.json | 56 +++++ pos_next/pos_next_auth_gate/__init__.py | 0 .../pos_next_auth_gate/doctype/__init__.py | 0 .../pos_authorization_approver/__init__.py | 0 .../pos_authorization_approver.json | 72 ++++++ .../pos_authorization_approver.py | 8 + .../doctype/pos_authorization_log/__init__.py | 0 .../pos_authorization_log.json | 115 +++++++++ .../pos_authorization_log.py | 8 + .../pos_authorization_rule/__init__.py | 0 .../pos_authorization_rule.js | 8 + .../pos_authorization_rule.json | 92 +++++++ .../pos_authorization_rule.py | 26 ++ .../test_pos_authorization_rule.py | 9 + .../pos_authorization_settings/__init__.py | 0 .../pos_authorization_settings.json | 83 ++++++ .../pos_authorization_settings.py | 9 + pos_next/public/js/user.js | 115 +++++++++ 48 files changed, 2796 insertions(+), 7 deletions(-) create mode 100644 POS/src/components/common/AuthorizationDialog.vue create mode 100644 POS/src/composables/useAuthorization.js create mode 100644 pos_next/api/authorization.py create mode 100644 pos_next/api/test_authorization.py create mode 100644 pos_next/authorization/__init__.py create mode 100644 pos_next/authorization/actions/__init__.py create mode 100644 pos_next/authorization/actions/sales_invoice.py create mode 100644 pos_next/authorization/gate.py create mode 100644 pos_next/authorization/grants.py create mode 100644 pos_next/authorization/log.py create mode 100644 pos_next/authorization/pin.py create mode 100644 pos_next/authorization/policy.py create mode 100644 pos_next/authorization/registry.py create mode 100644 pos_next/authorization/tests/__init__.py create mode 100644 pos_next/authorization/tests/helpers.py create mode 100644 pos_next/authorization/tests/test_actions_sales_invoice.py create mode 100644 pos_next/authorization/tests/test_gate.py create mode 100644 pos_next/authorization/tests/test_grants.py create mode 100644 pos_next/authorization/tests/test_log.py create mode 100644 pos_next/authorization/tests/test_pin.py create mode 100644 pos_next/authorization/tests/test_policy.py create mode 100644 pos_next/pos_next_auth_gate/__init__.py create mode 100644 pos_next/pos_next_auth_gate/doctype/__init__.py create mode 100644 pos_next/pos_next_auth_gate/doctype/pos_authorization_approver/__init__.py create mode 100644 pos_next/pos_next_auth_gate/doctype/pos_authorization_approver/pos_authorization_approver.json create mode 100644 pos_next/pos_next_auth_gate/doctype/pos_authorization_approver/pos_authorization_approver.py create mode 100644 pos_next/pos_next_auth_gate/doctype/pos_authorization_log/__init__.py create mode 100644 pos_next/pos_next_auth_gate/doctype/pos_authorization_log/pos_authorization_log.json create mode 100644 pos_next/pos_next_auth_gate/doctype/pos_authorization_log/pos_authorization_log.py create mode 100644 pos_next/pos_next_auth_gate/doctype/pos_authorization_rule/__init__.py create mode 100644 pos_next/pos_next_auth_gate/doctype/pos_authorization_rule/pos_authorization_rule.js create mode 100644 pos_next/pos_next_auth_gate/doctype/pos_authorization_rule/pos_authorization_rule.json create mode 100644 pos_next/pos_next_auth_gate/doctype/pos_authorization_rule/pos_authorization_rule.py create mode 100644 pos_next/pos_next_auth_gate/doctype/pos_authorization_rule/test_pos_authorization_rule.py create mode 100644 pos_next/pos_next_auth_gate/doctype/pos_authorization_settings/__init__.py create mode 100644 pos_next/pos_next_auth_gate/doctype/pos_authorization_settings/pos_authorization_settings.json create mode 100644 pos_next/pos_next_auth_gate/doctype/pos_authorization_settings/pos_authorization_settings.py create mode 100644 pos_next/public/js/user.js diff --git a/POS/components.d.ts b/POS/components.d.ts index 1f2e8b35f..6b5b0b148 100644 --- a/POS/components.d.ts +++ b/POS/components.d.ts @@ -9,6 +9,7 @@ export {} declare module 'vue' { export interface GlobalComponents { ActionButton: typeof import('./src/components/common/ActionButton.vue')['default'] + AuthorizationDialog: typeof import('./src/components/common/AuthorizationDialog.vue')['default'] AutocompleteSelect: typeof import('./src/components/common/AutocompleteSelect.vue')['default'] BatchSerialDialog: typeof import('./src/components/sale/BatchSerialDialog.vue')['default'] CheckboxField: typeof import('./src/components/settings/CheckboxField.vue')['default'] diff --git a/POS/package.json b/POS/package.json index 9c9f0dfc9..ab56be3d1 100644 --- a/POS/package.json +++ b/POS/package.json @@ -27,6 +27,7 @@ "frappe-ui": "^0.1.240", "pinia": "^3.0.4", "qz-tray": "^2.2.5", + "reka-ui": "^2.5.0", "socket.io-client": "^4.7.2", "vue": "3.5.13", "vue-router": "^4.5.0" diff --git a/POS/src/App.vue b/POS/src/App.vue index 73c5f397b..f108f0cf6 100644 --- a/POS/src/App.vue +++ b/POS/src/App.vue @@ -2,10 +2,12 @@
+
diff --git a/POS/src/components/common/AuthorizationDialog.vue b/POS/src/components/common/AuthorizationDialog.vue new file mode 100644 index 000000000..b57032a69 --- /dev/null +++ b/POS/src/components/common/AuthorizationDialog.vue @@ -0,0 +1,185 @@ + + + diff --git a/POS/src/components/sale/ReturnInvoiceDialog.vue b/POS/src/components/sale/ReturnInvoiceDialog.vue index 49e3c2293..003920924 100644 --- a/POS/src/components/sale/ReturnInvoiceDialog.vue +++ b/POS/src/components/sale/ReturnInvoiceDialog.vue @@ -1179,6 +1179,7 @@