Skip to content

Commit

Permalink
Merge pull request #212 from hamedshehab/develop
Browse files Browse the repository at this point in the history
Added Transaction Holder and Transfer Transaction and Sub Transactions
  • Loading branch information
hamedshehab authored Jan 25, 2025
2 parents 8541bba + f7e9564 commit 987c88f
Show file tree
Hide file tree
Showing 13 changed files with 623 additions and 180 deletions.
168 changes: 100 additions & 68 deletions academia/transactions/doctype/outbox_memo/outbox_memo.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ frappe.ui.form.on("Outbox Memo", {
if (response.message) {
user_id = response.message.user_id;
frm.set_value("current_action_maker", user_id);
frappe.db
.set_value(
"Transaction New",
frm.doc.transaction_reference,
"transaction_holder",
user_id
)
}
},
});
Expand All @@ -77,6 +84,13 @@ frappe.ui.form.on("Outbox Memo", {
});
} else if (frm.doc.type === "Internal" && frm.doc.direction === "Downward") {
frm.set_value("current_action_maker", frm.doc.recipients[0].recipient_email);
frappe.db
.set_value(
"Transaction New",
frm.doc.transaction_reference,
"transaction_holder",
frm.doc.recipients[0].recipient_email
)
} else {
console.log("External");
}
Expand Down Expand Up @@ -399,7 +413,16 @@ function add_approve_action(frm) {
r.message.action_maker
)
.then(() => {
location.reload();
frappe.db
.set_value(
"Transaction New",
frm.doc.transaction_reference,
"transaction_holder",
r.message.action_maker
)
.then(() => {
location.reload();
})
});
}
// frappe.db.set_value('Transaction', frm.docname, 'status', 'Approved');
Expand Down Expand Up @@ -512,75 +535,84 @@ function add_approve_action(frm) {
r.message.action_maker
)
.then(() => {
console.log(r.message);
global_action_name = r.message.action_name;
console.log(global_action_name);

frappe.call({
method: "academia.transactions.doctype.outbox_memo.outbox_memo.create_transaction_document_log",
args: {
start_employee: values.start_employee,
end_employee: global_next_recipient,
document_type: "Outbox Memo",
document_name: values.document_name,
document_action_type: "Outbox Memo Action",
document_action_name: global_action_name,
middle_man: values.middle_man,
through_middle_man: values.through_middle_man
? "True"
: "False",
proof: values.proof,
with_proof: values.with_proof
? "True"
: "False",
},
callback: function (r) {
if (r.message) {
console.log(
"Transaction Document Log created:",
r.message
);
if (r.message) {
if (
values.with_proof &&
!values.through_middle_man
) {
frappe.db
.set_value(
"Outbox Memo",
frm.docname,
"is_received",
1
)
.then(() => {
location.reload();
});
} else {
frappe.db
.set_value(
"Outbox Memo",
frm.docname,
"is_received",
0
)
.then(() => {
location.reload();
});
frappe.db
.set_value(
"Transaction New",
frm.doc.transaction_reference,
"transaction_holder",
r.message.action_maker
)
.then(() => {
console.log(r.message);
global_action_name = r.message.action_name;
console.log(global_action_name);

frappe.call({
method: "academia.transactions.doctype.outbox_memo.outbox_memo.create_transaction_document_log",
args: {
start_employee: values.start_employee,
end_employee: global_next_recipient,
document_type: "Outbox Memo",
document_name: values.document_name,
document_action_type: "Outbox Memo Action",
document_action_name: global_action_name,
middle_man: values.middle_man,
through_middle_man: values.through_middle_man
? "True"
: "False",
proof: values.proof,
with_proof: values.with_proof
? "True"
: "False",
},
callback: function (r) {
if (r.message) {
console.log(
"Transaction Document Log created:",
r.message
);
if (r.message) {
if (
values.with_proof &&
!values.through_middle_man
) {
frappe.db
.set_value(
"Outbox Memo",
frm.docname,
"is_received",
1
)
.then(() => {
location.reload();
});
} else {
frappe.db
.set_value(
"Outbox Memo",
frm.docname,
"is_received",
0
)
.then(() => {
location.reload();
});
}
// location.reload();
}
}
// location.reload();
}
}
},
error: function (r) {
frappe.msgprint("You are in the error");
console.error(r);
frappe.msgprint({
title: __("Error"),
indicator: "red",
message: r.message,
},
error: function (r) {
frappe.msgprint("You are in the error");
console.error(r);
frappe.msgprint({
title: __("Error"),
indicator: "red",
message: r.message,
});
},
});
},
});
});
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,32 @@ frappe.ui.form.on("Outbox Memo Action", {
},
callback: function (response) {
if (!response.exc) {
// frappe.set_route("Form", "Outbox Memo", frm.doc.outbox_memo)
frappe.set_route("Form", "Outbox Memo", frm.doc.outbox_memo);
location.reload();
frappe.call({
method: "frappe.client.get_value",
args: {
doctype: "Outbox Memo",
fieldname: "transaction_reference",
filters: { name: frm.doc.outbox_memo },
},
callback: function (response) {
if (response.message) {
const transaction_reference = response.message.transaction_reference;
frappe.db
.set_value(
"Transaction New",
transaction_reference,
"transaction_holder",
outbox_memo_action_doc.recipients[0].recipient_email
)
.then(() => {
frappe.set_route("Form", "Outbox Memo", frm.doc.outbox_memo);
location.reload();
});
} else {
frappe.msgprint("Transaction reference not found.");
}
},
});
} else {
frappe.msgprint("There was an error!");
}
Expand All @@ -55,8 +78,32 @@ frappe.ui.form.on("Outbox Memo Action", {
},
callback: function (response) {
if (!response.exc) {
frappe.set_route("Form", "Outbox Memo", frm.doc.outbox_memo);
location.reload();
frappe.call({
method: "frappe.client.get_value",
args: {
doctype: "Outbox Memo",
fieldname: "transaction_reference",
filters: { name: frm.doc.outbox_memo },
},
callback: function (response) {
if (response.message) {
const transaction_reference = response.message.transaction_reference;
frappe.db
.set_value(
"Transaction New",
transaction_reference,
"transaction_holder",
outbox_memo_action_doc.recipients[0].recipient_email
)
.then(() => {
frappe.set_route("Form", "Outbox Memo", frm.doc.outbox_memo);
location.reload();
});
} else {
frappe.msgprint("Transaction reference not found.");
}
},
});
} else {
frappe.msgprint("There was an error!");
}
Expand Down
74 changes: 48 additions & 26 deletions academia/transactions/doctype/request/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,32 +171,54 @@ frappe.ui.form.on("Request", {
},
before_submit: function (frm) {
frm.set_value("current_action_maker", frm.doc.recipients[0].recipient_email);
frappe.call({
method: "academia.transactions.doctype.request.request.update_share_permissions",
args: {
docname: frm.doc.name,
user: frappe.session.user,
permissions: {
read: 1,
write: 1,
share: 1,
submit: 1,
},
},
callback: function (response) {
if (response.message) {
// frappe.db.set_value(inbox_memo , 'current_action_maker')
frappe.db.set_value(
"Request",
frm.doc.name,
"current_action_maker",
Request_action_doc.recipients[0].recipient_email
);
// back to Transaction after save the transaction action
location.reload();
}
},
});
frappe.db
.set_value(
"Transaction New",
frm.doc.transaction_reference,
"transaction_holder",
frm.doc.recipients[0].recipient_email
)
.then(() => {
frappe.call({
method: "academia.transactions.doctype.request.request.update_share_permissions",
args: {
docname: frm.doc.name,
user: frappe.session.user,
permissions: {
read: 1,
write: 1,
share: 1,
submit: 1,
},
},
callback: function (response) {
if (response.message) {
// frappe.db.set_value(inbox_memo , 'current_action_maker')
frappe.db.set_value(
"Request",
frm.doc.name,
"current_action_maker",
Request_action_doc.recipients[0].recipient_email
)
.then(() => {
frappe.db
.set_value(
"Transaction New",
frm.doc.transaction_reference,
"transaction_holder",
Request_action_doc.recipients[0].recipient_email
)
.then(() => {
location.reload();
});
});
// back to Transaction after save the transaction action

}
},
});
});

},

refresh(frm) {
Expand Down
32 changes: 29 additions & 3 deletions academia/transactions/doctype/request_action/request_action.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,36 @@ frappe.ui.form.on("Request Action", {
frm.doc.request,
"current_action_maker",
request_action_doc.recipients[0].recipient_email
);
)
.then(() => {
frappe.call({
method: "frappe.client.get_value",
args: {
doctype: "Request",
fieldname: "transaction_reference",
filters: { name: frm.doc.request },
},
callback: function (response) {
if (response.message) {
const transaction_reference = response.message.transaction_reference;
frappe.db
.set_value(
"Transaction New",
transaction_reference,
"transaction_holder",
request_action_doc.recipients[0].recipient_email
)
.then(() => {
frappe.set_route("Form", "Request", frm.doc.request);
location.reload();
});
} else {
frappe.msgprint("Transaction reference not found.");
}
},
});
})
// back to Transaction after save the transaction action
frappe.set_route("Form", "Request", frm.doc.request);
location.reload();
}
},
});
Expand Down
Loading

0 comments on commit 987c88f

Please sign in to comment.