Skip to content

Commit

Permalink
get extra list and send extras
Browse files Browse the repository at this point in the history
  • Loading branch information
mogii committed Sep 12, 2024
1 parent 21c638a commit be8a221
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
13 changes: 9 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -681,9 +681,6 @@ class Plugin {
notes,
},
}) {
const extraText = extras && extras.length
? extras.map((e, i) => `Extra ${i + 1}: ${e.name} x ${e.quantity}`).join(`\n`)
: '';
const model = {
AddServiceRequest: {
AgentID: hostConnectAgentID,
Expand Down Expand Up @@ -716,7 +713,15 @@ class Plugin {
${doInfo.flightDetails ? `Flight: ${doInfo.flightDetails || 'NA'},` : ''}
`),
} : {}),
Remarks: this.escapeInvalidXmlChars(`${notes || ''} ${extraText ? `\nExtras: ${extraText}` : ''}`).slice(0, 220),
...(extras && extras.filter(e => e.selectedExtra && e.selectedExtra.id).length ? {
ExtraQuantities: {
ExtraQuantityItem: extras.filter(e => e.selectedExtra && e.selectedExtra.id).map(e => ({
SequenceNumber: e.selectedExtra.id,
ExtraQuantity: e.quantity,
})),
},
} : {}),
Remarks: this.escapeInvalidXmlChars(notes).slice(0, 220),
Opt: optionId,
DateFrom: startDate,
RateId: 'Default',
Expand Down
11 changes: 11 additions & 0 deletions resolvers/product.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ const translateTPOption = ({ optionsGroupedBySupplierId, supplierData }) => {
options: optionsGroupedBySupplierId.map(option => {
const comment = R.path(['OptGeneral', 'Comment'], option);
const st = R.pathOr('', ['OptGeneral', 'ButtonName'], option);
// when only one extra is present, it is not an array
let OptExtras = R.pathOr([], ['OptGeneral', 'OptExtras', 'OptExtra'], option);
// console.log({ OptExtras })
if (!Array.isArray(OptExtras)) OptExtras = [OptExtras];
const keyData = {
optionId: R.path(['Opt'], option),
optionName: `${R.path(['OptGeneral', 'Description'], option)}${
Expand Down Expand Up @@ -83,6 +87,13 @@ const translateTPOption = ({ optionsGroupedBySupplierId, supplierData }) => {
};
}, {}),
},
extras: OptExtras.map(obj => ({
id: R.path(['SequenceNumber'], obj),
name: R.path(['Description'], obj),
chargeBasis: R.path(['ChargeBasis'], obj),
isCompulsory: R.path(['IsCompulsory'], obj),
isPricePerPerson: R.path(['IsPricePerPerson'], obj),
})),
};
/*
SType: One character that specifies the service type of the
Expand Down

0 comments on commit be8a221

Please sign in to comment.