Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ codeunit 30161 "Shpfy Import Order"
var
OrderLine: Record "Shpfy Order Line";
DataCapture: Record "Shpfy Data Capture";
OrderTaxLine: Record "Shpfy Order Tax Line";
Hash: Codeunit "Shpfy Hash";
JOrderLine: JsonToken;
LineIds: Text;
Expand All @@ -172,7 +173,7 @@ codeunit 30161 "Shpfy Import Order"
OrderLine.Copy(TempOrderLine);
UpdateLocationIdAndDeliveryMethodOnOrderLine(OrderLine);
OrderLine.Insert();
AddTaxLines(OrderLine."Line Id", JsonHelper.GetJsonArray(JOrderLine, 'taxLines'));
OrderTaxLine.ImportFromJson(OrderLine."Line Id", JsonHelper.GetJsonArray(JOrderLine, 'taxLines'));
ImportCustomAttributtes(OrderLine."Shopify Order Id", OrderLine.SystemId, JsonHelper.GetJsonArray(JOrderLine, 'customAttributes'));
end;
DataCapture.Add(Database::"Shpfy Order Line", OrderLine.SystemId, Format(JOrderLine));
Expand Down Expand Up @@ -268,14 +269,15 @@ codeunit 30161 "Shpfy Import Order"

local procedure SetAndCreateRelatedRecords(JOrder: JsonObject; var OrderHeader: Record "Shpfy Order Header")
var
OrderTaxLine: Record "Shpfy Order Tax Line";
FulfillmentOrdersAPI: Codeunit "Shpfy Fulfillment Orders API";
ShippingCharges: Codeunit "Shpfy Shipping Charges";
Transactions: Codeunit "Shpfy Transactions";
ReturnsAPI: Codeunit "Shpfy Returns API";
RefundsAPI: Codeunit "Shpfy Refunds API";
IReturnRefundProcess: Interface "Shpfy IReturnRefund Process";
begin
AddTaxLines(OrderHeader."Shopify Order Id", JsonHelper.GetJsonArray(JOrder, 'taxLines'));
OrderTaxLine.ImportFromJson(OrderHeader."Shopify Order Id", JsonHelper.GetJsonArray(JOrder, 'taxLines'));
OrderHeader.SetWorkDescription(JsonHelper.GetValueAsText(JOrder, 'note'));
ImportCustomAttributtes(OrderHeader."Shopify Order Id", JsonHelper.GetJsonArray(JOrder, 'customAttributes'));
OrderHeader.UpdateTags(JsonHelper.GetArrayAsText(JOrder, 'tags'));
Expand Down Expand Up @@ -794,35 +796,6 @@ codeunit 30161 "Shpfy Import Order"
OrderHeaderRecordRef.Field(OrderHeader.FieldNo("Salesperson Code")).Value := StaffMember."Salesperson Code";
end;

/// <summary>
/// Add Tax Lines.
/// </summary>
/// <param name="ParentId">Parameter of type BigInteger.</param>
/// <param name="JTaxLines">Parameter of type JsonArray.</param>
local procedure AddTaxLines(ParentId: BigInteger; JTaxLines: JsonArray)
var
OrderTaxLine: Record "Shpfy Order Tax Line";
RecordRef: RecordRef;
JToken: JsonToken;
begin
OrderTaxLine.SetRange("Parent Id", ParentId);
if not OrderTaxLine.IsEmpty() then
OrderTaxLine.DeleteAll();
foreach JToken in JTaxLines do begin
RecordRef.Open(Database::"Shpfy Order Tax Line");
RecordRef.Init();
RecordRef.Field(OrderTaxLine.FieldNo("Parent Id")).Value := ParentId;
JsonHelper.GetValueIntoField(JToken, 'title', RecordRef, OrderTaxLine.FieldNo(Title));
JsonHelper.GetValueIntoField(JToken, 'rate', RecordRef, OrderTaxLine.FieldNo(Rate));
JsonHelper.GetValueIntoField(JToken, 'ratePercentage', RecordRef, OrderTaxLine.FieldNo("Rate %"));
JsonHelper.GetValueIntoField(JToken, 'priceSet.shopMoney.amount', RecordRef, OrderTaxLine.FieldNo(Amount));
JsonHelper.GetValueIntoField(JToken, 'priceSet.presentmentMoney.amount', RecordRef, OrderTaxLine.FieldNo("Presentment Amount"));
JsonHelper.GetValueIntoField(JToken, 'channelLiable', RecordRef, OrderTaxLine.FieldNo("Channel Liable"));
RecordRef.Insert(true);
RecordRef.Close();
end;
end;

