Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: create repost payment ledger entries from the report for differerences #44268

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,32 @@ function get_filters() {

frappe.query_reports["General and Payment Ledger Comparison"] = {
filters: get_filters(),

get_datatable_options(options) {
return Object.assign(options, {
checkboxColumn: true,
});
},

onload(report) {
report.page.add_inner_button(__("Repost"), function () {
let message = `Are you sure you want to Repost Payment Ledger Entry for the selected differences?`;
let indexes = frappe.query_report.datatable.rowmanager.getCheckedRows();
let selected_rows = indexes.map((i) => frappe.query_report.data[i]);

if (!selected_rows.length) {
frappe.throw(__("Please select rows to create repost entries"));
}

frappe.confirm(__(message), () => {
frappe.call({
method: "erpnext.accounts.report.general_and_payment_ledger_comparison.general_and_payment_ledger_comparison.create_repost_payment_ledger_entry",
args: {
rows: selected_rows,
company: frappe.query_report.get_filter_values().company,
},
});
});
});
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from frappe import _, qb
from frappe.query_builder import Criterion
from frappe.query_builder.functions import Sum
from frappe.utils import getdate


class General_Payment_Ledger_Comparison:
Expand Down Expand Up @@ -272,3 +273,19 @@ def execute(filters=None):
columns, data = rpt.run()

return columns, data


@frappe.whitelist()
def create_repost_payment_ledger_entry(rows, company):
if isinstance(rows, str):
rows = frappe.parse_json(rows)

entry = frappe.new_doc("Repost Payment Ledger", company=company, posting_date=getdate(), add_manually=1)

for row in rows:
entry.append(
"repost_vouchers", {"voucher_type": row.get("voucher_type"), "voucher_no": row.get("voucher_no")}
)

entry.save()
entry.submit()
Loading