-
Notifications
You must be signed in to change notification settings - Fork 436
[main] features 640066 Add integration events for events for CZ Adv. Payment and CZ Cash Desk #10079
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
v-janpopr
wants to merge
7
commits into
main
Choose a base branch
from
features/640066-main-EventsforAdvPaymentandCashDesk
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
[main] features 640066 Add integration events for events for CZ Adv. Payment and CZ Cash Desk #10079
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8337702
Add integration events for advance letter validation and lookup; enha…
v-janpopr f35fa6a
Enhance cash document validation by ensuring VAT amounts are calculat…
v-janpopr 64921ff
Refactor OnBeforeValidateAdvanceLetterNoCZZ procedure to simplify par…
v-janpopr 6f02397
Refactor mandatory fields check by separating amount validation into …
v-janpopr d626781
Add test codeunit for advance letter number validation and lookup han…
v-janpopr ae7eaf1
Add tests for cash document release amount validation and subscriber …
v-janpopr 9df93e9
Add copyright headers and namespace declarations to test codeunits
v-janpopr 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
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
40 changes: 40 additions & 0 deletions
40
src/Apps/CZ/AdvancePaymentsLocalization/test/Src/CashDocLineTestHandlerCZZ.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,40 @@ | ||
| // ------------------------------------------------------------------------------------------------ | ||
| // 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.AdvancePayments; | ||
|
|
||
| using Microsoft.Finance.CashDesk; | ||
|
|
||
| codeunit 148132 "Cash Doc Line Test Handler CZZ" | ||
| { | ||
| EventSubscriberInstance = Manual; | ||
|
|
||
| var | ||
| ValidateAdvanceLetterNoEventRaised: Boolean; | ||
| LookupAdvanceLetterNoEventRaised: Boolean; | ||
|
|
||
| [EventSubscriber(ObjectType::Table, Database::"Cash Document Line CZP", 'OnBeforeValidateAdvanceLetterNoCZZ', '', false, false)] | ||
| local procedure HandleOnBeforeValidateAdvanceLetterNoCZZ(var CashDocumentLineCZP: Record "Cash Document Line CZP"; var IsHandled: Boolean) | ||
| begin | ||
| ValidateAdvanceLetterNoEventRaised := true; | ||
| IsHandled := true; | ||
| end; | ||
|
|
||
| [EventSubscriber(ObjectType::Table, Database::"Cash Document Line CZP", 'OnBeforeLookupAdvanceLetterNoCZZ', '', false, false)] | ||
| local procedure HandleOnBeforeLookupAdvanceLetterNoCZZ(var CashDocumentLineCZP: Record "Cash Document Line CZP"; var IsHandled: Boolean) | ||
| begin | ||
| LookupAdvanceLetterNoEventRaised := true; | ||
| IsHandled := true; | ||
| end; | ||
|
|
||
| procedure GetValidateAdvanceLetterNoEventRaised(): Boolean | ||
| begin | ||
| exit(ValidateAdvanceLetterNoEventRaised); | ||
| end; | ||
|
|
||
| procedure GetLookupAdvanceLetterNoEventRaised(): Boolean | ||
| begin | ||
| exit(LookupAdvanceLetterNoEventRaised); | ||
| end; | ||
| } | ||
|
v-janpopr marked this conversation as resolved.
|
||
92 changes: 92 additions & 0 deletions
92
src/Apps/CZ/AdvancePaymentsLocalization/test/Src/CashDocumentLineCZZ.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,92 @@ | ||
| // ------------------------------------------------------------------------------------------------ | ||
| // 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.AdvancePayments; | ||
|
|
||
| using Microsoft.Finance.CashDesk; | ||
| using Microsoft.Finance.GeneralLedger.Setup; | ||
| using Microsoft.Sales.Customer; | ||
|
|
||
| codeunit 148133 "Cash Document Line CZZ" | ||
| { | ||
| Subtype = Test; | ||
| TestPermissions = Disabled; | ||
|
|
||
| var | ||
| Assert: Codeunit Assert; | ||
| CashDocLineTestHandlerCZZ: Codeunit "Cash Doc Line Test Handler CZZ"; | ||
| LibraryCashDeskCZP: Codeunit "Library - Cash Desk CZP"; | ||
| LibraryCashDocumentCZP: Codeunit "Library - Cash Document CZP"; | ||
| LibraryUtility: Codeunit "Library - Utility"; | ||
| LibrarySales: Codeunit "Library - Sales"; | ||
|
|
||
| [Test] | ||
| procedure ValidateAdvanceLetterNoCanBeHandled() | ||
| var | ||
| CashDocumentLineCZP: Record "Cash Document Line CZP"; | ||
| AdvanceLetterNo: Code[20]; | ||
| begin | ||
| // [SCENARIO] Validation of the advance letter number can be handled by a subscriber | ||
| Initialize(); | ||
| AdvanceLetterNo := CopyStr(LibraryUtility.GenerateRandomCode( | ||
| CashDocumentLineCZP.FieldNo("Advance Letter No. CZZ"), Database::"Cash Document Line CZP"), 1, MaxStrLen(CashDocumentLineCZP."Advance Letter No. CZZ")); | ||
| BindSubscription(CashDocLineTestHandlerCZZ); | ||
|
|
||
| // [WHEN] An advance letter number is validated on an otherwise invalid cash document line | ||
| CashDocumentLineCZP.Validate("Advance Letter No. CZZ", AdvanceLetterNo); | ||
| UnbindSubscription(CashDocLineTestHandlerCZZ); | ||
|
|
||
| // [THEN] The subscriber handles the validation before the standard checks are run | ||
| Assert.IsTrue(CashDocLineTestHandlerCZZ.GetValidateAdvanceLetterNoEventRaised(), 'The before validate event must be raised.'); | ||
| CashDocumentLineCZP.TestField("Advance Letter No. CZZ", AdvanceLetterNo); | ||
| end; | ||
|
|
||
| [Test] | ||
| procedure LookupAdvanceLetterNoCanBeHandled() | ||
| var | ||
| CashDeskCZP: Record "Cash Desk CZP"; | ||
| CashDeskUserCZP: Record "Cash Desk User CZP"; | ||
| CashDocumentHeaderCZP: Record "Cash Document Header CZP"; | ||
| CashDocumentLineCZP: Record "Cash Document Line CZP"; | ||
| Customer: Record Customer; | ||
| CashDocumentSubformCZP: TestPage "Cash Document Subform CZP"; | ||
| begin | ||
| // [SCENARIO] Lookup of the advance letter number can be handled by a subscriber | ||
| Initialize(); | ||
| LibrarySales.CreateCustomer(Customer); | ||
| LibraryCashDeskCZP.CreateCashDeskCZP(CashDeskCZP); | ||
| LibraryCashDeskCZP.SetupCashDeskCZP(CashDeskCZP, false); | ||
| LibraryCashDeskCZP.CreateCashDeskUserCZP(CashDeskUserCZP, CashDeskCZP."No.", true, true, true); | ||
| LibraryCashDocumentCZP.CreateCashDocumentHeaderCZP(CashDocumentHeaderCZP, CashDocumentHeaderCZP."Document Type"::Receipt, CashDeskCZP."No."); | ||
| LibraryCashDocumentCZP.CreateCashDocumentLineCZP( | ||
| CashDocumentLineCZP, CashDocumentHeaderCZP, | ||
| Enum::"Cash Document Account Type CZP"::Customer, Customer."No.", 0); | ||
| CashDocumentLineCZP."Gen. Document Type" := CashDocumentLineCZP."Gen. Document Type"::" "; | ||
| CashDocumentLineCZP.Modify(); | ||
| BindSubscription(CashDocLineTestHandlerCZZ); | ||
|
|
||
| // [WHEN] The advance letter number lookup is invoked on an otherwise invalid cash document line | ||
| CashDocumentSubformCZP.OpenEdit(); | ||
| CashDocumentSubformCZP.GoToRecord(CashDocumentLineCZP); | ||
| CashDocumentSubformCZP."Advance Letter No. CZZ".Lookup(); | ||
| CashDocumentSubformCZP.Close(); | ||
| UnbindSubscription(CashDocLineTestHandlerCZZ); | ||
|
|
||
| // [THEN] The subscriber handles the lookup before the standard checks are run | ||
| Assert.IsTrue(CashDocLineTestHandlerCZZ.GetLookupAdvanceLetterNoEventRaised(), 'The before lookup event must be raised.'); | ||
| end; | ||
|
|
||
| local procedure Initialize() | ||
| var | ||
| GeneralLedgerSetup: Record "General Ledger Setup"; | ||
| begin | ||
| Clear(CashDocLineTestHandlerCZZ); | ||
|
|
||
| GeneralLedgerSetup.Get(); | ||
| if GeneralLedgerSetup."Cash Desk Nos. CZP" = '' then begin | ||
| GeneralLedgerSetup.Validate("Cash Desk Nos. CZP", LibraryUtility.GetGlobalNoSeriesCode()); | ||
| GeneralLedgerSetup.Modify(true); | ||
| end; | ||
| 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
16 changes: 16 additions & 0 deletions
16
src/Apps/CZ/CashDeskLocalization/test/Src/CashDocReleaseHandlerCZP.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,16 @@ | ||
| // ------------------------------------------------------------------------------------------------ | ||
| // 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.CashDesk; | ||
|
|
||
| codeunit 148134 "Cash Doc. Release Handler CZP" | ||
| { | ||
| EventSubscriberInstance = Manual; | ||
|
|
||
| [EventSubscriber(ObjectType::Codeunit, Codeunit::"Cash Document-Release CZP", 'OnBeforeCheckMandatoryFieldsSkipAmounts', '', false, false)] | ||
| local procedure SetSkipAmountsTestFieldsOnBeforeCheckMandatoryFieldsSkipAmounts(CashDocumentHeaderCZP: Record "Cash Document Header CZP"; var SkipAmountsTestFields: Boolean) | ||
| begin | ||
| SkipAmountsTestFields := true; | ||
| end; | ||
| } |
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.