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

[E-Document Core] - Extending the Core app with payments #5

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

AdeleStankeviciute
Copy link
Collaborator

@AdeleStankeviciute AdeleStankeviciute commented Jan 6, 2025

Implementation

The new functionality improves E-Document feature by introducing payment tracking. Users can now track both Incoming and Outgoing payments, with ability to monitor payment statuses by showing whether they are fully paid, partially paid or unpaid.

New field "Payment Integration" was added to E-Document Services page together with "Calculate Payment VAT" boolean. For the "Payment Integration" a user can set a particular payment handler/service for sending and receiving payments. By enabling "Calculate Payment VAT" boolean, payment amount is split into Base Amount and VAT Amount.

Additionally, the "Paid Amount" and "Payment Status" fields were added on E-Document page. On "Paid Amount" drilldown, user can access "E-Documents Payments" page, where payment date, paid amount without VAT and VAT amount are displayed, together with payment status and whether payment is incoming or outgoing. The payment date and amount fields can be edited manually, while the other fields are automatically populated by the system.

New actions "Receive Payments" and "Send Payment" have also been added under the "Actions" menu on the E-Document page. "Receive Payments" actions allows user to receive payments via service and all data related to payment appears on "E-Document Payment" page, as well as updated payment status on E-Document. Meanwhile, "Send Payment" action can be used to filter unsent payments based on status and direction. The system adds E-Document and its values, identifies the right service for sending and updates the payment status of E-Document. This occurs even when the payment is created manually, regardless of whether it has been sent yet.

Additional fields were added on "E-Documents Service" page, related to background job: "Auto Sync Payments", "Sync Start Time" and "Minutes between runs". The job queue is created when "Auto Sync Payments" boolean is enabled and same background job runs both sending and receiving actions.

Default integration is a placeholder and does not actually send or receive payments. New integrations can be added by extending enum "Payment Integration" and implementing interface IDocumentPaymentHandler.

MS PR: microsoft#27972

@AdeleStankeviciute AdeleStankeviciute changed the title extending the Core app with payments [E-Document Core] - Extending the Core app with payments Jan 6, 2025
Copy link
Collaborator

@tinestaric tinestaric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great looking PR! I still have a few questions around the management CU pattern, but overall very nice, great work!

Apps/W1/EDocument/app/src/Document/EDocument.Page.al Outdated Show resolved Hide resolved
begin
ErrorMessage.SetRange("Context Record ID", EDocument.RecordId());
ErrorMessage.SetRange("Table Number", Database::"E-Document Payment");
ErrorMessage.DeleteAll();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add explicit RunTrigger


/// <summary>
/// This codeunit is used to implement the "Document Payment Handler" interface. It is used to provide a default implementation for the "Action Invoker" interface.
/// </summary>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action Invoker?

InherentPermissions = X;

procedure Send(var EDocument: Record "E-Document"; var EDocumentService: Record "E-Document Service"; PaymentContext: Codeunit PaymentContext)
begin
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, preference: I prefer to see a // Do nothing comment within these placeholder implementations as it makes it clear this is intentionally empty.


trigger OnInsert()
begin
if Rec.Status = Rec.Status::" " then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why even add the Empty status? Why not make Created the first one? or set the InitValue to Created?

using System.Utilities;

/// <summary>
/// Interface for sending and receiving paymnet information for E-Documents using E-Document service
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: ..payment..

FieldClass = FlowField;
CalcFormula = sum("E-Document Payment".Amount where("E-Document Entry No." = field("Entry No"), Direction = field("Payment Direction Filter")));
}
field(33; "Payment Direction Filter"; Enum "E-Document Direction")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think we need to have Payment Direction Filter in the E-Document table. Related payments can be filtered based on Entry No. (I assume the document should not change direction :D ). Maybe we could save the direction only on E-Document Payment table.

{
Caption = 'Partially Paid';
}
value(3; "Paid In Full")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would call it simple Paid

NotBlank = true;
InitValue = 0T;
}
field(33; "Payment Sync Min between runs"; Integer)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Payment Sync Min Between Runs ?

@@ -43,21 +52,31 @@ table 6101 "E-Document Payment"
{
Caption = 'VAT Base';
DecimalPlaces = 2;
Editable = false;
ToolTip = 'Specifies the value of the VAT Base field.';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add more meaningful tooltips.

@nerkel91
Copy link
Collaborator

Implementation

The new functionality improves E-Document feature by introducing payment tracking. Users can now track both Incoming and Outgoing payments, with ability to monitor payment statuses by showing whether they are fully paid, partially paid or unpaid.

  • New field "Payment Integration" was added to E-Document Services page together with "Calculate Payment VAT" boolean. For the "Payment Integration" a user can set a particular payment handler/service for sending and receiving payments. By enabling "Calculate Payment VAT" boolean, payment amount is split into Base Amount and VAT Amount.

  • Additionally, the "Paid Amount" and "Payment Status" fields were added on E-Document page. On "Paid Amount" drilldown, user can access "E-Documents Payments" page, where payment date, paid amount without VAT and VAT amount are displayed, together with payment status and whether payment is incoming or outgoing. The payment date and amount fields can be edited manually, while the other fields are automatically populated by the system.

  • New actions "Receive Payments" and "Send Payment" have also been added under the "Actions" menu on the E-Document page. "Receive Payments" actions allows user to receive payments via service and all data related to payment appears on "E-Document Payment" page, as well as updated payment status on E-Document. Meanwhile, "Send Payment" action can be used to filter unsent payments based on status and direction. The system adds E-Document and its values, identifies the right service for sending and updates the payment status of E-Document. This occurs even when the payment is created manually, regardless of whether it has been sent yet.

  • Additional fields were added on "E-Documents Service" page, related to background job: "Auto Sync Payments", "Sync Start Time" and "Minutes between runs". The job queue is created when "Auto Sync Payments" boolean is enabled and same background job runs both sending and receiving actions.

Default integration is a placeholder and does not actually send or receive payments. New integrations can be added by extending enum "Payment Integration" and implementing interface IDocumentPaymentHandler.

if Rec."Paid Amount" < Rec."Amount Incl. VAT" then
this.PaymentStatus := this.PaymentStatus::"Partially Paid"
else
this.PaymentStatus := this.PaymentStatus::Paid
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.PaymentStatus := this.PaymentStatus::Paid; ( ; is missing)

// ------------------------------------------------------------------------------------------------
namespace Microsoft.eServices.EDocument.Integration.Payments;


Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One empty line should be between namespace and using

PaymentStatus: Enum "Payment Status";
Date: Date;
Amount: Decimal;

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the empty line before the global variables and object closing bracket

Payment.Date := PaymentContext.GetDate();
Payment.Validate(Amount, PaymentContext.GetAmount());
Payment.Status := PaymentContext.GetPaymentStatus();
Payment.Insert();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add explicit of RunTrigger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants