Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3e81f6a
add EDocument app workspace
petemchlk Dec 11, 2024
f4c11e2
add code analyzers settings to code workspace
petemchlk Dec 12, 2024
26753b9
Merge pull request #1 from GMatuleviciute/dev/pmi/EDocumentWorkspace
GMatuleviciute Dec 12, 2024
d89a2a0
extending the Core app with payments
AdeleStankeviciute Jan 6, 2025
be90cbf
remove direction filter, add small fixes
AdeleStankeviciute Jan 9, 2025
9672d29
add automated tests
AdeleStankeviciute Jan 14, 2025
8f89380
fixes
AdeleStankeviciute Jan 21, 2025
0768d7d
fixes
AdeleStankeviciute Jan 21, 2025
9809c08
modify permission sets
AdeleStankeviciute Jan 22, 2025
ac0892d
Format fixes
GMatuleviciute Jan 22, 2025
185f95a
Merge branch 'dev/asm/86422' of https://github.com/GMatuleviciute/ALA…
GMatuleviciute Jan 22, 2025
89e251c
change automated tests
AdeleStankeviciute Jan 22, 2025
aee7aea
Merge branch 'dev/asm/86422' of https://github.com/GMatuleviciute/ALA…
AdeleStankeviciute Jan 22, 2025
d6774b8
Removed workspace
GMatuleviciute Jan 22, 2025
67671f4
Merge branch 'main' of https://github.com/GMatuleviciute/ALAppExtensions
GMatuleviciute Feb 10, 2025
498825b
Merge branch 'main' of https://github.com/GMatuleviciute/ALAppExtensions
GMatuleviciute Feb 13, 2025
b24c215
Merge branch 'main' into dev/asm/86422
AdeleStankeviciute Feb 13, 2025
3cf281c
change objects ids
AdeleStankeviciute Feb 13, 2025
96b6d3c
Merge branch 'main' into dev/asm/86422
AdeleStankeviciute Feb 13, 2025
d8c4999
Merge branch 'main' of https://github.com/GMatuleviciute/ALAppExtensions
GMatuleviciute Feb 14, 2025
e3ed73f
Merge branch 'main' into dev/asm/86422
AdeleStankeviciute Feb 17, 2025
75d29ac
remove not used namespace
AdeleStankeviciute Feb 17, 2025
710a8e8
change test codeunit ids to avoid conflicts
AdeleStankeviciute Feb 17, 2025
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
88 changes: 88 additions & 0 deletions Apps/W1/EDocument/app/src/Document/EDocument.Page.al
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ using Microsoft.eServices.EDocument.Integration.Receive;
using Microsoft.Bank.Reconciliation;
using Microsoft.eServices.EDocument.OrderMatch;
using Microsoft.eServices.EDocument.OrderMatch.Copilot;
using Microsoft.eServices.EDocument.Integration.Payments;
using Microsoft.eServices.EDocument.Payments;

