agritheory / approvals

Customizable Approval Workflows
Other
5 stars 1 forks source link

feat: customer credit limit approval #66

Open MyuddinKhatri opened 3 months ago

MyuddinKhatri commented 3 months ago

issue - #42

github-actions[bot] commented 3 months ago

Coverage

Coverage Report
FileStmtsMissCoverMissing
__init__.py10100% 
hooks.py130100% 
install.py880%1, 4–5, 8–11, 17
approvals
   __init__.py00100% 
   api.py19415321%19–21, 23, 33, 39, 41–44, 47–48, 53, 58–61, 70–74, 77, 81–83, 86–93, 103–106, 117–130, 132–137, 139–141, 143, 148–157, 162–165, 170–176, 181, 184–185, 188, 193, 197–198, 202–203, 208–212, 214–219, 224–225, 229–238, 243–255, 257, 266–267, 269, 272–273, 275–277, 279, 293, 309, 311–316, 326, 328–330, 341–343
approvals/doctype
   __init__.py00100% 
approvals/doctype/approval_doctype
   __init__.py00100% 
   approval_doctype.py30100% 
approvals/doctype/document_approval
   __init__.py00100% 
   document_approval.py15150%1–3, 6–9, 11–14, 16–17, 26–27
   test_document_approval.py30100% 
approvals/doctype/document_approval_rule
   __init__.py00100% 
   document_approval_rule.py65650%1–4, 6, 9–11, 13, 20–21, 23–24, 26–27, 30, 42–47, 51–52, 54–58, 61–64, 66–70, 72–74, 83, 85–87, 95–106, 109–111, 114–116, 122, 126
   test_document_approval_rule.py30100% 
approvals/doctype/document_approval_settings
   __init__.py00100% 
   document_approval_settings.py15473%18–19, 22–23
   test_document_approval_settings.py30100% 
approvals/doctype/user_document_approval
   __init__.py00100% 
   test_user_document_approval.py30100% 
   user_document_approval.py28280%1–4, 6, 9–12, 14–15, 17–18, 20–30, 32, 39–40, 43
config
   __init__.py00100% 
   desktop.py330%1, 4–5
   docs.py220%10–11
tests
   conftest.py23291%25–26
   test_approval_workflow.py200100% 
   test_non_workflow_approval.py352140%13, 18, 23, 31–32, 35–37, 44, 46–55, 57–58
TOTAL43730131% 

