Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ codeunit 30286 "Shpfy Company API"
UpdateCompanyLocationPaymentTerms(CompanyLocation)
end;

internal procedure SetShop(ShopifyShop: Record "Shpfy Shop")
internal procedure SetShop(Shop: Record "Shpfy Shop")
begin
this.Shop := ShopifyShop;
CommunicationMgt.SetShop(ShopifyShop);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

namespace Microsoft.Integration.Shopify;

using Microsoft.Sales.Customer;

/// <summary>
/// Page Shpfy Company Locations (ID 30165).
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
namespace Microsoft.Integration.Shopify;

using Microsoft.Integration.Shopify;
using Microsoft.Sales.Customer;

/// <summary>
/// A report to add customers as locations to a parent company.
/// </summary>
report 30121 "Shpfy Add Cust. as Locations"
{
ApplicationArea = All;
Caption = 'Add Customer as Shopify Location';
ProcessingOnly = true;
UsageCategory = Administration;

dataset
{
dataitem(Customer; Customer)
{
RequestFilterFields = "No.";
trigger OnPreDataItem()
begin
if IsNullGuid(ShopifyCompany.SystemId) then
Error(MissingCompanyErr);

Clear(CompanyAPI);
CompanyAPI.SetCompany(ShopifyCompany);
CompanyAPI.SetShop(Shop);

if GuiAllowed then begin
CurrCustomerNo := Customer."No.";
ProcessDialog.Open(ProcessMsg, CurrCustomerNo);
ProcessDialog.Update();
end;
end;

trigger OnAfterGetRecord()
begin
if GuiAllowed then begin
CurrCustomerNo := Customer."No.";
ProcessDialog.Update();
end;

CompanyAPI.CreateCompanyLocation(Customer);
end;

trigger OnPostDataItem()
begin
if GuiAllowed then
ProcessDialog.Close();
end;
}
}

requestpage
{
SaveValues = true;
layout
{
area(Content)
{
group(CompanyFilter)
{
Caption = 'Options';
field(Shop; Shop.Code)
{
ApplicationArea = All;
Caption = 'Shop Code';
Editable = false;
ToolTip = 'Specifies the Shopify Shop.';
ShowMandatory = true;
}
field(ParentCompanyName; CompanyName)
{
ApplicationArea = All;
Caption = 'Parent Company Name';
ToolTip = 'Specifies the parent company to which the customers will be added as locations.';
Editable = false;
ShowMandatory = true;
}
}
}
}
}

var
ShopifyCompany: Record "Shpfy Company";
Shop: Record "Shpfy Shop";
CompanyAPI: Codeunit "Shpfy Company API";
CompanyName: Text[100];
CurrCustomerNo: Code[20];
ProcessDialog: Dialog;
ProcessMsg: Label 'Adding customer #1####################', Comment = '#1 = Customer no.';
MissingCompanyErr: Label 'You must select a parent company to add the customers as locations to.';

/// <summary>
/// Sets the parent company to which customers will be added as locations.
/// </summary>
/// <param name="CompanySystemId">The parent company system ID.</param>
internal procedure SetParentCompany(CompanySystemId: Guid)
begin
this.ShopifyCompany.GetBySystemId(CompanySystemId);
this.Shop.Get(ShopifyCompany."Shop Code");
this.CompanyName := ShopifyCompany.Name;
end;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace Microsoft.Integration.Shopify;

/// <summary>
/// Codeunit Shpfy GQL CreateCompanyLocation (ID 30105) implements Interface Shpfy IGraphQL.
/// </summary>
codeunit 30105 "Shpfy GQL CreateCompLocation" implements "Shpfy IGraphQL"
{
Access = Internal;

/// <summary>
/// GetGraphQL.
/// </summary>
/// <returns>Return value of type Text.</returns>
internal procedure GetGraphQL(): Text
begin
exit('{"query": "mutation { companyLocationCreate( companyId: \"gid://shopify/Company/{{CompanyId}}\" input: { externalId: \"{{ExternalId}}\" name: \"{{Name}}\" phone: \"{{Phone}}\" taxExempt: {{TaxExempt}} taxRegistrationId: \"{{TaxRegistrationId}}\" billingAddress: { address1: \"{{BillingAddress1}}\" address2: \"{{BillingAddress2}}\" city: \"{{BillingCity}}\" countryCode: {{BillingCountryCode}} firstName: \"{{BillingFirstName}}\" lastName: \"{{BillingLastName}}\" phone: \"{{BillingPhone}}\" zoneCode: \"{{BillingZoneCode}}\" zip: \"{{BillingZip}}\" } shippingAddress: { address1: \"{{ShippingAddress1}}\" address2: \"{{ShippingAddress2}}\" city: \"{{ShippingCity}}\" countryCode: {{ShippingCountryCode}} firstName: \"{{ShippingFirstName}}\" lastName: \"{{ShippingLastName}}\" phone: \"{{ShippingPhone}}\" zoneCode: \"{{ShippingZoneCode}}\" zip: \"{{ShippingZip}}\" } billingSameAsShipping: {{BillingSameAsShipping}} buyerExperienceConfiguration: { checkoutToDraft: {{CheckoutToDraft}} paymentTermsTemplateId: \"gid://shopify/PaymentTermsTemplate/{{PaymentTermsTemplateId}}\" editableShippingAddress: {{EditableShippingAddress}} } } ) { companyLocation { id name billingAddress { address1 address2 city countryCode phone province recipient zip zoneCode } shippingAddress { address1 address2 city countryCode phone province recipient zip zoneCode } buyerExperienceConfiguration { paymentTermsTemplate { id } checkoutToDraft editableShippingAddress } taxRegistrationId taxExemptions } userErrors { field message } } }"}');
end;

/// <summary>
/// GetExpectedCost.
/// </summary>
/// <returns>Return value of type Integer.</returns>
internal procedure GetExpectedCost(): Integer
begin
exit(15);
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ permissionset 30104 "Shpfy - Objects"
codeunit "Shpfy GQL CompanyMetafieldIds" = X,
codeunit "Shpfy GQL CompLocations" = X,
codeunit "Shpfy GQL CreateCatalog" = X,
codeunit "Shpfy GQL CreateCompLocation" = X,
codeunit "Shpfy GQL CreateCompLocTaxId" = X,
codeunit "Shpfy GQL CreateFulfillmentSvc" = X,
codeunit "Shpfy GQL CreatePriceList" = X,
Expand Down
Loading