Skip to content

Commit

Permalink
fix: Use sbool to handle string bool values from JS
Browse files Browse the repository at this point in the history
- Keep type consistent, use boolean everywhere for `allow_edit`
  • Loading branch information
marination committed Apr 12, 2024
1 parent 907e35a commit d994f9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from frappe.model.document import Document
from frappe.query_builder.custom import ConstantColumn
from frappe.query_builder.functions import Coalesce
from frappe.utils import cint, flt
from frappe.utils import cint, flt, sbool
from pypika.terms import Parameter

from erpnext import get_company_currency, get_default_cost_center
Expand Down Expand Up @@ -78,11 +78,11 @@ def create_journal_entry_bts(
mode_of_payment: str = None,
party_type: str = None,
party: str = None,
allow_edit: int = 0,
allow_edit: bool | str = False,
):
"""Create a new Journal Entry for Reconciling the Bank Transaction"""
if isinstance(allow_edit, str):
allow_edit = cint(allow_edit)
allow_edit = sbool(allow_edit)

bank_transaction = frappe.get_doc("Bank Transaction", bank_transaction_name)
if bank_transaction.deposit and bank_transaction.withdrawal:
Expand Down Expand Up @@ -182,6 +182,9 @@ def create_payment_entry_bts(
cost_center: str = None,
allow_edit: bool = False,
):
if isinstance(allow_edit, str):
allow_edit = sbool(allow_edit)

# Create a new payment entry based on the bank transaction
bank_transaction = frappe.db.get_values(
"Bank Transaction",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ erpnext.accounts.bank_reconciliation.CreateTab = class CreateTab {
});
}

create_voucher_bts(allow_edit, success_callback) {
create_voucher_bts(allow_edit=false, success_callback) {
// Create PE or JV and run `success_callback`
let values = this.create_field_group.get_values();
let document_type = values.document_type;
Expand All @@ -64,7 +64,7 @@ erpnext.accounts.bank_reconciliation.CreateTab = class CreateTab {
party: values.party,
posting_date: values.posting_date,
mode_of_payment: values.mode_of_payment,
allow_edit: allow_edit || 0,
allow_edit: allow_edit,
};

if (document_type === "Payment Entry") {
Expand Down

0 comments on commit d994f9d

Please sign in to comment.