Skip to content

Commit

Permalink
Merge pull request #172 from efeone/dev_TASK-2023-00464
Browse files Browse the repository at this point in the history
feat: Design Analysis Rejection Case
  • Loading branch information
muhammadmp authored Nov 7, 2023
2 parents dcefda0 + 04cf4fd commit c49ef56
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 15 deletions.
60 changes: 47 additions & 13 deletions aumms/aumms/doctype/design_analysis/design_analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,7 @@ frappe.ui.form.on('Design Analysis', {
}
},
refresh: function(frm){
if(frm.doc.status == 'Draft'){
create_custom_buttons(frm);
}
if(frm.doc.status == 'Request For Verification'){
request_for_approval(frm);
}
if(frm.doc.status == 'Request For Approval'){
approve_design_analysis(frm)
}
create_custom_buttons(frm);
},

check_dr_required: function(frm){
Expand All @@ -75,11 +67,13 @@ frappe.ui.form.on('Design Analysis', {
});

let create_custom_buttons = function(frm){
if(!frm.is_new()){
if(!frm.is_new() && frm.doc.status=='Draft'){
frm.add_custom_button('Request For Verification',() =>{
request_for_verification(frm);
}, 'Actions');
}
approve_design_analysis(frm);
request_for_approval(frm);
}

let request_for_verification = function(frm){
Expand All @@ -103,7 +97,7 @@ let request_for_verification = function(frm){
}

let request_for_approval = function(frm){
if(frm.doc.status == "Request For Verification"){
if((frm.doc.status == "Request For Verification" ) || (frm.doc.dr_required_check == 0 && frm.doc.verified_item.length>0 && frm.doc.status != 'Request For Approval' && frm.doc.status != 'Approved')){
frm.add_custom_button('Request For Approval', () =>{
make_request_for_approval(frm);
},'Actions');
Expand Down Expand Up @@ -169,7 +163,7 @@ let make_request_for_approval = function(frm){
// Check if the logged-in user is a supervisor
const isSupervisor = frappe.user_roles.includes('Supervisor');
let approve_design_analysis = function(frm) {
if (frm.doc.status === "Request For Approval") {
if (frm.doc.status == "Request For Approval") {
if (isSupervisor) {
frm.add_custom_button('Approve', () => {
const item_code = frm.doc.item_code;
Expand Down Expand Up @@ -198,11 +192,51 @@ let approve_design_analysis = function(frm) {
});
}, 'Actions');
frm.add_custom_button('Reject', () =>{
reject_design_analysis(frm)
},'Actions');
}
}
}

let reject_design_analysis = function(frm){
let d = new frappe.ui.Dialog({
title: 'Reason for Rejection',
fields: [
{
label: 'Comment',
fieldname: 'comment',
fieldtype: 'Small Text',
reqd: 1
},
],
size: 'small',
primary_action_label: 'Add comment',
primary_action(values) {
frappe.call({
method: 'aumms.aumms.utils.rejection_action',
args: {
'doctype': frm.doc.doctype,
'doc':frm.doc.name,
'comment':values.comment
},
callback: function(r) {
if (r.message){
frm.set_value("status","Rejected")
frm.save()
frappe.show_alert({
message:__('Rejected........'),
indicator:'red'
}, 5);
}
}
})
d.hide();
}
});

d.show();
}

frappe.ui.form.on('Verified Item',{
item: function(frm,cdt,cdn){
let d = locals[cdt][cdn];
Expand All @@ -212,7 +246,7 @@ frappe.ui.form.on('Verified Item',{
frm.doc.verified_item.forEach(function(d){
gold_weight += d.gold_wt;
expected_weight += d.net_wt;
calculated_stone_weight += d.stone_wt;
calculated_stone_weight += d.stone_wt;
})
frm.set_value('gold_weight',gold_weight),
frm.set_value('expected_weight',expected_weight),
Expand Down
3 changes: 2 additions & 1 deletion aumms/aumms/doctype/design_analysis/design_analysis.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
{
"fieldname": "status",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Status",
"options": "Draft\nRequest For Verification\nRequest For Approval\nApproved\nHold\nRejected\nBOM Created\nWorkorder Created"
},
Expand All @@ -190,7 +191,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-11-03 17:23:27.828034",
"modified": "2023-11-04 09:49:21.108122",
"modified_by": "Administrator",
"module": "AuMMS",
"name": "Design Analysis",
Expand Down
9 changes: 8 additions & 1 deletion aumms/aumms/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,11 @@ def create_notification_log(doctype, docname, recipient, subject, content=None,
notification_log.subject = subject
if content:
notification_log.email_content = content
notification_log.save(ignore_permissions=True)
notification_log.save(ignore_permissions=True)

@frappe.whitelist()
def rejection_action(doctype,doc,comment):
doc = frappe.get_doc(doctype,doc)
if comment:
doc.add_comment('Comment', comment)
return True

0 comments on commit c49ef56

Please sign in to comment.