Skip to content

Commit

Permalink
PR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
petemchlk committed Oct 28, 2024
1 parent 506f35a commit 958bdbe
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 72 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Microsoft.Integration.Shopify;

using Microsoft.Integration.Shopify;
using Microsoft.Sales.Customer;
using Microsoft.Foundation.Company;
using Microsoft.Foundation.Address;
Expand Down Expand Up @@ -37,7 +36,7 @@ codeunit 30284 "Shpfy Company Export"
Shop: Record "Shpfy Shop";
CompanyAPI: Codeunit "Shpfy Company API";
CatalogAPI: Codeunit "Shpfy Catalog API";
ShpfySkipRecord: Codeunit "Shpfy Skip Record";
SkippedRecord: Codeunit "Shpfy Skipped Record";
CreateCustomers: Boolean;
CountyCodeTooLongLbl: Label 'Can not export customer %1 %2. The length of the string is %3, but it must be less than or equal to %4 characters. Value: %5, field: %6', Comment = '%1 - Customer No., %2 - Customer Name, %3 - Length, %4 - Max Length, %5 - Value, %6 - Field Name';

Expand All @@ -49,7 +48,7 @@ codeunit 30284 "Shpfy Company Export"
EmptyEmailAddressLbl: Label 'Customer (Company) has no e-mail address.';
begin
if Customer."E-Mail" = '' then begin
ShpfySkipRecord.LogSkippedRecord(Customer.RecordId, 'Customer does not have an email address.', Shop);
SkippedRecord.LogSkippedRecord(Customer.RecordId, EmptyEmailAddressLbl, Shop);
exit;
end;

Expand Down Expand Up @@ -189,7 +188,7 @@ codeunit 30284 "Shpfy Company Export"
begin
ShopifyCompany.Get(CompanyId);
if ShopifyCompany."Customer SystemId" <> Customer.SystemId then begin
ShpfySkipRecord.LogSkippedRecord(ShopifyCompany.Id, Customer.RecordId, CompanyWithPhoneNoOrEmailExistsLbl, Shop);
SkippedRecord.LogSkippedRecord(ShopifyCompany.Id, Customer.RecordId, CompanyWithPhoneNoOrEmailExistsLbl, Shop);
exit;
end;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ codeunit 30116 "Shpfy Customer Export"
var
Shop: Record "Shpfy Shop";
CustomerApi: Codeunit "Shpfy Customer API";
ShopifySkipRecord: Codeunit "Shpfy Skip Record";
SkippedRecord: Codeunit "Shpfy Skipped Record";
CreateCustomers: Boolean;
CountyCodeTooLongLbl: Label 'Can not export customer %1 %2. The length of the string is %3, but it must be less than or equal to %4 characters. Value: %5, field: %6', Comment = '%1 - Customer No., %2 - Customer Name, %3 - Length, %4 - Max Length, %5 - Value, %6 - Field Name';

Expand Down Expand Up @@ -91,7 +91,7 @@ codeunit 30116 "Shpfy Customer Export"
EmptyEmailAddressLbl: Label 'Customer has no e-mail address.';
begin
if Customer."E-Mail" = '' then begin
ShopifySkipRecord.LogSkippedRecord(Customer.RecordId, EmptyEmailAddressLbl, Shop);
SkippedRecord.LogSkippedRecord(Customer.RecordId, EmptyEmailAddressLbl, Shop);
exit;
end;

Expand Down Expand Up @@ -304,7 +304,7 @@ codeunit 30116 "Shpfy Customer Export"
begin
ShopifyCustomer.Get(CustomerID);
if ShopifyCustomer."Customer SystemId" <> Customer.SystemId then begin
ShopifySkipRecord.LogSkippedRecord(ShopifyCustomer.Id, Customer.RecordId, CustomerWithPhoneNoOrEmailExistsLbl, Shop);
SkippedRecord.LogSkippedRecord(ShopifyCustomer.Id, Customer.RecordId, CustomerWithPhoneNoOrEmailExistsLbl, Shop);
exit; // An other customer with the same e-mail or phone is the source of it.
end;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ codeunit 30362 "Shpfy Posted Invoice Export"
DraftOrdersAPI: Codeunit "Shpfy Draft Orders API";
FulfillmentAPI: Codeunit "Shpfy Fulfillment API";
JsonHelper: Codeunit "Shpfy Json Helper";
SkipRecordMgt: Codeunit "Shpfy Skip Record";
SkippedRecord: Codeunit "Shpfy Skipped Record";

