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
30 changes: 30 additions & 0 deletions src/Apps/DE/EDocumentDE/app/src/EDocItemChargesDE.PageExt.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.eServices.EDocument.Formats;

using Microsoft.Inventory.Item;

pageextension 11036 "E-Doc Item Charges DE" extends "Item Charges"
{
layout
{
modify("E-Invoice Mapping")
{
Visible = true;
}
modify("E-Invoice Reason Text")
{
Visible = true;
}
modify("E-Invoice Reason Code")
{
Visible = true;
}
modify("E-Invoice Unit Code")
{
Visible = true;
}
}
}
21 changes: 21 additions & 0 deletions src/Apps/DE/EDocumentDE/app/src/EDocumentDEHelper.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,27 @@ codeunit 11038 "E-Document DE Helper"
end;
end;

/// <summary>
/// Tells whether a signed amount is reported as a charge or as an allowance.
/// </summary>
/// <param name="SignedAmount">The signed amount of the allowance/charge.</param>
/// <returns>True for a charge, false for an allowance.</returns>
internal procedure IsCharge(SignedAmount: Decimal): Boolean
begin
exit(SignedAmount >= 0);
end;

/// <summary>
/// Gets the amount to report for a signed allowance/charge amount. The e-document formats report allowances with a
/// positive amount and distinguish them from charges through the charge indicator.
/// </summary>
/// <param name="SignedAmount">The signed amount of the allowance/charge.</param>
/// <returns>The absolute amount.</returns>
internal procedure GetReportedAmount(SignedAmount: Decimal): Decimal
begin
exit(Abs(SignedAmount));
end;

[TryFunction]
local procedure TryValidateRoutingNo(RoutingNo: Text[50])
begin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ pageextension 13915 "E-Document Service DE" extends "E-Document Service"
}
#pragma warning restore AS0125
}
modify("Item Charge E-Invoice Mapping")
{
Visible = true;
}

modify("Export Format")
{
trigger OnBeforeValidate()
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions src/Apps/DE/EDocumentDE/demo data/app.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"id": "f3e4e6f8-2ba7-4202-834d-141ed9b89194",
"name": "E-Document Core Demo Data (DE)",
"publisher": "Microsoft",
Expand Down Expand Up @@ -54,8 +54,5 @@
"includeSourceInSymbolFile": true
},
"application": "29.0.0.0",
"target": "OnPrem",
"features": [
"TranslationFile"
]
"target": "OnPrem"
}
162 changes: 162 additions & 0 deletions src/Apps/DE/EDocumentDE/test/src/ItemChargeUIDETests.Codeunit.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.eServices.EDocument.Formats;

using Microsoft.eServices.EDocument;
using Microsoft.eServices.EDocument.Integration;
using Microsoft.Inventory.Item;

