Skip to content

Commit

Permalink
handle negotiated rate request option
Browse files Browse the repository at this point in the history
  • Loading branch information
danh91 committed Nov 20, 2018
1 parent 2bebf20 commit dfd1b08
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions purplship/mappers/ups/ups_mapper/partials/rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ def create_package_rate_request(self, payload: T.shipment_request) -> PRate.Rate
(payload.shipment.paid_by == 'SENDER' and payload.shipper.account_number != None) or
(payload.shipment.paid_by == 'RECIPIENT' and payload.recipient.account_number != None)
)
is_negotiated_rate = any((payload.shipment.payment_account_number, payload.shipper.account_number))
return PRate.RateRequest(
Request=Common.RequestType(
RequestOption=payload.shipment.extra.get('RequestOption') or ["Rate"],
Expand Down Expand Up @@ -313,12 +314,12 @@ def create_package_rate_request(self, payload: T.shipment_request) -> PRate.Rate
ShipmentServiceOptions=None,
ShipmentRatingOptions=(lambda rating:
PRate.ShipmentRatingOptionsType(
NegotiatedRatesIndicator="" if 'NegotiatedRatesIndicator' in rating else None,
NegotiatedRatesIndicator="" if is_negotiated_rate else None,
FRSShipmentIndicator="" if 'FRSShipmentIndicator' in rating else None,
RateChartIndicator="" if 'RateChartIndicator' in rating else None,
UserLevelDiscountIndicator="" if 'UserLevelDiscountIndicator' in rating else None
)
)(payload.shipment.extra.get('ShipmentRatingOptions')) if 'ShipmentRatingOptions' in payload.shipment.extra else None,
)(payload.shipment.extra.get('ShipmentRatingOptions') or {}) if 'ShipmentRatingOptions' in payload.shipment.extra or is_negotiated_rate else None,
InvoiceLineTotal=None,
RatingMethodRequestedIndicator=None,
TaxInformationIndicator=None,
Expand Down
3 changes: 3 additions & 0 deletions tests/ups/quote.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,9 @@ def test_parse_quote_missing_args_error(self):
<rate:Weight>4.0</rate:Weight>
</rate:PackageWeight>
</rate:Package>
<rate:ShipmentRatingOptions>
<rate:NegotiatedRatesIndicator></rate:NegotiatedRatesIndicator>
</rate:ShipmentRatingOptions>
</rate:Shipment>
</rate:RateRequest>
</tns:Body>
Expand Down

0 comments on commit dfd1b08

Please sign in to comment.