/// <summary>
/// Description for GetName.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,19 @@ page 30168 "Shpfy Order Tax Lines"
var
OrderHeader: Record "Shpfy Order Header";
OrderLine: Record "Shpfy Order Line";
OrderShippingCharges: Record "Shpfy Order Shipping Charges";
begin
OrderLine.SetRange("Line Id", Rec."Parent Id");
if not OrderLine.FindFirst() then
exit;
if not OrderHeader.Get(OrderLine."Shopify Order Id") then
exit;
if OrderLine.FindFirst() then begin
if not OrderHeader.Get(OrderLine."Shopify Order Id") then
exit;
end else
if OrderShippingCharges.Get(Rec."Parent Id") then begin
if not OrderHeader.Get(OrderShippingCharges."Shopify Order Id") then
exit;
end else
if not OrderHeader.Get(Rec."Parent Id") then
exit;

PresentmentCurrencyVisible := OrderHeader.IsPresentmentCurrencyOrder();
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,64 @@ table 30122 "Shpfy Order Tax Line"
end;
end;

internal procedure ImportFromJson(ParentId: BigInteger; JTaxLines: JsonArray)
var
OrderTaxLine: Record "Shpfy Order Tax Line";
JsonHelper: Codeunit "Shpfy Json Helper";
RecordRef: RecordRef;
JToken: JsonToken;
begin
OrderTaxLine.SetRange("Parent Id", ParentId);
if not OrderTaxLine.IsEmpty() then
OrderTaxLine.DeleteAll(false);
foreach JToken in JTaxLines do begin
RecordRef.Open(Database::"Shpfy Order Tax Line");
RecordRef.Init();
RecordRef.Field(OrderTaxLine.FieldNo("Parent Id")).Value := ParentId;
JsonHelper.GetValueIntoField(JToken, 'title', RecordRef, OrderTaxLine.FieldNo(Title));
JsonHelper.GetValueIntoField(JToken, 'rate', RecordRef, OrderTaxLine.FieldNo(Rate));
JsonHelper.GetValueIntoField(JToken, 'ratePercentage', RecordRef, OrderTaxLine.FieldNo("Rate %"));
JsonHelper.GetValueIntoField(JToken, 'priceSet.shopMoney.amount', RecordRef, OrderTaxLine.FieldNo(Amount));
JsonHelper.GetValueIntoField(JToken, 'priceSet.presentmentMoney.amount', RecordRef, OrderTaxLine.FieldNo("Presentment Amount"));
JsonHelper.GetValueIntoField(JToken, 'channelLiable', RecordRef, OrderTaxLine.FieldNo("Channel Liable"));
RecordRef.Insert(true);
RecordRef.Close();
end;
end;

local procedure OrderCurrencyCode(): Code[10]
var
OrderHeader: Record "Shpfy Order Header";
OrderLine: Record "Shpfy Order Line";
OrderShippingCharges: Record "Shpfy Order Shipping Charges";
begin
if OrderLine.Get("Parent Id") then
if OrderLine.Get("Parent Id") then begin
if OrderHeader.Get(OrderLine."Shopify Order Id") then
exit(OrderHeader."Currency Code");
end else
if OrderShippingCharges.Get("Parent Id") then begin
if OrderHeader.Get(OrderShippingCharges."Shopify Order Id") then
exit(OrderHeader."Currency Code");
end else
if OrderHeader.Get("Parent Id") then
exit(OrderHeader."Currency Code");
end;