trigger OnRun()
begin
Expand Down Expand Up @@ -102,23 +102,23 @@ codeunit 30362 "Shpfy Posted Invoice Export"
if ShopifyCompany.IsEmpty() then begin
ShopifyCustomer.SetRange("Customer No.", SalesInvoiceHeader."Bill-to Customer No.");
if ShopifyCustomer.IsEmpty() then begin
SkipRecordMgt.LogSkippedRecord(SalesInvoiceHeader.RecordId, CustomerNotExistInShopifyLbl, Shop);
SkippedRecord.LogSkippedRecord(SalesInvoiceHeader.RecordId, CustomerNotExistInShopifyLbl, Shop);
exit(false);
end;
end;

if not ShopifyPaymentTermsExists(SalesInvoiceHeader."Payment Terms Code") then begin
SkipRecordMgt.LogSkippedRecord(SalesInvoiceHeader.RecordId, StrSubstNo(PaymentTermsNotExistLbl, SalesInvoiceHeader."Payment Terms Code"), Shop);
SkippedRecord.LogSkippedRecord(SalesInvoiceHeader.RecordId, StrSubstNo(PaymentTermsNotExistLbl, SalesInvoiceHeader."Payment Terms Code"), Shop);
exit(false);
end;

if Shop."Default Customer No." = SalesInvoiceHeader."Bill-to Customer No." then begin
SkipRecordMgt.LogSkippedRecord(SalesInvoiceHeader.RecordId, CustomerNoIsDefaultCustomerNoLbl, Shop);
SkippedRecord.LogSkippedRecord(SalesInvoiceHeader.RecordId, CustomerNoIsDefaultCustomerNoLbl, Shop);
exit(false);
end;

if CheckCustomerTemplates(SalesInvoiceHeader."Bill-to Customer No.") then begin
SkipRecordMgt.LogSkippedRecord(SalesInvoiceHeader.RecordId, StrSubstNo(CustomerTemplateExistsLbl, SalesInvoiceHeader."Bill-to Customer No.", Shop.Code), Shop);
SkippedRecord.LogSkippedRecord(SalesInvoiceHeader.RecordId, StrSubstNo(CustomerTemplateExistsLbl, SalesInvoiceHeader."Bill-to Customer No.", Shop.Code), Shop);
exit(false);
end;

Expand Down Expand Up @@ -165,7 +165,7 @@ codeunit 30362 "Shpfy Posted Invoice Export"
SalesInvoiceLine.SetRange("Document No.", SalesInvoiceHeader."No.");
SalesInvoiceLine.SetFilter(Type, '<>%1', SalesInvoiceLine.Type::" ");
if SalesInvoiceLine.IsEmpty() then begin
SkipRecordMgt.LogSkippedRecord(SalesInvoiceHeader.RecordId, NoLinesInSalesInvoiceLbl, Shop);
SkippedRecord.LogSkippedRecord(SalesInvoiceHeader.RecordId, NoLinesInSalesInvoiceLbl, Shop);
exit(false);
end;

Expand All @@ -176,12 +176,12 @@ codeunit 30362 "Shpfy Posted Invoice Export"
if SalesInvoiceLine.FindSet() then
repeat
if (SalesInvoiceLine.Quantity <> 0) and (SalesInvoiceLine.Quantity <> Round(SalesInvoiceLine.Quantity, 1)) then begin
SkipRecordMgt.LogSkippedRecord(SalesInvoiceLine.RecordId, InvalidQuantityLbl, Shop);
SkippedRecord.LogSkippedRecord(SalesInvoiceLine.RecordId, InvalidQuantityLbl, Shop);
exit(false);
end;

