-
Notifications
You must be signed in to change notification settings - Fork 371
Deliverable 629871: [master] [UK] Payment Practices updates #7624
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
Open
AleksanderGladkov
wants to merge
22
commits into
main
Choose a base branch
from
features/629871-master-Payment-Practices-W1-GB-Simple
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
fc0689b
GB + AU + tests
f12e66b
GB + AU + tests
7f473e0
Merge branch 'features/629871-master-Payment-Practices-W1-GB-Simple' …
3ddd9d5
Merge branch 'main' of https://github.com/microsoft/BCApps into featu…
7a426db
Merge branch 'features/629871-master-Payment-Practices-W1-GB-Simple' …
64360f7
Merge branch 'main' of https://github.com/microsoft/BCApps into featu…
335a48a
Merge branch 'main' of https://github.com/microsoft/BCApps into featu…
f2d919a
Changes for AU
AndreasHans 2b8f36d
Merge branch 'main' of https://github.com/microsoft/BCApps into featu…
e9eb12f
Merge branch 'features/629871-master-Payment-Practices-W1-GB-Simple' …
37f2ca4
Merge branch 'main' of https://github.com/microsoft/BCApps into featu…
ed429cb
fix review comments
f1d7c4a
Merge branch 'main' of https://github.com/microsoft/BCApps into featu…
016d56d
more fixes for copilot bot comments
09c9eac
fix for non-existing library procedure
5db3eb9
fixed bug in sorting list procedure
0bd53d5
improve tooltips, add xml tags, some renaming
AndreasHans a64bf43
Merge branch 'main' into features/629871-master-Payment-Practices-W1-…
AndreasHans ba3a425
resolve some pr comments and fix a test
AndreasHans 4d94c07
fix overflow of company size
AndreasHans 5fc2906
fix review comments, part 2
6258c27
more caching
AndreasHans File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/Apps/W1/PaymentPractices/App/src/Core/Enums/PaymPracReportingScheme.Enum.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // ------------------------------------------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
| // ------------------------------------------------------------------------------------------------ | ||
| namespace Microsoft.Finance.Analysis; | ||
|
|
||
| enum 680 "Paym. Prac. Reporting Scheme" implements PaymentPracticeSchemeHandler | ||
| { | ||
| Extensible = true; | ||
|
|
||
| value(0; Standard) | ||
| { | ||
| Implementation = PaymentPracticeSchemeHandler = "Paym. Prac. Standard Handler"; | ||
| } | ||
| value(1; "Dispute & Retention") | ||
| { | ||
| Implementation = PaymentPracticeSchemeHandler = "Paym. Prac. Dispute Ret. Hdlr"; | ||
| } | ||
| value(2; "Small Business") | ||
| { | ||
| Implementation = PaymentPracticeSchemeHandler = "Paym. Prac. Small Bus. Handler"; | ||
| } | ||
| } |
66 changes: 66 additions & 0 deletions
66
src/Apps/W1/PaymentPractices/App/src/Core/Implementations/PaymPracDisputeRetHdlr.Codeunit.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // ------------------------------------------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
| // ------------------------------------------------------------------------------------------------ | ||
| namespace Microsoft.Finance.Analysis; | ||
|
|
||
| codeunit 681 "Paym. Prac. Dispute Ret. Hdlr" implements PaymentPracticeSchemeHandler | ||
| { | ||
| Access = Internal; | ||
|
|
||
| procedure ValidateHeader(var PaymentPracticeHeader: Record "Payment Practice Header") | ||
| begin | ||
| // Dispute & Retention: no additional header type restrictions | ||
| end; | ||
|
|
||
| procedure UpdatePaymentPracData(var PaymentPracticeData: Record "Payment Practice Data"): Boolean | ||
| begin | ||
| if PaymentPracticeData."Source Type" = PaymentPracticeData."Source Type"::Vendor then | ||
| if PaymentPracticeData."SCF Payment Date" <> 0D then begin | ||
| PaymentPracticeData."Actual Payment Days" := PaymentPracticeData."SCF Payment Date" - PaymentPracticeData."Invoice Received Date"; | ||
|
AleksanderGladkov marked this conversation as resolved.
|
||
| if PaymentPracticeData."Actual Payment Days" < 0 then | ||
| PaymentPracticeData."Actual Payment Days" := 0; | ||
| end; | ||
|
|
||
| if (not PaymentPracticeData."Invoice Is Open") and | ||
| (PaymentPracticeData."Actual Payment Days" > PaymentPracticeData."Agreed Payment Days") | ||
| then | ||
| PaymentPracticeData."Overdue Due to Dispute" := PaymentPracticeData."Dispute Status" <> ''; | ||
|
|
||
| exit(true); | ||
| end; | ||
|
|
||
|
AleksanderGladkov marked this conversation as resolved.
|
||
| procedure CalculateHeaderTotals(var PaymentPracticeHeader: Record "Payment Practice Header"; var PaymentPracticeData: Record "Payment Practice Data") | ||
| var | ||
| TotalPayments: Integer; | ||
| TotalAmount: Decimal; | ||
| TotalOverdueAmount: Decimal; | ||
| OverdueCount: Integer; | ||
| OverdueDueToDisputeCount: Integer; | ||
| begin | ||
| if PaymentPracticeData.FindSet() then | ||
| repeat | ||
| if not PaymentPracticeData."Invoice Is Open" then begin | ||
|
AleksanderGladkov marked this conversation as resolved.
|
||
| TotalPayments += 1; | ||
| TotalAmount += PaymentPracticeData."Invoice Amount"; | ||
| if PaymentPracticeData."Actual Payment Days" > PaymentPracticeData."Agreed Payment Days" then begin | ||
| OverdueCount += 1; | ||
| TotalOverdueAmount += PaymentPracticeData."Invoice Amount"; | ||
| if PaymentPracticeData."Overdue Due to Dispute" then | ||
| OverdueDueToDisputeCount += 1; | ||
|
AleksanderGladkov marked this conversation as resolved.
|
||
| end; | ||
| end; | ||
| until PaymentPracticeData.Next() = 0; | ||
|
|
||
| PaymentPracticeHeader."Total Number of Payments" := TotalPayments; | ||
| PaymentPracticeHeader."Total Amount of Payments" := TotalAmount; | ||
| PaymentPracticeHeader."Total Amt. of Overdue Payments" := TotalOverdueAmount; | ||
| if OverdueCount > 0 then | ||
| PaymentPracticeHeader."Pct Overdue Due to Dispute" := OverdueDueToDisputeCount / OverdueCount * 100; | ||
| end; | ||
|
|
||
| procedure CalculateLineTotals(var PaymentPracticeLine: Record "Payment Practice Line"; var PaymentPracticeData: Record "Payment Practice Data") | ||
| begin | ||
| // Dispute & Retention: no additional line totals | ||
| end; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
...Apps/W1/PaymentPractices/App/src/Core/Implementations/PaymPracSmallBusHandler.Codeunit.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| // ------------------------------------------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
| // ------------------------------------------------------------------------------------------------ | ||
| namespace Microsoft.Finance.Analysis; | ||
|
|
||
| using Microsoft.Purchases.Vendor; | ||
|
|
||
| codeunit 682 "Paym. Prac. Small Bus. Handler" implements PaymentPracticeSchemeHandler | ||
| { | ||
| Access = Internal; | ||
|
|
||
| var | ||
| PaymentPracticeMath: Codeunit "Payment Practice Math"; | ||
| SmallBusinessCache: Dictionary of [Code[20], Boolean]; | ||
| WrongHeaderTypeErr: Label 'Payment Practice Header Type must be Vendor for the Small Business reporting scheme.'; | ||
| WrongHeaderAggErr: Label 'Payment Practice Aggregation Type must be Period for the Small Business reporting scheme.'; | ||
|
|
||
| procedure ValidateHeader(var PaymentPracticeHeader: Record "Payment Practice Header") | ||
| begin | ||
| if PaymentPracticeHeader."Header Type" <> PaymentPracticeHeader."Header Type"::Vendor then | ||
| Error(WrongHeaderTypeErr); | ||
| if PaymentPracticeHeader."Aggregation Type" <> PaymentPracticeHeader."Aggregation Type"::Period then | ||
| Error(WrongHeaderAggErr); | ||
| end; | ||
|
|
||
| procedure UpdatePaymentPracData(var PaymentPracticeData: Record "Payment Practice Data"): Boolean | ||
| var | ||
| Vendor: Record Vendor; | ||
| CompanySize: Record "Company Size"; | ||
| IsSmallBusiness: Boolean; | ||
| begin | ||
| if PaymentPracticeData."Source Type" <> PaymentPracticeData."Source Type"::Vendor then | ||
| exit(false); | ||
|
|
||
| if SmallBusinessCache.Get(PaymentPracticeData."CV No.", IsSmallBusiness) then | ||
| exit(IsSmallBusiness); | ||
|
|
||
| Vendor.SetLoadFields("Company Size Code"); | ||
| if not Vendor.Get(PaymentPracticeData."CV No.") then begin | ||
| SmallBusinessCache.Add(PaymentPracticeData."CV No.", false); | ||
| exit(false); | ||
| end; | ||
|
|
||
| if CompanySize.Get(Vendor."Company Size Code") then | ||
| IsSmallBusiness := CompanySize."Small Business" | ||
| else | ||
| IsSmallBusiness := false; | ||
|
|
||
| SmallBusinessCache.Add(PaymentPracticeData."CV No.", IsSmallBusiness); | ||
| exit(IsSmallBusiness); | ||
| end; | ||
|
|
||
| procedure CalculateHeaderTotals(var PaymentPracticeHeader: Record "Payment Practice Header"; var PaymentPracticeData: Record "Payment Practice Data") | ||
| var | ||
| TotalCount: Integer; | ||
| TotalValue: Decimal; | ||
| ModePaymentTime: Integer; | ||
| ModePaymentTimeMin: Integer; | ||
| ModePaymentTimeMax: Integer; | ||
| MedianPaymentTime: Decimal; | ||
| P80PaymentTime: Integer; | ||
| P95PaymentTime: Integer; | ||
| PctPeppolEnabled: Decimal; | ||
| PctSmallBusinessPayments: Decimal; | ||
| begin | ||
| PaymentPracticeMath.CalculateHeaderStatistics( | ||
| PaymentPracticeData, TotalCount, TotalValue, | ||
| ModePaymentTime, ModePaymentTimeMin, ModePaymentTimeMax, | ||
| MedianPaymentTime, P80PaymentTime, P95PaymentTime, | ||
| PctPeppolEnabled, PctSmallBusinessPayments); | ||
|
|
||
| PaymentPracticeHeader."Total Number of Payments" := TotalCount; | ||
| PaymentPracticeHeader."Total Amount of Payments" := TotalValue; | ||
| PaymentPracticeHeader."Mode Payment Time" := ModePaymentTime; | ||
| PaymentPracticeHeader."Mode Payment Time Min." := ModePaymentTimeMin; | ||
| PaymentPracticeHeader."Mode Payment Time Max." := ModePaymentTimeMax; | ||
| PaymentPracticeHeader."Median Payment Time" := MedianPaymentTime; | ||
| PaymentPracticeHeader."80th Percentile Payment Time" := P80PaymentTime; | ||
| PaymentPracticeHeader."95th Percentile Payment Time" := P95PaymentTime; | ||
| PaymentPracticeHeader."Pct Peppol Enabled" := PctPeppolEnabled; | ||
| PaymentPracticeHeader."Pct Small Business Payments" := PctSmallBusinessPayments; | ||
| end; | ||
|
|
||
| procedure CalculateLineTotals(var PaymentPracticeLine: Record "Payment Practice Line"; var PaymentPracticeData: Record "Payment Practice Data") | ||
| var | ||
| InvoiceCount: Integer; | ||
| InvoiceValue: Decimal; | ||
| begin | ||
| PaymentPracticeData.SetRange("Invoice Is Open", false); | ||
|
AleksanderGladkov marked this conversation as resolved.
|
||
| InvoiceCount := PaymentPracticeData.Count(); | ||
| PaymentPracticeData.CalcSums("Invoice Amount"); | ||
| InvoiceValue := PaymentPracticeData."Invoice Amount"; | ||
| PaymentPracticeData.SetRange("Invoice Is Open"); | ||
|
|
||
| PaymentPracticeLine."Invoice Count" := InvoiceCount; | ||
| PaymentPracticeLine."Invoice Value" := InvoiceValue; | ||
| end; | ||
| } | ||
30 changes: 30 additions & 0 deletions
30
...Apps/W1/PaymentPractices/App/src/Core/Implementations/PaymPracStandardHandler.Codeunit.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.Finance.Analysis; | ||
|
|
||
| codeunit 680 "Paym. Prac. Standard Handler" implements PaymentPracticeSchemeHandler | ||
| { | ||
| Access = Internal; | ||
|
|
||
| procedure ValidateHeader(var PaymentPracticeHeader: Record "Payment Practice Header") | ||
| begin | ||
| // Standard scheme: no additional validation | ||
| end; | ||
|
|
||
| procedure UpdatePaymentPracData(var PaymentPracticeData: Record "Payment Practice Data"): Boolean | ||
| begin | ||
| exit(true); | ||
| end; | ||
|
|
||
| procedure CalculateHeaderTotals(var PaymentPracticeHeader: Record "Payment Practice Header"; var PaymentPracticeData: Record "Payment Practice Data") | ||
| begin | ||
| // Standard scheme: no additional header totals | ||
| end; | ||
|
|
||
| procedure CalculateLineTotals(var PaymentPracticeLine: Record "Payment Practice Line"; var PaymentPracticeData: Record "Payment Practice Data") | ||
| begin | ||
| // Standard scheme: no additional line totals | ||
| end; | ||
| } |
38 changes: 38 additions & 0 deletions
38
...pps/W1/PaymentPractices/App/src/Core/Interfaces/PaymentPracticeSchemeHandler.Interface.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // ------------------------------------------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
| // ------------------------------------------------------------------------------------------------ | ||
| namespace Microsoft.Finance.Analysis; | ||
|
|
||
| interface PaymentPracticeSchemeHandler | ||
| { | ||
| /// <summary> | ||
| /// Validates the Payment Practice Header before data generation. | ||
| /// </summary> | ||
| /// <param name="PaymentPracticeHeader">The header to validate.</param> | ||
| procedure ValidateHeader(var PaymentPracticeHeader: Record "Payment Practice Header") | ||
|
|
||
| /// <summary> | ||
| /// Enriches or filters a Payment Practice Data row before insertion. | ||
| /// Returns true to include the row, false to skip it. | ||
| /// </summary> | ||
| /// <param name="PaymentPracticeData">The data row to enrich/filter.</param> | ||
| /// <returns>True to include the row, false to skip.</returns> | ||
| procedure UpdatePaymentPracData(var PaymentPracticeData: Record "Payment Practice Data"): Boolean | ||
|
|
||
| /// <summary> | ||
| /// Calculates scheme-specific header totals after standard totals are generated. | ||
| /// </summary> | ||
| /// <param name="PaymentPracticeHeader">The header to update with totals.</param> | ||
| /// <param name="PaymentPracticeData">The data to aggregate from.</param> | ||
| procedure CalculateHeaderTotals(var PaymentPracticeHeader: Record "Payment Practice Header"; var PaymentPracticeData: Record "Payment Practice Data") | ||
|
|
||
| /// <summary> | ||
| /// Calculates scheme-specific line totals for the currently visible slice of data. | ||
| /// The caller is responsible for applying any filters (period, company size, etc.) on | ||
| /// PaymentPracticeData before invoking this method, and for restoring them afterwards. | ||
| /// </summary> | ||
| /// <param name="PaymentPracticeLine">The line to update with totals.</param> | ||
| /// <param name="PaymentPracticeData">The data to aggregate from. Filters set by the caller define the slice.</param> | ||
| procedure CalculateLineTotals(var PaymentPracticeLine: Record "Payment Practice Line"; var PaymentPracticeData: Record "Payment Practice Data") | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.