page 6121 "E-Document"
{
Expand Down Expand Up @@ -119,6 +121,17 @@ page 6121 "E-Document"
Importance = Additional;
ToolTip = 'Specifies the electronic document posting date.';
}
field("Payment Status"; this.PaymentStatus)
{
Caption = 'Payment Status';
Visible = false;
Editable = false;
ToolTip = 'Specifies the electronic document payment status.';
}
field("Paid Amount"; Rec."Paid Amount")
{
Visible = false;
}
}
group(ReceivingCompanyInfo)
{
Expand Down Expand Up @@ -346,6 +359,35 @@ page 6121 "E-Document"
end;
}
}
group(Payments)
{
Caption = 'Payments';

action(ReceivePayments)
{
Caption = 'Receive Payments';
ToolTip = 'Receive payments for the electronic document.';
Image = Payment;
Visible = false;

trigger OnAction()
begin
this.ReceivePaymentsForEDoc();
end;
}
action(SendPayments)
{
Caption = 'Send Payment';
ToolTip = 'Send payment for the electronic document.';
Image = Payment;
Visible = false;

trigger OnAction()
begin
this.SendPaymentsForEDoc();
end;
}
}
group(Troubleshoot)
{
Caption = 'Troubleshoot';
Expand Down Expand Up @@ -507,6 +549,8 @@ page 6121 "E-Document"
SetIncomingDocActions();

EDocImport.ProcessEDocPendingOrderMatch(Rec);

this.SetPaymentStatus();
end;

local procedure SetStyle()
Expand Down Expand Up @@ -589,13 +633,57 @@ page 6121 "E-Document"
ShowRelink := false;
end;

local procedure SetPaymentStatus()
begin
if Rec."Paid Amount" = 0 then
this.PaymentStatus := this.PaymentStatus::"Not Paid"
else
if Rec."Paid Amount" < Rec."Amount Incl. VAT" then
this.PaymentStatus := this.PaymentStatus::"Partially Paid"
else
this.PaymentStatus := this.PaymentStatus::Paid;
end;

local procedure ReceivePaymentsForEDoc()
var
EDocService: Record "E-Document Service";
PaymentContext: Codeunit PaymentContext;
PaymentIntegrationManagement: Codeunit "Payment Integration Management";
EDocServices: Page "E-Document Services";
begin
EDocServices.LookupMode(true);
if EDocServices.RunModal() <> Action::LookupOK then
exit;

EDocServices.GetRecord(EDocService);
this.EDocumentErrorHelper.ClearPaymentErrorMessages(Rec);
PaymentIntegrationManagement.ReceivePayments(Rec, EDocService, PaymentContext);
end;

local procedure SendPaymentsForEDoc()
var
EDocService: Record "E-Document Service";
PaymentContext: Codeunit PaymentContext;
PaymentIntegrationManagement: Codeunit "Payment Integration Management";
EDocServices: Page "E-Document Services";
begin
EDocServices.LookupMode(true);
if EDocServices.RunModal() <> Action::LookupOK then
exit;

EDocServices.GetRecord(EDocService);
this.EDocumentErrorHelper.ClearPaymentErrorMessages(Rec);
PaymentIntegrationManagement.SendPayments(Rec, EDocService, PaymentContext);
end;

var
EDocumentBackgroundjobs: Codeunit "E-Document Background Jobs";
EDocIntegrationManagement: Codeunit "E-Doc. Integration Management";
EDocImport: Codeunit "E-Doc. Import";
EDocumentErrorHelper: Codeunit "E-Document Error Helper";
EDocumentHelper: Codeunit "E-Document Processing";
ErrorsAndWarningsNotification: Notification;
PaymentStatus: Enum "E-Document Payment Progress";
RecordLinkTxt, StyleStatusTxt : Text;
ShowRelink, ShowMapToOrder, HasErrorsOrWarnings, HasErrors, IsIncomingDoc, IsProcessed, CopilotVisible : Boolean;
EDocHasErrorOrWarningMsg: Label 'Errors or warnings found for E-Document. Please review below in "Error Messages" section.';
Expand Down
10 changes: 9 additions & 1 deletion Apps/W1/EDocument/app/src/Document/EDocument.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ using System.Automation;
using System.IO;
using System.Reflection;
using System.Threading;
using Microsoft.eServices.EDocument.Payments;

table 6121 "E-Document"
{
Expand Down Expand Up @@ -182,7 +183,14 @@ table 6121 "E-Document"
Caption = 'Receiving Company Id';
ToolTip = 'Specifies the receiving company id, such as PEPPOL id, or other identifiers used in the electronic document exchange.';
}

field(32; "Paid Amount"; Decimal)
{
Caption = 'Paid Amount';
Editable = false;
FieldClass = FlowField;
CalcFormula = sum("E-Document Payment".Amount where("E-Document Entry No." = field("Entry No")));
ToolTip = 'Specifies the amount that has already been paid.';
}
}
keys
{
Expand Down
14 changes: 14 additions & 0 deletions Apps/W1/EDocument/app/src/Helpers/EDocumentErrorHelper.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Microsoft.eServices.EDocument;

using System.Telemetry;
using System.Utilities;
using Microsoft.eServices.EDocument.Payments;

codeunit 6115 "E-Document Error Helper"
{
Expand Down Expand Up @@ -105,6 +106,19 @@ codeunit 6115 "E-Document Error Helper"
ErrorMessage.LogSimpleMessage(ErrorMessage."Message Type"::Error, Message);
end;

/// <summary>
/// Use it to clear errors for E-Document related to payments.
/// </summary>
/// <param name="EDocument">The E-Document record.</param>
procedure ClearPaymentErrorMessages(EDocument: Record "E-Document")
var
ErrorMessage: Record "Error Message";
begin
ErrorMessage.SetRange("Context Record ID", EDocument.RecordId());
ErrorMessage.SetRange("Table Number", Database::"E-Document Payment");
ErrorMessage.DeleteAll(false);
end;

internal procedure GetTelemetryImplErrLbl(): Text
begin
exit(EDocTelemetryImplErr);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// ------------------------------------------------------------------------------------------------
// 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.Integration.Interfaces;

using Microsoft.eServices.EDocument;
using Microsoft.eServices.EDocument.Integration.Payments;
using System.Utilities;

/// <summary>
/// Interface for sending and receiving payment information for E-Documents using E-Document service
/// </summary>
interface IDocumentPaymentHandler
{
procedure Send(var EDocument: Record "E-Document"; var EDocumentService: Record "E-Document Service"; PaymentContext: Codeunit PaymentContext)

procedure Receive(var EDocument: Record "E-Document"; var EDocumentService: Record "E-Document Service"; var PaymentsMetadata: Codeunit "Temp Blob List"; PaymentContext: Codeunit PaymentContext)

procedure GetDetails(var EDocument: Record "E-Document"; var EDocumentService: Record "E-Document Service"; PaymentMetadata: Codeunit "Temp Blob"; PaymentContext: Codeunit PaymentContext)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// ------------------------------------------------------------------------------------------------
// 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.Integration.Payments;

using System.Utilities;
using Microsoft.eServices.EDocument;
using Microsoft.eServices.EDocument.Integration.Interfaces;

codeunit 6107 "Get Payment Details"
{
Access = Internal;
InherentEntitlements = X;
InherentPermissions = X;

trigger OnRun()
begin
this.EDocumentService.TestField(Code);
this.IDocumentPaymentHandler.GetDetails(this.EDocument, this.EDocumentService, this.PaymentMetadata, this.PaymentContext);
end;

/// <summary>
/// Sets the global variable PaymentContext.
/// </summary>
/// <param name="PaymentContext">Payment context codeunit.</param>
procedure SetContext(PaymentContext: Codeunit PaymentContext)
begin
this.PaymentContext := PaymentContext;
end;

/// <summary>
/// Sets the IDocumentPaymentHandler instance.
/// </summary>
/// <param name="PaymentHandler">IDocumentPaymentHandler implementation used for receiving payment details.</param>
procedure SetInstance(PaymentHandler: Interface IDocumentPaymentHandler)
begin
this.IDocumentPaymentHandler := PaymentHandler;
end;


/// <summary>
/// Sets the parameters for the payment information receiving.
/// </summary>
/// <param name="EDocument">Electronic document for which payment is received.</param>
/// <param name="EDocumentService">Service for receiving payments.</param>
/// <param name="PaymentMetadata">TempBlob which contains received payment information.</param>
procedure SetParameters(var EDocument: Record "E-Document"; var EDocumentService: Record "E-Document Service"; PaymentMetadata: Codeunit "Temp Blob")
begin
this.EDocument.Copy(EDocument);
this.EDocumentService.Copy(EDocumentService);
this.PaymentMetadata := PaymentMetadata;
end;

var
EDocument: Record "E-Document";
EDocumentService: Record "E-Document Service";
PaymentMetadata: Codeunit "Temp Blob";
PaymentContext: Codeunit PaymentContext;
IDocumentPaymentHandler: Interface IDocumentPaymentHandler;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// ------------------------------------------------------------------------------------------------
// 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.Integration.Payments;

using Microsoft.eServices.EDocument;
using Microsoft.eServices.EDocument.Integration.Interfaces;
using Microsoft.eServices.EDocument.Payments;
using System.Utilities;

/// <summary>
/// This codeunit is used to provide a default implementation for the "Document Payment Handler" interface.
/// </summary>
codeunit 6105 "Empty Payment Handler" implements IDocumentPaymentHandler
{
Access = Internal;
InherentEntitlements = X;
InherentPermissions = X;

procedure Send(var EDocument: Record "E-Document"; var EDocumentService: Record "E-Document Service"; PaymentContext: Codeunit PaymentContext)
begin
// This method serves as a placeholder implementation for the IDocumentPaymentHandler interface.
end;

procedure Receive(var EDocument: Record "E-Document"; var EDocumentService: Record "E-Document Service"; var PaymentsMetadata: Codeunit "Temp Blob List"; PaymentContext: Codeunit PaymentContext)
begin
// This method serves as a placeholder implementation for the IDocumentPaymentHandler interface.
end;

procedure GetDetails(var EDocument: Record "E-Document"; var EDocumentService: Record "E-Document Service"; PaymentMetadata: Codeunit "Temp Blob"; PaymentContext: Codeunit PaymentContext)
begin
// This method serves as a placeholder implementation for the IDocumentPaymentHandler interface.
end;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// ------------------------------------------------------------------------------------------------
// 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.Integration.Payments;

using Microsoft.eServices.EDocument.Integration;
using Microsoft.eServices.EDocument.Payments;

codeunit 6104 PaymentContext
{
/// <summary>
/// Get the Http Message State codeunit.
/// </summary>
/// <returns>codeunit Http Message State that contains http request and response messages.</returns>
procedure Http(): Codeunit "Http Message State"
begin
exit(this.HttpMessageState);
end;

/// <summary>
/// Retrieves the payment date.
/// </summary>
/// <returns>Date when the payment was made.</returns>
procedure GetDate(): Date
begin
exit(this.Date);
end;

/// <summary>
/// Retrieves the payment amount.
/// </summary>
/// <returns>Amount of the payment.</returns>
procedure GetAmount(): Decimal
begin
exit(this.Amount);
end;

/// <summary>
/// Sets the payment date and amount.
/// </summary>
/// <param name="Date">Date when the payment was made.</param>
/// <param name="Amount">Amount of the payment.</param>
procedure SetPaymentInformation(Date: Date; Amount: Decimal)
begin
this.Date := Date;
this.Amount := Amount;
end;

/// <summary>
/// Retrieves the payment status.
/// </summary>
/// <returns>Current payment status.</returns>
procedure GetPaymentStatus(): Enum "Payment Status"
begin
exit(this.PaymentStatus);
end;

/// <summary>
/// Sets the payment status.
/// </summary>
/// <param name="NewPaymentStatus">New payment status.</param>
procedure SetPaymentStatus(NewPaymentStatus: Enum "Payment Status")
begin
this.PaymentStatus := NewPaymentStatus;
end;

var
HttpMessageState: Codeunit "Http Message State";
PaymentStatus: Enum "Payment Status";
Date: Date;
Amount: Decimal;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// ------------------------------------------------------------------------------------------------
// 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.Integration.Payments;

using Microsoft.eServices.EDocument.Integration.Interfaces;

enum 6105 "Payment Integration" implements IDocumentPaymentHandler
{
Extensible = true;
Access = Public;

value(0; "No Integration")
{
Caption = 'No Integration';
Implementation = IDocumentPaymentHandler = "Empty Payment Handler";
}
}
Loading