Skip to content

Commit

Permalink
style: prettify code
Browse files Browse the repository at this point in the history
  • Loading branch information
agritheory authored and actions-user committed Nov 7, 2023
1 parent 2cdcab3 commit 23e823d
Showing 1 changed file with 29 additions and 32 deletions.
61 changes: 29 additions & 32 deletions electronic_payments/www/payments/index.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
frappe.ready(() => {
$('#payment-method').on('change', event => {
let total = event.target.selectedOptions[0].dataset.total
let currency = $('#doc-currency')[0].dataset.currency
let currency_symbol = $('#doc-currency')[0].dataset.symbol
let formatted_currency = format_currency(total, currency, 2).replace(currency, currency_symbol)

let order_button = $('#pay-for-order')[0]
order_button.innerHTML = `${__('Pay')} ${formatted_currency}`
})
$('#pay-for-order').on('click', () => {
$('#pay-for-order').addClass('disabled')
let order_url = new URL(window.location)
let dt = order_url.searchParams.get('dt')
let dn = order_url.searchParams.get('dn')
let payment_method = $('#payment-method')[0].value
frappe.call('pay', {dt: dt, dn: dn, payment_method: payment_method})
.then(r => {
if ('success_message' in r.message){
$('#payments-messages')[0].innerHTML = r.message.success_message
setTimeout(() => {
window.location = '/invoices'
}, 3000)
}
if ('error_message' in r.message) {
$('#payments-messages')[0].innerHTML = r.message.error_message
}
})
})

})

frappe.ready(() => {
$('#payment-method').on('change', event => {
let total = event.target.selectedOptions[0].dataset.total
let currency = $('#doc-currency')[0].dataset.currency
let currency_symbol = $('#doc-currency')[0].dataset.symbol
let formatted_currency = format_currency(total, currency, 2).replace(currency, currency_symbol)

let order_button = $('#pay-for-order')[0]
order_button.innerHTML = `${__('Pay')} ${formatted_currency}`
})
$('#pay-for-order').on('click', () => {
$('#pay-for-order').addClass('disabled')
let order_url = new URL(window.location)
let dt = order_url.searchParams.get('dt')
let dn = order_url.searchParams.get('dn')
let payment_method = $('#payment-method')[0].value
frappe.call('pay', { dt: dt, dn: dn, payment_method: payment_method }).then(r => {
if ('success_message' in r.message) {
$('#payments-messages')[0].innerHTML = r.message.success_message
setTimeout(() => {
window.location = '/invoices'
}, 3000)
}
if ('error_message' in r.message) {
$('#payments-messages')[0].innerHTML = r.message.error_message
}
})
})
})

0 comments on commit 23e823d

Please sign in to comment.