Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/gga/shopify v2 #4

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
14 changes: 7 additions & 7 deletions Apps/W1/Shopify/app/src/Base/Pages/ShpfyShopCard.Page.al
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,6 @@ page 30101 "Shpfy Shop Card"
ToolTip = 'Specifies the date on which Business Central will no longer support Shopify Admin API version. To continue to use your integration, upgrade to the latest version of Business Central before this date.';
Editable = false;
}
field("Posted Invoice Sync"; Rec."Posted Invoice Sync")
{
ApplicationArea = All;
Importance = Additional;
ToolTip = 'Specifies whether the posted sales invoices can be synchronized to Shopify.';
}
}
group(ItemSync)
{
Expand Down Expand Up @@ -253,6 +247,7 @@ page 30101 "Shpfy Shop Card"
}
field("Items Mapped to Products"; Rec."Items Mapped to Products")
{
ApplicationArea = All;
ToolTip = 'Specifies if only the items that are mapped to Shopify products/Shopify variants are synchronized from Posted Sales Invoices to Shopify.';
}
}
Expand Down Expand Up @@ -534,6 +529,12 @@ page 30101 "Shpfy Shop Card"
ToolTip = 'Specifies whether to keep zero quantity lines in the Shopify order. If you do not select this option, zero quantity lines are removed from the Shopify order.';
Visible = false;
}
field("Posted Invoice Sync"; Rec."Posted Invoice Sync")
{
ApplicationArea = All;
Importance = Additional;
ToolTip = 'Specifies whether the posted sales invoices can be synchronized to Shopify.';
}
}
group(ReturnsAndRefunds)
{
Expand Down Expand Up @@ -1002,7 +1003,6 @@ page 30101 "Shpfy Shop Card"
ApplicationArea = All;
Caption = 'Sync Posted Sales Invoices';
Image = Export;
Enabled = Rec."Posted Invoice Sync";
Promoted = true;
PromotedCategory = Category5;
PromotedIsBig = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,24 @@ codeunit 30316 "Shpfy Posted Invoice Export"
if ShpfyShop."Default Customer No." = SalesInvoiceHeader."Bill-to Customer No." then
exit(false);

if CheckCustomerTemplates(SalesInvoiceHeader."Bill-to Customer No.") then
exit(false);

if not CheckSalesInvoiceHeaderLines(SalesInvoiceHeader) then
exit(false);

exit(true);
end;

local procedure CheckCustomerTemplates(CustomerNo: Code[20]): Boolean
var
ShpfyCustomerTemplate: Record "Shpfy Customer Template";
begin
ShpfyCustomerTemplate.SetRange("Default Customer No.", CustomerNo);
ShpfyCustomerTemplate.SetRange("Shop Code", ShpfyShop.Code);
exit(not ShpfyCustomerTemplate.IsEmpty());
end;

local procedure CheckSalesInvoiceHeaderLines(SalesInvoiceHeader: Record "Sales Invoice Header"): Boolean
var
SalesInvoiceLine: Record "Sales Invoice Line";
Expand Down Expand Up @@ -247,7 +259,7 @@ codeunit 30316 "Shpfy Posted Invoice Export"
var
ShpfyCustomer: Record "Shpfy Customer";
begin
TempShpfyOrderHeader."Bill-to Name" := Format(SalesInvoiceHeader."Bill-to Name");
TempShpfyOrderHeader."Bill-to Name" := CopyStr(SalesInvoiceHeader."Bill-to Name", 1, MaxStrLen(TempShpfyOrderHeader."Bill-to Name"));
TempShpfyOrderHeader."Bill-to Name 2" := SalesInvoiceHeader."Bill-to Name 2";
TempShpfyOrderHeader."Bill-to Address" := SalesInvoiceHeader."Bill-to Address";
TempShpfyOrderHeader."Bill-to Address 2" := SalesInvoiceHeader."Bill-to Address 2";
Expand All @@ -259,7 +271,7 @@ codeunit 30316 "Shpfy Posted Invoice Export"

ShpfyCustomer.SetRange("Customer No.", SalesInvoiceHeader."Bill-to Customer No.");
if ShpfyCustomer.FindFirst() then begin
TempShpfyOrderHeader.Email := Format(ShpfyCustomer.Email);
TempShpfyOrderHeader.Email := CopyStr(ShpfyCustomer.Email, 1, MaxStrLen(TempShpfyOrderHeader.Email));
TempShpfyOrderHeader."Phone No." := ShpfyCustomer."Phone No.";
end;
end;
Expand All @@ -269,7 +281,7 @@ codeunit 30316 "Shpfy Posted Invoice Export"
SalesInvoiceHeader: Record "Sales Invoice Header"
)
begin
TempShpfyOrderHeader."Ship-to Name" := Format(SalesInvoiceHeader."Ship-to Name");
TempShpfyOrderHeader."Ship-to Name" := CopyStr(SalesInvoiceHeader."Ship-to Name", 1, MaxStrLen(TempShpfyOrderHeader."Ship-to Name"));
TempShpfyOrderHeader."Ship-to Name 2" := SalesInvoiceHeader."Ship-to Name 2";
TempShpfyOrderHeader."Ship-to Address" := SalesInvoiceHeader."Ship-to Address";
TempShpfyOrderHeader."Ship-to Address 2" := SalesInvoiceHeader."Ship-to Address 2";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ report 30117 "Shpfy Sync Invoices to Shpfy"
trigger OnPreDataItem()
var
ShopCodeNotSetErr: Label 'Shopify Shop Code is empty.';
PostedInvoiceSyncNotSetErr: Label 'Posted Invoice Sync is not enabled for this shop.';
begin
if ShopCode = '' then
Error(ShopCodeNotSetErr);

if not ShpfyShop."Posted Invoice Sync" then
Error(PostedInvoiceSyncNotSetErr);

ShpfyPostedInvoiceExport.SetShop(ShopCode);
SetRange("Shpfy Order Id", 0);

Expand Down Expand Up @@ -81,6 +85,7 @@ report 30117 "Shpfy Sync Invoices to Shpfy"
}

var
ShpfyShop: Record "Shpfy Shop";
ShpfyPostedInvoiceExport: Codeunit "Shpfy Posted Invoice Export";
ShopCode: Code[20];
CurrSalesInvoiceHeaderNo: Code[20];
Expand All @@ -94,5 +99,6 @@ report 30117 "Shpfy Sync Invoices to Shpfy"
internal procedure SetShop(NewShopCode: Code[20])
begin
ShopCode := NewShopCode;
ShpfyShop.Get(ShopCode);
end;
}