Page 30115 Shpfy Orders

Shopify Connector, Microsoft.Integration.Shopify

src/Apps/W1/Shopify/App/src/Order handling/Pages/ShpfyOrders.Page.al471 lines, Copyright (c) Microsoft Corporation. MIT

// ------------------------------------------------------------------------------------------------// Copyright (c) Microsoft Corporation. All rights reserved.// Licensed under the MIT License. See License.txt in the project root for license information.// ------------------------------------------------------------------------------------------------namespace Microsoft.Integration.Shopify;using Microsoft.Sales.Customer;using Microsoft.Sales.Document;/// <summary>/// Page Shpfy Orders (ID 30115)./// </summary>page 30115 "Shpfy Orders"{    ApplicationArea = All;    Caption = 'Shopify Orders';    CardPageID = "Shpfy Order";    Editable = false;    InsertAllowed = false;    PageType = List;    PromotedActionCategories = 'New,Process,Report,Order,Manage';    SourceTable = "Shpfy Order Header";    UsageCategory = Lists;    AboutTitle = 'About Shopify Orders';    AboutText = 'These orders from all your connected shops are ready to become sales orders or invoices in Business Central. They''re here because you aren''t automatically creating sales documents in Business Central.';    SourceTableView = sorting("Created At") order(descending);    layout    {        area(content)        {            repeater(Group)            {                field(ShopifyOrderNo; Rec."Shopify Order No.")                {                    ApplicationArea = All;                    ToolTip = 'Specifies the order number from Shopify';                }                field(ShopCode; Rec."Shop Code")                {                    ApplicationArea = All;                    ToolTip = 'Specifies the Shopify Shop from which the order originated.';                }                field("High Risk"; Rec."High Risk")                {                    ApplicationArea = All;                    ToolTip = 'Specifies if the order is considered high risk.';                }                field(Closed; Rec.Closed)                {                    ApplicationArea = All;                    ToolTip = 'Specifies if the Shopify order is archived by D365BC.';                }                field(SellToCustomerNo; Rec."Sell-to Customer No.")                {                    ApplicationArea = All;                    ToolTip = 'Specifies the number of the customer who will buy the products and be billed by default.';                }                field(SellToCustomerName; Rec."Sell-to Customer Name")                {                    ApplicationArea = All;                    ToolTip = 'Specifies the name of the customer who will buy the products and be billed by default.';                }                field(SellToPostCode; Rec."Sell-to Post Code")                {                    ApplicationArea = All;                    Visible = false;                    ToolTip = 'Specifies the postal code of the buy address.';                }                field(SellToCountryCode; Rec."Sell-to Country/Region Code")                {                    ApplicationArea = All;                    Visible = false;                    ToolTip = 'Specifies country/region code of the buy address.';                }                field(BillToName; Rec."Bill-to Name")                {                    ApplicationArea = All;                    Visible = false;                    ToolTip = 'Specifies the name of the customer who be billed.';                }                field(BillToPostCode; Rec."Bill-to Post Code")                {                    ApplicationArea = All;                    Visible = false;                    ToolTip = 'Specifies the postal code of the billing address.';                }                field(BillToCountryCode; Rec."Bill-to Country/Region Code")                {                    ApplicationArea = All;                    Visible = false;                    ToolTip = 'Specifies the country/region code of the billing address.';                }                field(ShipToName; Rec."Ship-to Name")                {                    ApplicationArea = All;                    Visible = false;                    ToolTip = 'Specifies the name that products on the sales order are shipped to.';                }                field(ShipToPostCode; Rec."Ship-to Post Code")                {                    ApplicationArea = All;                    Visible = false;                    ToolTip = 'Specifies the ZIP code of the address that the products are shipped to.';                }                field(ShipToCountryCode; Rec."Ship-to Country/Region Code")                {                    ApplicationArea = All;                    Visible = false;                    ToolTip = 'Specifies the country/region code of the address that the items are shipped to.';                }                field(CreatedAt; Rec."Created At")                {                    ApplicationArea = All;                    ToolTip = 'Specifies the date and time when the order was created in Shopify.';                }                field(Confirmed; Rec.Confirmed)                {                    ApplicationArea = All;                    ToolTip = 'Specifies whether the order has been confirmed.';                }                field(FinancialStatus; Rec."Financial Status")                {                    ApplicationArea = All;                    ToolTip = 'Specifies the status of payments associated with the order. Valid values are: pending, authorized, partially paid, paid, partially refunded, refunded, voided.';                }                field(FulfillmentStatus; Rec."Fulfillment Status")                {                    ApplicationArea = All;                    ToolTip = 'Specifies the order''s status in terms of fulfilled line items. Valid values are: fulfilled, in progress, open, pending fulfillment, restocked, unfulfilled, partially fulfilled, on hold.';                }                field(ReturnStatus; Rec."Return Status")                {                    ApplicationArea = All;                    Visible = false;                    ToolTip = 'Specifies the status or returns assocuated with the order. Valid values are: inspection complete, in progress, no return, returned, return failed, return requested.';                }                field(TotalAmount; Rec."Total Amount")                {                    ApplicationArea = All;                    ToolTip = 'Specifies the sum of the line amounts on all lines in the document minus any discount amounts plus the shipping costs.';                }                field(AppName; Rec."App Name")                {                    ApplicationArea = All;                    ToolTip = 'Specifies the name of the app used by the channel where you sell your products. A channel can be a platform or a marketplace such as an online store or POS.';                    Visible = false;                }                field("Channel Liable Taxes"; Rec."Channel Liable Taxes")                {                    ApplicationArea = All;                    ToolTip = 'Specifies if any tax line on the order is liable to be charged by the channel.';                    Visible = false;                }                field(CancelReason; Rec."Cancel Reason")                {                    ApplicationArea = All;                    Visible = false;                    ToolTip = 'Specifies the reason why the order was cancelled. Valid values are: customer, fraud, inventory, declined, other.';                }                field(Processed; Rec.Processed)                {                    ApplicationArea = All;                    ToolTip = 'Specifies if the order is already processed.';                }                field(SalesOrderNo; Rec."Sales Order No.")                {                    ApplicationArea = All;                    Style = Favorable;                    StyleExpr = true;                    ToolTip = 'Specifies the sales order number that has been created for the Shopify Order.';                    LookupPageId = "Sales Order List";                }                field(SalesInvoiceNo; Rec."Sales Invoice No.")                {                    ApplicationArea = All;                    Style = Favorable;                    StyleExpr = true;                    ToolTip = 'Specifies the sales invoice number that has been created for the Shopify Order.';                    LookupPageId = "Sales Invoice List";                }                field("Error"; Rec."Has Error")                {                    ApplicationArea = All;                    ToolTip = 'Specifies whether there is an error when creating a sales document.';                }                field(ErrorMessage; Rec."Error Message")                {                    ApplicationArea = All;                    Style = Attention;                    StyleExpr = true;                    ToolTip = 'Specifies the error message if an error has occurred.';                }            }        }        area(factboxes)        {            part(LinkedBCDocuments; "Shpfy Linked To Documents")            {                ApplicationArea = All;                Caption = 'Linked Documents';                SubPageLink = "Shopify Document Type" = const("Shpfy Shop Document Type"::"Shopify Shop Order"), "Shopify Document Id" = field("Shopify Order Id");            }            part(OrderTotals; "Shpfy Order Totals FactBox")            {                ApplicationArea = All;                Caption = 'Order Totals';                SubPageLink = "Shopify Order Id" = field("Shopify Order Id");                Visible = (Rec."Sales Order No." <> '') or (Rec."Sales Invoice No." <> '');            }            part(CustomerStatistics; "Customer Statistics FactBox")            {                ApplicationArea = All;                SubPageLink = "No." = field("Sell-to Customer No.");            }            part(CustomerDetails; "Customer Details FactBox")            {                ApplicationArea = All;                SubPageLink = "No." = field("Sell-to Customer No.");            }            part(OrderTags; "Shpfy Tag Factbox")            {                ApplicationArea = All;                SubPageLink = "Parent Table No." = const(30118), "Parent Id" = field("Shopify Order Id");            }            part(OrderAttributes; "Shpfy Order Attributes")            {                ApplicationArea = all;                Caption = 'Order Attributes';                SubPageLink = "Order Id" = field("Shopify Order Id");            }            systempart(Links; Links)            {                ApplicationArea = All;                Visible = false;            }            systempart(Notes; Notes)            {                ApplicationArea = All;            }        }    }    actions    {        area(processing)        {            action(DeleteSelected)            {                ApplicationArea = All;                Caption = 'Delete Selected Rows';                Image = DeleteRow;                Promoted = true;                PromotedCategory = Category5;                PromotedIsBig = true;                PromotedOnly = true;                ToolTip = 'Delete the selected rows.';                trigger OnAction()                var                    OrderHeader: Record "Shpfy Order Header";                begin                    CurrPage.SetSelectionFilter(OrderHeader);                    OrderHeader.DeleteAll(true);                end;            }            action(SyncOrdersFromShopify)            {                ApplicationArea = All;                Caption = 'Sync Orders From Shopify';                Image = Import;                Promoted = true;                PromotedCategory = Process;                PromotedIsBig = true;                PromotedOnly = true;                ToolTip = 'Synchronize orders from Shopify.';                AboutTitle = 'Synchronize orders manually';                AboutText = 'If you aren''t automatically synchronizing orders from Shopify, use this action to synchronize them yourself. This imports orders from all your connected shops so that you can work with them in Business Central.';                trigger OnAction();                var                    Shop: Record "Shpfy Shop";                    BackgroundSyncs: Codeunit "Shpfy Background Syncs";                begin                    if Rec.GetFilter("Shop Code") <> '' then                        Shop.SetFilter(Code, Rec.GetFilter("Shop Code"));                    BackgroundSyncs.OrderSync(Shop);                end;            }            action(CreateSalesDocuments)            {                ApplicationArea = All;                Caption = 'Create Sales Documents';                Image = MakeOrder;                Promoted = true;                PromotedCategory = Process;                PromotedIsBig = true;                ToolTip = 'Convert the Shopify Order to a sales order or sales invoice. The sales document will contain the Shopify order number.';                trigger OnAction();                var                    ShopifyOrderHeader: Record "Shpfy Order Header";                    ProcessShopifyOrders: Codeunit "Shpfy Process Orders";                begin                    if Confirm(ConfirmLbl) then begin                        CurrPage.SetSelectionFilter(ShopifyOrderHeader);                        ProcessShopifyOrders.ProcessShopifyOrders(ShopifyOrderHeader);                        CurrPage.Update(false);                    end;                end;            }            action(SyncShipments)            {                ApplicationArea = All;                Caption = 'Sync Shipments To Shopify';                Image = Export;                Promoted = true;                PromotedCategory = Process;                PromotedIsBig = true;                ToolTip = 'Synchronize shipments to Shopify.';                trigger OnAction();                begin                    Report.Run(Report::"Shpfy Sync Shipm. to Shopify");                end;            }            action(MarkConflictAsResolved)            {                ApplicationArea = All;                Caption = 'Mark Conflict as Resolved';                Enabled = Rec."Has Order State Error";                Image = Approval;                ToolTip = 'Mark the conflict as resolved.';                trigger OnAction()                var                    ImportOrder: Codeunit "Shpfy Import Order";                begin                    ImportOrder.MarkOrderConflictAsResolved(Rec);                    Rec.Modify();                end;            }            action(ProvideFeedback)            {                ApplicationArea = All;                Caption = 'Provide Feedback';                ToolTip = 'Provide feedback on Shopify Connector.';                Image = Comment;                trigger OnAction()                var                    ShopMgt: Codeunit "Shpfy Shop Mgt.";                begin                    ShopMgt.RequestFeedback();                end;            }        }        area(navigation)        {            group(ShopifyOrder)            {                Caption = 'Shopify Order';                action(Risks)                {                    ApplicationArea = All;                    Caption = 'Risks';                    Image = Warning;                    Promoted = true;                    PromotedCategory = Category4;                    PromotedIsBig = true;                    PromotedOnly = true;                    RunObject = Page "Shpfy Order Risks";                    RunPageLink = "Order Id" = field("Shopify Order Id");                    RunPageMode = View;                    ToolTip = 'View the level and message that indicates the results of the fraud check.';                }                action(SalesOrder)                {                    ApplicationArea = All;                    Caption = 'Sales Order';                    Image = Document;                    Promoted = true;                    PromotedCategory = Category4;                    PromotedIsBig = true;                    PromotedOnly = true;                    ToolTip = 'Open the related sales order.';                    trigger OnAction();                    var                        SalesHeader: Record "Sales Header";                        SalesOrder: Page "Sales Order";                    begin                        Rec.TestField("Sales Order No.");                        SalesHeader.Get(SalesHeader."Document Type"::Order, Rec."Sales Order No.");                        SalesOrder.SetRecord(SalesHeader);                        SalesOrder.Run();                    end;                }                action(SalesInvoice)                {                    ApplicationArea = All;                    Caption = 'Sales Invoice';                    Image = Document;                    Promoted = true;                    PromotedCategory = Category4;                    PromotedIsBig = true;                    PromotedOnly = true;                    ToolTip = 'Open the related sales invoice.';                    trigger OnAction();                    var                        SalesHeader: Record "Sales Header";                        SalesOrder: Page "Sales Invoice";                    begin                        Rec.TestField("Sales Invoice No.");                        SalesHeader.Get(SalesHeader."Document Type"::Invoice, Rec."Sales Invoice No.");                        SalesOrder.SetRecord(SalesHeader);                        SalesOrder.Run();                    end;                }                action(ShopifyStatusPage)                {                    ApplicationArea = All;                    Caption = 'Shopify Status Page';                    Image = Web;                    Promoted = true;                    PromotedCategory = Category4;                    PromotedIsBig = true;                    PromotedOnly = true;                    ToolTip = 'Open the order status page from Shopify.';                    AboutTitle = 'See the order on Shopify';                    AboutText = 'Access details about order on the Shopify administration portal. For example, you can track the status of the payment.';                    trigger OnAction();                    begin                        Hyperlink(Rec."Order Status URL");                    end;                }            }        }    }    views    {        view(UnprocessedOrders)        {            Caption = 'Unprocessed Orders';            Filters = where(Processed = const(false));        }        view(OrderWithConflicts)        {            Caption = 'Orders with Conflicts';            Filters = where("Has Order State Error" = const(true));        }        view(OrderWithProcessingErrors)        {            Caption = 'Orders with Processing Errors';            Filters = where("Has Error" = const(true));        }        view(OpenOrders)        {            Caption = 'Open Orders';            Filters = where(Closed = const(false));        }    }    var        ConfirmLbl: Label 'Create sales document(s) from the selected Shopify order(s)?';}