MyuddinKhatri commented 3 months ago
Workflow
{
    "name":"Customer",
    "owner":"Administrator",
    "creation":"2024-07-17 13:34:20.596129",
    "modified":"2024-07-17 13:40:17.807270",
    "modified_by":"Administrator",
    "docstatus":0,
    "idx":0,
    "workflow_name":"Customer",
    "document_type":"Customer",
    "is_active":1,
    "override_status":0,
    "send_email_alert":0,
    "workflow_state_field":"workflow_state",
    "doctype":"Workflow",
    "transitions":[
        {
            "name":"01gui08d70",
            "owner":"Administrator",
            "creation":"2024-07-17 13:34:20.596129",
            "modified":"2024-07-17 13:40:17.807270",
            "modified_by":"Administrator",
            "docstatus":0,
            "idx":1,
            "state":"Draft",
            "action":"Save",
            "next_state":"Draft",
            "allowed":"All",
            "allow_self_approval":1,
            "parent":"Customer",
            "parentfield":"transitions",
            "parenttype":"Workflow",
            "doctype":"Workflow Transition",
            "__unsaved":1
        },
        {
            "name":"01gu0atn9d",
            "owner":"Administrator",
            "creation":"2024-07-17 13:34:20.596129",
            "modified":"2024-07-17 13:40:17.807270",
            "modified_by":"Administrator",
            "docstatus":0,
            "idx":2,
            "state":"Draft",
            "action":"Send for Approval",
            "next_state":"Pending Approval",
            "allowed":"All",
            "allow_self_approval":1,
            "parent":"Customer",
            "parentfield":"transitions",
            "parenttype":"Workflow",
            "doctype":"Workflow Transition",
            "__unsaved":1
        },
        {
            "name":"01gugjgh3a",
            "owner":"Administrator",
            "creation":"2024-07-17 13:34:20.596129",
            "modified":"2024-07-17 13:40:17.807270",
            "modified_by":"Administrator",
            "docstatus":0,
            "idx":3,
            "state":"Pending Approval",
            "action":"Approve",
            "next_state":"Approved",
            "allowed":"All",
            "allow_self_approval":1,
            "parent":"Customer",
            "parentfield":"transitions",
            "parenttype":"Workflow",
            "doctype":"Workflow Transition",
            "__unsaved":1
        },
        {
            "name":"01gunadm3o",
            "owner":"Administrator",
            "creation":"2024-07-17 13:34:20.596129",
            "modified":"2024-07-17 13:40:17.807270",
            "modified_by":"Administrator",
            "docstatus":0,
            "idx":4,
            "state":"Approved",
            "action":"Save",
            "next_state":"Draft",
            "allowed":"All",
            "allow_self_approval":1,
            "parent":"Customer",
            "parentfield":"transitions",
            "parenttype":"Workflow",
            "doctype":"Workflow Transition",
            "__unsaved":1
        },
        {
            "name":"01gu1vobp2",
            "owner":"Administrator",
            "creation":"2024-07-17 13:34:20.596129",
            "modified":"2024-07-17 13:40:17.807270",
            "modified_by":"Administrator",
            "docstatus":0,
            "idx":5,
            "state":"Approved",
            "action":"Save",
            "next_state":"Approved",
            "allowed":"All",
            "allow_self_approval":1,
            "parent":"Customer",
            "parentfield":"transitions",
            "parenttype":"Workflow",
            "doctype":"Workflow Transition",
            "__unsaved":1
        },
        {
            "docstatus":0,
            "doctype":"Workflow Transition",
            "name":"04nbb1u4kr",
            "__unsaved":1,
            "owner":"Administrator",
            "allow_self_approval":1,
            "parent":"Customer",
            "parentfield":"transitions",
            "parenttype":"Workflow",
            "idx":6,
            "state":"Pending Approval",
            "action":"Reject",
            "next_state":"Draft",
            "allowed":"All",
            "creation":"2024-07-17 13:34:20.596129",
            "modified":"2024-07-17 13:40:17.807270",
            "modified_by":"Administrator"
        }
    ],
    "states":[
        {
            "name":"01gu4f804j",
            "owner":"Administrator",
            "creation":"2024-07-17 13:34:20.596129",
            "modified":"2024-07-17 13:40:17.807270",
            "modified_by":"Administrator",
            "docstatus":0,
            "idx":1,
            "state":"Draft",
            "doc_status":"0",
            "is_optional_state":0,
            "avoid_status_override":0,
            "allow_edit":"All",
            "parent":"Customer",
            "parentfield":"states",
            "parenttype":"Workflow",
            "doctype":"Workflow Document State",
            "__unsaved":1
        },
        {
            "name":"01gurmn3nh",
            "owner":"Administrator",
            "creation":"2024-07-17 13:34:20.596129",
            "modified":"2024-07-17 13:40:17.807270",
            "modified_by":"Administrator",
            "docstatus":0,
            "idx":2,
            "state":"Pending Approval",
            "doc_status":"0",
            "is_optional_state":0,
            "avoid_status_override":0,
            "allow_edit":"All",
            "parent":"Customer",
            "parentfield":"states",
            "parenttype":"Workflow",
            "doctype":"Workflow Document State",
            "__unsaved":1
        },
        {
            "name":"01gu3tclpi",
            "owner":"Administrator",
            "creation":"2024-07-17 13:34:20.596129",
            "modified":"2024-07-17 13:40:17.807270",
            "modified_by":"Administrator",
            "docstatus":0,
            "idx":3,
            "state":"Approved",
            "doc_status":"0",
            "is_optional_state":0,
            "avoid_status_override":0,
            "allow_edit":"All",
            "parent":"Customer",
            "parentfield":"states",
            "parenttype":"Workflow",
            "doctype":"Workflow Document State",
            "__unsaved":1
        }
    ],
    "approval_state":"Approved"
}
Document Approval Rule
{
    "name":"033lc8oo7s",
    "owner":"Administrator",
    "creation":"2024-07-17 13:37:02.951572",
    "modified":"2024-07-17 13:41:37.472312",
    "modified_by":"Administrator",
    "docstatus":0,
    "idx":0,
    "approval_doctype":"Customer",
    "approval_role":"Sales Manager",
    "enabled":1,
    "primary_assignee":"arivers@cfc.co",
    "assign_users":1,
    "condition":"True # any([c.credit_limit != frappe.get_value('Customer Credit Limit', c.name, 'credit_limit') for c in doc.credit_limits])",
    "title":"Customer - Sales Manager",
    "doctype":"Document Approval Rule"
}

After creating the above mentioned Workflow and Document Approval Rule and adding Customer Doctype to Approval Doctypes in Document Approval Settings -

@agritheory any thoughts?