Bugzilla – Attachment 153306 Details for
Bug 33863
On receive "change currency" is always checked
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33863: Update values in data that will be saved
Bug-33863-Update-values-in-data-that-will-be-saved.patch (text/plain), 5.40 KB, created by
Jonathan Druart
on 2023-07-11 08:25:23 UTC
(
hide
)
Description:
Bug 33863: Update values in data that will be saved
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-07-11 08:25:23 UTC
Size:
5.40 KB
patch
obsolete
>From db65040beaad79699f2bd02678e22468c0f73fb2 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 11 Jul 2023 10:21:09 +0200 >Subject: [PATCH] Bug 33863: Update values in data that will be saved > >We are not saving the values of the input but a representation of the >form, contains in $("#order_edit").data('row'); > >To acchieve that it's preferable to reuse _update_unitprice and call it >when #change_currency is modified. > >Some code cleaning slipped into the patch, for readability purpose. >--- > .../prog/en/modules/acqui/orderreceive.tt | 41 +++++++++++-------- > 1 file changed, 24 insertions(+), 17 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >index 67eb84210bc..f169a117e50 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >@@ -365,7 +365,7 @@ > <span id="unitprice_hint" class="hint"></span> > </li> > <li> >- <label style="margin-left: 12em; text-align: left; font-weight: inherit; float:none;"><input type="checkbox" name="change_currency">Change currency</label> >+ <label style="margin-left: 12em; text-align: left; font-weight: inherit; float:none;"><input type="checkbox" id="change_currency" name="change_currency">Change currency</label> > </li> > <li id="select_currency"> > <label for="invoice_unitprice"></label> >@@ -909,32 +909,39 @@ > > }); > >- $("#order_edit").on("change", "input[name='change_currency']", function(){ >- if ( $(this).is(":checked") ) { >+ function _update_unitprice() { >+ let row = $("#order_edit").data('row'); >+ >+ let unitprice = $("#unitprice").val(); >+ let invoice_currency = $("#invoice_currency").val(); >+ let invoice_unitprice = $("#invoice_unitprice").val(); >+ let change_currency = $("#change_currency").is(":checked"); >+ >+ if ( change_currency ) { > $("#select_currency").show(); >- if(!$("#invoice_unitprice").val()) >- $("#invoice_unitprice").val($('#unitprice').val()); >+ if(!$("#invoice_unitprice").val()){ >+ invoice_unitprice = unitprice; >+ } >+ var rate = Number($("#invoice_currency option:selected").data('rate')); >+ unitprice = Number( invoice_unitprice * rate ).toFixed(2); > $("#unitprice").prop("readonly", "true"); > } else { > $("#select_currency").hide(); > $("#unitprice").prop("readonly", ""); >- $("#invoice_unitprice").val(""); >- $("#invoice_currency").val(active_currency); >+ invoice_unitprice = ""; >+ invoice_currency = active_currency; > } >- }); > >- function _update_unitprice() { >- var row = $("#order_edit").data('row'); >- var rate = Number($("select[name='invoice_currency'] option:selected").data('rate')); >- var invoice_currency = $("select[name='invoice_currency'] option:selected").val(); >- var invoice_unitprice = $("#invoice_unitprice").val(); >- var unitprice = Number( invoice_unitprice * rate ).toFixed(2); >+ $("#invoice_unitprice").val(invoice_unitprice); >+ $("#invoice_currency").val(invoice_currency); > $("#unitprice").val(unitprice).change(); >+ > row.invoice_currency = invoice_currency; > row.invoice_unit_price = invoice_unitprice; > } >- $("#order_edit").on("change", "select[name='invoice_currency']", _update_unitprice ); >+ $("#order_edit").on("change", "#invoice_currency", _update_unitprice ); > $("#order_edit").on("change", "#invoice_unitprice", _update_unitprice ); >+ $("#order_edit").on("change", "#change_currency", _update_unitprice ); > > $("#order_edit").on("change", "#replacementprice", function() { > var val = $(this).val(); >@@ -1247,13 +1254,13 @@ > if(row.invoice_currency && row.invoice_currency != active_currency) { > $("#select_currency").show(); > $("#unitprice").prop("readonly", true); >- $("input[name='change_currency']").prop('checked', true); >+ $("#change_currency").prop('checked', true); > $("#invoice_currency").val(row.invoice_currency); > $("#invoice_unitprice").val(row.invoice_unit_price); > } else { > $("#select_currency").hide(); > $("#unitprice").prop("readonly", ""); >- $("input[name='change_currency']").prop('checked', false); >+ $("#change_currency").prop('checked', false); > $("#invoice_currency").val(active_currency); > $("#invoice_unitprice").val(''); > } >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 33863
:
151796
|
153043
|
153306
|
153341
|
153342
|
153343
|
153402
|
153403
|
153404