Skip to content

Commit

Permalink
Merge pull request #2 from agritheory/version-13-hotfix
Browse files Browse the repository at this point in the history
Check run render fixes
  • Loading branch information
agritheory authored Jul 8, 2022
2 parents df8692b + bc05bde commit 8d740bd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 40 deletions.
3 changes: 1 addition & 2 deletions check_run/check_run/doctype/check_run/check_run.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ function set_queries(frm){
function get_entries(frm){
frappe.xcall('check_run.check_run.doctype.check_run.check_run.get_entries', { doc: frm.doc}
).then((r) => {
console.log("TRANSACTIONS", frm.transactions.length, r.transactions.length)
frm.transactions = r.transactions
frm.modes_of_payment = r.modes_of_payment
check_run.mount_table(frm)
Expand Down Expand Up @@ -211,4 +210,4 @@ function reprint_checks(frm){
d.hide()
})
d.show()
}
}
8 changes: 7 additions & 1 deletion check_run/check_run/doctype/check_run/check_run.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"pay_to_account",
"section_break_9",
"check_run_table",
"html_15",
"transactions",
"amended_from",
"print_count",
Expand Down Expand Up @@ -145,11 +146,16 @@
{
"fieldname": "check_run_table",
"fieldtype": "HTML"
},
{
"default": "<span></span>",
"fieldname": "html_15",
"fieldtype": "HTML"
}
],
"is_submittable": 1,
"links": [],
"modified": "2022-07-04 05:50:56.817736",
"modified": "2022-07-08 10:10:39.971682",
"modified_by": "Administrator",
"module": "Check Run",
"name": "Check Run",
Expand Down
20 changes: 3 additions & 17 deletions check_run/check_run/doctype/check_run/check_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,6 @@ def validate(self):
else:
self.validate_last_check_number()

def is_dirty(self, doc):
dirty = False
for key in ('start_date', 'end_date', 'check_run_date', 'initial_check_number', 'company', 'bank_account', 'pay_to_account'):
if self.get(key) != doc.get(key):
return True
for db_row in json.loads(self.transactions):
for frm_row in doc.transactions:
if db_row.get('name') == frm_row.get('name'):
if db_row.get('mode_of_payment') != frm_row.get('mode_of_payment'):
return True
if db_row.get('pay') != frm_row.get('pay'):
return True

def set_status(self, status=None):
if status:
self.status = status
Expand Down Expand Up @@ -276,9 +263,8 @@ def get_entries(doc):
modes_of_payment = frappe.get_all('Mode of Payment', order_by='name')
if frappe.db.exists('Check Run', doc.name):
db_doc = frappe.get_doc('Check Run', doc.name)
print("dirty", db_doc.is_dirty(doc))
if db_doc.docstatus > 0 or not db_doc.is_dirty(doc):
return {'transactions': json.loads(frappe.get_value('Check Run', doc.name, 'transactions')), 'modes_of_payment': modes_of_payment}
if db_doc.transactions and json.loads(db_doc.transactions):
return {'transactions': json.loads(db_doc.transactions), 'modes_of_payment': modes_of_payment}
transactions = frappe.db.sql("""
(
SELECT
Expand Down Expand Up @@ -319,7 +305,7 @@ def get_entries(doc):
AND `tabExpense Claim`.payable_account = %(pay_to_account)s
)
UNION (
SELECT
SELECT
'Journal Entry' AS doctype,
`tabJournal Entry`.name,
`tabJournal Entry`.name AS ref_number,
Expand Down
35 changes: 15 additions & 20 deletions check_run/public/js/check_run/check_run.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,30 @@ import CheckRun from './CheckRun.vue'
frappe.provide('check_run')

check_run.mount_table = frm => {
if (frm.$check_run instanceof Vue) {
console.log('existing vue app')
frm.check_run_state.docstatus = frm.doc.docstatus
frm.check_run_state.transactions = frm.transactions
frm.check_run_state.modes_of_payment = state.modes_of_payment
frm.check_run_state.state = state
frm.$check_run.$forceUpdate()
return
}
const state = Vue.observable({
frm.check_run_state = Vue.observable({
transactions: frm.transactions,
party_filter: "",
docstatus: frm.doc.docstatus,
modes_of_payment: frm.modes_of_payment,
show_party_filter: false
})

frm.check_run_state = state
// if (frm.$check_run instanceof Vue) { return }
if (frm.$check_run instanceof Vue) {
frm.$check_run.$destroy();
}
$('#check-run-vue').remove()
$(frm.fields_dict['check_run_table'].wrapper).html($("<div id='check-run-vue'></div>").get(0));
frm.$check_run = new window.Vue({
el: $(frm.fields_dict['check_run_table'].wrapper).get(0),
el: $("#check-run-vue").get(0),
render: h => h(
CheckRun,
{ props: {
transactions: state.transactions, //list of transtactions
modes_of_payment: state.modes_of_payment, // populate modes_of_payment select. doesn't get updated
docstatus: state.docstatus, // used to conditionally render column inputs based on submission status. doesn't get updated
state: state
}
transactions: frm.check_run_state.transactions, //list of transtactions
modes_of_payment: frm.check_run_state.modes_of_payment, // populate modes_of_payment select. doesn't get updated
docstatus: frm.check_run_state.docstatus, // used to conditionally render column inputs based on submission status. doesn't get updated
state: frm.check_run_state
}
})
})
}


}

0 comments on commit 8d740bd

Please sign in to comment.