local procedure OrderPresentmentCurrencyCode(): Code[10]
var
OrderHeader: Record "Shpfy Order Header";
OrderLine: Record "Shpfy Order Line";
OrderShippingCharges: Record "Shpfy Order Shipping Charges";
begin
if OrderLine.Get("Parent Id") then
if OrderLine.Get("Parent Id") then begin
if OrderHeader.Get(OrderLine."Shopify Order Id") then
exit(OrderHeader."Presentment Currency Code");
end else
if OrderShippingCharges.Get("Parent Id") then begin
if OrderHeader.Get(OrderShippingCharges."Shopify Order Id") then
exit(OrderHeader."Presentment Currency Code");
end else
if OrderHeader.Get("Parent Id") then
exit(OrderHeader."Presentment Currency Code");
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ codeunit 30191 "Shpfy Shipping Charges"
OrderShippingCharges: Record "Shpfy Order Shipping Charges";
ShipmentMethodMapping: Record "Shpfy Shipment Method Mapping";
DataCapture: Record "Shpfy Data Capture";
OrderTaxLine: Record "Shpfy Order Tax Line";
RecordRef: RecordRef;
Id: BigInteger;
JToken: JsonToken;
Expand Down Expand Up @@ -83,6 +84,7 @@ codeunit 30191 "Shpfy Shipping Charges"
else
OrderShippingCharges.Modify();
RecordRef.Close();
OrderTaxLine.ImportFromJson(OrderShippingCharges."Shopify Shipping Line Id", JsonHelper.GetJsonArray(JToken, 'taxLines'));
DataCapture.Add(Database::"Shpfy Order Shipping Charges", OrderShippingCharges.SystemId, JToken);
if not ShipmentMethodMapping.Get(OrderHeader."Shop Code", OrderShippingCharges.Title) then begin
Clear(ShipmentMethodMapping);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ page 30128 "Shpfy Order Shipping Charges"
InsertAllowed = false;
ModifyAllowed = false;
PageType = List;
PromotedActionCategories = 'New,Process,Report,Inspect';
SourceTable = "Shpfy Order Shipping Charges";
UsageCategory = None;

Expand Down Expand Up @@ -87,15 +86,26 @@ page 30128 "Shpfy Order Shipping Charges"
{
area(Processing)
{
action(TaxLines)
{
ApplicationArea = All;
Caption = 'Tax Lines';
Image = TaxDetail;
ToolTip = 'View the tax lines for the selected shipping charge.';

trigger OnAction();
var
OrderTaxLine: Record "Shpfy Order Tax Line";
begin
OrderTaxLine.SetRange("Parent Id", Rec."Shopify Shipping Line Id");
Page.Run(Page::"Shpfy Order Tax Lines", OrderTaxLine);
end;
}
action(RetrievedShopifyData)
{
ApplicationArea = All;
Caption = 'Retrieved Shopify Data';
Image = Entry;
Promoted = true;
PromotedCategory = Category4;
PromotedIsBig = true;
PromotedOnly = true;
ToolTip = 'View the data retrieved from Shopify.';

trigger OnAction();
Expand All @@ -109,6 +119,11 @@ page 30128 "Shpfy Order Shipping Charges"
end;
}
}
area(Promoted)
{
actionref(TaxLines_Promoted; TaxLines) { }
actionref(RetrievedShopifyData_Promoted; RetrievedShopifyData) { }
}
}

var
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,13 @@ table 30130 "Shpfy Order Shipping Charges"

trigger OnDelete()
var
OrderTaxLine: Record "Shpfy Order Tax Line";
DataCapture: Record "Shpfy Data Capture";
begin
OrderTaxLine.SetRange("Parent Id", Rec."Shopify Shipping Line Id");
if not OrderTaxLine.IsEmpty() then
OrderTaxLine.DeleteAll(false);

DataCapture.SetRange("Linked To Table", Database::"Shpfy Order Shipping Charges");
DataCapture.SetRange("Linked To Id", Rec.SystemId);
if not DataCapture.IsEmpty then
Expand Down
Loading
Loading