-
Notifications
You must be signed in to change notification settings - Fork 2
[9.0][IMP] pos_payment_terminal: better pywebdriver interface #3
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
base: 9.0-add_pos_payment_terminal-dro
Are you sure you want to change the base?
[9.0][IMP] pos_payment_terminal: better pywebdriver interface #3
Conversation
| if ('transaction_id' in response){ | ||
| line.transaction_id = response['transaction_id'] | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simplify by writing line.transaction_id = response.transaction_id, no need to test for the field presence.
| } | ||
| this.update_transaction_data(line, data) | ||
| this.message('payment_terminal_transaction_start', {'payment_info' : JSON.stringify(data)}); | ||
| self.update_transaction_data(line, data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| self.update_transaction_data(line, data) | |
| self.update_transaction_data(line, data); |
| vals['transaction_id'] = this.transaction_id || false; | ||
| vals['success'] = this.success || false; | ||
| vals['status'] = this.status || false; | ||
| vals['reference'] = this.reference || false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|| false sounds suspicious. Because for sucess, we want to distinguish (null/undefined, false, true).
I'd say you can simply do
vals.transaction_id = this.transaction_id
Codecov Report
@@ Coverage Diff @@
## 9.0-add_pos_payment_terminal-dro #3 +/- ##
====================================================================
+ Coverage 55.67% 55.83% +0.16%
====================================================================
Files 20 20
Lines 273 274 +1
====================================================================
+ Hits 152 153 +1
Misses 121 121
Continue to review full report at Codecov.
|
Payment lines are updated with response details Amount due is updated if 'success' == True in response
94fefb5 to
145be15
Compare
| var screens = require('point_of_sale.screens'); | ||
|
|
||
| screens.PaymentScreenWidget.include({ | ||
| deactivate_next: function(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| deactivate_next: function(){ | |
| deactivate_validate_button: function(){ |
| deactivate_next: function(){ | ||
| this.$('.next').toggle(false); | ||
| }, | ||
| activate_next: function(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| activate_next: function(){ | |
| activate_validate_button: function(){ |
| }); | ||
| paymentwidget.order_changes(); | ||
| }, | ||
| update_payment_line: function(response){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| update_payment_line: function(response){ | |
| update_payment_line: function(driver_status){ |
| if ('reference' in transaction){ | ||
| line.terminal_transaction_reference = transaction['reference']; | ||
| } | ||
| if (line){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this if line seems redundant
| if ('transaction_id' in response){ | ||
| line.terminal_transaction_id = response['transaction_id'] | ||
| } | ||
| if ('success' in response){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test seems useless: line.terminal_success = response.success should be sufficient.
| } | ||
| else if (line.terminal_transaction_success === true){ | ||
| self.activate_next(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handle all this button state inside render_payment_line
| on_click_transaction_start: function(event){ | ||
| var line_cid = $(event.currentTarget).data('cid'); | ||
| var self = this; | ||
| self.hide_transaction_started(line_cid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do this in render_payment_line to have all the rendering logic in one place
91a0862 to
631d54f
Compare
| var payment_lines = self.get_paymentlines(); | ||
| for (var id in payment_lines){ | ||
| var payment_line = payment_lines[id] | ||
| if payment_line.in_transaction{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need in_transaction: it should be equivalent to (transaction_id is not null and transaction_success is null).
6ab341e to
9d84324
Compare
8db0e32 to
0d6ccba
Compare
0d6ccba to
b86459f
Compare
Better pywebdriver interface in the case the driver can obtain transaction statuses from the terminal.