if (SalesInvoiceLine.Type <> SalesInvoiceLine.Type::" ") and (SalesInvoiceLine."No." = '') then begin
SkipRecordMgt.LogSkippedRecord(SalesInvoiceLine.RecordId, EmptyNoInLineLbl, Shop);
SkippedRecord.LogSkippedRecord(SalesInvoiceLine.RecordId, EmptyNoInLineLbl, Shop);
exit(false);
end;
until SalesInvoiceLine.Next() = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace Microsoft.Integration.Shopify;
/// <summary>
/// Codeunit Shpfy Skip Record (ID 30313).
/// </summary>
codeunit 30313 "Shpfy Skip Record"
codeunit 30313 "Shpfy Skipped Record"
{
Access = Internal;
Permissions = tabledata "Shpfy Skipped Record" = rimd;
Expand All @@ -18,16 +18,16 @@ codeunit 30313 "Shpfy Skip Record"
/// <param name="Shop">Shop record.</param>
internal procedure LogSkippedRecord(ShopifyId: BigInteger; RecordId: RecordID; SkippedReason: Text[250]; Shop: Record "Shpfy Shop")
var
ShpfySkippedRecord: Record "Shpfy Skipped Record";
SkippedRecord: Record "Shpfy Skipped Record";
begin
if Shop."Logging Mode" = Enum::"Shpfy Logging Mode"::Disabled then
exit;
ShpfySkippedRecord.Init();
ShpfySkippedRecord.Validate("Shopify Id", ShopifyId);
ShpfySkippedRecord.Validate("Table ID", RecordId.TableNo());
ShpfySkippedRecord.Validate("Record ID", RecordId);
ShpfySkippedRecord.Validate("Skipped Reason", SkippedReason);
ShpfySkippedRecord.Insert(true);
SkippedRecord.Init();
SkippedRecord.Validate("Shopify Id", ShopifyId);
SkippedRecord.Validate("Table ID", RecordId.TableNo());
SkippedRecord.Validate("Record ID", RecordId);
SkippedRecord.Validate("Skipped Reason", SkippedReason);
SkippedRecord.Insert(true);
end;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ page 30166 "Shpfy Skipped Records"
ApplicationArea = All;
Caption = 'Delete Entries Older Than 7 Days';
Image = ClearLog;
ToolTip = 'Clear the list of log entries that are older than 7 days.';
ToolTip = 'Clear the list of skipped records that are older than 7 days.';

trigger OnAction();
begin
Expand All @@ -83,7 +83,7 @@ page 30166 "Shpfy Skipped Records"
ApplicationArea = All;
Caption = 'Delete All Entries';
Image = Delete;
ToolTip = 'Clear the list of all log entries.';
ToolTip = 'Clear the list of all skipped records.';

trigger OnAction();
begin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ codeunit 30178 "Shpfy Product Export"
ProductEvents: Codeunit "Shpfy Product Events";
ProductPriceCalc: Codeunit "Shpfy Product Price Calc.";
VariantApi: Codeunit "Shpfy Variant API";
ShopifySkipRecord: Codeunit "Shpfy Skip Record";
SkippedRecord: Codeunit "Shpfy Skipped Record";
OnlyUpdatePrice: Boolean;
RecordCount: Integer;
NullGuid: Guid;
Expand Down Expand Up @@ -321,7 +321,7 @@ codeunit 30178 "Shpfy Product Export"
if (not Item.Blocked) and (not Item."Sales Blocked") then
ProductPriceCalc.CalcPrice(Item, '', ItemUnitofMeasure.Code, ShopifyVariant."Unit Cost", ShopifyVariant.Price, ShopifyVariant."Compare at Price")
else
ShopifySkipRecord.LogSkippedRecord(ShopifyVariant.Id, Item.RecordId, VariantPriceCalcSkippedLbl, Shop);
SkippedRecord.LogSkippedRecord(ShopifyVariant.Id, Item.RecordId, VariantPriceCalcSkippedLbl, Shop);
if not OnlyUpdatePrice then begin
ShopifyVariant."Available For Sales" := (not Item.Blocked) and (not Item."Sales Blocked");
ShopifyVariant.Barcode := CopyStr(GetBarcode(Item."No.", '', ItemUnitofMeasure.Code), 1, MaxStrLen(ShopifyVariant.Barcode));
Expand Down Expand Up @@ -358,7 +358,7 @@ codeunit 30178 "Shpfy Product Export"
if (not Item.Blocked) and (not Item."Sales Blocked") then
ProductPriceCalc.CalcPrice(Item, ItemVariant.Code, Item."Sales Unit of Measure", ShopifyVariant."Unit Cost", ShopifyVariant.Price, ShopifyVariant."Compare at Price")
else
ShopifySkipRecord.LogSkippedRecord(ShopifyVariant.Id, Item.RecordId, VariantPriceCalcSkippedLbl, Shop);
SkippedRecord.LogSkippedRecord(ShopifyVariant.Id, Item.RecordId, VariantPriceCalcSkippedLbl, Shop);
if not OnlyUpdatePrice then begin
ShopifyVariant."Available For Sales" := (not Item.Blocked) and (not Item."Sales Blocked");
ShopifyVariant.Barcode := CopyStr(GetBarcode(Item."No.", ItemVariant.Code, Item."Sales Unit of Measure"), 1, MaxStrLen(ShopifyVariant.Barcode));
Expand Down Expand Up @@ -405,7 +405,7 @@ codeunit 30178 "Shpfy Product Export"
if (not Item.Blocked) and (not Item."Sales Blocked") then
ProductPriceCalc.CalcPrice(Item, ItemVariant.Code, ItemUnitofMeasure.Code, ShopifyVariant."Unit Cost", ShopifyVariant.Price, ShopifyVariant."Compare at Price")
else
ShopifySkipRecord.LogSkippedRecord(ShopifyVariant.Id, Item.RecordId, VariantPriceCalcSkippedLbl, Shop);
SkippedRecord.LogSkippedRecord(ShopifyVariant.Id, Item.RecordId, VariantPriceCalcSkippedLbl, Shop);
if not OnlyUpdatePrice then begin
ShopifyVariant."Available For Sales" := (not Item.Blocked) and (not Item."Sales Blocked");
ShopifyVariant.Barcode := CopyStr(GetBarcode(Item."No.", ItemVariant.Code, ItemUnitofMeasure.Code), 1, MaxStrLen(ShopifyVariant.Barcode));
Expand Down Expand Up @@ -560,17 +560,17 @@ codeunit 30178 "Shpfy Product Export"
case Shop."Action for Removed Products" of
Shop."Action for Removed Products"::StatusToArchived:
if Item.Blocked and (ShopifyProduct.Status = ShopifyProduct.Status::Archived) then begin
ShopifySkipRecord.LogSkippedRecord(ShopifyProduct.Id, Item.RecordId, ItemIsArchivedLbl, Shop);
SkippedRecord.LogSkippedRecord(ShopifyProduct.Id, Item.RecordId, ItemIsArchivedLbl, Shop);
exit;
end;
Shop."Action for Removed Products"::StatusToDraft:
if Item.Blocked and (ShopifyProduct.Status = ShopifyProduct.Status::Draft) then begin
ShopifySkipRecord.LogSkippedRecord(ShopifyProduct.Id, Item.RecordId, ItemIsDraftLbl, Shop);
SkippedRecord.LogSkippedRecord(ShopifyProduct.Id, Item.RecordId, ItemIsDraftLbl, Shop);
exit;
end;
Shop."Action for Removed Products"::DoNothing:
if Item.Blocked then begin
ShopifySkipRecord.LogSkippedRecord(ShopifyProduct.Id, Item.RecordId, ItemIsBlockedLbl, Shop);
SkippedRecord.LogSkippedRecord(ShopifyProduct.Id, Item.RecordId, ItemIsBlockedLbl, Shop);
exit;
end;
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ codeunit 30190 "Shpfy Export Shipments"
ShopifyOrderHeader: Record "Shpfy Order Header";
OrderFulfillments: Codeunit "Shpfy Order Fulfillments";
JsonHelper: Codeunit "Shpfy Json Helper";
SkipRecordMgt: Codeunit "Shpfy Skip Record";
SkippedRecord: Codeunit "Shpfy Skipped Record";
JFulfillment: JsonToken;
JResponse: JsonToken;
FulfillmentOrderRequest: Text;
NoCorespondingFulfilmentLinesLbl: Label 'No corresponding fulfillment lines found.';
NoFullfilmentCreatedInShopifyLbl: Label 'Fullfilment was not created in Shopify.';
NoCorrespondingFulfillmentLinesLbl: Label 'No corresponding fulfillment lines found.';
NoFulfillmentCreatedInShopifyLbl: Label 'Fulfillment was not created in Shopify.';
begin
if ShopifyOrderHeader.Get(SalesShipmentHeader."Shpfy Order Id") then begin
ShopifyCommunicationMgt.SetShop(ShopifyOrderHeader."Shop Code");
Expand All @@ -57,11 +57,11 @@ codeunit 30190 "Shpfy Export Shipments"
if (JFulfillment.IsObject) then
SalesShipmentHeader."Shpfy Fulfillment Id" := OrderFulfillments.ImportFulfillment(SalesShipmentHeader."Shpfy Order Id", JFulfillment)
else begin
SkipRecordMgt.LogSkippedRecord(SalesShipmentHeader."Shpfy Order Id", SalesShipmentHeader.RecordId, NoFullfilmentCreatedInShopifyLbl, Shop);
SkippedRecord.LogSkippedRecord(SalesShipmentHeader."Shpfy Order Id", SalesShipmentHeader.RecordId, NoFulfillmentCreatedInShopifyLbl, Shop);
SalesShipmentHeader."Shpfy Fulfillment Id" := -1;
end;
end else begin
SkipRecordMgt.LogSkippedRecord(SalesShipmentHeader."Shpfy Order Id", SalesShipmentHeader.RecordId, NoCorespondingFulfilmentLinesLbl, Shop);
SkippedRecord.LogSkippedRecord(SalesShipmentHeader."Shpfy Order Id", SalesShipmentHeader.RecordId, NoCorrespondingFulfillmentLinesLbl, Shop);
SalesShipmentHeader."Shpfy Fulfillment Id" := -1;
end;
SalesShipmentHeader.Modify(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ report 30109 "Shpfy Sync Shipm. to Shopify"
ShopifyOrderHeader: Record "Shpfy Order Header";
ShipmentLine: Record "Sales Shipment Line";
Shop: Record "Shpfy Shop";
SkipRecordMgt: Codeunit "Shpfy Skip Record";
SkippedRecord: Codeunit "Shpfy Skipped Record";
NoLinesApplicableLbl: Label 'No lines applicable for fulfillment.';
ShopifyOrderNotExistsLbl: Label 'Shopify order %1 does not exist.', Comment = '%1 = Shopify Order Id';
begin
ShipmentLine.SetRange("Document No.", "No.");
ShipmentLine.SetRange(Type, ShipmentLine.Type::"Item");
ShipmentLine.SetFilter(Quantity, '>0');
if ShipmentLine.IsEmpty() then begin
SkipRecordMgt.LogSkippedRecord("Sales Shipment Header"."Shpfy Order Id", "Sales Shipment Header".RecordId, NoLinesApplicableLbl, Shop);
SkippedRecord.LogSkippedRecord("Sales Shipment Header"."Shpfy Order Id", "Sales Shipment Header".RecordId, NoLinesApplicableLbl, Shop);
"Shpfy Fulfillment Id" := -2;
Modify();
end else
Expand All @@ -48,7 +48,7 @@ report 30109 "Shpfy Sync Shipm. to Shopify"
FulfillmentOrdersAPI.GetShopifyFulfillmentOrdersFromShopifyOrder(Shop, "Sales Shipment Header"."Shpfy Order Id");
ExportShipments.CreateShopifyFulfillment("Sales Shipment Header");
end else
SkipRecordMgt.LogSkippedRecord("Sales Shipment Header"."Shpfy Order Id", "Sales Shipment Header".RecordId, StrSubstNo(ShopifyOrderNotExistsLbl, "Sales Shipment Header"."Shpfy Order Id"), Shop);
SkippedRecord.LogSkippedRecord("Sales Shipment Header"."Shpfy Order Id", "Sales Shipment Header".RecordId, StrSubstNo(ShopifyOrderNotExistsLbl, "Sales Shipment Header"."Shpfy Order Id"), Shop);
end;
}
}
Expand Down
Loading

0 comments on commit 958bdbe

Please sign in to comment.