codeunit 148502 "Item Charge UI DE Tests"
{
Subtype = Test;
TestType = Uncategorized;

trigger OnRun();
begin
// [FEATURE] [E-Document] [Item Charge] [UI]
end;

var
LibraryInventory: Codeunit "Library - Inventory";
LibraryEdocument: Codeunit "Library - E-Document";
Assert: Codeunit Assert;
IncorrectValueErr: Label 'Incorrect value for %1', Locked = true;

#region EDocumentService
[Test]
procedure ItemChargeMappingIsVisibleAndEditableOnServicePageForXRechnung()
var
EDocumentService: Record "E-Document Service";
EDocumentServicePage: TestPage "E-Document Service";
begin
// [SCENARIO] The Item Charge E-Invoice Mapping setting can be changed on the E-Document Service page for an XRechnung service
// [GIVEN] An E-Document service with XRechnung format
EDocumentService.Get(LibraryEdocument.CreateService("E-Document Format"::XRechnung, "Service Integration"::"No Integration"));

// [WHEN] The E-Document Service page is opened for the service
EDocumentServicePage.Trap();
Page.Run(Page::"E-Document Service", EDocumentService);

// [THEN] The Item Charge E-Invoice Mapping field is visible and editable
Assert.IsTrue(EDocumentServicePage."Item Charge E-Invoice Mapping".Visible(), 'Item Charge E-Invoice Mapping must be visible for XRechnung');
Assert.IsTrue(EDocumentServicePage."Item Charge E-Invoice Mapping".Editable(), 'Item Charge E-Invoice Mapping must be editable for XRechnung');

// [WHEN] A mapping is selected on the page
EDocumentServicePage."Item Charge E-Invoice Mapping".SetValue(Format(Enum::"Item Charge E-Invoice Mapping"::"Line with Unit Code"));
EDocumentServicePage.Close();

// [THEN] The selected mapping is stored on the service record
EDocumentService.Find();
Assert.AreEqual(EDocumentService."Item Charge E-Invoice Mapping"::"Line with Unit Code", EDocumentService."Item Charge E-Invoice Mapping", StrSubstNo(IncorrectValueErr, EDocumentService.FieldCaption("Item Charge E-Invoice Mapping")));
end;

[Test]
procedure ItemChargeMappingIsVisibleOnServicePageForZUGFeRD()
var
EDocumentService: Record "E-Document Service";
EDocumentServicePage: TestPage "E-Document Service";
begin
// [SCENARIO] The Item Charge E-Invoice Mapping setting is offered for a ZUGFeRD service
// [GIVEN] An E-Document service with ZUGFeRD format
EDocumentService.Get(LibraryEdocument.CreateService("E-Document Format"::ZUGFeRD, "Service Integration"::"No Integration"));

// [WHEN] The E-Document Service page is opened for the service
EDocumentServicePage.Trap();
Page.Run(Page::"E-Document Service", EDocumentService);

// [THEN] The Item Charge E-Invoice Mapping field is visible
Assert.IsTrue(EDocumentServicePage."Item Charge E-Invoice Mapping".Visible(), 'Item Charge E-Invoice Mapping must be visible for ZUGFeRD');
EDocumentServicePage.Close();
end;

[Test]
procedure ItemChargeMappingIsVisibleOnServicePageForPeppolBisDE()
var
EDocumentService: Record "E-Document Service";
EDocumentServicePage: TestPage "E-Document Service";
begin
// [SCENARIO] The Item Charge E-Invoice Mapping setting is offered for every German e-document format, including PEPPOL BIS 3.0 DE
// [GIVEN] An E-Document service with PEPPOL BIS 3.0 DE format
EDocumentService.Get(LibraryEdocument.CreateService("E-Document Format"::"PEPPOL BIS 3.0 DE", "Service Integration"::"No Integration"));

// [WHEN] The E-Document Service page is opened for the service
EDocumentServicePage.Trap();
Page.Run(Page::"E-Document Service", EDocumentService);

// [THEN] The Item Charge E-Invoice Mapping field is visible
Assert.IsTrue(EDocumentServicePage."Item Charge E-Invoice Mapping".Visible(), 'Item Charge E-Invoice Mapping must be visible for PEPPOL BIS 3.0 DE');
EDocumentServicePage.Close();
end;
#endregion

#region ItemCharges
[Test]
procedure ItemChargeOverrideFieldsAreEditableOnItemChargesPage()
var
ItemCharge: Record "Item Charge";
ItemChargesPage: TestPage "Item Charges";
begin
// [SCENARIO] The per-item-charge e-invoice override fields can be changed on the Item Charges page
// [GIVEN] An item charge
LibraryInventory.CreateItemCharge(ItemCharge);

// [WHEN] The Item Charges page is opened for the item charge
ItemChargesPage.OpenEdit();
ItemChargesPage.GoToRecord(ItemCharge);

// [THEN] The four override fields are visible and editable
Assert.IsTrue(ItemChargesPage."E-Invoice Mapping".Visible(), 'E-Invoice Mapping must be visible');
Assert.IsTrue(ItemChargesPage."E-Invoice Mapping".Editable(), 'E-Invoice Mapping must be editable');
Assert.IsTrue(ItemChargesPage."E-Invoice Reason Text".Visible(), 'E-Invoice Reason Text must be visible');
Assert.IsTrue(ItemChargesPage."E-Invoice Reason Text".Editable(), 'E-Invoice Reason Text must be editable');
Assert.IsTrue(ItemChargesPage."E-Invoice Reason Code".Visible(), 'E-Invoice Reason Code must be visible');
Assert.IsTrue(ItemChargesPage."E-Invoice Reason Code".Editable(), 'E-Invoice Reason Code must be editable');
Assert.IsTrue(ItemChargesPage."E-Invoice Unit Code".Visible(), 'E-Invoice Unit Code must be visible');
Assert.IsTrue(ItemChargesPage."E-Invoice Unit Code".Editable(), 'E-Invoice Unit Code must be editable');

// [WHEN] Values are entered in the override fields
ItemChargesPage."E-Invoice Mapping".SetValue(Format(Enum::"Item Charge Mapping Override"::"Document Allowance/Charge"));
ItemChargesPage."E-Invoice Reason Text".SetValue('Freight surcharge');
ItemChargesPage."E-Invoice Reason Code".SetValue('FC');
ItemChargesPage."E-Invoice Unit Code".SetValue('HUR');
ItemChargesPage.Close();

// [THEN] The values are stored on the item charge record
ItemCharge.Find();
Assert.AreEqual(ItemCharge."E-Invoice Mapping"::"Document Allowance/Charge", ItemCharge."E-Invoice Mapping", StrSubstNo(IncorrectValueErr, ItemCharge.FieldCaption("E-Invoice Mapping")));
Assert.AreEqual('Freight surcharge', ItemCharge."E-Invoice Reason Text", StrSubstNo(IncorrectValueErr, ItemCharge.FieldCaption("E-Invoice Reason Text")));
Assert.AreEqual('FC', ItemCharge."E-Invoice Reason Code", StrSubstNo(IncorrectValueErr, ItemCharge.FieldCaption("E-Invoice Reason Code")));
Assert.AreEqual('HUR', ItemCharge."E-Invoice Unit Code", StrSubstNo(IncorrectValueErr, ItemCharge.FieldCaption("E-Invoice Unit Code")));
end;

[Test]
procedure ItemChargeBlankMappingIsDistinctFromAutomaticOnItemChargesPage()
var
ItemCharge: Record "Item Charge";
ItemChargesPage: TestPage "Item Charges";
begin
// [SCENARIO] A blank mapping override (use the service setting) and the Automatic override are two distinct states in the UI
// [GIVEN] An item charge without a mapping override
LibraryInventory.CreateItemCharge(ItemCharge);

// [WHEN] The Item Charges page is opened for the item charge
ItemChargesPage.OpenEdit();
ItemChargesPage.GoToRecord(ItemCharge);

// [THEN] The mapping override is shown as blank, not as Automatic
Assert.AreNotEqual(Format(Enum::"Item Charge Mapping Override"::Automatic), ItemChargesPage."E-Invoice Mapping".Value(), 'A blank override must not be rendered as Automatic');
Assert.AreEqual('', DelChr(ItemChargesPage."E-Invoice Mapping".Value(), '<>', ' '), 'An item charge without override must show a blank mapping');

// [WHEN] Automatic is selected on the page
ItemChargesPage."E-Invoice Mapping".SetValue(Format(Enum::"Item Charge Mapping Override"::Automatic));
ItemChargesPage.Close();

// [THEN] The Automatic override is stored, distinct from the blank value
ItemCharge.Find();
Assert.AreEqual(ItemCharge."E-Invoice Mapping"::Automatic, ItemCharge."E-Invoice Mapping", StrSubstNo(IncorrectValueErr, ItemCharge.FieldCaption("E-Invoice Mapping")));
Assert.AreNotEqual(ItemCharge."E-Invoice Mapping"::" ", ItemCharge."E-Invoice Mapping", 'Automatic must be stored as an override, not as the blank value');
end;
#endregion
}
Loading
Loading