cap-sflight icon indicating copy to clipboard operation
cap-sflight copied to clipboard

Fix deductDiscountEnabled

Open danjoa opened this issue 4 years ago • 7 comments
trafficstars

Fixes this UI glitch:

  1. Open any travel entry in Object Page
  2. Do Deduct Discount once
  3. Deduct Discount button is erroneously disabled now
  4. Leave to list page and re-enter Object Page
  5. Deduct Discount button is correctly enabled now

This fix is not a nice one though → we should calculate there properties in the client, not in server

danjoa avatar Nov 12 '21 13:11 danjoa

I think we should go for calculated fields instead of the programmatically filled field controls: https://github.com/SAP-samples/cap-sflight/pull/50/commits/ebbfe15457ddf58db9be92738648601894bcf295

Fix https://github.com/SAP-samples/cap-sflight/pull/50/commits/75c0f721e0b50c27e4bf25c445d425921fff413c was in general wrong before, I think. With calculated fields it is necessary

Still: the real best practice would be to move all of this to the client. → just learned that Olingo is a blocker for that

danjoa avatar Nov 12 '21 16:11 danjoa

todo: java code that sets acceptEnabled, rejectEnabled, deductDiscountEnabled needs to be removed

stewsk avatar Dec 10 '21 17:12 stewsk

Hi Robin,

I can reprouce what Steffen reports here, I think it is a backend implementation issue:

The actions decribed trigger this $ batch request:

POST TravelService.deductDiscount {"percent":10}

GET select=deductDiscountEnabled

In all responses, deductDiscountEnabled is null, therefore rendered as inactive: The response must contain trie/falöse, not null.

{"@odata.context":"$metadata#Travel(TravelUUID,deductDiscountEnabled,IsActiveEntity)/$entity","@odata.metadataEtag":"W/"3c18da24a6589c44ae5da0e8317ac0ad35757b6a4b458b5c2b3c694badfa41bf"","@odata.id":"Travel(TravelUUID='75757221a8e4645c17002df03754ab66',IsActiveEntity=true)","TravelUUID":"75757221a8e4645c17002df03754ab66","deductDiscountEnabled":null,"IsActiveEntity":true}

"Travel(TravelUUID='75757221a8e4645c17002df03754ab66',IsActiveEntity=true)","TravelUUID":"75757221a8e4645c17002df03754ab66","deductDiscountEnabled":null,"IsActiveEntity":true}

The responses must contain true/false, not null.

In AcceptRejectHandler.java, the values are set using setUiEnabledFields(). But this is not happening in DeductDiscountHandler.java as far as I can see.

Could you have a look?

Best regards, Roland

rbrechter avatar Dec 13 '21 11:12 rbrechter

So, as far as I understand this PR it would be sufficient to just remove the server side handling in AcceptRejectHandler.java. For the DeductDiscountHandler no code needs to be removed as there was no handler implemented so far.

rjayasinghe avatar Dec 17 '21 15:12 rjayasinghe

Yes, that is how I understand it. So we could remove the respective code to get the tests of this PR green, then merge it, and then check whether the problem with the deployed Java app is gone (or there maybe is some other code that has similar issues ...??)

stewsk avatar Dec 17 '21 15:12 stewsk

... to make the tests green, all custom code referring to the virtual elements acceptEnabled, rejectEnabled, deductDiscountEnabled has to be removed, as these virtual elements are removed (replaced by calculated fields in the db view)

stewsk avatar Dec 17 '21 15:12 stewsk

Simply removing the java code that accesses the removed virtual fields dosn't help:

Caused by: org.h2.jdbc.JdbcSQLFeatureNotSupportedException: Dieses Feature wird nicht unterstⁿtzt: "VIEW"
Feature not supported: "VIEW"; SQL statement:
UPDATE TravelService_Travel SET LastChangedAt = ?, LastChangedBy = ?, TravelStatus_code = ? WHERE TravelUUID = ? [50100-200]

stewsk avatar Dec 17 '21 23:12 stewsk

has become obsolete logic has been moved to client via OData annos with expressions

stewsk avatar Dec 21 '22 08:12 stewsk