repo_id
stringclasses
36 values
file_path
stringlengths
63
188
content
stringlengths
62
41.5k
__index_level_0__
int64
0
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/PreDisplayLoyaltyCardBalanceTrigger.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Triggers from "PosApi/Extend/Triggers/CustomerTriggers"; import { ClientEntities } from "PosApi/Entities"; /** * Example implementation of PreDisplayLoyaltyCardBalance trigger that logs to the console. */ export default class PreDisplayLoyaltyCardBalanceTrigger extends Triggers.PreDisplayLoyaltyCardBalanceTrigger { /** * Executes the trigger functionality. * @param {Triggers.IPreDisplayLoyaltyCardBalanceTriggerOptions} options The options provided to the trigger. * @return {Promise<ClientEntities.ICancelable>} The cancelable promise. */ public execute(options: Triggers.IPreDisplayLoyaltyCardBalanceTriggerOptions): Promise<ClientEntities.ICancelable> { this.context.logger.logInformational("Executing PreDisplayLoyaltyCardBalanceTrigger with options " + JSON.stringify(options) + "."); return Promise.resolve({ canceled: false }); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/PreShipFulfillmentLinesTrigger.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Triggers from "PosApi/Extend/Triggers/SalesOrderTriggers"; import { CancelableTriggerResult } from "PosApi/Extend/Triggers/Triggers"; /** * Example implementation of an PreShipFulfillmentLinesTrigger trigger that logs its execution. */ export default class PreShipFulfillmentLinesTrigger extends Triggers.PreShipFulfillmentLinesTrigger { /** * Executes the trigger functionality. * @param {Triggers.IPreShipFulfillmentLinesTriggerOptions} options The options provided to the trigger. * @return {Promise<CancelableTriggerResult<Triggers.IPreShipFulfillmentLinesTriggerOptions>>} The cancelable promise containing the response. */ public execute(options: Triggers.IPreShipFulfillmentLinesTriggerOptions): Promise<CancelableTriggerResult<Triggers.IPreShipFulfillmentLinesTriggerOptions>> { this.context.logger.logInformational("Executing PreShipFulfillmentLinesTrigger with options " + JSON.stringify(options) + "."); return Promise.resolve(new CancelableTriggerResult(false, options)); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/PreFloatEntryTrigger.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Triggers from "PosApi/Extend/Triggers/CashManagementTriggers"; import { ClientEntities } from "PosApi/Entities"; export default class PreFloatEntryTrigger extends Triggers.PreFloatEntryTrigger { /** * Executes the trigger functionality. * @param {Triggers.IPreFloatEntryTriggerOptions} options The options provided to the trigger. * @return {Promise<ClientEntities.ICancelable>} The cancelable promise. */ public execute(options: Triggers.IPreFloatEntryTriggerOptions): Promise<ClientEntities.ICancelable> { this.context.logger.logVerbose("Executing PreFloatEntryTrigger with options " + JSON.stringify(options) + " at " + new Date().getTime() + "."); return Promise.resolve({ canceled: false }); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/PostGetSerialNumberTrigger.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Triggers from "PosApi/Extend/Triggers/ProductTriggers"; import { ClientEntities } from "PosApi/Entities"; import { StringExtensions } from "PosApi/TypeExtensions"; export default class PostGetSerialNumberTrigger extends Triggers.PostGetSerialNumberTrigger { /** * Executes the trigger functionality. * @param {Triggers.IPostGetSerialNumberTriggerOptions} options The options provided to the trigger. * @return {Promise<void>} The promise as resolved or rejected. */ public execute(options: Triggers.IPostGetSerialNumberTriggerOptions): Promise<void> { this.context.logger.logInformational("Executing PostSerialInputTrigger with options " + JSON.stringify(options) + "."); if (StringExtensions.isNullOrWhitespace(options.serialNumber)) { /* This condition is necessary if you want to continue allowing the feature of adding the serial number later. */ return Promise.resolve(); } else if (options.serialNumber === "111") { /* Does not add the item to the cart and shows an error message on the dialog. */ let error: ClientEntities.ExtensionError = new ClientEntities.ExtensionError ("The serial number entered has been rejected. Please enter it again or Add Later."); return Promise.reject(error); } else { /* Adds the item to the cart and dismisses the dialog. */ return Promise.resolve(); } } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/BeepSoundPostProductSaleTrigger.ts
import { IPostProductSaleTriggerOptions, PostProductSaleTrigger } from "PosApi/Extend/Triggers/ProductTriggers"; /** * Example implementation of a PostProductSale trigger that trigger beep sound. */ export default class BeepSoundPostProductSaleTrigger extends PostProductSaleTrigger { /** * Executes the trigger functionality. * @param {IPostProductSaleTriggerOptions} options The options provided to the trigger. */ public execute(options: IPostProductSaleTriggerOptions): Promise<void> { this.context.logger.logInformational("Executing BeepSoundPostProductSaleTrigger with options " + JSON.stringify(options) + "."); // You have to provide a full path to your resource file starting from the root of POS project. let resourcePath: string = "/Resources/audio/beep.wav"; // And the apply it to the base URL of the extension package. let filePath: string = this.context.extensionPackageInfo.baseUrl + resourcePath; let beeper: HTMLAudioElement = new Audio(filePath); beeper.play(); return Promise.resolve(); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/PreGetLoyaltyCardBalanceTrigger.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Triggers from "PosApi/Extend/Triggers/CustomerTriggers"; import { ClientEntities } from "PosApi/Entities"; /** * Example implementation of PreGetLoyaltyCardBalance trigger that logs to the console. */ export default class PreGetLoyaltyCardBalanceTrigger extends Triggers.PreGetLoyaltyCardBalanceTrigger { /** * Executes the trigger functionality. * @param {Triggers.IPreGetLoyaltyCardBalanceTriggerOptions} options The options provided to the trigger. * @return {Promise<ClientEntities.ICancelable>} The cancelable promise. */ public execute(options: Triggers.IPreGetLoyaltyCardBalanceTriggerOptions): Promise<ClientEntities.ICancelable> { this.context.logger.logInformational("Executing PreGetLoyaltyCardBalanceTrigger with options " + JSON.stringify(options) + "."); return Promise.resolve({ canceled: false }); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/OpenDeepLinkUrlTrigger.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { IPreOpenUrlTriggerOptions, PreOpenUrlTrigger } from "PosApi/Extend/Triggers/ApplicationTriggers"; import { CancelableTriggerResult } from "PosApi/Extend/Triggers/Triggers"; /** * Example implementation of a PreOpenUrlTrigger trigger that shows how to open a native app using deep linking. */ export default class OpenDeepLinkUrlTrigger extends PreOpenUrlTrigger { /** * Executes the trigger functionality. * @param {IPreOpenUrlTriggerOptions} options The options provided to the trigger. * @return {Promise<CancelableTriggerResult<IPreOpenUrlTriggerOptions>>} The cancelable promise. */ public execute(options: IPreOpenUrlTriggerOptions): Promise<CancelableTriggerResult<IPreOpenUrlTriggerOptions>> { let deepLinkUrl: URL; try { // Validate the URL provided in trigger options deepLinkUrl = new URL(options.url); // Open new window with deep link URL window.open(deepLinkUrl); this.context.logger.logInformational("Opened deep link " + deepLinkUrl); } catch (e) { // Log error but do not block execution this.context.logger.logError("Unable to open deep link url: " + deepLinkUrl + ". Exception: " + e); } // Return a canceled trigger result so that execution stops and another window is not opened through the normal workflow return Promise.resolve(new CancelableTriggerResult<IPreOpenUrlTriggerOptions>(true, options)); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/PostFloatEntryTrigger.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Triggers from "PosApi/Extend/Triggers/CashManagementTriggers"; /** * Example implementation of an PostFloatEntry trigger that logs to the console. */ export default class PostFloatEntryTrigger extends Triggers.PostFloatEntryTrigger { /** * Executes the trigger functionality. * @param {Triggers.IPostFloatEntryTriggerOptions} options The options provided to the trigger. */ public execute(options: Triggers.IPostFloatEntryTriggerOptions): Promise<void> { this.context.logger.logInformational("Executing PostFloatEntryTrigger with options " + JSON.stringify(options) + "."); return Promise.resolve(); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/ChangeUnitOfMeasurePostProductSaleTrigger copy.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Triggers from "PosApi/Extend/Triggers/ProductTriggers"; import { ProxyEntities } from "PosApi/Entities"; import { ChangeCartLineUnitOfMeasureOperationRequest, ChangeCartLineUnitOfMeasureOperationResponse } from "PosApi/Consume/Cart"; import { ObjectExtensions, ArrayExtensions } from "PosApi/TypeExtensions"; /** * Example implementation of an PostProductSale trigger that execute ChangeUnitOfMeasureClientRequest for different products and different options. */ export default class ChangeUnitOfMeasurePostProductSaleTrigger extends Triggers.PostProductSaleTrigger { /** * Executes the trigger functionality. * @param {Triggers.IPostProductSaleTriggerOptions} options The options provided to the trigger. */ public execute(options: Triggers.IPostProductSaleTriggerOptions): Promise<void> { // Set "true" to enable this sample. const enabled: boolean = false; if (enabled) { // This code is example for executing ChangeCartLineUnitOfMeasureOperationRequest. // The dialog of choice for unit of measure will be prompted when "unitOfMeasure" parameter of "ChangeCartLineUnitOfMeasureOperationRequest" request // is not provided.Otherwise the dialog won't appear. if (!ObjectExtensions.isNullOrUndefined(options.cart) && !ObjectExtensions.isNullOrUndefined(options.cart.CartLines)) { return this.doChangeUnitOfMeasure(options, "81211") .then((): Promise<any> => this.doChangeUnitOfMeasure(options, "81212", { DecimalPrecision: 0, Symbol: "pcs", Description: "Pieces", ExtensionProperties: [] })); } } this.context.logger.logInformational("Executing ChangeUnitOfMeasurePostProductSaleTrigger with options " + JSON.stringify(options) + "."); return Promise.resolve(); } /** * Executes ChangeCartLineUnitOfMeasureOperationRequest. * @param options The options provided to the trigger. * @param itemId The item identifier. * @param unitOfMeasure The unit of measure. * @returns {Promise<any>} The promise. */ private doChangeUnitOfMeasure( options: Triggers.IPostProductSaleTriggerOptions, itemId: string, unitOfMeasure?: ProxyEntities.UnitOfMeasure): Promise<any> { let cartLine: ProxyEntities.CartLine = ArrayExtensions.firstOrUndefined(options.cart.CartLines, (cl: ProxyEntities.CartLine) => { return cl.ItemId === itemId; }); if (!ObjectExtensions.isNullOrUndefined(cartLine)) { let changeUnitOfMeasureClientRequest: ChangeCartLineUnitOfMeasureOperationRequest<ChangeCartLineUnitOfMeasureOperationResponse> = new ChangeCartLineUnitOfMeasureOperationRequest(cartLine.LineId, this.context.logger.getNewCorrelationId(), unitOfMeasure); return this.context.runtime.executeAsync(changeUnitOfMeasureClientRequest); } return Promise.resolve(); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/ChangeUnitOfMeasurePostProductSaleTrigger.ts
import { ChangeCartLineUnitOfMeasureOperationRequest, ChangeCartLineUnitOfMeasureOperationResponse } from "PosApi/Consume/Cart"; import { ProxyEntities } from "PosApi/Entities"; import { IPostProductSaleTriggerOptions, PostProductSaleTrigger } from "PosApi/Extend/Triggers/ProductTriggers"; import { ObjectExtensions, ArrayExtensions } from "PosApi/TypeExtensions"; /** * Example implementation of a PostProductSale trigger that executes ChangeUnitOfMeasureClientRequest for Product 81212 when modifying the cart. */ export default class ChangeUnitOfMeasurePostProductSaleTrigger extends PostProductSaleTrigger { /** * Executes the trigger functionality. * @param {IPostProductSaleTriggerOptions} options The options provided to the trigger. */ public execute(options: IPostProductSaleTriggerOptions): Promise<void> { this.context.logger.logInformational("Executing ChangeUnitOfMeasurePostProductSaleTrigger with options " + JSON.stringify(options) + "."); // Check if there any cart lines if (!ObjectExtensions.isNullOrUndefined(options.cart) && !ObjectExtensions.isNullOrUndefined(options.cart.CartLines)) { // Check if specific product is in the cart let cartLine: ProxyEntities.CartLine = ArrayExtensions.firstOrUndefined(options.cart.CartLines, (cl: ProxyEntities.CartLine) => { return cl.ItemId === "81212"; }); // If the product is in the cart, update its unit of measure if (!ObjectExtensions.isNullOrUndefined(cartLine)) { let changeUnitOfMeasureClientRequest: ChangeCartLineUnitOfMeasureOperationRequest<ChangeCartLineUnitOfMeasureOperationResponse> = new ChangeCartLineUnitOfMeasureOperationRequest( cartLine.LineId, this.context.logger.getNewCorrelationId(), { DecimalPrecision: 0, Symbol: "dz", Description: "Dozen", ExtensionProperties: [] } ); this.context.runtime.executeAsync(changeUnitOfMeasureClientRequest); } } return Promise.resolve(); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/PostReceiptPromptTrigger.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Triggers from "PosApi/Extend/Triggers/PrintingTriggers"; /** * Example implementation of an PostReceiptPromptTrigger trigger that logs to the console. */ export default class PostReceiptPromptTrigger extends Triggers.PostReceiptPromptTrigger { /** * Executes the trigger functionality. * @param {Triggers.IPostReceiptPromptTriggerOptions} options The options provided to the trigger. */ public execute(options: Triggers.IPostReceiptPromptTriggerOptions): Promise<void> { console.log("Executing PostReceiptPromptTrigger with options " + JSON.stringify(options) + "."); return Promise.resolve(); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/CreditCardOnlyPreSelectTransactionPaymentMethod.ts
import { IPreSelectTransactionPaymentMethodTriggerOptions, PreSelectTransactionPaymentMethod } from "PosApi/Extend/Triggers/TransactionTriggers"; import { CancelableTriggerResult } from "PosApi/Extend/Triggers/Triggers"; import { ObjectExtensions } from "PosApi/TypeExtensions"; /** * Example implementation of a PreSelectTransactionPaymentMethod trigger that filters out all non-credit card payment methods. */ export default class CreditCardOnlyPreSelectTransactionPaymentMethod extends PreSelectTransactionPaymentMethod { /** * Executes the trigger functionality. * @param {IPreSelectTransactionPaymentMethodTriggerOptions} options The options provided to the trigger. * @return {Promise<CancelableTriggerResult<IPreSelectTransactionPaymentMethodTriggerOptions>>} The cancelable promise containing the response. */ public execute(options: IPreSelectTransactionPaymentMethodTriggerOptions): Promise<CancelableTriggerResult<IPreSelectTransactionPaymentMethodTriggerOptions>> { this.context.logger.logInformational("Executing CreditCardOnlyPreSelectTransactionPaymentMethod with options " + JSON.stringify(options) + "."); // Check if any payment options are configured. if (!ObjectExtensions.isNullOrUndefined(options.tenderTypes) && options.tenderTypes.length > 0) { // Filter out all non-credit card options. options.tenderTypes = options.tenderTypes.filter(value => { return (value.Name == "Cards"); }); } // Return non-canceled result with modified data options. return Promise.resolve(new CancelableTriggerResult<IPreSelectTransactionPaymentMethodTriggerOptions>(false, options)) } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/PreCustomerSaveTrigger.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Triggers from "PosApi/Extend/Triggers/CustomerTriggers"; import { ClientEntities } from "PosApi/Entities"; /** * Example implementation of an PreCustomerSaveTrigger trigger that logs to the console. */ export default class PreCustomerSaveTrigger extends Triggers.PreCustomerSaveTrigger { /** * Executes the trigger functionality. * @param {Triggers.IPreCustomerSaveTriggerOptions} options The options provided to the trigger. * @return {Promise<ClientEntities.ICancelable>} The cancelable promise. */ public execute(options: Triggers.IPreCustomerSaveTriggerOptions): Promise<ClientEntities.ICancelable> { this.context.logger.logInformational("Executing PreCustomerSaveTrigger with options " + JSON.stringify(options) + "."); return Promise.resolve({ canceled: false }); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/PreProductSaleTrigger.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Triggers from "PosApi/Extend/Triggers/ProductTriggers"; import { ObjectExtensions } from "PosApi/TypeExtensions"; import { ClientEntities } from "PosApi/Entities"; export default class PreProductSaleTrigger extends Triggers.PreProductSaleTrigger { /** * Executes the trigger functionality. * @param {Triggers.IPreProductSaleTriggerOptions} options The options provided to the trigger. * @return {Promise<ClientEntities.ICancelable>} The cancelable promise. */ public execute(options: Triggers.IPreProductSaleTriggerOptions): Promise<ClientEntities.ICancelable> { this.context.logger.logVerbose("Executing PreProductSaleTrigger with options " + JSON.stringify(options) + " at " + new Date().getTime() + "."); if (ObjectExtensions.isNullOrUndefined(options)) { // This will never happen, but is included to demonstrate how to return a rejected promise when validation fails. let error: ClientEntities.ExtensionError = new ClientEntities.ExtensionError("The options provided to the PreProductSaleTrigger were invalid. Please select a product and try again."); return Promise.reject(error); } else { return Promise.resolve({ canceled: false }); } } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/PostGetLoyaltyCardBalanceTrigger.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Triggers from "PosApi/Extend/Triggers/CustomerTriggers"; /** * Example implementation of an PostGetLoyaltyCardBalance trigger that logs to the console. */ export default class PostGetLoyaltyCardBalanceTrigger extends Triggers.PostGetLoyaltyCardBalanceTrigger { /** * Executes the trigger functionality. * @param {Triggers.IPostGetLoyaltyCardBalanceTriggerOptions} options The options provided to the trigger. */ public execute(options: Triggers.IPostGetLoyaltyCardBalanceTriggerOptions): Promise<void> { this.context.logger.logInformational("Executing PostGetLoyaltyCardBalanceTrigger with options " + JSON.stringify(options) + "."); return Promise.resolve(); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/PreSearchOrdersTrigger.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Triggers from "PosApi/Extend/Triggers/SalesOrderTriggers"; import { StringExtensions, ObjectExtensions } from "PosApi/TypeExtensions"; import { ProxyEntities } from "PosApi/Entities"; import { CancelableTriggerResult } from "PosApi/Extend/Triggers/Triggers"; import MessageDialog from "../../Create/Dialogs/DialogSample/MessageDialog"; import IPreElevateUserTriggerOptions = Triggers.IPreSearchOrdersTriggerOptions; /** * Example implementation of an PreSearchOrdersTrigger trigger that modifies the order search criteria and logs to the console. */ export default class PreSearchOrdersTrigger extends Triggers.PreSearchOrdersTrigger { /** * Executes the trigger functionality. * The orderSearchCriteria can be updated on the newOptions and this becomes the default value in the orders search view. * @param {Triggers.IPreUnlockTerminalTriggerOptions} options The options provided to the trigger. * @return {Promise<CancelableTriggerResult<IPreElevateUserTriggerOptions>>} The cancelable promise containing the response. */ public execute(options: IPreElevateUserTriggerOptions): Promise<CancelableTriggerResult<IPreElevateUserTriggerOptions>> { const NEW_ORDER_SEARCH_CRITERIA: ProxyEntities.OrderSearchCriteria = { CustomerAccountNumber: "testCustomerAccountNumber", CustomerName: "testCustomerName", EmailAddress: "testEmailAddress", SalesId: "testSalesId", ReceiptId: "testReceiptId", OrderStatusValues: [1, 2, 3], StartDateTime: new Date(), EndDateTime: new Date(), ChannelReferenceId: "testChannelReferenceId", StoreId: "testStoreId", OrderType: ProxyEntities.CustomerOrderType.SalesOrder, CustomFilters: undefined }; let newOptions: IPreElevateUserTriggerOptions = ObjectExtensions.clone(options); newOptions.orderSearchCriteria = NEW_ORDER_SEARCH_CRITERIA; return MessageDialog.show(this.context, StringExtensions.format("Executing PreSearchOrdersTrigger with options {0}.", JSON.stringify(newOptions))) .then((): Promise<CancelableTriggerResult<IPreElevateUserTriggerOptions>> => { // Returning a CancelableTriggerResult is needed for the data modification in the options to take effect. return Promise.resolve(new CancelableTriggerResult(false, newOptions)); }); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/InfoLoggingPreProductSaleTrigger.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Triggers from "PosApi/Extend/Triggers/ProductTriggers"; import { ClientEntities } from "PosApi/Entities"; export default class InfoLoggingPreProductSaleTrigger extends Triggers.PreProductSaleTrigger { /** * Executes the trigger functionality. * @param {Triggers.IPreProductSaleTriggerOptions} options The options provided to the trigger. * @return {Promise<ICancelable>} The cancelable promise. */ public execute(options: Triggers.IPreProductSaleTriggerOptions): Promise<ClientEntities.ICancelable> { this.context.logger.logInformational("Executing InfoLoggingPreProductSaleTrigger at " + new Date().getTime() + "."); return Promise.resolve({ canceled: false }); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/PostGetGiftCardNumberTrigger.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Triggers from "PosApi/Extend/Triggers/PaymentTriggers"; import { ClientEntities } from "PosApi/Entities"; export default class PostGetGiftCardNumberTrigger extends Triggers.PostGetGiftCardNumberTrigger { /** * Executes the trigger functionality. * @param {Triggers.IPostGetGiftCardNumberTriggerOptions} options The options provided to the trigger. * @return {Promise<ClientEntities.ICancelable>} The promise as resolved or rejected */ public execute(options: Triggers.IPostGetGiftCardNumberTriggerOptions): Promise<ClientEntities.ICancelable> { this.context.logger.logInformational("Executing PostGetGiftCardNumberTrigger with options " + JSON.stringify(options) + "."); return Promise.resolve({ canceled: false }); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/ConfirmChangeQuantityTrigger.ts
import { IMessageDialogOptions, ShowMessageDialogClientRequest, ShowMessageDialogClientResponse } from "PosApi/Consume/Dialogs"; import { ClientEntities } from "PosApi/Entities"; import { IPreSetQuantityTriggerOptions, PreSetQuantityTrigger } from "PosApi/Extend/Triggers/ProductTriggers"; /** * Example implementation of a PreSetQuantityTrigger trigger that shows a dialog asking the user to confirm the quantity change. */ export default class ConfirmChangeQuantityTrigger extends PreSetQuantityTrigger { private static dialogMessage: string = "Are you sure you want to change the quantity?\n\nChanging the quantity will require recalculation of the line charges."; private static yesButtonLabel: string = 'Yes'; private static noButtonLabel: string = 'No'; /** * Executes the trigger functionality. * @param {IPreSetQuantityTriggerOptions} options The options provided to the trigger. * @return {Promise<ICancelable>} The cancelable promise. */ public execute(options: IPreSetQuantityTriggerOptions): Promise<ClientEntities.ICancelable> { this.context.logger.logInformational("Executing ConfirmChangeQuantityTrigger with options " + JSON.stringify(options) + "."); // Configure options for dialog that will confirm user wants to change quantity. let dialogOptions: IMessageDialogOptions = { message: ConfirmChangeQuantityTrigger.dialogMessage, showCloseX: false, button1: { id: 'yesButton', label: ConfirmChangeQuantityTrigger.yesButtonLabel, result: ConfirmChangeQuantityTrigger.yesButtonLabel, isPrimary: true }, button2: { id: 'noButton', label: ConfirmChangeQuantityTrigger.noButtonLabel, result: ConfirmChangeQuantityTrigger.noButtonLabel, isPrimary: false } }; // Construct show dialog request. let showMessageDialogClientRequest: ShowMessageDialogClientRequest<ShowMessageDialogClientResponse> = new ShowMessageDialogClientRequest(dialogOptions); // Show the confirmation dialog to the user and process the result. return this.context.runtime.executeAsync(showMessageDialogClientRequest).then((value) => { // If user clicks 'Yes', continue with the Set Quantity flow. if (!value.canceled && value.data.result.dialogResult == ConfirmChangeQuantityTrigger.yesButtonLabel) { return Promise.resolve({ canceled: false }); // ... else if user clicks 'No', cancel the Set Quantity flow. } else { return Promise.resolve({ canceled: true }) } // Continue with the Set Quantity flow if any errors occur with the confirmation dialog. }).catch((reason: any) => { return Promise.resolve({ canceled: false }) }); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/PostLogOnTrigger.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Triggers from "PosApi/Extend/Triggers/ApplicationTriggers"; import { IPostLogOnViewOptions } from "../../Create/Views/NavigationContracts"; /** * Example implementation of a PostLogOnTrigger trigger that navigates to a new view and waits for the resolve callback from the navigated view. * The navigated view can delay the resuming of the logon operation to perform any other custom operations. */ export default class PostLogOnTrigger extends Triggers.PostLogOnTrigger { /** * Executes the trigger functionality. * @param {Triggers.IPostLogOnTriggerOptions} options The options provided to the trigger. */ public execute(options: Triggers.IPostLogOnTriggerOptions): Promise<any> { this.context.logger.logInformational("Executing PostLogOnTrigger with options " + JSON.stringify(options) + "."); let promise = new Promise((resolve, reject) => { let options: IPostLogOnViewOptions = { resolveCallback: resolve, rejectCallback: reject }; this.context.logger.logInformational("Navigating to PostLogOnView..."); this.context.navigator.navigate("PostLogOnView", options); }); promise.then((value: any) => { this.context.logger.logInformational("Promise resolved"); }); return promise; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/ForceErrorPreProductSaleTrigger.ts
import { ClientEntities } from "PosApi/Entities"; import { IPreProductSaleTriggerOptions, PreProductSaleTrigger } from "PosApi/Extend/Triggers/ProductTriggers"; /** * Example implementation of a PreProductSaleTrigger trigger that throws an error when trying to add Product 81213 to the cart. */ export default class ForceErrorPreProductSaleTrigger extends PreProductSaleTrigger { /** * Executes the trigger functionality. * @param {IPreProductSaleTriggerOptions} options The options provided to the trigger. * @return {Promise<ICancelable>} The cancelable promise. */ public execute(options: IPreProductSaleTriggerOptions): Promise<ClientEntities.ICancelable> { this.context.logger.logInformational("Executing ForceErrorPreProductSaleTrigger with options " + JSON.stringify(options) + "."); // If trying to add product 81213 to the cart, then return error from trigger... if (options.productSaleDetails.length > 0 && options.productSaleDetails[0].product.ItemId == "81213") { return Promise.reject(new ClientEntities.ExtensionError("Product 81213 is not available.")); // ... else do not block the trigger flow. } else { return Promise.resolve({ canceled: false }); } } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/PrePrintReceiptCopyTrigger.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Triggers from "PosApi/Extend/Triggers/PrintingTriggers"; import { ProxyEntities } from "PosApi/Entities"; import { ArrayExtensions, ObjectExtensions } from "PosApi/TypeExtensions"; import { ClientEntities } from "PosApi/Entities"; import { GetReceiptsClientRequest, GetReceiptsClientResponse } from "PosApi/Consume/SalesOrders"; export default class PrePrintReceiptCopyTrigger extends Triggers.PrePrintReceiptCopyTrigger { /** * Executes the trigger functionality. * @param {Triggers.IPrePrintReceiptCopyTriggerOptions} options The options provided to the trigger. * @return {Promise<ClientEntities.ICancelable>} The cancelable promise. */ public execute(options: Triggers.IPrePrintReceiptCopyTriggerOptions): Promise<ClientEntities.ICancelable> { this.context.logger.logVerbose("Executing PreProductSaleTrigger with options " + JSON.stringify(options) + "."); let receiptPair: { receipt: ProxyEntities.Receipt, printer: ProxyEntities.Printer } = ArrayExtensions.firstOrUndefined(options.receiptAndPrinterPairs); let criteria: ProxyEntities.ReceiptRetrievalCriteria = { IsCopy: true, ReceiptTypeValue: ObjectExtensions.isNullOrUndefined(receiptPair) ? ProxyEntities.ReceiptType.Unknown : receiptPair.receipt.ReceiptTypeValue, IsRemoteTransaction: false }; let request: GetReceiptsClientRequest<GetReceiptsClientResponse> = new GetReceiptsClientRequest(options.salesOrder.Id, criteria); return this.context.runtime.executeAsync(request) .then((response: ClientEntities.ICancelableDataResult<GetReceiptsClientResponse>): ClientEntities.ICancelable => { return response; }); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/ApplicationSuspendTrigger.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Triggers from "PosApi/Extend/Triggers/ApplicationTriggers"; /** * Example implementation of an ApplicationSuspend trigger that logs to the console. */ export default class ApplicationSuspendTrigger extends Triggers.ApplicationSuspendTrigger { /** * Executes the trigger functionality. * @param {Triggers.IApplicationSuspendTriggerOptions} options The options provided to the trigger. */ public execute(options: Triggers.IApplicationSuspendTriggerOptions): Promise<void> { this.context.logger.logInformational("Executing ApplicationSuspendTrigger at " + new Date().getTime() + "."); return Promise.resolve(); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/PreMarkFulfillmentLinesAsPackedTrigger.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Triggers from "PosApi/Extend/Triggers/SalesOrderTriggers"; /** * Example implementation of PreMarkFulfillmentLinesAsPacked trigger that logs its execution. */ export default class PreMarkFulfillmentLinesAsPackedTrigger extends Triggers.PreMarkFulfillmentLinesAsPackedTrigger { /** * Executes the trigger functionality. * @param {Triggers.PreMarkFulfillmentLinesAsPackedTriggerOptions} options The options provided to the trigger. * @return {Promise<Commerce.Triggers.CancelableTriggerResult<Triggers.IPreMarkFulfillmentLinesAsPackedTriggerOptions>>} The cancelable promise containing the response. */ public execute(options: Triggers.IPreMarkFulfillmentLinesAsPackedTriggerOptions): Promise<Commerce.Triggers.CancelableTriggerResult<Triggers.IPreMarkFulfillmentLinesAsPackedTriggerOptions>> { this.context.logger.logInformational("Executing PreMarkFulfillmentLinesAsPackedTrigger with options " + JSON.stringify(options) + "."); return Promise.resolve(new Commerce.Triggers.CancelableTriggerResult(false, options)); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/OverrideTaxPreEndTransactionTrigger.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Triggers from "PosApi/Extend/Triggers/TransactionTriggers"; import { ProxyEntities, ClientEntities } from "PosApi/Entities"; import { GetTaxOverridesServiceRequest, GetTaxOverridesServiceResponse, OverrideTransactionTaxOperationRequest } from "PosApi/Consume/Cart"; import { ArrayExtensions } from "PosApi/TypeExtensions"; /** * Example implementation of a PreEndTransaction trigger that execute GetTaxOverridesServiceRequest and OverrideTransactionTaxOperationRequest. */ export default class OverrideTaxPreEndTransactionTrigger extends Triggers.PreEndTransactionTrigger { /** * Executes the trigger functionality. * @param {Triggers.IPreEndTransactionTriggerOptions} options The options provided to the trigger. * @return {Promise<ICancelable>} The cancelable promise. */ public execute(options: Triggers.IPreEndTransactionTriggerOptions): Promise<ClientEntities.ICancelable> { // This code is example for executing GetTaxOverridesServiceRequest and GetTaxOverridesServiceResponse. this.context.logger.logInformational("Executing OverrideTaxPreEndTransactionTrigger with options " + JSON.stringify(options) + "."); let correlationId: string = this.context.logger.getNewCorrelationId(); let getTaxOverridesServiceRequest: GetTaxOverridesServiceRequest = new GetTaxOverridesServiceRequest(correlationId, ProxyEntities.TaxOverrideBy.Cart); return this.context.runtime.executeAsync(getTaxOverridesServiceRequest) .then((result: ClientEntities.ICancelableDataResult<GetTaxOverridesServiceResponse>): Promise<ClientEntities.ICancelable> => { if (ArrayExtensions.hasElements(result.data.taxOverrides)) { let overrideTransactionTaxOperationRequest: OverrideTransactionTaxOperationRequest = new OverrideTransactionTaxOperationRequest(correlationId, result.data.taxOverrides[0].Code); return this.context.runtime.executeAsync(overrideTransactionTaxOperationRequest); } return Promise.reject(new ClientEntities.ExtensionError("Could not override tax. No sales tax group has been set up for the store")); }); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Triggers/PostProductSaleTrigger.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Triggers from "PosApi/Extend/Triggers/ProductTriggers"; /** * Example implementation of an PostProductSale trigger that logs to the console. */ export default class PostProductSaleTrigger extends Triggers.PostProductSaleTrigger { /** * Executes the trigger functionality. * @param {Triggers.IPostProductSaleTriggerOptions} options The options provided to the trigger. */ public execute(options: Triggers.IPostProductSaleTriggerOptions): Promise<void> { console.log("Executing PostProductSaleTrigger with options " + JSON.stringify(options) + "."); return Promise.resolve(); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/FieldDefinitions/CustomerAddEditFieldDefinitions.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ICustomerAddEditExtensionDefinition } from "PosApi/Extend/FieldDefinitions/FieldDefinitions"; import { ClientEntities } from "PosApi/Entities"; export default (): ICustomerAddEditExtensionDefinition[] => { return [ { field: ClientEntities.CustomerFieldDefinitionType.FirstName, enabled: true, required: true, visible: true, type: ClientEntities.HtmlInputFieldType.Text, pattern: new RegExp("[A-Z]\w+"), maxLength: 20 } ]; };
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/FieldDefinitions/AddressAddEditFieldDefinitions.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { IAddressAddEditExtensionDefinition } from "PosApi/Extend/FieldDefinitions/FieldDefinitions"; import { ClientEntities } from "PosApi/Entities"; export default (): IAddressAddEditExtensionDefinition[] => { return [ { field: ClientEntities.AddressFieldDefinitionType.Zip, enabled: true, required: true, visible: true, type: ClientEntities.HtmlInputFieldType.Number, pattern: new RegExp("[1-9]\d+"), maxLength: 20 }, { field: ClientEntities.AddressFieldDefinitionType.StreetName, enabled: false, required: true, visible: true, type: ClientEntities.HtmlInputFieldType.Text, pattern: new RegExp("[A-Z]\w+"), maxLength: 20 } ]; };
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Header/SamplesViewPackingItem.html
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>Gas Pumps Status Item Templates</title> </head> <body> <script id="UnpackedSimpleExtensionViewItem" type="text/html"> <button class="pad0 center row" data-bind="click: onItemClickedHandler"> <div class="iconTrackers buttonIcon width48 height20"></div> </button> </script> <script id="PackedSimpleExtensionViewItem" type="text/html"> <button class="row pad0" data-bind="click: onItemClickedHandler"> <div class="iconTrackers buttonIcon height20 margin12"></div> <div class="grow col marginLeft8 padTop12"> <div class="h4 row" data-bind="text: label"></div> </div> </button> </script> </body> </html>
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Header/SamplesViewPackingItem.ts
import { CustomPackingItem, ICustomPackingItemContext, CustomPackingItemPosition, ICustomPackingItemState } from "PosApi/Extend/Header"; import ko from "knockout"; /** * (Sample) Custom packing item that shows the overall gas pump statuses and opens a dialog with more detailed info on click. */ export default class SamplesViewPackingItem extends CustomPackingItem { /** * The position of the custom packing item relative to the out-of-the-box items. */ public readonly position: CustomPackingItemPosition = CustomPackingItemPosition.Before; /** * The label of the packing item. */ public label: ko.Computed<string>; /** * Initializes a new instance of the CartAmountDuePackingItem class. * @param {string} id The item identifier. * @param {ICustomPackingItemContext} context The custom packing item context. */ constructor(id: string, context: ICustomPackingItemContext) { super(id, context); this.visible = true; this.label = "Navigate to Samples View"; } /** * Called when the control element is ready. * @param {HTMLElement} packedElement The DOM element of the packed element. * @param {HTMLElement} unpackedElement The DOM element of the unpacked element. */ public onReady(packedElement: HTMLElement, unpackedElement: HTMLElement): void { ko.applyBindingsToNode(unpackedElement, { template: { name: "UnpackedSimpleExtensionViewItem", data: this } }); ko.applyBindingsToNode(packedElement, { template: { name: "PackedSimpleExtensionViewItem", data: this } }); } /** * Initializes the control. * @param {ICustomPackingItemState} state The custom control state. */ public init(state: ICustomPackingItemState): void { return; } /** * Disposes the control releasing its resources. */ public dispose(): void { super.dispose(); } /** * Method used to handle the onClick of the custom packing item. */ public onItemClickedHandler(): void { this.context.navigator.navigate("SamplesView"); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Header/CartAmountDuePackingItem.html
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>Cart Amount Due Item Templates</title> </head> <body> <script id="Microsoft_Pos_Extensibility_Samples_UnpackedCartAmountDueItem" type="text/html"> <button class="pad0 center row" data-bind="click: onItemClickedHandler"> <div class="iconShop buttonIcon height20"></div> <div class="h4 padRight8" data-bind="text: amountDueLabel"></div> </button> </script> <script id="Microsoft_Pos_Extensibility_Samples_PackedCartAmountDueItem" type="text/html"> <button class="row pad0" data-bind="click: onItemClickedHandler"> <div class="iconShop buttonIcon height20 margin12"> </div> <div class="grow row marginLeft8 padTop12"> <div class="h4 padRight4">Amount due: </div> <div class="h4 padRight8" data-bind="text: amountDueLabel"></div> </div> </button> </script> </body> </html>
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/Header/CartAmountDuePackingItem.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { CustomPackingItem, ICustomPackingItemContext, CustomPackingItemPosition, ICustomPackingItemState, CartChangedData } from "PosApi/Extend/Header"; import { CurrencyFormatter } from "PosApi/Consume/Formatters"; import { ClientEntities } from "PosApi/Entities"; import { StringExtensions } from "PosApi/TypeExtensions"; import ko from "knockout"; /** * (Sample) Custom packing item that shows the cart's amount due and navigates to the cart on click. */ export default class CartAmountDuePackingItem extends CustomPackingItem { /** * The position of the custom packing item relative to the out-of-the-box items. */ public readonly position: CustomPackingItemPosition = CustomPackingItemPosition.After; /** * Label displayed in the custom packing item with the current amount due. */ public amountDueLabel: ko.Observable<string>; private _currentAmountDue: ko.Observable<number>; private _amountDueSubscription: Commerce.IDisposable; /** * Initializes a new instance of the CartAmountDuePackingItem class. * @param {string} id The item identifier. * @param {ICustomPackingItemContext} context The custom packing item context. */ constructor(id: string, context: ICustomPackingItemContext) { super(id, context); this.amountDueLabel = ko.observable(StringExtensions.EMPTY); this._currentAmountDue = ko.observable(0); this._amountDueSubscription = this._currentAmountDue.subscribe((newValue: number) => { if (newValue > 0) { this.amountDueLabel(CurrencyFormatter.toCurrency(newValue)); this.visible = true; } else { this.visible = false; } }); this.cartChangedHandler = this._cartChangedHandler.bind(this); } /** * Called when the control element is ready. * @param {HTMLElement} packedElement The DOM element of the packed element. * @param {HTMLElement} unpackedElement The DOM element of the unpacked element. */ public onReady(packedElement: HTMLElement, unpackedElement: HTMLElement): void { this.context.logger.logInformational("Executing onReady!"); ko.applyBindingsToNode(unpackedElement, { template: { name: "Microsoft_Pos_Extensibility_Samples_UnpackedCartAmountDueItem", data: this } }); ko.applyBindingsToNode(packedElement, { template: { name: "Microsoft_Pos_Extensibility_Samples_PackedCartAmountDueItem", data: this } }); } /** * Initializes the control. * @param {ICustomPackingItemState} state The custom control state. */ public init(state: ICustomPackingItemState): void { return; } /** * Disposes the control releasing its resources. */ public dispose(): void { this._amountDueSubscription.dispose(); super.dispose(); } /** * Method used to handle the onClick of the custom packing item. */ public onItemClickedHandler(): void { const correlationId: string = this.context.logger.getNewCorrelationId(); let cartViewOptions: ClientEntities.CartViewNavigationParameters = new ClientEntities.CartViewNavigationParameters(correlationId); this.context.logger.logInformational("Cart amount due packing item clicked.", correlationId); this.context.navigator.navigateToPOSView("CartView", cartViewOptions); } /** * Handler for the cart changed event. * @param {CartChangedData} data The data sent with the event. */ private _cartChangedHandler(data: CartChangedData): void { this.context.logger.logInformational("CartChanged received."); this._currentAmountDue(data.cart.AmountDue); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/ShippingMethods/ShippingMethodsViewController.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as ShippingMethodsView from "PosApi/Extend/Views/ShippingMethodsView"; import { IExtensionShippingMethodsViewControllerContext } from "PosApi/Extend/Views/ShippingMethodsView"; import { StringExtensions } from "PosApi/TypeExtensions"; /** * This class extends the base one to modify the default shipping address' city according to the customer's name */ export default class ShippingMethodsViewController extends ShippingMethodsView.ShippingMethodsExtensionViewControllerBase { /** * Creates a new instance of the ShippingMethodsViewController class. * @param {IExtensionShippingMethodsViewControllerContext} context The events Handler context. * @remarks The events handler context contains APIs through which a handler can communicate with POS. */ constructor(context: IExtensionShippingMethodsViewControllerContext) { super(context); this.shippingAddressUpdatedHandler = (data: ShippingMethodsView.ShippingAddressUpdatedData): void => { data.shippingAddress.City = StringExtensions.format("{0} - Home of {1}", data.shippingAddress.City, data.customer.Name); this.shippingAddress = data.shippingAddress; }; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/SearchOrders/SampleOrderSearchTextFilter.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ISearchFilterDefinitionContext, CustomTextSearchFilterDefinitionBase } from "PosApi/Extend/Views/CustomSearchFilters"; /** * Represents a sample text search filter. */ export default class SampleOrderSearchTextFilter extends CustomTextSearchFilterDefinitionBase { protected readonly labelValue: string; protected readonly id: string; /** * Creates a new instance of the SampleOrderSearchTextFilter class. * @param {ISearchFilterDefinitionContext} context The search filter definition context. */ constructor(context: ISearchFilterDefinitionContext) { super(context); this.id = "SampleOrderSearchTextFilter"; this.labelValue = "Sample Order Search Filter"; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/SearchOrders/SampleSearchOrdersCommand.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as SearchOrdersView from "PosApi/Extend/Views/SearchOrdersView"; import { ProxyEntities } from "PosApi/Entities"; import { IExtensionCommandContext } from "PosApi/Extend/Views/AppBarCommands"; import MessageDialog from "../../../Create/Dialogs/DialogSample/MessageDialog"; export default class SampleSearchOrdersCommand extends SearchOrdersView.SearchOrdersExtensionCommandBase { private _salesOrderTmp: ProxyEntities.SalesOrder; /** * Creates a new instance of the SampleSearchOrdersCommand class. * @param {IExtensionCommandContext<SearchOrdersView.ISearchOrdersToExtensionCommandMessageTypeMap>} context The command context. * @remarks The command context contains APIs through which a command can communicate with POS. */ constructor(context: IExtensionCommandContext<SearchOrdersView.ISearchOrdersToExtensionCommandMessageTypeMap>) { super(context); this.id = "sampleSearchOrdersCommand"; this.label = "Sample search orders command"; this.extraClass = "iconLightningBolt"; } /** * Initializes the command. * @param {SearchOrdersView.ISerchOrdersExtensionCommandState} state The state used to initialize the command. */ protected init(state: SearchOrdersView.ISerchOrdersExtensionCommandState): void { this.isVisible = true; this.orderSelectionHandler = (data: SearchOrdersView.SearchOrdersSelectedData): void => { this.canExecute = true; this._salesOrderTmp = data.salesOrder; }; this.orderSelectionClearedHandler = () => { this.canExecute = false; this._salesOrderTmp = undefined; }; } /** * Executes the command. */ protected execute(): void { let message: string = this._salesOrderTmp.Name + " : " + this._salesOrderTmp.CreatedDateTime; MessageDialog.show(this.context, message); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/SearchOrders/CustomOrdersListColumns.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { IOrdersListColumn } from "PosApi/Extend/Views/SearchOrdersView"; import { ICustomColumnsContext } from "PosApi/Extend/Views/CustomListColumns"; import { ClientEntities } from "PosApi/Entities"; import { CurrencyFormatter, DateFormatter } from "PosApi/Consume/Formatters"; export default (context: ICustomColumnsContext): IOrdersListColumn[] => { return [ { title: "SALES ORDER", computeValue: (row: ClientEntities.ISalesOrderDetails): string => { return row.salesOrder.SalesId; }, ratio: 10, collapseOrder: 8, minWidth: 100 }, { title: "ORDER TYPE", computeValue: (row: ClientEntities.ISalesOrderDetails): string => { return row.customerOrderType; }, ratio: 15, collapseOrder: 2, minWidth: 200 }, { title: "ORDER STATUS", computeValue: (row: ClientEntities.ISalesOrderDetails): string => { return row.orderStatus; }, ratio: 15, collapseOrder: 4, minWidth: 150 }, { title: "CREATED DATE", computeValue: (row: ClientEntities.ISalesOrderDetails): string => { return DateFormatter.toShortDate(row.salesOrder.CreatedDateTime); }, ratio: 10, collapseOrder: 5, minWidth: 100 }, { title: "DOCUMENT STATUS", computeValue: (row: ClientEntities.ISalesOrderDetails): string => { return row.documentStatus; }, ratio: 10, collapseOrder: 3, minWidth: 150 }, { title: "CUSTOMER NAME", computeValue: (row: ClientEntities.ISalesOrderDetails): string => { return row.salesOrder.Name; }, ratio: 15, collapseOrder: 6, minWidth: 200 }, { title: "RECEIPT EMAIL", computeValue: (row: ClientEntities.ISalesOrderDetails): string => { return row.salesOrder.ReceiptEmail; }, ratio: 15, collapseOrder: 1, minWidth: 200 }, { title: "ORDER TOTAL", computeValue: (row: ClientEntities.ISalesOrderDetails): string => { return CurrencyFormatter.toCurrency(row.salesOrder.TotalAmount); }, ratio: 10, collapseOrder: 7, minWidth: 100, isRightAligned: true } ]; };
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/FulfillmentLine/DeliveryModeSortColumn.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { CustomSortColumnDefinitionBase } from "PosApi/Extend/Views/CustomSortColumnDefinitions"; export default class DeliveryModeSortColumn extends CustomSortColumnDefinitionBase { private readonly _columnLabel: string = "Delivery Mode"; private readonly _columnName: string = "deliveryMode"; public label(): string { return this._columnLabel; } public columnName(): string { return this._columnName; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/FulfillmentLine/FulfillmentLineCommand.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ClientEntities, ProxyEntities } from "PosApi/Entities"; import { IExtensionCommandContext } from "PosApi/Extend/Views/AppBarCommands"; import { ArrayExtensions, ObjectExtensions, StringExtensions } from "PosApi/TypeExtensions"; import { FulfillmentLineExtensionCommandBase, FulfillmentLinesSelectedData, FulfillmentLinePackingSlipSelectedData, FulfillmentLinesLoadedData, IFulfillmentLineExtensionCommandState, IFulfillmentLineToExtensionCommandMessageTypeMap } from "PosApi/Extend/Views/FulfillmentLineView"; import { ShowMessageDialogClientRequest, ShowMessageDialogClientResponse, IMessageDialogOptions } from "PosApi/Consume/Dialogs"; import { GetScanResultClientRequest, GetScanResultClientResponse } from "PosApi/Consume/ScanResults"; import BarcodeMsrDialog from "../../../Create/Dialogs/BarCodeMsrDialog/BarcodeMsrDialog"; import { IBarcodeMsrDialogResult } from "../../../Create/Dialogs/BarCodeMsrDialog/BarcodeMsrDialogTypes"; export default class FulfillmentLineCommand extends FulfillmentLineExtensionCommandBase { private _fulfillmentLines: ProxyEntities.FulfillmentLine[]; private _selectedFulfillmentLines: ProxyEntities.FulfillmentLine[]; /** * Creates a new instance of the FulfillmentLineViewCommand class. * @param {IExtensionCommandContext<IFulfillmentLineToExtensionCommandMessageTypeMap>} context The context. * @remarks The command context contains APIs through which a command can communicate with POS. */ constructor(context: IExtensionCommandContext<IFulfillmentLineToExtensionCommandMessageTypeMap>) { super(context); this.id = "sampleFulfillmentLineCommand"; this.label = "Scan and Select Product"; this.extraClass = "iconLightningBolt"; this._selectedFulfillmentLines = []; this.fulfillmentLinesSelectionHandler = (data: FulfillmentLinesSelectedData): void => { this._selectedFulfillmentLines = data.fulfillmentLines; }; this.fulfillmentLinesSelectionClearedHandler = (): void => { this._selectedFulfillmentLines = []; }; this.packingSlipSelectedHandler = (data: FulfillmentLinePackingSlipSelectedData): void => { this.isVisible = false; }; this.packingSlipSelectionClearedHandler = (): void => { this.isVisible = true; }; this.fulfillmentLinesLoadedHandler = (data: FulfillmentLinesLoadedData): void => { this._fulfillmentLines = data.fulfillmentLines; }; } /** * Initializes the command. * @param {FulfillmentLineView.IFulfillmentLineExtensionCommandState} state The state used to initialize the command. */ protected init(state: IFulfillmentLineExtensionCommandState): void { this.isVisible = true; this.canExecute = true; } /** * Executes the command. */ protected execute(): void { let dialog: BarcodeMsrDialog = new BarcodeMsrDialog(); let correlationId: string = this.context.logger.getNewCorrelationId(); this.context.logger.logInformational("FulfillmentLineCommand.execute started", correlationId); dialog.open().then((dialogResult: IBarcodeMsrDialogResult): Promise<void> => { if (!dialogResult.canceled && dialogResult.inputType !== "MSR" && dialogResult.inputType !== "None" && !StringExtensions.isNullOrWhitespace(dialogResult.value)) { let getScanResultRequest: GetScanResultClientRequest<GetScanResultClientResponse> = new GetScanResultClientRequest(dialogResult.value, correlationId); return this.context.runtime.executeAsync(getScanResultRequest) .then((scanResult: ClientEntities.ICancelableDataResult<GetScanResultClientResponse>): Promise<void> => { if (!scanResult.canceled && !ObjectExtensions.isNullOrUndefined(scanResult.data) && !ObjectExtensions.isNullOrUndefined(scanResult.data.result) && !ObjectExtensions.isNullOrUndefined(scanResult.data.result.Product)) { let product: ProxyEntities.SimpleProduct = scanResult.data.result.Product; let matchingLine: ProxyEntities.FulfillmentLine = ArrayExtensions.firstOrUndefined(this._fulfillmentLines, (line: ProxyEntities.FulfillmentLine): boolean => { return line.ProductId === product.RecordId; }); if (ObjectExtensions.isNullOrUndefined(matchingLine)) { return Promise.reject(new ClientEntities.ExtensionError("Please scan a product that matches a selected fulfillment line.")); } else { if (!this._selectedFulfillmentLines.some((line: ProxyEntities.FulfillmentLine): boolean => { return line.ProductId === matchingLine.ProductId; })) { this._selectedFulfillmentLines.push(matchingLine); this.setSelectedFulfillmentLines({ fulfillmentLines: this._selectedFulfillmentLines }); } return Promise.resolve(); } } else { return Promise.reject(new ClientEntities.ExtensionError("Please scan a product that matches a selected fulfillment line.")); } }); } else { return Promise.resolve(); } }).catch((reason: any): void => { this._displayErrorAsync(reason); }); } /** * Displays an error message for the provided error. * @param {any} reason The error. * @returns Promise<ICancelable> The promise. */ private _displayErrorAsync(reason: any): Promise<ClientEntities.ICancelable> { let messageDialogOptions: IMessageDialogOptions; if (reason instanceof ClientEntities.ExtensionError) { messageDialogOptions = { message: reason.localizedMessage }; } else if (reason instanceof Error) { messageDialogOptions = { message: reason.message }; } else if (typeof reason === "string") { messageDialogOptions = { message: reason }; } else { messageDialogOptions = { message: "An unexpected error occurred." }; } let errorMessageRequest: ShowMessageDialogClientRequest<ShowMessageDialogClientResponse> = new ShowMessageDialogClientRequest(messageDialogOptions); return this.context.runtime.executeAsync(errorMessageRequest); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/SearchPickingAndReceiving/SearchPickingAndReceivingCmd.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as SearchPickingAndReceivingView from "PosApi/Extend/Views/SearchPickingAndReceivingView"; import { ClientEntities } from "PosApi/Entities"; import { IExtensionCommandContext } from "PosApi/Extend/Views/AppBarCommands"; import MessageDialog from "../../../Create/Dialogs/DialogSample/MessageDialog"; export default class SearchPickingAndReceivingViewCommand extends SearchPickingAndReceivingView.SearchPickingAndReceivingExtensionCommandBase { private _order: ClientEntities.IPickingAndReceivingOrder; /** * Creates a new instance of the SearchPickingAndReceivingViewCommand class. * @param {IExtensionCommandContext<SearchPickingAndReceivingView.ISearchPickingAndReceivingToExtensionCommandMessageTypeMap>} context The command context. * @remarks The command context contains APIs through which a command can communicate with POS. */ constructor(context: IExtensionCommandContext<SearchPickingAndReceivingView.ISearchPickingAndReceivingToExtensionCommandMessageTypeMap>) { super(context); this.id = "sampleSearchPickingAndReceivingCommand"; this.label = "Sample search picking and receiving command"; this.extraClass = "iconLightningBolt"; } /** * Initializes the command. * @param {SearchPickingAndReceivingView.ISearchPickingAndReceivingExtensionCommandState} state The state used to initialize the command. */ protected init(state: SearchPickingAndReceivingView.ISearchPickingAndReceivingExtensionCommandState): void { this.isVisible = true; this.orderLineSelectedHandler = (data: SearchPickingAndReceivingView.OrderLineSelectedData): void => { this.canExecute = true; this._order = data.order; }; this.orderLineSelectionClearedHandler = (): void => { this.canExecute = false; this._order = null; }; } /** * Executes the command. */ protected execute(): void { let message: string = this._order.orderId + " : " + this._order.orderType; MessageDialog.show(this.context, message); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/SearchPickingAndReceiving/CustomOrdersListColumns.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { IOrdersListColumn } from "PosApi/Extend/Views/SearchPickingAndReceivingView"; import { ICustomColumnsContext } from "PosApi/Extend/Views/CustomListColumns"; import { ClientEntities, ProxyEntities } from "PosApi/Entities"; import { PurchaseTransferOrderTypeFormatter } from "PosApi/Consume/Formatters"; import { ObjectExtensions, StringExtensions } from "PosApi/TypeExtensions"; export default (context: ICustomColumnsContext): IOrdersListColumn[] => { return [ { title: "NUMBER", computeValue: (row: ClientEntities.IPickingAndReceivingOrder): string => { return row.orderId; }, ratio: 30, collapseOrder: 3, minWidth: 100 }, { title: "TYPE", computeValue: (row: ClientEntities.IPickingAndReceivingOrder): string => { return PurchaseTransferOrderTypeFormatter.toName(row.orderType); }, ratio: 40, collapseOrder: 2, minWidth: 200 }, { title: "STATUS", computeValue: (row: ClientEntities.IPickingAndReceivingOrder): string => { return row.status; }, ratio: 20, collapseOrder: 1, minWidth: 150 }, { title: "EXTENSION_PROP", computeValue: (row: ClientEntities.IPickingAndReceivingOrder): string => { if (!ObjectExtensions.isNullOrUndefined(row.extensionProperties)) { let commentsProperties: ProxyEntities.CommerceProperty[] = row.extensionProperties.filter( (value: ProxyEntities.CommerceProperty): boolean => { return value.Key === "Comments"; } ); return commentsProperties.length > 0 ? commentsProperties[0].Value.StringValue : StringExtensions.EMPTY; } return StringExtensions.EMPTY; }, ratio: 10, collapseOrder: 4, minWidth: 120 }, ]; };
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/PriceCheck/PriceCheckCustomControlPanel.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Controls from "PosApi/Consume/Controls"; import { PriceCheckCustomControlBase, IPriceCheckCustomControlState, IPriceCheckCustomControlContext, PriceCheckPriceCheckCompletedData, PriceCheckCustomerChangedData } from "PosApi/Extend/Views/PriceCheckView"; import { ObjectExtensions } from "PosApi/TypeExtensions"; import { ProxyEntities } from "PosApi/Entities"; import ko from "knockout"; export interface IMonthlyPrice { month: string; price: string; } export default class PriceCheckCustomControlPanel extends PriceCheckCustomControlBase { public readonly title: ko.Observable<string>; public readonly customerName: ko.Observable<string>; public dataList: Controls.IDataList<IMonthlyPrice>; private static readonly TEMPLATE_ID: string = "Microsoft_Pos_Extensibility_Samples_PriceCheckPanel"; private _monthlyProductPrices: IMonthlyPrice[] = []; constructor(id: string, context: IPriceCheckCustomControlContext) { super(id, context); this.title = ko.observable("Monthly Payment Plan"); this.customerName = ko.observable(null); this.customerChangedHandler = this.customerChanged; this.priceCheckCompletedHandler = this.priceCheckCompleted; } /** * Binds the control to the specified element. * @param {HTMLElement} element The element to which the control should be bound. */ public onReady(element: HTMLElement): void { ko.applyBindingsToNode(element, { template: { name: PriceCheckCustomControlPanel.TEMPLATE_ID, data: this } }); let dataListOptions: Readonly<Controls.IDataListOptions<IMonthlyPrice>> = { columns: [ { title: "Month", ratio: 50, collapseOrder: 1, minWidth: 100, computeValue: (value: IMonthlyPrice): string => { return value.month; } }, { title: "Price", ratio: 50, collapseOrder: 2, minWidth: 60, computeValue: (value: IMonthlyPrice): string => { return value.price; } } ], interactionMode: Controls.DataListInteractionMode.None, data: this._monthlyProductPrices }; let dataListRootElem: HTMLDivElement = element.querySelector("#Microsoft_Pos_Extensibility_Samples_PriceCheckPanel_DataList") as HTMLDivElement; this.dataList = this.context.controlFactory.create("", "DataList", dataListOptions, dataListRootElem); } /** * Initializes the control. * @param {IPriceCheckCustomControlState} state The initial state of the page used to initialize the control. */ public init(state: IPriceCheckCustomControlState): void { this.isVisible = true; this._setCustomer(state.customer); this._updateMonthlyProductPrice(state.productPrice.CustomerContextualPrice); } /** * The handler for the price check completed message. * @param {PriceCheckPriceCheckCompletedData} data The result data of product search. */ public priceCheckCompleted(data: PriceCheckPriceCheckCompletedData): void { this._updateMonthlyProductPrice(data.productPrice.CustomerContextualPrice); } /** * The handler for the customer changed message. * @param {PriceCheckCustomerChangedData} customer The changed customer. */ public customerChanged(data: PriceCheckCustomerChangedData): void { this._setCustomer(data.customer); } /** * Sets the customer. * @param {ProxyEntities.Customer} customer The customer to set */ private _setCustomer(customer: ProxyEntities.Customer): void { if (!ObjectExtensions.isNullOrUndefined(customer)) { this.customerName(customer.Name); } else { this.customerName(null); } } /** * Calculates and updates the monthly price. * @param {number} productPrice The product price. */ private _updateMonthlyProductPrice(productPrice: number): void { let monthlyProductPrice: string = "$" + this._getMonthlyPrice(productPrice); this._monthlyProductPrices = [ { month: "January", price: monthlyProductPrice }, { month: "February", price: monthlyProductPrice }, { month: "March", price: monthlyProductPrice }, { month: "April", price: monthlyProductPrice }, { month: "May", price: monthlyProductPrice }, { month: "June", price: monthlyProductPrice }, { month: "July", price: monthlyProductPrice }, { month: "August", price: monthlyProductPrice }, { month: "September", price: monthlyProductPrice }, { month: "October", price: monthlyProductPrice }, { month: "November", price: monthlyProductPrice }, { month: "December", price: monthlyProductPrice } ]; this.dataList.data = this._monthlyProductPrices; } /** * Returns the monthly price. * @param {number} productPrice The product price. * @returns {string} The monthly product price. */ private _getMonthlyPrice(productPrice: number): string { if (ObjectExtensions.isNullOrUndefined(productPrice)) { return "0"; } let monthlyPaymentAmount: number = productPrice / 12.0; return monthlyPaymentAmount.toFixed(2); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/PriceCheck/PriceCheckCustomControlPanel.html
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title></title> </head> <body> <!-- Note: The element id is different than the id generated by the POS extensibility framework. This 'template' id is not used by the POS extensibility framework. --> <script id="Microsoft_Pos_Extensibility_Samples_PriceCheckPanel" type="text/html"> <div class="h2 marginTop8 marginBottom8" data-bind="text: title"></div> <div class="h4 wrapText" data-bind="text: customerName"></div> <div class="gutter20x20"></div> <div class="width400 grow col"> <div id="Microsoft_Pos_Extensibility_Samples_PriceCheckPanel_DataList"></div> </div> </script> </body> </html>
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart/CustomerDetailsCustomControl.html
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title></title> </head> <body> <!-- Note: The element id is different than the id generated by the POS extensibility framework. This 'template' id is not used by the POS extensibility framework. --> <script id="Microsot_Pos_Extensibility_Samples_CustomerDetails" type="text/html"> <!-- ko if: isCustomerSelected --> <div class="row"> <div class="col stretch"> <div class="marginBottom20"> <label for="SampleExtensions_CustomerDetails_AccountHolder" data-bind="text: accountHolderLabel">Account holder</label> <input id="SampleExtensions_CustomerDetails_AccountHolder" type="text" readonly data-bind="value: accountHolder" /> </div> <div class="marginBottom20"> <label for="SampleExtensions_CustomerDetails_AccountNumber" data-bind="text: accountNumberLabel">Account number</label> <input id="SampleExtensions_CustomerDetails_AccountNumber" type="text" readonly data-bind="value: accountNumber" /> </div> </div> <div class="gutter40x40"></div> <div class="col stretch"> <div class="marginBottom20"> <label for="SampleExtensions_CustomerDetails_Phone" data-bind="text: phoneLabel">Phone</label> <input id="SampleExtensions_CustomerDetails_Phone" type="text" readonly data-bind="value: phone" /> </div> <div class="marginBottom20"> <label for="SampleExtensions_CustomerDetails_Email" data-bind="text: emailLabel">Email</label> <input id="SampleExtensions_CustomerDetails_Email" type="text" readonly data-bind="value: email" /> </div> </div> </div> <!-- /ko --> </script> </body> </html>
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart/LineDetailsCustomControl.html
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title></title> </head> <body> <!-- Note: The element id is different than the id generated by the POS extensibility framework. This 'template' id is not used by the POS extensibility framework. --> <script id="Microsoft_Pos_Extensibility_Samples_LineDetails" type="text/html"> <!-- ko ifnot: isCartLineSelected --> <div class="h4">No cart lines selected</div> <!-- /ko --> <!-- ko if: isCartLineSelected --> <div class="h4" data-bind="text: cartLineItemId">Item ID</div> <div class="h4" data-bind="text: cartLineDescription">Item ID</div> <!-- /ko --> </script> </body> </html>
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart/TipsCustomField.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { CartViewTotalsPanelCustomFieldBase } from "PosApi/Extend/Views/CartView"; import { ProxyEntities } from "PosApi/Entities"; export default class TipsCustomField extends CartViewTotalsPanelCustomFieldBase { public computeValue(cart: ProxyEntities.Cart): string { // Add 10% tips of total amount. if (isNaN(cart.TotalAmount) || cart.TotalAmount <= 0) { return "$0.00"; } return "$" + (cart.TotalAmount * 0.1).toFixed(2).toString(); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart/CartViewController.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as CartView from "PosApi/Extend/Views/CartView"; import { ProxyEntities } from "PosApi/Entities"; import { IExtensionCartViewControllerContext } from "PosApi/Extend/Views/CartView"; import { ArrayExtensions, StringExtensions } from "PosApi/TypeExtensions"; /** * Example implementation of an extension view controller for the CartView. */ export default class CartViewController extends CartView.CartExtensionViewControllerBase { public static selectedCartLineId: string = StringExtensions.EMPTY; private _selectedCartLines: ProxyEntities.CartLine[]; private _selectedTenderLines: ProxyEntities.TenderLine[]; private _isProcessingAddItemOrCustomer: boolean; /** * Creates a new instance of the CartViewController class. * @param {IExtensionCartViewControllerContext} context The events Handler context. * @remarks The events handler context contains APIs through which a handler can communicate with POS. */ constructor(context: IExtensionCartViewControllerContext) { super(context); this.cartLineSelectedHandler = (data: CartView.CartLineSelectedData): void => { this._selectedCartLines = data.cartLines; if (ArrayExtensions.hasElements(this._selectedCartLines)) { CartViewController.selectedCartLineId = this._selectedCartLines[0].LineId; } }; this.cartLineSelectionClearedHandler = (): void => { this._selectedCartLines = undefined; CartViewController.selectedCartLineId = null; }; this.tenderLineSelectedHandler = (data: CartView.TenderLineSelectedData): void => { this._selectedTenderLines = data.tenderLines; }; this.tenderLineSelectionClearedHandler = (): void => { this._selectedCartLines = undefined; }; this.processingAddItemOrCustomerChangedHandler = (processing: boolean): void => { this._isProcessingAddItemOrCustomer = processing; }; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart/CustomerDetailsCustomControl.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { CartViewCustomControlBase, ICartViewCustomControlState, ICartViewCustomControlContext, CartChangedData } from "PosApi/Extend/Views/CartView"; import { ObjectExtensions, StringExtensions } from "PosApi/TypeExtensions"; import { ProxyEntities } from "PosApi/Entities"; import ko from "knockout"; /** * The controller for CustomerDetailsCustomControl. */ export default class CustomerDetailsCustomControl extends CartViewCustomControlBase { public readonly isCustomerSelected: ko.Computed<boolean>; public readonly accountHolder: ko.Computed<string>; public readonly accountNumber: ko.Computed<string>; public readonly phone: ko.Computed<string>; public readonly email: ko.Computed<string>; public readonly accountHolderLabel: string; public readonly accountNumberLabel: string; public readonly phoneLabel: string; public readonly emailLabel: string; private static readonly TEMPLATE_ID: string = "Microsot_Pos_Extensibility_Samples_CustomerDetails"; private readonly _customer: ko.Observable<ProxyEntities.Customer>; constructor(id: string, context: ICartViewCustomControlContext) { super(id, context); this.accountHolderLabel = this.context.resources.getString("string_63"); this.accountNumberLabel = this.context.resources.getString("string_64"); this.phoneLabel = this.context.resources.getString("string_65"); this.emailLabel = this.context.resources.getString("string_66"); this._customer = ko.observable(null); this.isCustomerSelected = ko.computed(() => !ObjectExtensions.isNullOrUndefined(this._customer())); this.accountHolder = ko.computed(() => { if (this.isCustomerSelected()) { return this._customer().Name; } return StringExtensions.EMPTY; }); this.accountNumber = ko.computed(() => { if (this.isCustomerSelected()) { return this._customer().AccountNumber; } return StringExtensions.EMPTY; }); this.phone = ko.computed(() => { if (this.isCustomerSelected()) { return this._customer().Phone; } return StringExtensions.EMPTY; }); this.email = ko.computed(() => { if (this.isCustomerSelected()) { return this._customer().Email; } return StringExtensions.EMPTY; }); this.cartChangedHandler = (data: CartChangedData) => { this._customer(data.customer); }; } /** * Binds the control to the specified element. * @param {HTMLElement} element The element to which the control should be bound. */ public onReady(element: HTMLElement): void { ko.applyBindingsToNode(element, { template: { name: CustomerDetailsCustomControl.TEMPLATE_ID, data: this } }); } /** * Initializes the control. * @param {ICartViewCustomControlState} state The initial state of the page used to initialize the control. */ public init(state: ICartViewCustomControlState): void { this._customer(state.customer); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart/LineDetailsCustomControl.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { CartViewCustomControlBase, ICartViewCustomControlState, ICartViewCustomControlContext, CartLineSelectedData } from "PosApi/Extend/Views/CartView"; import { ObjectExtensions, StringExtensions, ArrayExtensions } from "PosApi/TypeExtensions"; import { ProxyEntities } from "PosApi/Entities"; import ko from "knockout"; /** * The controller for LineDetailsCustomControl. */ export default class LineDetailsCustomControl extends CartViewCustomControlBase { public readonly cartLineItemId: ko.Computed<string>; public readonly cartLineDescription: ko.Computed<string>; public readonly isCartLineSelected: ko.Computed<boolean>; private static readonly TEMPLATE_ID: string = "Microsoft_Pos_Extensibility_Samples_LineDetails"; private readonly _cartLine: ko.Observable<ProxyEntities.CartLine>; private _state: ICartViewCustomControlState; constructor(id: string, context: ICartViewCustomControlContext) { super(id, context); this._cartLine = ko.observable(null); this.cartLineItemId = ko.computed(() => { let cartLine: ProxyEntities.CartLine = this._cartLine(); if (!ObjectExtensions.isNullOrUndefined(cartLine)) { return cartLine.ItemId; } return StringExtensions.EMPTY; }); this.cartLineDescription = ko.computed(() => { let cartLine: ProxyEntities.CartLine = this._cartLine(); if (!ObjectExtensions.isNullOrUndefined(cartLine)) { return cartLine.Description; } return StringExtensions.EMPTY; }); this.isCartLineSelected = ko.computed(() => !ObjectExtensions.isNullOrUndefined(this._cartLine())); this.cartLineSelectedHandler = (data: CartLineSelectedData) => { if (ArrayExtensions.hasElements(data.cartLines)) { this._cartLine(data.cartLines[0]); } }; this.cartLineSelectionClearedHandler = () => { this._cartLine(null); }; } /** * Binds the control to the specified element. * @param {HTMLElement} element The element to which the control should be bound. */ public onReady(element: HTMLElement): void { ko.applyBindingsToNode(element, { template: { name: LineDetailsCustomControl.TEMPLATE_ID, data: this } }); } /** * Initializes the control. * @param {ICartViewCustomControlState} state The initial state of the page used to initialize the control. */ public init(state: ICartViewCustomControlState): void { this._state = state; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart/PaymentsGrid/CustomColumn1Configuration.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ICustomPaymentsGridColumnContext, CustomPaymentsGridColumnBase } from "PosApi/Extend/Views/CartView"; import { CustomGridColumnAlignment } from "PosApi/Extend/Views/CustomGridColumns"; import { ProxyEntities } from "PosApi/Entities"; /** * HOW TO ENABLE THIS SAMPLE * * 1) In HQ, go to Retail > Channel setup > POS > Screen layouts * 2) Filter results to "Fabrikam Manager" * 3) Under Layout sizes, select the resolution of your MPOS, and click on Layout designer * 4) Download, run and sign in to the designer. * 5) Right click on Payment, and click on customize. * 6) Find CUSTOM COLUMN 1 in Available columns and move it to Selected columns. * 7) Click OK and close the designer. * 8) Back in HQ, Go to Retail > Retail IT > Distribution schedule. * 9) Select job "9999" and click on Run now. */ export default class PaymentsCustomGridColumn1 extends CustomPaymentsGridColumnBase { /** * Creates a new instance of the PaymentsCustomGridColumn1 class. * @param {ICustomPaymentsGridColumnContext} context The extension context. */ constructor(context: ICustomPaymentsGridColumnContext) { super(context); } /** * Gets the custom column title. * @return {string} The column title. */ public title(): string { return this.context.resources.getString("string_70"); // Line number } /** * The custom column cell compute value. * @param {ProxyEntities.TenderLine} data The input data. * @return {string} The cell value. */ public computeValue(tenderLine: ProxyEntities.TenderLine): string { return tenderLine.LineNumber.toString(); } /** * Gets the custom column alignment. * @return {CustomGridColumnAlignment} The alignment. */ public alignment(): CustomGridColumnAlignment { return CustomGridColumnAlignment.Right; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart/IncomeExpenseGrid/IncomeExpenseLineSubfield.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ICustomLinesGridIncomeExpenseSubfieldContext, CustomLinesGridIncomeExpenseSubfieldBase } from "PosApi/Extend/Views/CartView"; import { ProxyEntities } from "PosApi/Entities"; import { ObjectExtensions, StringExtensions } from "PosApi/TypeExtensions"; export default class IncomeExpenseLineSubfield extends CustomLinesGridIncomeExpenseSubfieldBase { constructor(context: ICustomLinesGridIncomeExpenseSubfieldContext) { super(context); } /** * Computes a value to display as an item subfield based on the given encome/expense line. * @param {ProxyEntities.IncomeExpenseLine} cartLine The income/expense line. * @returns {string} The computed value do display as a subfield. */ public computeValue(incomeExpenseLine: ProxyEntities.IncomeExpenseLine): string { let value: string = null; if (!ObjectExtensions.isNullOrUndefined(incomeExpenseLine) && Math.abs(incomeExpenseLine.Amount) > 1000) { value = StringExtensions.format("The amount is greater then 1000. Please check the amount.", incomeExpenseLine.IncomeExpenseAccount); } return value; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart/LinesGrid/CustomColumn5Configuration.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ICustomLinesGridColumnContext, CustomLinesGridColumnBase } from "PosApi/Extend/Views/CartView"; import { CustomGridColumnAlignment } from "PosApi/Extend/Views/CustomGridColumns"; import { ProxyEntities } from "PosApi/Entities"; /** * HOW TO ENABLE THIS SAMPLE * * 1) In HQ, go to Retail > Channel setup > POS > Screen layouts * 2) Filter results to "Fabrikam Manager" * 3) Under Layout sizes, select the resolution of your MPOS, and click on Layout designer * 4) Download, run and sign in to the designer. * 5) Right click on Lines, and click on customize. * 6) Find CUSTOM COLUMN 5 in Available columns and move it to Selected columns. * 7) Click OK and close the designer. * 8) Back in HQ, Go to Retail > Retail IT > Distribution schedule. * 9) Select job "9999" and click on Run now. */ export default class LinesCustomGridColumn5 extends CustomLinesGridColumnBase { constructor(context: ICustomLinesGridColumnContext) { super(context); } /** * Gets the column title. * @returns {string} The column title. */ public title(): string { return this.context.resources.getString("string_74"); } /** * Computes the value to display in the column. * @param cartLine The cart line. * @returns {string} The value to display in the column. */ public computeValue(cartLine: ProxyEntities.CartLine): string { return cartLine.Comment; } /** * Gets the alignment of the column. * @returns {CustomGridColumnAlignment} The alignment. */ public alignment(): CustomGridColumnAlignment { return CustomGridColumnAlignment.Left; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart/LinesGrid/SubscribeAndSaveItemSubfield.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ICustomLinesGridItemSubfieldContext, CustomLinesGridItemSubfieldBase } from "PosApi/Extend/Views/CartView"; import { CurrencyFormatter } from "PosApi/Consume/Formatters"; import { ProxyEntities } from "PosApi/Entities"; import { ObjectExtensions, StringExtensions } from "PosApi/TypeExtensions"; export default class SubscribeAndSaveItemSubfield extends CustomLinesGridItemSubfieldBase { constructor(context: ICustomLinesGridItemSubfieldContext) { super(context); } /** * Computes a value to display as an item subfield based on the given cart line. * @param {ProxyEntities.CartLine} cartLine The cart line. * @returns {string} The computed value do display as an item subfield. */ public computeValue(cartLine: ProxyEntities.CartLine): string { let value: string = StringExtensions.EMPTY; if (this._isSubscribeAndSaveCartLine(cartLine)) { value = StringExtensions.format("Subscribe and save: {0} each month", CurrencyFormatter.toCurrency(cartLine.NetAmountWithoutTax * .95)); } return value; } /** * Returns whether or not the given cart line is for an item that supports subscribing and saving. * @param {ProxyEntities.CartLine} cartLine The cart line. * @returns {boolean} Whether or not the given cart line is for an item that supports subscribing and saving. */ private _isSubscribeAndSaveCartLine(cartLine: ProxyEntities.CartLine): boolean { return !ObjectExtensions.isNullOrUndefined(cartLine) && cartLine.ItemId === "0006"; // Inner Tube Patches. } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart/LinesGrid/CustomColumn4Configuration.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ICustomLinesGridColumnContext, CustomLinesGridColumnBase } from "PosApi/Extend/Views/CartView"; import { CustomGridColumnAlignment } from "PosApi/Extend/Views/CustomGridColumns"; import { ProxyEntities } from "PosApi/Entities"; import { BooleanFormatter } from "PosApi/Consume/Formatters"; /** * HOW TO ENABLE THIS SAMPLE * * 1) In HQ, go to Retail > Channel setup > POS > Screen layouts * 2) Filter results to "Fabrikam Manager" * 3) Under Layout sizes, select the resolution of your MPOS, and click on Layout designer * 4) Download, run and sign in to the designer. * 5) Right click on Lines, and click on customize. * 6) Find CUSTOM COLUMN 4 in Available columns and move it to Selected columns. * 7) Click OK and close the designer. * 8) Back in HQ, Go to Retail > Retail IT > Distribution schedule. * 9) Select job "9999" and click on Run now. */ export default class LinesCustomGridColumn4 extends CustomLinesGridColumnBase { constructor(context: ICustomLinesGridColumnContext) { super(context); } /** * Gets the column title. * @returns {string} The column title. */ public title(): string { return this.context.resources.getString("string_73"); } /** * Computes the value to display in the column. * @param cartLine The cart line. * @returns {string} The value to display in the column. */ public computeValue(cartLine: ProxyEntities.CartLine): string { return BooleanFormatter.toYesNo(cartLine.IsVoided); } /** * Gets the alignment of the column. * @returns {CustomGridColumnAlignment} The alignment. */ public alignment(): CustomGridColumnAlignment { return CustomGridColumnAlignment.Left; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart/LinesGrid/CustomColumn3Configuration.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ICustomLinesGridColumnContext, CustomLinesGridColumnBase } from "PosApi/Extend/Views/CartView"; import { CustomGridColumnAlignment } from "PosApi/Extend/Views/CustomGridColumns"; import { ProxyEntities } from "PosApi/Entities"; /** * HOW TO ENABLE THIS SAMPLE * * 1) In HQ, go to Retail > Channel setup > POS > Screen layouts * 2) Filter results to "Fabrikam Manager" * 3) Under Layout sizes, select the resolution of your MPOS, and click on Layout designer * 4) Download, run and sign in to the designer. * 5) Right click on Lines, and click on customize. * 6) Find CUSTOM COLUMN 3 in Available columns and move it to Selected columns. * 7) Click OK and close the designer. * 8) Back in HQ, Go to Retail > Retail IT > Distribution schedule. * 9) Select job "9999" and click on Run now. */ export default class LinesCustomGridColumn3 extends CustomLinesGridColumnBase { constructor(context: ICustomLinesGridColumnContext) { super(context); } /** * Gets the column title. * @returns {string} The column title. */ public title(): string { return this.context.resources.getString("string_72"); } /** * Computes the value to display in the column. * @param cartLine The cart line. * @returns {string} The value to display in the column. */ public computeValue(cartLine: ProxyEntities.CartLine): string { return cartLine.ProductId.toString(); } /** * Gets the alignment of the column. * @returns {CustomGridColumnAlignment} The alignment. */ public alignment(): CustomGridColumnAlignment { return CustomGridColumnAlignment.Left; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart/LinesGrid/CustomColumn2Configuration.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ICustomLinesGridColumnContext, CustomLinesGridColumnBase } from "PosApi/Extend/Views/CartView"; import { CustomGridColumnAlignment } from "PosApi/Extend/Views/CustomGridColumns"; import { ProxyEntities } from "PosApi/Entities"; /** * HOW TO ENABLE THIS SAMPLE * * 1) In HQ, go to Retail > Channel setup > POS > Screen layouts * 2) Filter results to "Fabrikam Manager" * 3) Under Layout sizes, select the resolution of your MPOS, and click on Layout designer * 4) Download, run and sign in to the designer. * 5) Right click on Lines, and click on customize. * 6) Find CUSTOM COLUMN 2 in Available columns and move it to Selected columns. * 7) Click OK and close the designer. * 8) Back in HQ, Go to Retail > Retail IT > Distribution schedule. * 9) Select job "9999" and click on Run now. */ export default class LinesCustomGridColumn2 extends CustomLinesGridColumnBase { constructor(context: ICustomLinesGridColumnContext) { super(context); } /** * Gets the column title. * @returns {string} The column title. */ public title(): string { return this.context.resources.getString("string_71"); } /** * Computes the value to display in the column. * @param cartLine The cart line. * @returns {string} The value to display in the column. */ public computeValue(cartLine: ProxyEntities.CartLine): string { return cartLine.ItemId; } /** * Gets the alignment of the column. * @returns {CustomGridColumnAlignment} The alignment. */ public alignment(): CustomGridColumnAlignment { return CustomGridColumnAlignment.Right; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart/LinesGrid/FraudCheckReminderItemSubfield.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ICustomLinesGridItemSubfieldContext, CustomLinesGridItemSubfieldBase } from "PosApi/Extend/Views/CartView"; import { ProxyEntities } from "PosApi/Entities"; import { ObjectExtensions, StringExtensions } from "PosApi/TypeExtensions"; export default class FraudCheckReminderItemSubfield extends CustomLinesGridItemSubfieldBase { constructor(context: ICustomLinesGridItemSubfieldContext) { super(context); } /** * Computes a value to display as an item subfield based on the given cart line. * @param {ProxyEntities.CartLine} cartLine The cart line. * @returns {string} The computed value do display as an item subfield. */ public computeValue(cartLine: ProxyEntities.CartLine): string { let value: string = StringExtensions.EMPTY; if (!ObjectExtensions.isNullOrUndefined(cartLine) && cartLine.TotalAmount > 100) { value = "Please check the purchasers I.D. in order to prevent fraud."; } return value; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart/LinesGrid/CustomColumn1Configuration.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ICustomLinesGridColumnContext, CustomLinesGridColumnBase } from "PosApi/Extend/Views/CartView"; import { CustomGridColumnAlignment } from "PosApi/Extend/Views/CustomGridColumns"; import { ProxyEntities } from "PosApi/Entities"; /** * HOW TO ENABLE THIS SAMPLE * * 1) In HQ, go to Retail > Channel setup > POS > Screen layouts * 2) Filter results to "Fabrikam Manager" * 3) Under Layout sizes, select the resolution of your MPOS, and click on Layout designer * 4) Download, run and sign in to the designer. * 5) Right click on Lines, and click on customize. * 6) Find CUSTOM COLUMN 1 in Available columns and move it to Selected columns. * 7) Click OK and close the designer. * 8) Back in HQ, Go to Retail > Retail IT > Distribution schedule. * 9) Select job "9999" and click on Run now. */ export default class LinesCustomGridColumn1 extends CustomLinesGridColumnBase { constructor(context: ICustomLinesGridColumnContext) { super(context); } /** * Gets the column title. * @returns {string} The column title. */ public title(): string { return this.context.resources.getString("string_70"); } /** * Computes the value to display in the column. * @param cartLine The cart line. * @returns {string} The value to display in the column. */ public computeValue(cartLine: ProxyEntities.CartLine): string { return cartLine.LineNumber.toString(); } /** * Gets the alignment of the column. * @returns {CustomGridColumnAlignment} The alignment. */ public alignment(): CustomGridColumnAlignment { return CustomGridColumnAlignment.Right; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Cart/DeliveryGrid/CustomColumn1Configuration.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ICustomDeliveryGridColumnContext, CustomDeliveryGridColumnBase } from "PosApi/Extend/Views/CartView"; import { CustomGridColumnAlignment } from "PosApi/Extend/Views/CustomGridColumns"; import { ProxyEntities } from "PosApi/Entities"; /** * HOW TO ENABLE THIS SAMPLE * * 1) In HQ, go to Retail > Channel setup > POS > Screen layouts * 2) Filter results to "Fabrikam Manager" * 3) Under Layout sizes, select the resolution of your MPOS, and click on Layout designer * 4) Download, run and sign in to the designer. * 5) Right click on Delivery, and click on customize. * 6) Find CUSTOM COLUMN 1 in Available columns and move it to Selected columns. * 7) Click OK and close the designer. * 8) Back in HQ, Go to Retail > Retail IT > Distribution schedule. * 9) Select job "9999" and click on Run now. */ export default class DeliveryCustomGridColumn1 extends CustomDeliveryGridColumnBase { /** * Creates a new instance of the DeliveryCustomGridColumn1 class. * @param {ICustomDeliveryGridColumnContext} context The extension context. */ constructor(context: ICustomDeliveryGridColumnContext) { super(context); } /** * Gets the custom column title. * @return {string} The column title. */ public title(): string { return this.context.resources.getString("string_70"); // Line number } /** * The custom column cell compute value. * @param {ProxyEntities.CartLine} tenderLine The tender line. * @return {string} The cell value. */ public computeValue(tenderLine: ProxyEntities.CartLine): string { return tenderLine.LineNumber.toString(); } /** * Gets the custom column alignment. * @return {CustomGridColumnAlignment} The alignment. */ public alignment(): CustomGridColumnAlignment { return CustomGridColumnAlignment.Right; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/ManageShifts/ManageShiftsCommand.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as ManageShiftsView from "PosApi/Extend/Views/ManageShiftsView"; import { ProxyEntities } from "PosApi/Entities"; import { IExtensionCommandContext } from "PosApi/Extend/Views/AppBarCommands"; import MessageDialog from "../../../Create/Dialogs/DialogSample/MessageDialog"; export default class ManageShiftsCommand extends ManageShiftsView.ManageShiftsExtensionCommandBase { private _nonClosedShifts: ProxyEntities.Shift[]; private _selectedShift: ProxyEntities.Shift; /** * Creates a new instance of the ManageShiftsCommand class. * @param {IExtensionCommandContext<ManageShiftsView.IManageShiftsToExtensionCommandMessageTypeMap>} context The context. * @remarks The command context contains APIs through which a command can communicate with POS. */ constructor(context: IExtensionCommandContext<ManageShiftsView.IManageShiftsToExtensionCommandMessageTypeMap>) { super(context); this.id = "sampleManageShiftsCommand"; this.label = "Sample manage shifts command"; this.extraClass = "iconLightningBolt"; this.shiftSelectedHandler = (data: ManageShiftsView.ShiftSelectedData): void => { this.canExecute = true; this._selectedShift = data.selectedShift; }; this.shiftSelectionClearedHandler = (): void => { this.canExecute = false; }; } /** * Initializes the command. * @param {ManageShiftsView.IManageShiftsViewExtensionCommandState} state The state used to initialize the command. */ protected init(state: ManageShiftsView.IManageShiftsExtensionCommandState): void { this.isVisible = true; this._nonClosedShifts = state.nonClosedShifts; } /** * Executes the command. */ protected execute(): void { let message: string = "Shift ID: " + this._selectedShift.ShiftId + "; Non closed shifts: " + this._nonClosedShifts.length; // Retrieves the shifts from the server and reload them on the screen (The shift selection is cleared). this.refreshShifts(); MessageDialog.show(this.context, message.toString()); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Payment/PaymentViewCommand.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as PaymentView from "PosApi/Extend/Views/PaymentView"; import { IExtensionCommandContext } from "PosApi/Extend/Views/AppBarCommands"; import MessageDialog from "../../../Create/Dialogs/DialogSample/MessageDialog"; export default class PaymentViewCommand extends PaymentView.PaymentViewExtensionCommandBase { private _paymentCard: Commerce.Proxy.Entities.PaymentCard; private _tenderType: Commerce.Proxy.Entities.TenderType; private _fullAmount: number; private _currency: Commerce.Proxy.Entities.Currency; private _paymentAmount: string; /** * Creates a new instance of the ButtonCommand class. * @param {IExtensionCommandContext<PaymentView.IPaymentToExtensionCommandMessageTypeMap>} context The command context. * @remarks The command context contains APIs through which a command can communicate with POS. */ constructor(context: IExtensionCommandContext<PaymentView.IPaymentViewToExtensionCommandMessageTypeMap>) { super(context); this.label = "Payment Command"; this.id = "PaymentCommand"; this.extraClass = "iconLightningBolt"; } /** * Initializes the command. * @param {PaymentView.IPaymentViewExtensionCommandState} state The state used to initialize the command. */ protected init(state: PaymentView.IPaymentViewExtensionCommandState): void { this._paymentCard = null; this._tenderType = state.tenderType; this._fullAmount = state.fullAmount; this._currency = state.currency; // Only allow button if it is for credit cards. if (state.tenderType.OperationId === Commerce.Proxy.Entities.RetailOperation.PayCard) { this.isVisible = true; this.canExecute = true; this.paymentViewPaymentCardChangedHandler = (data: PaymentView.PaymentViewPaymentCardChanged): void => { this._paymentCard = data.paymentCard; this.context.logger.logInformational("Payment View Command - Payment card changed"); }; this.paymentViewAmountChangedHandler = (data: PaymentView.PaymentViewAmountChanged): void => { this._paymentAmount = data.paymentAmount; this.context.logger.logInformational("Payment View Command - Amount changed"); }; } else { this.isVisible = false; this.canExecute = false; } } /** * Executes the command. */ protected execute(): void { MessageDialog.show(this.context, "Payment View Command - Execute"); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/InventoryLookupMatrix/MoreDetailsMenuCommand.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { InventoryLookupMatrixExtensionMenuCommandBase, IInventoryLookupMatrixExtensionMenuCommandState, IInventoryLookupMatrixExtensionMenuCommandContext, InventoryLookupMatrixItemAvailabilitySelectedData, InventoryLookupMatrixStoreChangedData } from "PosApi/Extend/Views/InventoryLookupMatrixView"; import { ProxyEntities } from "PosApi/Entities"; import { IMessageDialogOptions, ShowMessageDialogClientRequest, ShowMessageDialogClientResponse } from "PosApi/Consume/Dialogs"; /** * A sample extension menu command for the the InventoryLookupMatrixView that shows additional information about the selected item availability. */ export default class MoreDetailsMenuCommand extends InventoryLookupMatrixExtensionMenuCommandBase { public readonly label: string; public readonly id: string; private _selectedAvailability: ProxyEntities.ItemAvailability; private _store: ProxyEntities.OrgUnit; /** * Creates a new instance of the MoreDetailsMenuCommand class. * @param {IInventoryLookupMatrixExtensionCommandContext} context The extension context. */ constructor(context: IInventoryLookupMatrixExtensionMenuCommandContext) { super(context); // Initialize the label that represents the command in the POS menu. this.label = "More details"; // Initialize the menu command identifier. This is used as the command's element id. this.id = "moreDetailsMenuCommand"; // Add a handler for the ItemAvailabilitySelected message in order to be notified when the user selects an item availability. this.itemAvailabilitySelectedHandler = (data: InventoryLookupMatrixItemAvailabilitySelectedData): void => { this._selectedAvailability = data.itemAvailability; this.canExecute = !this.canExecute; }; // Add a handler for the StoreChanged message in order to be notified when the store context is changed. this.storeChangedHandler = (data: InventoryLookupMatrixStoreChangedData): void => { this._store = data.store; }; } /** * Initializes the menu command state with the initial state of the InventoryLookupMatrix page. * @param {IInventoryLookupMatrixExtensionMenuCommandState} state The initial state. */ protected init(state: IInventoryLookupMatrixExtensionMenuCommandState): void { this.context.logger.logInformational("MoreDetailsMenuCommand.init was called."); this._store = state.store; } /** * Executes the menu command logic. * @remarks This is the function that gets executed when the user clicks the menu command. */ protected execute(): void { const CORRELATION_ID: string = this.context.logger.getNewCorrelationId(); this.context.logger.logInformational("MoreDetailsMenuCommand.execute was called.", CORRELATION_ID); // Set isProcessing to true to notify POS that the command execution is processing. this.isProcessing = true; let options: IMessageDialogOptions = { title: "More details", subTitle: "Item availability details", message: JSON.stringify(this._selectedAvailability), button1: { id: "OKButtonId", label: "OK", isPrimary: true, result: "OKButtonResult" } }; let request: ShowMessageDialogClientRequest<ShowMessageDialogClientResponse> = new ShowMessageDialogClientRequest(options, CORRELATION_ID); this.context.runtime.executeAsync(request).then((result): void => { // Set isProcessing to false to notify POS that the command execution has completed. this.isProcessing = false; this.context.logger.logInformational("MoreDetailsMenuCommand.execute show message dialog request completed successfully.", CORRELATION_ID); }).catch((reason: any): void => { // Set isProcessing to false to notify POS that the command execution has completed. this.isProcessing = false; this.context.logger.logError("MoreDetailsMenuCommand.execute show message dialog request execution failed.", CORRELATION_ID); }); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/ResumeCart/ResumeCartListColumns.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ISuspendedCartsListColumn } from "PosApi/Extend/Views/ResumeCartView"; import { ICustomColumnsContext } from "PosApi/Extend/Views/CustomListColumns"; import { ClientEntities } from "PosApi/Entities"; import { DateFormatter, CurrencyFormatter } from "PosApi/Consume/Formatters"; import { ObjectExtensions, StringExtensions } from "PosApi/TypeExtensions"; export default (context: ICustomColumnsContext): ISuspendedCartsListColumn[] => { return [ { title: "DATE", computeValue: (row: ClientEntities.ISuspendedCart): string => { return DateFormatter.toShortDateAndTime(row.cart.ModifiedDateTime); }, ratio: 40, collapseOrder: 2, minWidth: 200 }, { title: "CUSTOMER NAME", computeValue: (row: ClientEntities.ISuspendedCart): string => { return !ObjectExtensions.isNullOrUndefined(row.customer) ? row.customer.Name : StringExtensions.EMPTY; }, ratio: 30, collapseOrder: 1, minWidth: 100 }, { title: "TOTAL", computeValue: (row: ClientEntities.ISuspendedCart): string => { return CurrencyFormatter.toCurrency(row.cart.TotalAmount); }, ratio: 30, collapseOrder: 3, minWidth: 100 } ]; };
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/HealthCheck/CustomHealthCheck.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ICustomHealthCheckContext, IHealthCheckSetupDetail, CustomHealthCheckBase } from "PosApi/Extend/Views/HealthCheckView"; import { ClientEntities } from "PosApi/Entities"; /** * The custom health check class. */ export default class CustomHealthCheck extends CustomHealthCheckBase { private _lastStatus: ClientEntities.IHealthCheckStatus; /** * Creates a new instance of the class. * @param {ICustomHealthCheckContext} context The extension context. */ constructor(context: ICustomHealthCheckContext) { // Health check name and type that is shown on HealthCheckView grid. let healthCheckName: string = "Custom Health Check Name"; let healthCheckType: string = "Custom Health Check Type"; // This is the configuration that is shown on HealthCheckView "About" section of this health check entity. let healthCheckConfiguration: IHealthCheckSetupDetail[] = [ { label: "Device Type", value: "Printer" }, { label: "API Name", value: "External" }, { label: "API Version", value: "1.0" } ]; super(context, healthCheckName, healthCheckType, healthCheckConfiguration); this._lastStatus = null; } /** * Executes the health check test. * @returns {Promise<ClientEntities.IHealthCheckStatus>} The promise containing the health check status. */ public executeHealthCheckAsync(): Promise<ClientEntities.IHealthCheckStatus> { // Add implementation that gets status of this health check entity. let status: ClientEntities.IHealthCheckStatus = { healthCheckState: ClientEntities.HealthCheckStatusEnum.Succeeded, result: null, timestamp: new Date() }; this._lastStatus = status; return Promise.resolve(status); } /** * Get last run health check status. * @return {ClientEntities.IHealthCheckStatus} Returns health check status. */ public getLastStatus(): ClientEntities.IHealthCheckStatus { return this._lastStatus; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/PickingAndReceivingDetails/PickingAndReceivingDetailsCmd.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ClientEntities } from "PosApi/Entities"; import { ProxyEntities } from "PosApi/Entities"; import { IExtensionCommandContext } from "PosApi/Extend/Views/AppBarCommands"; import * as PickingAndReceivingDetailsView from "PosApi/Extend/Views/PickingAndReceivingDetailsView"; import MessageDialog from "../../../Create/Dialogs/DialogSample/MessageDialog"; export default class PickingAndReceivingDetailsViewCommand extends PickingAndReceivingDetailsView.PickingAndReceivingDetailsExtensionCommandBase { private _selectedJournalLine: ClientEntities.IPickingAndReceivingOrderLine; private _journalLines: ClientEntities.IPickingAndReceivingOrderLine[]; private _journal: ClientEntities.IPickingAndReceivingOrder; private _receipt: ProxyEntities.Receipt; /** * Creates a new instance of the PickingAndReceivingDetailsViewCommand class. * @param {IExtensionCommandContext<PickingAndReceivingDetailsView.IPickingAndReceivingDetailsToExtensionCommandMessageTypeMap>} context The context. * @remarks The command context contains APIs through which a command can communicate with POS. */ constructor(context: IExtensionCommandContext<PickingAndReceivingDetailsView.IPickingAndReceivingDetailsToExtensionCommandMessageTypeMap>) { super(context); this.id = "samplePickingAndReceivingDetailsCommand"; this.label = "Sample picking and receiving details command"; this.extraClass = "iconLightningBolt"; } /** * Initializes the command. * @param {PickingAndReceivingDetailsView.IPickingAndReceivingDetailsExtensionCommandState} state The state used to initialize the command. */ protected init(state: PickingAndReceivingDetailsView.IPickingAndReceivingDetailsExtensionCommandState): void { this.isVisible = true; this._journal = state.journal; this.journalLinesChangedHandler = (data: PickingAndReceivingDetailsView.JournalLinesChangedData): void => { this._journalLines = data.journalLines; }; this.journalSavedHandler = (data: PickingAndReceivingDetailsView.JournalSavedData): void => { this._journal = data.journal; }; this.journalLineSelectedHandler = (data: PickingAndReceivingDetailsView.JournalLineSelectedData): void => { this.canExecute = true; this._selectedJournalLine = data.journalLine; }; this.journalLineSelectionClearedHandler = (): void => { this.canExecute = false; this._selectedJournalLine = null; }; this.receiptSelectionHandler = (data: PickingAndReceivingDetailsView.PickingAndReceivingDetailsReceiptSelectedData): void => { this.isVisible = false; this._receipt = data.receipt; }; this.receiptSelectionClearedHandler = (): void => { this.isVisible = true; }; } /** * Executes the command. */ protected execute(): void { let message: string = this._journal.lines + " : " + this._selectedJournalLine.productNumber + " : " + this._selectedJournalLine.quantityOrdered; MessageDialog.show(this.context, message); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/PickingAndReceivingDetails/CustomOrderLinesListColumns.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { IOrderLinesListColumn } from "PosApi/Extend/Views/PickingAndReceivingDetailsView"; import { ICustomColumnsContext } from "PosApi/Extend/Views/CustomListColumns"; import { ClientEntities } from "PosApi/Entities"; export default (context: ICustomColumnsContext): IOrderLinesListColumn[] => { return [ { title: "PRODUCT NUMBER", computeValue: (row: ClientEntities.IPickingAndReceivingOrderLine): string => { return row.productNumber; }, ratio: 40, collapseOrder: 3, minWidth: 100 }, { title: "QUANTITY ORDERED", computeValue: (row: ClientEntities.IPickingAndReceivingOrderLine): string => { return row.quantityOrdered.toString(); }, ratio: 30, collapseOrder: 2, minWidth: 100 }, { title: "UNIT OF MEASURE", computeValue: (row: ClientEntities.IPickingAndReceivingOrderLine): string => { return row.unitOfMeasure; }, ratio: 30, collapseOrder: 1, minWidth: 100 } ]; };
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/ReturnTransaction/ReturnTransactionCommand.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as ReturnTransactionView from "PosApi/Extend/Views/ReturnTransactionView"; import { IExtensionCommandContext } from "PosApi/Extend/Views/AppBarCommands"; import { ProxyEntities } from "PosApi/Entities"; import { StringExtensions, ObjectExtensions } from "PosApi/TypeExtensions"; import MessageDialog from "../../../Create/Dialogs/DialogSample/MessageDialog"; export default class ReturnTransactionCommand extends ReturnTransactionView.ReturnTransactionExtensionCommandBase { private _salesLines: ProxyEntities.SalesLine[] = []; private _receiptNumber: string = StringExtensions.EMPTY; private _salesOrder: ProxyEntities.SalesOrder = null; /** * Creates a new instance of the ReturnTransactionCommand class. * @param {IExtensionCommandContext<ReturnTransactionView.IReturnTransactionToExtensionCommandMessageTypeMap>} context The context. * @remarks The command context contains APIs through which a command can communicate with POS. */ constructor(context: IExtensionCommandContext<ReturnTransactionView.IReturnTransactionToExtensionCommandMessageTypeMap>) { super(context); this.id = "sampleReturnTransactionCommand"; this.label = "Sample return transaction command"; this.extraClass = "iconLightningBolt"; } /** * Initializes the command. * @param {ReturnTransactionView.IReturnTransactionExtensionCommandState} state The state used to initialize the command. */ protected init(state: ReturnTransactionView.IReturnTransactionExtensionCommandState): void { this.isVisible = true; this.canExecute = true; this._receiptNumber = state.receiptNumber; this._salesOrder = state.salesOrder; this.transactionLineSelectedHandler = (data: ReturnTransactionView.ReturnTransactionTransactionLineSelectedData): void => { this._salesLines = data.salesLines; }; this.transactionLineSelectionClearedHandler = () => { this._salesLines = []; }; this.transactionSelectedHandler = (data: ReturnTransactionView.ReturnTransactionTransactionSelectedData): void => { this._salesOrder = data.salesOrder; }; this.transactionSelectionClearedHandler = () => { this._salesOrder = null; }; } /** * Executes the command. */ protected execute(): void { let salesOrderId: string = !ObjectExtensions.isNullOrUndefined(this._salesOrder) ? this._salesOrder.Id : StringExtensions.EMPTY; let message: string = `Receipt number: ${this._receiptNumber}; Selected sales order: ${salesOrderId}; Return transaction selected data:` + this._salesLines.map((value: ProxyEntities.SalesLine) => { return ` ItemId: ${value.ItemId}`; }); MessageDialog.show(this.context, message); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/ReturnTransaction
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/ReturnTransaction/LinesGrid/FraudCheckReminderItemSubfield.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ICustomSalesOrderLinesGridItemSubfieldContext, CustomSalesOrderLinesGridItemSubfieldBase } from "PosApi/Extend/Views/ReturnTransactionView"; import { ProxyEntities } from "PosApi/Entities"; import { ObjectExtensions, StringExtensions } from "PosApi/TypeExtensions"; /** * This class extends the base one to issue a fraud check warning in case the total value of the purchase is above $100.00. */ export default class FraudCheckReminderItemSubfield extends CustomSalesOrderLinesGridItemSubfieldBase { /** * Creates a new instance of the FraudCheckReminderItemSubfield class. * @param {ICustomSalesOrderLinesGridItemSubfieldContext} context The events Handler context. * @remarks The events handler context contains APIs through which a handler can communicate with POS. */ constructor(context: ICustomSalesOrderLinesGridItemSubfieldContext) { super(context); } /** * Computes a value to display as an item subfield based on the given sales line. * @param {ClientEntities.ISalesLineForDisplay} salesLine The sales line. * @returns {string} The computed value do display as an item subfield. */ public computeValue(salesLine: ProxyEntities.SalesLine): string { let value: string = StringExtensions.EMPTY; if (!ObjectExtensions.isNullOrUndefined(salesLine) && salesLine.TotalAmount > 100) { value = "Please check the purchasers I.D. in order to prevent fraud."; } return value; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/AddressAddEdit/AddressAddEditCustomFieldsSection.html
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title></title> </head> <body> <!-- Note: The element id is different than the id generated by the POS extensibility framework. This 'template' id is not used by the POS extensibility framework. --> <script id="Microsoft_Pos_Extensibility_Samples_AddressAddEditCustomFieldsSection" type="text/html"> <div class="marginTop24"> <h2 class="marginTop8 marginBottom8">Additional information</h2> <div class="height52 marginBottom20"> <label for="notesInput">Notes</label> <input type="text" id="notesInput" data-bind="value: notes, valueUpdate: 'afterkeydown'" /> </div> <div class="height52 marginBottom20"> <label for="isResidentialAddressToggle">Residential address</label> <div id="isResidentialAddressToggle"/> </div> </div> </script> </body> </html>
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/AddressAddEdit/GetExternalAddressCommand.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as AddressAddEditView from "PosApi/Extend/Views/AddressAddEditView"; import { ProxyEntities, ClientEntities } from "PosApi/Entities"; import { IAlphanumericInputDialogOptions, ShowAlphanumericInputDialogClientResponse, ShowAlphanumericInputDialogClientRequest } from "PosApi/Consume/Dialogs"; import { IExtensionCommandContext } from "PosApi/Extend/Views/AppBarCommands"; /** * This class extends the base one to include an additional button in the app bar. * The button populates the address' fields with a specific value depending on user's input. */ export default class GetExternalAddressCommand extends AddressAddEditView.AddressAddEditExtensionCommandBase { /** * Creates a new instance of the GetExternalAddressCommand class. * @param {IExtensionCommandContext<AddressAddEditView.IAddressAddEditToExtensionCommandMessageTypeMap>} context The command context. * @remarks The command context contains APIs through which a command can communicate with POS. */ constructor(context: IExtensionCommandContext<AddressAddEditView.IAddressAddEditToExtensionCommandMessageTypeMap>) { super(context); this.id = "getExternalAddressCommand"; this.label = "Get Address"; this.extraClass = "iconLightningBolt"; } /** * Initializes the command. * @param {ProductDetailsView.IProductDetailsExtensionCommandState} state The state used to initialize the command. */ protected init(state: AddressAddEditView.IAddressAddEditExtensionCommandState): void { this.canExecute = true; this.isVisible = true; } /** * Executes the command. */ protected execute(): void { let inputAlphanumericDialogOptions: IAlphanumericInputDialogOptions = { title: "External System", numPadLabel: "Please enter code:" }; let dialogRequest: ShowAlphanumericInputDialogClientRequest<ShowAlphanumericInputDialogClientResponse> = new ShowAlphanumericInputDialogClientRequest<ShowAlphanumericInputDialogClientResponse>(inputAlphanumericDialogOptions); this.context.runtime.executeAsync(dialogRequest) .then((dialogResponse: ClientEntities.ICancelableDataResult<ShowAlphanumericInputDialogClientResponse>) => { if (!dialogResponse.canceled) { let address: ProxyEntities.Address = new ProxyEntities.AddressClass(); if (dialogResponse.data.result.value === "1") { address.AddressTypeValue = ClientEntities.ExtensibleAddressType.Business.Value; address.City = "Redmond"; address.IsPrimary = true; address.Name = "Contoso Consulting USA"; address.State = "WA"; address.StateName = "Washington"; address.Street = "454 1st Street\nSuite 99"; address.ThreeLetterISORegionName = "USA"; address.ZipCode = "98052"; } else { address.AddressTypeValue = ClientEntities.ExtensibleAddressType.Home.Value; address.City = "Redmond"; address.IsPrimary = true; address.Name = "Town house"; address.State = "WA"; address.StateName = "Washington"; address.Street = "One microsoft way"; address.ThreeLetterISORegionName = "USA"; address.ZipCode = "98052"; } this.address = address; } }); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/AddressAddEdit/AddressAddEditCustomFieldsSection.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { AddressAddEditCustomControlBase, IAddressAddEditCustomControlState, IAddressAddEditCustomControlContext } from "PosApi/Extend/Views/AddressAddEditView"; import { ProxyEntities } from "PosApi/Entities"; import { ObjectExtensions } from "PosApi/TypeExtensions"; import * as Controls from "PosApi/Consume/Controls"; import ko from "knockout"; /** * This is extension custom control for address add/edit view. It adds to the page 2 new fields: notes and toggle for residential address. */ export default class AddressAddEditCustomFieldsSection extends AddressAddEditCustomControlBase { public notes: ko.Observable<string>; public toggleSwitch: Controls.IToggle; private static readonly TEMPLATE_ID: string = "Microsoft_Pos_Extensibility_Samples_AddressAddEditCustomFieldsSection"; constructor(id: string, context: IAddressAddEditCustomControlContext) { super(id, context); this.notes = ko.observable(""); this.notes.subscribe((newValue: string): void => { this._addOrUpdateExtensionProperty("notes", <ProxyEntities.CommercePropertyValue>{ StringValue: newValue }); }); } /** * Binds the control to the specified element. * @param {HTMLElement} element The element to which the control should be bound. */ public onReady(element: HTMLElement): void { ko.applyBindingsToNode(element, { template: { name: AddressAddEditCustomFieldsSection.TEMPLATE_ID, data: this } }); let toggleOptions: Controls.IToggleOptions = { tabIndex: 0, enabled: true, checked: false, labelOn: "Yes", labelOff: "No", }; let toggleRootElem: HTMLDivElement = element.querySelector("#isResidentialAddressToggle") as HTMLDivElement; this.toggleSwitch = this.context.controlFactory.create(this.context.logger.getNewCorrelationId(), "Toggle", toggleOptions, toggleRootElem); this.toggleSwitch.addEventListener("CheckedChanged", (eventData: { checked: boolean }) => { this.toggleSwitchChanged(eventData.checked); }); } /** * Initializes the control. * @param {ICustomerIAddressAddEditCustomControlStateDetailCustomControlState} state The initial state of the page used to initialize the control. */ public init(state: IAddressAddEditCustomControlState): void { this.isVisible = true; } /** * Toggles Residential address property. * @param {boolean} checked Indicates if residential address is checked or not. */ public toggleSwitchChanged(checked: boolean): void { this._addOrUpdateExtensionProperty("isResidentialAddress", <ProxyEntities.CommercePropertyValue>{ BooleanValue: checked }); } /** * Gets the property value from the property bag, by its key. Optionally creates the property value on the bag, if it does not exist. */ private _addOrUpdateExtensionProperty(key: string, newValue: ProxyEntities.CommercePropertyValue): void { let address: ProxyEntities.Address = this.address; let extensionProperty: ProxyEntities.CommerceProperty = Commerce.ArrayExtensions.firstOrUndefined(address.ExtensionProperties, (property: ProxyEntities.CommerceProperty) => { return property.Key === key; }); if (ObjectExtensions.isNullOrUndefined(extensionProperty)) { let newProperty: ProxyEntities.CommerceProperty = { Key: key, Value: newValue }; if (ObjectExtensions.isNullOrUndefined(address.ExtensionProperties)) { address.ExtensionProperties = []; } address.ExtensionProperties.push(newProperty); } else { extensionProperty.Value = newValue; } this.address = address; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/InventoryLookup/DownloadDocCommand.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as InventoryLookupView from "PosApi/Extend/Views/InventoryLookupView"; import { ProxyEntities } from "PosApi/Entities"; import { IExtensionCommandContext } from "PosApi/Extend/Views/AppBarCommands"; import { ObjectExtensions } from "PosApi/TypeExtensions"; export default class DownloadDocCommand extends InventoryLookupView.InventoryLookupExtensionCommandBase { private _locationAvailability: ProxyEntities.OrgUnitAvailability; private _locationAvailabilities: ProxyEntities.OrgUnitAvailability[]; /** * Creates a new instance of the DownloadDocCommand class. * @param {IExtensionCommandContext<Extensibility.IInventoryLookupToExtensionCommandMessageTypeMap>} context The command context. * @remarks The command context contains APIs through which a command can communicate with POS. */ constructor(context: IExtensionCommandContext<InventoryLookupView.IInventoryLookupToExtensionCommandMessageTypeMap>) { super(context); this.id = "DownloadDocCommand"; this.label = "Download document"; this.extraClass = "iconInvoice"; this.productChangedHandler = (data: InventoryLookupView.InventoryLookupProductChangedData): void => { this._productChanged(data); }; this.locationSelectionHandler = (data: InventoryLookupView.InventoryLookupLocationSelectedData): void => { this._locationAvailability = data.locationAvailability; this.isVisible = !ObjectExtensions.isNullOrUndefined(this._locationAvailability); }; } /** * Initializes the command. * @param {Extensibility.IInventoryLookupExtensionCommandState} state The state used to initialize the command. */ protected init(state: InventoryLookupView.IInventoryLookupExtensionCommandState): void { this._locationAvailabilities = state.locationAvailabilities; this.isVisible = true; } /** * Executes the command. */ protected execute(): void { this.isProcessing = true; window.setTimeout((): void => { this.isProcessing = false; }, 2000); } /** * Handles the product changed message by sending a message by updating the command state. * @param {Extensibility.InventoryLookupProductChangedData} data The information about the selected product. */ private _productChanged(data: InventoryLookupView.InventoryLookupProductChangedData): void { this._locationAvailabilities = data.locationAvailabilities; this.canExecute = true; this.isVisible = true; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/InventoryLookup/CustomInventoryByStoreListColumns.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { IInventoryByStoreListColumn } from "PosApi/Extend/Views/InventoryLookupView"; import { ICustomColumnsContext } from "PosApi/Extend/Views/CustomListColumns"; import { BooleanFormatter } from "PosApi/Consume/Formatters"; import { ProxyEntities } from "PosApi/Entities"; function getItemAvailability(orgUnitAvailability: ProxyEntities.OrgUnitAvailability): ProxyEntities.ItemAvailability { "use strict"; return (orgUnitAvailability && orgUnitAvailability.ItemAvailabilities) ? orgUnitAvailability.ItemAvailabilities[0] : undefined; } export default (context: ICustomColumnsContext): IInventoryByStoreListColumn[] => { return [ { title: "LOCATION_CUSTOMIZED", computeValue: (row: ProxyEntities.OrgUnitAvailability): string => { return row.OrgUnitLocation.OrgUnitName; }, ratio: 50, collapseOrder: 5, minWidth: 150 }, { title: "STORE", computeValue: (row: ProxyEntities.OrgUnitAvailability): string => { const nonStoreWarehouseIdentifier: number = 0; // Non-Store Warehouses do not have a Channel Id. let isRetailStore: boolean = row.OrgUnitLocation.ChannelId !== nonStoreWarehouseIdentifier; return BooleanFormatter.toYesNo(isRetailStore); }, ratio: 10, collapseOrder: 2, minWidth: 50 }, { title: "INVENTORY", computeValue: (row: ProxyEntities.OrgUnitAvailability): string => { let inventoryAvailability: ProxyEntities.ItemAvailability = getItemAvailability(row); let quantity: number = (inventoryAvailability && inventoryAvailability.AvailableQuantity) ? inventoryAvailability.AvailableQuantity : 0; return quantity.toString(); }, ratio: 10, collapseOrder: 6, minWidth: 60, isRightAligned: true }, { title: "RESERVED", computeValue: (row: ProxyEntities.OrgUnitAvailability): string => { let inventoryAvailability: ProxyEntities.ItemAvailability = getItemAvailability(row); let physicalReserved: number = (inventoryAvailability && inventoryAvailability.PhysicalReserved) ? inventoryAvailability.PhysicalReserved : 0; return physicalReserved.toString(); }, ratio: 10, collapseOrder: 3, minWidth: 60, isRightAligned: true }, { title: "ORDERED", computeValue: (row: ProxyEntities.OrgUnitAvailability): string => { let inventoryAvailability: ProxyEntities.ItemAvailability = getItemAvailability(row); let orderedSum: number = (inventoryAvailability && inventoryAvailability.OrderedSum) ? inventoryAvailability.OrderedSum : 0; return orderedSum.toString(); }, ratio: 10, collapseOrder: 4, minWidth: 60, isRightAligned: true }, { title: "UNIT", computeValue: (row: ProxyEntities.OrgUnitAvailability): string => { let inventoryAvailability: ProxyEntities.ItemAvailability = getItemAvailability(row); let unitOfMeasure: string = (inventoryAvailability && inventoryAvailability.UnitOfMeasure) ? inventoryAvailability.UnitOfMeasure : ""; return unitOfMeasure; }, ratio: 10, collapseOrder: 1, minWidth: 60, isRightAligned: true } ]; };
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/StockCountDetails/StockCountDetailsCommand.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as StockCountDetailsView from "PosApi/Extend/Views/StockCountDetailsView"; import { IExtensionCommandContext } from "PosApi/Extend/Views/AppBarCommands"; import { ProxyEntities, ClientEntities } from "PosApi/Entities"; import { ObjectExtensions, StringExtensions } from "PosApi/TypeExtensions"; import MessageDialog from "../../../Create/Dialogs/DialogSample/MessageDialog"; export default class StockCountDetailsCommand extends StockCountDetailsView.StockCountDetailsExtensionCommandBase { private _isNewJournal: Boolean = false; private _isAdvancedWarehousingEnabled: Boolean = false; private _journal: ProxyEntities.StockCountJournal = null; private _journalLines: ClientEntities.IStockCountLine[] = []; private _selectedJournalLines: ClientEntities.IStockCountLine[] = []; /** * Creates a new instance of the StockCountDetailsCommand class. * @param {IExtensionCommandContext<StockCountDetailsView.IStockCountDetailsToExtensionCommandMessageTypeMap>} context The context. * @remarks The command context contains APIs through which a command can communicate with POS. */ constructor(context: IExtensionCommandContext<StockCountDetailsView.IStockCountDetailsToExtensionCommandMessageTypeMap>) { super(context); this.id = "sampleStockCountDetailsCommand"; this.label = "Sample StockCountDetails Command"; this.extraClass = "iconLightningBolt"; this.journalLineSelectedHandler = (data: StockCountDetailsView.StockCountDetailsJournalLineSelectedData): void => { this._selectedJournalLines = data.journalLines; }; this.journalLineSelectionClearedHandler = () => { this._selectedJournalLines = []; }; this.journalLinesUpdatedHandler = (data: StockCountDetailsView.StockCountDetailsJournalLinesUpdatedData): void => { this._journalLines = data.journalLines; }; this.journalSavedHandler = (data: StockCountDetailsView.StockCountDetailsJournalSavedData): void => { this._journalLines = data.journalLines; }; } /** * Initializes the command. * @param {StockCountDetailsView.IStockCountDetailsExtensionCommandState} state The state used to initialize the command. */ protected init(state: StockCountDetailsView.IStockCountDetailsExtensionCommandState): void { this.isVisible = true; this.canExecute = true; this._isNewJournal = state.isNewJournal; this._isAdvancedWarehousingEnabled = state.isAdvancedWarehousingEnabled; this._journal = state.journal; } /** * Executes the command. */ protected execute(): void { let journalId: string = ObjectExtensions.isNullOrUndefined(this._journal) ? StringExtensions.EMPTY : this._journal.JournalId; let message: string = `JournalId: ${journalId}; IsNewJournal: ${this._isNewJournal}; ` + `IsAdvancedWarehousingEnabled: ${this._isAdvancedWarehousingEnabled}; StockCountLine:` + this._journalLines.map((value: ClientEntities.IStockCountLine) => { return ` ${ value.itemId}`; }) + " SelectedJournalLines:" + this._selectedJournalLines.map((value: ClientEntities.IStockCountLine) => { return ` ${value.itemId}`; }); MessageDialog.show(this.context, message); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/CustomerDetails/CustomerDetailsFriendsPanel.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { CustomerDetailsCustomControlBase, ICustomerDetailsCustomControlState, ICustomerDetailsCustomControlContext } from "PosApi/Extend/Views/CustomerDetailsView"; import { GetCustomerClientRequest, GetCustomerClientResponse } from "PosApi/Consume/Customer"; import { ClientEntities, ProxyEntities } from "PosApi/Entities"; import { StringExtensions } from "PosApi/TypeExtensions"; import * as Controls from "PosApi/Consume/Controls"; import ko from "knockout"; export default class CustomerDetailsFriendsPanel extends CustomerDetailsCustomControlBase { public dataList: Controls.IDataList<ProxyEntities.Customer>; public readonly title: ko.Observable<string>; private static readonly TEMPLATE_ID: string = "Microsoft_Pos_Extensibility_Samples_CustomerDetailsFriendsPanel"; private _state: ICustomerDetailsCustomControlState; private _friends: ProxyEntities.Customer[] = []; constructor(id: string, context: ICustomerDetailsCustomControlContext) { super(id, context); this.title = ko.observable(""); } /** * Binds the control to the specified element. * @param {HTMLElement} element The element to which the control should be bound. */ public onReady(element: HTMLElement): void { ko.applyBindingsToNode(element, { template: { name: CustomerDetailsFriendsPanel.TEMPLATE_ID, data: this } }); let dataListOptions: Readonly<Controls.IDataListOptions<ProxyEntities.Customer>> = { columns: [ { title: "Account Number", ratio: 40, collapseOrder: 1, minWidth: 100, computeValue: (value: ProxyEntities.Customer): string => { return value.AccountNumber; } }, { title: "Name", ratio: 60, collapseOrder: 2, minWidth: 100, computeValue: (value: ProxyEntities.Customer): string => { return value.Name; } } ], data: this._friends, interactionMode: Controls.DataListInteractionMode.Invoke, }; let dataListRootElem: HTMLDivElement = element.querySelector("#dataListSample") as HTMLDivElement; this.dataList = this.context.controlFactory.create(this.context.logger.getNewCorrelationId(), "DataList", dataListOptions, dataListRootElem); this.dataList.addEventListener("ItemInvoked", (eventData: { item: ProxyEntities.Customer }): any => { this._viewFriendDetails(eventData.item); }); } /** * Initializes the control. * @param {ICustomerDetailsCustomControlState} state The initial state of the page used to initialize the control. */ public init(state: ICustomerDetailsCustomControlState): void { this._state = state; if (!this._state.isSelectionMode) { this.isVisible = true; this.title(this._state.customer.FirstName + "'s Friends"); let allFriendAccountNumbers: string[] = ["2001", "2002", "2003", "2004", "2005"]; let friendLoadPromises: Promise<void>[] = []; let friends: ProxyEntities.Customer[] = []; allFriendAccountNumbers.forEach((friendAccountNumber: string): void => { if (friendAccountNumber !== this._state.customer.AccountNumber) { let getFirstFriendRequest: GetCustomerClientRequest<GetCustomerClientResponse> = new GetCustomerClientRequest(friendAccountNumber); let loadPromise: Promise<void> = this.context.runtime.executeAsync(getFirstFriendRequest) .then((result: ClientEntities.ICancelableDataResult<GetCustomerClientResponse>): void => { if (!result.canceled) { friends.push(result.data.result); } }).catch((reason: any): void => { this.context.logger.logError("Failed to load customer information for customer with account number: " + friendAccountNumber); }); friendLoadPromises.push(loadPromise); } }); Promise.all(friendLoadPromises).then((): void => { this._friends = friends.sort((left: ProxyEntities.Customer, right: ProxyEntities.Customer): number => { return StringExtensions.compare(left.AccountNumber, right.AccountNumber); }); this.dataList.data = this._friends; }); } } /** * Navigates to the customer details page for the specified friend. * @param {ProxyEntities.Customer} friend The friend whose details should be shown. */ private _viewFriendDetails(friend: ProxyEntities.Customer): void { const correlationId: string = this.context.logger.getNewCorrelationId(); this.context.logger.logInformational("The view friend details button was clicked on the customer details friends panel.", correlationId); let customerDetailsOptions: ClientEntities.CustomerDetailsNavigationParameters = new ClientEntities.CustomerDetailsNavigationParameters(friend.AccountNumber, correlationId); this.context.navigator.navigateToPOSView("CustomerDetailsView", customerDetailsOptions); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/CustomerDetails/DisplayCustomerSummaryCommand.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as CustomerDetailsView from "PosApi/Extend/Views/CustomerDetailsView"; import { ProxyEntities } from "PosApi/Entities"; import { IExtensionCommandContext } from "PosApi/Extend/Views/AppBarCommands"; import SendEmailRequest from "../../../Create/RequestHandlers/SendEmailRequest"; import SendEmailResponse from "../../../Create/RequestHandlers/SendEmailResponse"; export default class DisplayCustomerSummaryCommand extends CustomerDetailsView.CustomerDetailsExtensionCommandBase { private _customer: ProxyEntities.Customer; private _affiliations: ProxyEntities.CustomerAffiliation[]; private _wishLists: ProxyEntities.CommerceList[]; private _loyaltyCards: ProxyEntities.LoyaltyCard[]; /** * Creates a new instance of the EmailCustomerCommand class. * @param {IExtensionCommandContext<CustomerDetailsView.ICustomerDetailsToExtensionCommandMessageTypeMap>} context The command context. * @remarks The command context contains APIs through which a command can communicate with POS. */ constructor(context: IExtensionCommandContext<CustomerDetailsView.ICustomerDetailsToExtensionCommandMessageTypeMap>) { super(context); this.id = "emailCustomerCommand"; this.label = "Send Email"; this.extraClass = "iconLightningBolt"; this._affiliations = []; this.affiliationAddedHandler = (data: CustomerDetailsView.CustomerDetailsAffiliationAddedData): void => { this._affiliations = data.affiliations; }; this._wishLists = []; this.wishListsLoadedHandler = (data: CustomerDetailsView.CustomerDetailsWishListsLoadedData): void => { this._wishLists = data.wishLists; }; this._loyaltyCards = []; this.loyaltyCardsLoadedHandler = (data: CustomerDetailsView.CustomerDetailsLoyaltyCardsLoadedData): void => { this._loyaltyCards = data.loyaltyCards; }; } /** * Initializes the command. * @param {CustomerDetailsView.ICustomerDetailsExtensionCommandState} state The state used to initialize the command. */ protected init(state: CustomerDetailsView.ICustomerDetailsExtensionCommandState): void { if (!state.isSelectionMode) { this.isVisible = true; this.canExecute = true; this._customer = state.customer; this._affiliations = state.customer.CustomerAffiliations || []; } } /** * Executes the command. */ protected execute(): void { let message: string = "Customer Account: " + this._customer.AccountNumber + " | "; message += "Affiliations: " + this._affiliations.map((a: ProxyEntities.CustomerAffiliation) => a.Name).join(", ") + " | "; message += "Loyalty Cards: " + this._loyaltyCards.map((lc: ProxyEntities.LoyaltyCard) => lc.CardNumber).join(", ") + " | "; message += "Wish Lists: " + this._wishLists.map((wl: ProxyEntities.CommerceList) => wl.Name).join(", "); let request: SendEmailRequest<SendEmailResponse> = new SendEmailRequest<SendEmailResponse>(); request.emailAddress = this._customer.Email; request.message = message; this.context.runtime.executeAsync(request); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/CustomerDetails/CustomerDetailsFriendsPanel.html
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title></title> </head> <body> <!-- Note: The element id is different than the id generated by the POS extensibility framework. This 'template' id is not used by the POS extensibility framework. --> <script id="Microsoft_Pos_Extensibility_Samples_CustomerDetailsFriendsPanel" type="text/html"> <h2 class="marginTop8 marginBottom8" data-bind="text: title"></h2> <!-- Note: The default panels on the customer details page have a width of either 320px or 400px --> <div class="width400 no-shrink col height100Percent"> <div class="col grow marginBottom48"> <div id="dataListSample"></div> </div> </div> </script> </body> </html>
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/ShowJournal/DownloadDocumentCommand.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as ShowJournalView from "PosApi/Extend/Views/ShowJournalView"; import { ClientEntities, ProxyEntities } from "PosApi/Entities"; import { IExtensionCommandContext } from "PosApi/Extend/Views/AppBarCommands"; export default class DownloadDocumentCommand extends ShowJournalView.ShowJournalExtensionCommandBase { private _selectedJournal: ProxyEntities.SalesOrder; private _products: ProxyEntities.SimpleProduct[]; private _customer: ProxyEntities.Customer; private _mode: ClientEntities.ShowJournalMode; /** * Creates a new instance of the DownloadDocumentCommand class. * @param {IExtensionCommandContext<Extensibility.IShowJournalToExtensionCommandMessageTypeMap>} context The command context. * @remarks The command context contains APIs through which a command can communicate with POS. */ constructor(context: IExtensionCommandContext<ShowJournalView.IShowJournalToExtensionCommandMessageTypeMap>) { super(context); this.id = "downloadDocumentCommand"; this.label = "Download document"; this.extraClass = "iconInvoice"; this.journalSelectionHandler = (data: ShowJournalView.ShowJournalJournalSelectedData): void => { this._journalChanged(data); }; this.journalSelectionClearedHandler = (): void => { this._selectedJournal = undefined; this._products = []; this._customer = undefined; this.canExecute = false; }; this.receiptSelectionHandler = (data: ShowJournalView.ShowJournalReceiptSelectedData): void => { this.isVisible = false; }; this.receiptSelectionClearedHandler = (): void => { this.isVisible = true; }; this.journalTransactionsLoadedHandler = (data: ShowJournalView.ShowJournalJournalTransactionsLoadedData): void => { this.isVisible = this._mode === ClientEntities.ShowJournalMode.ShowJournal; this.context.logger.logInformational("Executing journalTransactionsLoadedHandler for DownloadDocumentCommand: " + JSON.stringify(data) + "."); }; } /** * Initializes the command. * @param {Extensibility.IShowJournalExtensionCommandState} state The state used to initialize the command. */ protected init(state: ShowJournalView.IShowJournalExtensionCommandState): void { this._mode = state.mode; } /** * Executes the command. */ protected execute(): void { this.isProcessing = true; window.setTimeout((): void => { this.isProcessing = false; }, 2000); } /** * Handles the journal changed message by sending a message by updating the command state. * @param {Extensibility.ShowJournalJournalSelectedData} data The information about the selected journal. */ private _journalChanged(data: ShowJournalView.ShowJournalJournalSelectedData): void { this._selectedJournal = data.salesOrder; this._products = data.products; this._customer = data.customer; this.canExecute = true; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/ShowJournal/TransactionListColumns.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { IShowJournalTransactionListColumn } from "PosApi/Extend/Views/ShowJournalView"; import { ICustomColumnsContext } from "PosApi/Extend/Views/CustomListColumns"; import { DateFormatter, TransactionTypeFormatter, CurrencyFormatter } from "PosApi/Consume/Formatters"; import { ProxyEntities } from "PosApi/Entities"; export default (context: ICustomColumnsContext): IShowJournalTransactionListColumn[] => { return [ { title: "Date_CUSTOMIZED", computeValue: (row: ProxyEntities.Transaction): string => { return DateFormatter.toShortDateAndTime(row.CreatedDateTime); }, ratio: 20, collapseOrder: 6, minWidth: 200 }, { title: "Operator ID", computeValue: (row: ProxyEntities.Transaction): string => { return "Neato custom Staff ID: " + row.StaffId; }, ratio: 15, collapseOrder: 1, minWidth: 300 }, { title: "Register", computeValue: (row: ProxyEntities.Transaction): string => { return row.TerminalId; }, ratio: 15, collapseOrder: 2, minWidth: 100 }, { title: "Type", computeValue: (row: ProxyEntities.Transaction): string => { return TransactionTypeFormatter.toName( row.TransactionTypeValue, row.TransactionStatusValue); }, ratio: 20, collapseOrder: 3, minWidth: 200 }, { title: "Receipt", computeValue: (row: ProxyEntities.Transaction): string => { return "Customized: " + row.ReceiptId; }, ratio: 20, collapseOrder: 5, minWidth: 300 }, { title: "Total", computeValue: (row: ProxyEntities.Transaction): string => { return CurrencyFormatter.toCurrency(row.TotalAmount); }, ratio: 10, collapseOrder: 4, minWidth: 100, isRightAligned: true } ]; };
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/ShowJournal/SampleTransactionSearchTextFilter.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ISearchFilterDefinitionContext, CustomTextSearchFilterDefinitionBase } from "PosApi/Extend/Views/CustomSearchFilters"; /** * Represents a sample text search filter. */ export default class SampleTransactionSearchTextFilter extends CustomTextSearchFilterDefinitionBase { protected readonly labelValue: string; protected readonly id: string; /** * Creates a new instance of the SampleTransactionSearchTextFilter class. * @param {ISearchFilterDefinitionContext} context The search filter definition context. */ constructor(context: ISearchFilterDefinitionContext) { super(context); this.id = "SampleTransactionSearchTextFilter"; this.labelValue = "Text Search Filter Label"; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/ShowJournal/CustomerOrderHistoryListColumns.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { IShowJournalCustomerOrderHistoryListColumn } from "PosApi/Extend/Views/ShowJournalView"; import { ICustomColumnsContext } from "PosApi/Extend/Views/CustomListColumns"; import { DateFormatter, TransactionTypeFormatter, CurrencyFormatter } from "PosApi/Consume/Formatters"; import { ProxyEntities } from "PosApi/Entities"; export default (context: ICustomColumnsContext): IShowJournalCustomerOrderHistoryListColumn[] => { return [ { title: "Date_CUSTOMIZED", computeValue: (row: ProxyEntities.SalesOrder): string => { return DateFormatter.toShortDateAndTime(row.CreatedDateTime); }, ratio: 20, collapseOrder: 7, minWidth: 200 }, { title: "Operator ID", computeValue: (row: ProxyEntities.SalesOrder): string => { return "Neato custom Staff ID: " + row.StaffId; }, ratio: 10, collapseOrder: 1, minWidth: 100 }, { title: "Register", computeValue: (row: ProxyEntities.SalesOrder): string => { return row.TerminalId; }, ratio: 15, collapseOrder: 2, minWidth: 100 }, { title: "Type", computeValue: (row: ProxyEntities.SalesOrder): string => { return TransactionTypeFormatter.toName(row.TransactionTypeValue); }, ratio: 15, collapseOrder: 3, minWidth: 200 }, { title: "Status", computeValue: (row: ProxyEntities.SalesOrder): string => { return TransactionTypeFormatter.toName(row.StatusValue); }, ratio: 10, collapseOrder: 4, minWidth: 100, }, { title: "Receipt", computeValue: (row: ProxyEntities.SalesOrder): string => { return "Customized: " + row.ReceiptId; }, ratio: 20, collapseOrder: 6, minWidth: 200 }, { title: "Total", computeValue: (row: ProxyEntities.SalesOrder): string => { return CurrencyFormatter.toCurrency(row.TotalAmount); }, ratio: 10, collapseOrder: 5, minWidth: 100, isRightAligned: true } ]; };
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/ShowJournal
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/ShowJournal/IncomeExpenseGrid/IncomeExpenseLineSubfield.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ICustomLinesGridIncomeExpenseSubfieldContext, CustomLinesGridIncomeExpenseSubfieldBase } from "PosApi/Extend/Views/ShowJournalView"; import { ProxyEntities } from "PosApi/Entities"; import { ObjectExtensions, StringExtensions } from "PosApi/TypeExtensions"; export default class IncomeExpenseLineSubfield extends CustomLinesGridIncomeExpenseSubfieldBase { constructor(context: ICustomLinesGridIncomeExpenseSubfieldContext) { super(context); } /** * Computes a value to display as an item subfield based on the given encome/expense line. * @param {ProxyEntities.IncomeExpenseLine} cartLine The income/expense line. * @returns {string} The computed value do display as a subfield. */ public computeValue(incomeExpenseLine: ProxyEntities.IncomeExpenseLine): string { let value: string = StringExtensions.EMPTY; if (!ObjectExtensions.isNullOrUndefined(incomeExpenseLine) && Math.abs(incomeExpenseLine.Amount) > 1000) { value = StringExtensions.format("The amount is greater then 1000.", incomeExpenseLine.IncomeExpenseAccount); } return value; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/ShowJournal
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/ShowJournal/LinesGrid/SubscribeAndSaveItemSubfield.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ICustomLinesGridItemSubfieldContext, CustomLinesGridItemSubfieldBase } from "PosApi/Extend/Views/ShowJournalView"; import { CurrencyFormatter } from "PosApi/Consume/Formatters"; import { ProxyEntities } from "PosApi/Entities"; import { ObjectExtensions, StringExtensions } from "PosApi/TypeExtensions"; export default class SubscribeAndSaveItemSubfield extends CustomLinesGridItemSubfieldBase { constructor(context: ICustomLinesGridItemSubfieldContext) { super(context); } /** * Computes a value to display as an item subfield based on the given sales line. * @param {ClientEntities.ISalesLineForDisplay} salesLine The sales line. * @returns {string} The computed value do display as an item subfield. */ public computeValue(salesLine: ProxyEntities.SalesLine): string { let value: string = StringExtensions.EMPTY; if (this._isSubscribeAndSaveCartLine(salesLine)) { value = StringExtensions.format("Subscribe and save: {0} each month", CurrencyFormatter.toCurrency(salesLine.NetAmount * .95)); } return value; } /** * Returns whether or not the given sales line is for an item that supports subscribing and saving. * @param {ClientEntities.ISalesLineForDisplay} salesLine The sales line. * @returns {boolean} Whether or not the given sales line is for an item that supports subscribing and saving. */ private _isSubscribeAndSaveCartLine(salesLine: ProxyEntities.SalesLine): boolean { return !ObjectExtensions.isNullOrUndefined(salesLine) && salesLine.ItemId === "0006"; // Inner Tube Patches. } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/ShowJournal
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/ShowJournal/LinesGrid/FraudCheckReminderItemSubfield.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ICustomLinesGridItemSubfieldContext, CustomLinesGridItemSubfieldBase } from "PosApi/Extend/Views/ShowJournalView"; import { ProxyEntities } from "PosApi/Entities"; import { ObjectExtensions, StringExtensions } from "PosApi/TypeExtensions"; export default class FraudCheckReminderItemSubfield extends CustomLinesGridItemSubfieldBase { constructor(context: ICustomLinesGridItemSubfieldContext) { super(context); } /** * Computes a value to display as an item subfield based on the given sales line. * @param {ClientEntities.ISalesLineForDisplay} salesLine The sales line. * @returns {string} The computed value do display as an item subfield. */ public computeValue(salesLine: ProxyEntities.SalesLine): string { let value: string = StringExtensions.EMPTY; if (!ObjectExtensions.isNullOrUndefined(salesLine) && salesLine.TotalAmount > 100) { value = "Please check the purchasers I.D. in order to prevent fraud."; } return value; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Search/CustomCustomerSearchColumns.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ICustomerSearchColumn } from "PosApi/Extend/Views/SearchView"; import { ICustomColumnsContext } from "PosApi/Extend/Views/CustomListColumns"; import { ProxyEntities } from "PosApi/Entities"; export default (context: ICustomColumnsContext): ICustomerSearchColumn[] => { return [ { title: context.resources.getString("string_2"), computeValue: (row: ProxyEntities.GlobalCustomer): string => { return row.AccountNumber; }, ratio: 15, collapseOrder: 5, minWidth: 120 }, { title: context.resources.getString("string_3"), computeValue: (row: ProxyEntities.GlobalCustomer): string => { return row.FullName; }, ratio: 20, collapseOrder: 4, minWidth: 200 }, { title: context.resources.getString("string_4"), computeValue: (row: ProxyEntities.GlobalCustomer): string => { return row.FullAddress; }, ratio: 25, collapseOrder: 1, minWidth: 200 }, { title: context.resources.getString("string_5"), computeValue: (row: ProxyEntities.GlobalCustomer): string => { return row.Email; }, ratio: 20, collapseOrder: 2, minWidth: 200 }, { title: context.resources.getString("string_7"), computeValue: (row: ProxyEntities.GlobalCustomer): string => { return row.Phone; }, ratio: 20, collapseOrder: 3, minWidth: 120 } ]; };
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Search/NavigateToSamplesViewCommand.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { IExtensionCommandContext } from "PosApi/Extend/Views/AppBarCommands"; import * as SearchView from "PosApi/Extend/Views/SearchView"; export default class NavigateToSamplesViewCommand extends SearchView.ProductSearchExtensionCommandBase { /** * Creates a new instance of the NavigateToSamplesViewCommand class. * @param {IExtensionCommandContext<SearchView.IProductSearchToExtensionCommandMessageTypeMap>} context The command context. * @remarks The command context contains APIs through which a command can communicate with POS. */ constructor(context: IExtensionCommandContext<SearchView.IProductSearchToExtensionCommandMessageTypeMap>) { super(context); this.id = "navigateToKnockoutSamplesViewExtensionViewCommand"; this.label = "Navigate to Knockout Samples View"; this.extraClass = "iconGo"; } /** * Initializes the command. * @param {SearchView.IProductSearchExtensionCommandState} state The state used to initialize the command. */ protected init(state: SearchView.IProductSearchExtensionCommandState): void { this.canExecute = true; this.isVisible = true; } /** * Executes the command. */ protected execute(): void { this.context.navigator.navigate("SamplesView"); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Search/CustomProductSearchColumns.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { IProductSearchColumn } from "PosApi/Extend/Views/SearchView"; import { ICustomColumnsContext } from "PosApi/Extend/Views/CustomListColumns"; import { CurrencyFormatter } from "PosApi/Consume/Formatters"; import { ProxyEntities } from "PosApi/Entities"; export default (context: ICustomColumnsContext): IProductSearchColumn[] => { return [ { title: "Item ID_CUSTOMIZED", computeValue: (row: ProxyEntities.ProductSearchResult): string => { return row.ItemId; }, ratio: 20, collapseOrder: 3, minWidth: 120 }, { title: "Name", computeValue: (row: ProxyEntities.ProductSearchResult): string => { return row.Name; }, ratio: 40, collapseOrder: 2, minWidth: 200 }, { title: "Custom", computeValue: (row: ProxyEntities.ProductSearchResult): string => { return "RecID: " + row.RecordId; }, ratio: 20, collapseOrder: 4, minWidth: 200 }, { title: "Price", computeValue: (row: ProxyEntities.ProductSearchResult): string => { return CurrencyFormatter.toCurrency(row.Price); }, ratio: 20, collapseOrder: 1, minWidth: 100, isRightAligned: true } ]; };
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Search/ViewCustomerSummaryCommand.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as SearchView from "PosApi/Extend/Views/SearchView"; import { ProxyEntities } from "PosApi/Entities"; import { ArrayExtensions, ObjectExtensions } from "PosApi/TypeExtensions"; import { IExtensionCommandContext } from "PosApi/Extend/Views/AppBarCommands"; import MessageDialog from "../../../Create/Dialogs/DialogSample/MessageDialog"; export default class ViewCustomerSummaryCommand extends SearchView.CustomerSearchExtensionCommandBase { private _customerSearchResults: ProxyEntities.GlobalCustomer[]; /** * Creates a new instance of the ViewCustomerSummaryCommand class. * @param {IExtensionCommandContext<CustomerDetailsView.ICustomerSearchToExtensionCommandMessageTypeMap>} context The command context. * @remarks The command context contains APIs through which a command can communicate with POS. */ constructor(context: IExtensionCommandContext<SearchView.ICustomerSearchToExtensionCommandMessageTypeMap>) { super(context); this.id = "viewCustomerSummaryCommand"; this.label = context.resources.getString("string_1"); this.extraClass = "iconLightningBolt"; this._customerSearchResults = []; this.searchResultsSelectedHandler = (data: SearchView.CustomerSearchSearchResultSelectedData): void => { this._customerSearchResults = data.customers; this.canExecute = true; }; this.searchResultSelectionClearedHandler = (): void => { this._customerSearchResults = []; this.canExecute = false; }; } /** * Initializes the command. * @param {CustomerDetailsView.ICustomerDetailsExtensionCommandState} state The state used to initialize the command. */ protected init(state: SearchView.ICustomerSearchExtensionCommandState): void { this.isVisible = true; } /** * Executes the command. */ protected execute(): void { let customer: ProxyEntities.GlobalCustomer = ArrayExtensions.firstOrUndefined(this._customerSearchResults); if (!ObjectExtensions.isNullOrUndefined(customer)) { let message: string = "Customer Account: " + (customer.AccountNumber || "") + " | "; message += "Name: " + customer.FullName + " | "; message += "Phone Number: " + customer.Phone + " | "; message += "Email Address: " + customer.Email; MessageDialog.show(this.context, message); } } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/Search/QuickCompareProductsCommand.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as SearchView from "PosApi/Extend/Views/SearchView"; import { ProxyEntities } from "PosApi/Entities"; import { IExtensionCommandContext } from "PosApi/Extend/Views/AppBarCommands"; import MessageDialog from "../../../Create/Dialogs/DialogSample/MessageDialog"; export default class QuickCompareProductsCommand extends SearchView.ProductSearchExtensionCommandBase { private _productSearchResults: ProxyEntities.ProductSearchResult[]; /** * Creates a new instance of the QuickCompareProductsCommand class. * @param {IExtensionCommandContext<CustomerDetailsView.IProductSearchToExtensionCommandMessageTypeMap>} context The command context. * @remarks The command context contains APIs through which a command can communicate with POS. */ constructor(context: IExtensionCommandContext<SearchView.IProductSearchToExtensionCommandMessageTypeMap>) { super(context); this.id = "quickCompareProducts"; this.label = context.resources.getString("string_0"); this.extraClass = "iconLightningBolt"; this.searchResultsSelectedHandler = (data: SearchView.ProductSearchSearchResultSelectedData): void => { this.canExecute = true; this._productSearchResults = data.productSearchResults; }; this.searchResultSelectionClearedHandler = () => { this.canExecute = false; this._productSearchResults = []; }; } /** * Initializes the command. * @param {CustomerDetailsView.ICustomerDetailsExtensionCommandState} state The state used to initialize the command. */ protected init(state: SearchView.IProductSearchExtensionCommandState): void { this.isVisible = true; this._productSearchResults = state.productSearchResults; } /** * Executes the command. */ protected execute(): void { let message: string = ""; let productData: string[] = []; this._productSearchResults.forEach((result: ProxyEntities.ProductSearchResult): void => { let productMessage: string = " Product Name: " + result.Name + " - Item Id: " + result.ItemId + " - Price: " + result.Price; productData.push(productMessage); }); message = productData.join(" | "); MessageDialog.show(this.context, message); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/CustomerAddEdit/CustomFieldsSection.html
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title></title> </head> <body> <!-- Note: The element id is different than the id generated by the POS extensibility framework. This 'template' id is not used by the POS extensibility framework. --> <script id="Microsoft_Pos_Extensibility_Samples_CustomFieldsSection" type="text/html"> <div class="gutter20x20"></div> <div class="row"> <div class="col stretch"> <div data-bind="visible: customerIsPerson"> <label for="customerSSNInput">SSN</label> <input type="text" id="customerSSNInput" data-bind="value: ssn, valueUpdate: 'afterkeydown'" /> </div> <div data-bind="visible: !customerIsPerson()"> <label for="organizationIdInput">Organization Id</label> <input type="text" id="organizationIdInput" data-bind="value: organizationId, valueUpdate: 'afterkeydown'" /> </div> </div> <div class="gutter40x40"></div> <div class="col stretch"> <div data-bind="visible: customerIsPerson"> <label for="isVipToggle">IsVIP</label> <div id="isVipToggle"/> </div> </div> </div> </script> </body> </html>
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/CustomerAddEdit/GetExternalCustomerCommand.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as CustomerAddEditView from "PosApi/Extend/Views/CustomerAddEditView"; import { ProxyEntities, ClientEntities } from "PosApi/Entities"; import { IAlphanumericInputDialogOptions, ShowAlphanumericInputDialogClientResponse, ShowAlphanumericInputDialogClientRequest } from "PosApi/Consume/Dialogs"; import { IExtensionCommandContext } from "PosApi/Extend/Views/AppBarCommands"; export default class GetExternalCustomerCommand extends CustomerAddEditView.CustomerAddEditExtensionCommandBase { /** * Creates a new instance of the GetExternalCustomerCommand class. * @param {IExtensionCommandContext<CustomerAddEditView.ICustomerAddEditToExtensionCommandMessageTypeMap>} context The command context. * @remarks The command context contains APIs through which a command can communicate with POS. */ constructor(context: IExtensionCommandContext<CustomerAddEditView.ICustomerAddEditToExtensionCommandMessageTypeMap>) { super(context); this.id = "getExternalCustomerCommand"; this.label = "Get Customer"; this.extraClass = "iconLightningBolt"; } /** * Initializes the command. * @param {CustomerAddEditView.ICustomerAddEditExtensionCommandState} state The state used to initialize the command. */ protected init(state: CustomerAddEditView.ICustomerAddEditExtensionCommandState): void { if (state.isNewCustomer) { // We don't want to override a customer if it already exists. this.isVisible = true; this.canExecute = true; } } /** * Executes the command. */ protected execute(): void { let inputAlphanumericDialogOptions: IAlphanumericInputDialogOptions = { title: "External System", numPadLabel: "Please enter code:" }; let dialogRequest: ShowAlphanumericInputDialogClientRequest<ShowAlphanumericInputDialogClientResponse> = new ShowAlphanumericInputDialogClientRequest<ShowAlphanumericInputDialogClientResponse>(inputAlphanumericDialogOptions); this.context.runtime.executeAsync(dialogRequest) .then((dialogResponse: ClientEntities.ICancelableDataResult<ShowAlphanumericInputDialogClientResponse>) => { if (!dialogResponse.canceled) { let customer: ProxyEntities.Customer = this.customer; let primaryAddress: ProxyEntities.Address = new ProxyEntities.AddressClass(); if (dialogResponse.data.result.value === "1") { primaryAddress.AddressTypeValue = ClientEntities.ExtensibleAddressType.Business.Value; primaryAddress.City = "Redmond"; primaryAddress.IsPrimary = true; primaryAddress.Name = "Contoso Consulting USA"; primaryAddress.State = "WA"; primaryAddress.StateName = "Washington"; primaryAddress.Street = "454 1st Street\nSuite 99"; primaryAddress.ThreeLetterISORegionName = "USA"; primaryAddress.ZipCode = "98052"; let addresses: ProxyEntities.Address[] = [primaryAddress]; customer.CustomerTypeValue = ProxyEntities.CustomerType.Organization; // Having a name is mandatory. customer.Name = "Contoso Consulting USA"; customer.Addresses = addresses; } else { primaryAddress.AddressTypeValue = ClientEntities.ExtensibleAddressType.Home.Value; primaryAddress.City = "Redmond"; primaryAddress.IsPrimary = true; primaryAddress.Name = "Town house"; primaryAddress.State = "WA"; primaryAddress.StateName = "Washington"; primaryAddress.Street = "One microsoft way"; primaryAddress.ThreeLetterISORegionName = "USA"; primaryAddress.ZipCode = "98052"; let addresses: ProxyEntities.Address[] = [primaryAddress]; customer.CustomerTypeValue = ProxyEntities.CustomerType.Person; // Having a name is mandatory. customer.Name = "John Doe"; customer.FirstName = "John"; customer.LastName = "Doe"; customer.Addresses = addresses; } this.customer = customer; } }); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/CustomerAddEdit/CustomFieldsSection.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Controls from "PosApi/Consume/Controls"; import { CustomerAddEditCustomControlBase, ICustomerAddEditCustomControlState, ICustomerAddEditCustomControlContext, CustomerAddEditCustomerUpdatedData } from "PosApi/Extend/Views/CustomerAddEditView"; import { ObjectExtensions } from "PosApi/TypeExtensions"; import { ProxyEntities } from "PosApi/Entities"; import ko from "knockout"; export default class CustomFieldsSection extends CustomerAddEditCustomControlBase { public ssn: ko.Observable<string>; public organizationId: ko.Observable<string>; public isVip: boolean; public customerIsPerson: ko.Observable<boolean>; public toggleSwitch: Controls.IToggle; private static readonly TEMPLATE_ID: string = "Microsoft_Pos_Extensibility_Samples_CustomFieldsSection"; constructor(id: string, context: ICustomerAddEditCustomControlContext) { super(id, context); this.ssn = ko.observable(""); this.organizationId = ko.observable(""); this.isVip = false; this.customerIsPerson = ko.observable(false); this.ssn.subscribe((newValue: string): void => { this._addOrUpdateExtensionProperty("ssn", <ProxyEntities.CommercePropertyValue>{ StringValue: newValue }); }); this.organizationId.subscribe((newValue: string): void => { this._addOrUpdateExtensionProperty("organizationId", <ProxyEntities.CommercePropertyValue>{ StringValue: newValue }); }); this.customerUpdatedHandler = (data: CustomerAddEditCustomerUpdatedData) => { this.customerIsPerson(data.customer.CustomerTypeValue === ProxyEntities.CustomerType.Person); }; } /** * Binds the control to the specified element. * @param {HTMLElement} element The element to which the control should be bound. */ public onReady(element: HTMLElement): void { ko.applyBindingsToNode(element, { template: { name: CustomFieldsSection.TEMPLATE_ID, data: this } }); let toggleOptions: Controls.IToggleOptions = { labelOn: this.context.resources.getString("string_1357"), labelOff: this.context.resources.getString("string_1358"), checked: this.isVip, enabled: true, tabIndex: 0 }; let toggleRootElem: HTMLDivElement = element.querySelector("#isVipToggle") as HTMLDivElement; this.toggleSwitch = this.context.controlFactory.create(this.context.logger.getNewCorrelationId(), "Toggle", toggleOptions, toggleRootElem); this.toggleSwitch.addEventListener("CheckedChanged", (eventData: { checked: boolean }) => { this.toggleVip(eventData.checked); }); } /** * Initializes the control. * @param {ICustomerDetailCustomControlState} state The initial state of the page used to initialize the control. */ public init(state: ICustomerAddEditCustomControlState): void { if (!state.isSelectionMode) { this.isVisible = true; this.customerIsPerson(state.customer.CustomerTypeValue === ProxyEntities.CustomerType.Person); } } /** * Toggles Vip property. * @param {boolean} checked Indicates if vip is checked or not. */ public toggleVip(checked: boolean): void { this._addOrUpdateExtensionProperty("isVip", <ProxyEntities.CommercePropertyValue>{ BooleanValue: checked }); } /** * Gets the property value from the property bag, by its key. Optionally creates the property value on the bag, if it does not exist. * @param {string} key The key of the property to get. * @param {ProxyEntities.CommercePropertyValue} newValue The new value to set on the property. */ private _addOrUpdateExtensionProperty(key: string, newValue: ProxyEntities.CommercePropertyValue): void { let customer: ProxyEntities.Customer = this.customer; let extensionProperty: ProxyEntities.CommerceProperty = Commerce.ArrayExtensions.firstOrUndefined(customer.ExtensionProperties, (property: ProxyEntities.CommerceProperty) => { return property.Key === key; }); if (ObjectExtensions.isNullOrUndefined(extensionProperty)) { let newProperty: ProxyEntities.CommerceProperty = { Key: key, Value: newValue }; if (ObjectExtensions.isNullOrUndefined(customer.ExtensionProperties)) { customer.ExtensionProperties = []; } customer.ExtensionProperties.push(newProperty); } else { extensionProperty.Value = newValue; } this.customer = customer; } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/SimpleProductDetails/ProductAvailabilityPanel.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import * as Controls from "PosApi/Consume/Controls"; import { SimpleProductDetailsCustomControlBase, ISimpleProductDetailsCustomControlState, ISimpleProductDetailsCustomControlContext } from "PosApi/Extend/Views/SimpleProductDetailsView"; import { InventoryLookupOperationRequest, InventoryLookupOperationResponse } from "PosApi/Consume/OrgUnits"; import { ClientEntities, ProxyEntities } from "PosApi/Entities"; import { ArrayExtensions } from "PosApi/TypeExtensions"; import ko from "knockout"; export default class ProductAvailabilityPanel extends SimpleProductDetailsCustomControlBase { public dataList: Controls.IDataList<ProxyEntities.OrgUnitAvailability>; public readonly title: ko.Observable<string>; private static readonly TEMPLATE_ID: string = "Microsoft_Pos_Extensibility_Samples_ProductAvailabilityPanel"; private _state: ISimpleProductDetailsCustomControlState; private _orgUnitAvailabilities: ProxyEntities.OrgUnitAvailability[] = []; constructor(id: string, context: ISimpleProductDetailsCustomControlContext) { super(id, context); this.title = ko.observable("Product Availability"); } /** * Binds the control to the specified element. * @param {HTMLElement} element The element to which the control should be bound. */ public onReady(element: HTMLElement): void { ko.applyBindingsToNode(element, { template: { name: ProductAvailabilityPanel.TEMPLATE_ID, data: this } }); let dataListOptions: Readonly<Controls.IDataListOptions<ProxyEntities.OrgUnitAvailability>> = { columns: [ { title: "Location", ratio: 31, collapseOrder: 4, minWidth: 100, computeValue: (value: ProxyEntities.OrgUnitAvailability): string => { return value.OrgUnitLocation.OrgUnitName; } }, { title: "Inventory", ratio: 23, collapseOrder: 3, minWidth: 60, computeValue: (value: ProxyEntities.OrgUnitAvailability): string => { return ArrayExtensions.hasElements(value.ItemAvailabilities) ? value.ItemAvailabilities[0].AvailableQuantity.toString() : "0"; } }, { title: "Reserved", ratio: 23, collapseOrder: 1, minWidth: 60, computeValue: (value: ProxyEntities.OrgUnitAvailability): string => { return ArrayExtensions.hasElements(value.ItemAvailabilities) ? value.ItemAvailabilities[0].PhysicalReserved.toString() : "0"; } }, { title: "Ordered", ratio: 23, collapseOrder: 2, minWidth: 60, computeValue: (value: ProxyEntities.OrgUnitAvailability): string => { return ArrayExtensions.hasElements(value.ItemAvailabilities) ? value.ItemAvailabilities[0].OrderedSum.toString() : "0"; } } ], data: this._orgUnitAvailabilities, interactionMode: Controls.DataListInteractionMode.None, }; let dataListRootElem: HTMLDivElement = element.querySelector("#Microsoft_Pos_Extensibility_Samples_ProductAvailabilityPanel_DataList") as HTMLDivElement; this.dataList = this.context.controlFactory.create(this.context.logger.getNewCorrelationId(), "DataList", dataListOptions, dataListRootElem); } /** * Initializes the control. * @param {ISimpleProductDetailsCustomControlState} state The initial state of the page used to initialize the control. */ public init(state: ISimpleProductDetailsCustomControlState): void { this._state = state; let correlationId: string = this.context.logger.getNewCorrelationId(); if (!this._state.isSelectionMode) { this.isVisible = true; let request: InventoryLookupOperationRequest<InventoryLookupOperationResponse> = new InventoryLookupOperationRequest<InventoryLookupOperationResponse> (this._state.product.RecordId, correlationId); this.context.runtime.executeAsync(request) .then((result: ClientEntities.ICancelableDataResult<InventoryLookupOperationResponse>) => { if (!result.canceled) { this._orgUnitAvailabilities = result.data.orgUnitAvailability; this.dataList.data = this._orgUnitAvailabilities; } }).catch((reason: any) => { this.context.logger.logError(JSON.stringify(reason), correlationId); }); } } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/SimpleProductDetails/ProductAvailabilityPanel.html
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title></title> </head> <body> <!-- Note: The element id is different than the id generated by the POS extensibility framework. This 'template' id is not used by the POS extensibility framework. --> <script id="Microsoft_Pos_Extensibility_Samples_ProductAvailabilityPanel" type="text/html"> <h2 class="marginTop8 marginBottom8" data-bind="text: title"></h2> <div class="width400 grow col"> <div id="Microsot_Pos_Extensibility_Samples_ProductAvailabilityPanel_DataList"></div> </div> </script> </body> </html>
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/ViewExtensions/ReportDetails/ReportDetailsCommand.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { IExtensionCommandContext } from "PosApi/Extend/Views/AppBarCommands"; import * as ReportDetailsView from "PosApi/Extend/Views/ReportDetailsView"; import { ProxyEntities } from "PosApi/Entities"; import { StringExtensions } from "PosApi/TypeExtensions"; export default class ReportDetailsCommand extends ReportDetailsView.ReportDetailsExtensionCommandBase { private _reportData: ProxyEntities.ReportDataSet = null; private _reportTitle: string = StringExtensions.EMPTY; private _reportId: string = StringExtensions.EMPTY; /** * Creates a new instance of the ReportDetailsCommand class. * @param {IExtensionCommandContext<ReportDetailsView.IReportDetailsToExtensionCommandMessageTypeMap>} context The context. * @remarks The command context contains APIs through which a command can communicate with POS. */ constructor(context: IExtensionCommandContext<ReportDetailsView.IReportDetailsToExtensionCommandMessageTypeMap>) { super(context); this.id = "sampleReportDetailsCommand"; this.label = "Print"; this.extraClass = "iconPrint"; this.reportDataLoadedDataHandler = (data: ReportDetailsView.ReportDataLoadedData): void => { this.canExecute = true; this._reportData = data.reportDataSet; }; } /** * Initializes the command. * @param {ReportDetailsView.IReportDetailsExtensionCommandState} state The state used to initialize the command. */ protected init(state: ReportDetailsView.IReportDetailsExtensionCommandState): void { this.isVisible = true; this._reportId = state.reportId; this._reportTitle = state.reportTitle; } /** * Executes the command. */ protected execute(): void { this.context.logger.logInformational("Report title: " + JSON.stringify(this._reportTitle)); this.context.logger.logInformational("Report Id: " + JSON.stringify(this._reportId)); this.context.logger.logInformational("Print report data: " + JSON.stringify(this._reportData)); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/RequestHandlers/ShowChangeDueClientRequestHandlerExt.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { ShowChangeDueClientRequestHandler } from "PosApi/Extend/RequestHandlers/CartRequestHandlers"; import { ShowChangeDueClientRequest, ShowChangeDueClientResponse } from "PosApi/Consume/Cart"; import { ClientEntities } from "PosApi/Entities"; /** * Override request handler class for showing change due. */ export default class ShowChangeDueClientRequestHandlerExt extends ShowChangeDueClientRequestHandler { /** * Executes the request handler asynchronously. * @param {ShowChangeDueClientRequest<ShowChangeDueClientResponse>} The request containing the response. * @return {Promise<ICancelableDataResult<ShowChangeDueClientResponse>>} The cancelable promise containing the response. */ public executeAsync(request: ShowChangeDueClientRequest): Promise<ClientEntities.ICancelableDataResult<ShowChangeDueClientResponse>> { // User could implement new business logic here to override the dialog. return this.defaultExecuteAsync(request); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/RequestHandlers/CashDrawerOpenRequestHandlerExt.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { CashDrawerOpenRequestHandler } from "PosApi/Extend/RequestHandlers/PeripheralsRequestHandlers"; import { CashDrawerOpenRequest, CashDrawerOpenResponse } from "PosApi/Consume/Peripherals"; import { ClientEntities } from "PosApi/Entities"; /** * Override request handler class for open cash drawer operation. */ export default class CashDrawerOpenRequestHandlerExt extends CashDrawerOpenRequestHandler { /** * Executes the request handler asynchronously. * @param {CashDrawerOpenRequest<CashDrawerOpenResponse>} The request containing the response. * @return {Promise<ICancelableDataResult<CashDrawerOpenResponse>>} The cancelable promise containing the response. */ public executeAsync(request: CashDrawerOpenRequest<CashDrawerOpenResponse>): Promise<ClientEntities.ICancelableDataResult<CashDrawerOpenResponse>> { // User could implement new business logic here to to override the open cash drawer operation. return this.defaultExecuteAsync(request); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/RequestHandlers/GetShippingChargeClientRequestHandlerExt.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { GetShippingChargeClientRequestHandler } from "PosApi/Extend/RequestHandlers/CartRequestHandlers"; import { GetShippingChargeClientRequest, GetShippingChargeClientResponse } from "PosApi/Consume/Cart"; import { ClientEntities } from "PosApi/Entities"; /** * Override request handler class for getting shipping charge. */ export default class GetShippingChargeClientRequestHandlerExt extends GetShippingChargeClientRequestHandler { /** * Executes the request handler asynchronously. * @param {GetShippingChargeClientRequest<GetShippingChargeClientResponse>} The request containing the response. * @return {Promise<ICancelableDataResult<GetShippingChargeClientResponse>>} The cancelable promise containing the response. */ public executeAsync(request: GetShippingChargeClientRequest<GetShippingChargeClientResponse>): Promise<ClientEntities.ICancelableDataResult<GetShippingChargeClientResponse>> { // User could implement new business logic here to override the dialog. return this.defaultExecuteAsync(request); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/RequestHandlers/GetReportParametersClientRequestHandlerExt.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { GetReportParametersClientRequestHandler } from "PosApi/Extend/RequestHandlers/StoreOperationsRequestHandlers"; import { ClientEntities } from "PosApi/Entities"; import { GetReportParametersClientRequest, GetReportParametersClientResponse } from "PosApi/Consume/StoreOperations"; /** * Override request handler class for get report parameters client request. */ export default class GetReportParametersClientRequestHandlerExt extends GetReportParametersClientRequestHandler { /** * Executes the request handler asynchronously. * @param {GetReportParametersClientRequest<GetReportParametersClientResponse>} request The request containing the response. * @return {Promise<ICancelableDataResult<GetReportParametersClientResponse>>} The cancelable promise containing the response. */ public executeAsync(request: GetReportParametersClientRequest<GetReportParametersClientResponse>): Promise<ClientEntities.ICancelableDataResult<GetReportParametersClientResponse>> { let parameters: ClientEntities.IReportParameter[] = request.reportParameters; // The original parameters may be modified here before sending them to the response. let response: GetReportParametersClientResponse = new GetReportParametersClientResponse(parameters); return Promise.resolve(<ClientEntities.ICancelableDataResult<GetReportParametersClientResponse>>{ canceled: false, data: response }); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/RequestHandlers/GetRefinerValuesByTextServiceRequestHandlerExt.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { GetRefinerValuesByTextServiceRequestHandler } from "PosApi/Extend/RequestHandlers/ProductsRequestHandlers"; import { GetRefinerValuesByTextServiceRequest, GetRefinerValuesByTextServiceResponse } from "PosApi/Consume/Products"; import { ClientEntities } from "PosApi/Entities"; /** * Override request handler class for getting the refiner values by text. */ export default class GetRefinerValuesByTextServiceRequestHandlerExt extends GetRefinerValuesByTextServiceRequestHandler { /** * Executes the request handler asynchronously. * @param {GetRefinerValuesByTextServiceRequest<GetShippingDateClientResponse>} request The request containing the response. * @return {Promise<ICancelableDataResult<GetRefinerValuesByTextServiceResponse>>} The cancelable promise containing the response. */ public executeAsync(request: GetRefinerValuesByTextServiceRequest<GetRefinerValuesByTextServiceResponse>): Promise<ClientEntities.ICancelableDataResult<GetRefinerValuesByTextServiceResponse>> { // User could implement new business logic here to override the dialog. return this.defaultExecuteAsync(request); } }
0
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend
Dynamics365Commerce.InStore/Dynamics365Commerce.InStore/src/StoreCommerceSamples/PosExtensionSamples/Pos/Extend/RequestHandlers/GetReceiptEmailAddressClientRequestHandlerExt.ts
/** * SAMPLE CODE NOTICE * * THIS SAMPLE CODE IS MADE AVAILABLE AS IS. MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, * OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY. * THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER. * NO TECHNICAL SUPPORT IS PROVIDED. YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO. */ import { GetReceiptEmailAddressClientRequestHandler } from "PosApi/Extend/RequestHandlers/CartRequestHandlers"; import { GetReceiptEmailAddressClientRequest, GetReceiptEmailAddressClientResponse } from "PosApi/Consume/Cart"; import { ClientEntities } from "PosApi/Entities"; /** * Override request handler class for getting the receipt email address. */ export default class GetReceiptEmailAddressClientRequestHandlerExt extends GetReceiptEmailAddressClientRequestHandler { /** * Executes the request handler asynchronously. * @param {GetReceiptEmailAddressClientRequest<GetReceiptEmailAddressClientResponse>} The request containing the response. * @return {Promise<ICancelableDataResult<GetReceiptEmailAddressClientResponse>>} The cancelable promise containing the response. */ public executeAsync(request: GetReceiptEmailAddressClientRequest<GetReceiptEmailAddressClientResponse>): Promise<ClientEntities.ICancelableDataResult<GetReceiptEmailAddressClientResponse>> { // User could implement new business logic here to override the dialog. return this.defaultExecuteAsync(request); } }
0