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
Original file line number Diff line number Diff line change
Expand Up @@ -10096,7 +10096,9 @@ table 39 "Purchase Line"
IsHandled: Boolean;
OutstandingAmountExclTax: Decimal;
begin
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) and
(Rec.Quantity = xRec.Quantity)
then
if PurchHeader."Document Type" <> PurchHeader."Document Type"::Invoice then
exit;

Expand Down
4 changes: 3 additions & 1 deletion src/Layers/APAC/BaseApp/Sales/Document/SalesLine.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -5792,7 +5792,9 @@ table 37 "Sales Line"
if IsHandled then
exit;

if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) and
Comment thread
Shikhverma marked this conversation as resolved.
(Rec.Quantity = xRec.Quantity)
then
if SalesHeader."Document Type" <> SalesHeader."Document Type"::Invoice then
exit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9586,7 +9586,9 @@ table 39 "Purchase Line"
var
OutstandingAmountExclTax: Decimal;
begin
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) and
(Rec.Quantity = xRec.Quantity)
then
if PurchHeader."Document Type" <> PurchHeader."Document Type"::Invoice then
exit;

Expand Down
4 changes: 3 additions & 1 deletion src/Layers/BE/BaseApp/Sales/Document/SalesLine.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -5703,7 +5703,9 @@ table 37 "Sales Line"
if IsHandled then
exit;

if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) and
(Rec.Quantity = xRec.Quantity)
then
if SalesHeader."Document Type" <> SalesHeader."Document Type"::Invoice then
exit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9481,7 +9481,9 @@ table 39 "Purchase Line"
var
OutstandingAmountExclTax: Decimal;
begin
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) and
(Rec.Quantity = xRec.Quantity)
then
if PurchHeader."Document Type" <> PurchHeader."Document Type"::Invoice then
exit;

Expand Down
4 changes: 3 additions & 1 deletion src/Layers/CH/BaseApp/Sales/Document/SalesLine.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -5813,7 +5813,9 @@ table 37 "Sales Line"
if IsHandled then
exit;

if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) and
(Rec.Quantity = xRec.Quantity)
then
if SalesHeader."Document Type" <> SalesHeader."Document Type"::Invoice then
exit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9480,7 +9480,9 @@ table 39 "Purchase Line"
var
OutstandingAmountExclTax: Decimal;
begin
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) and
(Rec.Quantity = xRec.Quantity)
then
if PurchHeader."Document Type" <> PurchHeader."Document Type"::Invoice then
exit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9499,7 +9499,9 @@ table 39 "Purchase Line"
var
OutstandingAmountExclTax: Decimal;
begin
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) and
(Rec.Quantity = xRec.Quantity)
then
if PurchHeader."Document Type" <> PurchHeader."Document Type"::Invoice then
exit;

Expand Down
4 changes: 3 additions & 1 deletion src/Layers/ES/BaseApp/Sales/Document/SalesLine.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -5727,7 +5727,9 @@ table 37 "Sales Line"
if IsHandled then
exit;

if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) and
(Rec.Quantity = xRec.Quantity)
then
if SalesHeader."Document Type" <> SalesHeader."Document Type"::Invoice then
exit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9473,7 +9473,9 @@ table 39 "Purchase Line"
var
OutstandingAmountExclTax: Decimal;
begin
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) and
(Rec.Quantity = xRec.Quantity)
then
if PurchHeader."Document Type" <> PurchHeader."Document Type"::Invoice then
exit;

Expand Down
4 changes: 3 additions & 1 deletion src/Layers/FI/BaseApp/Sales/Document/SalesLine.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -5714,7 +5714,9 @@ table 37 "Sales Line"
if IsHandled then
exit;

if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) and
(Rec.Quantity = xRec.Quantity)
then
if SalesHeader."Document Type" <> SalesHeader."Document Type"::Invoice then
exit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9524,7 +9524,9 @@ table 39 "Purchase Line"
var
OutstandingAmountExclTax: Decimal;
begin
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) and
(Rec.Quantity = xRec.Quantity)
then
if PurchHeader."Document Type" <> PurchHeader."Document Type"::Invoice then
exit;

Expand Down
4 changes: 3 additions & 1 deletion src/Layers/GB/BaseApp/Sales/Document/SalesLine.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -5766,7 +5766,9 @@ table 37 "Sales Line"
if IsHandled then
exit;

if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) and
(Rec.Quantity = xRec.Quantity)
then
if SalesHeader."Document Type" <> SalesHeader."Document Type"::Invoice then
exit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9759,7 +9759,9 @@ table 39 "Purchase Line"
var
OutstandingAmountExclTax: Decimal;
begin
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) and
(Rec.Quantity = xRec.Quantity)
then
if PurchHeader."Document Type" <> PurchHeader."Document Type"::Invoice then
exit;

Expand Down
4 changes: 3 additions & 1 deletion src/Layers/IT/BaseApp/Sales/Document/SalesLine.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -5815,7 +5815,9 @@ table 37 "Sales Line"
if IsHandled then
exit;

if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) and
(Rec.Quantity = xRec.Quantity)
then
if SalesHeader."Document Type" <> SalesHeader."Document Type"::Invoice then
exit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9802,7 +9802,9 @@ table 39 "Purchase Line"
var
OutstandingAmountExclTax: Decimal;
begin
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) and
(Rec.Quantity = xRec.Quantity)
then
if PurchHeader."Document Type" <> PurchHeader."Document Type"::Invoice then
exit;

Expand Down
4 changes: 3 additions & 1 deletion src/Layers/NA/BaseApp/Sales/Document/SalesLine.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -5802,7 +5802,9 @@ table 37 "Sales Line"
if IsHandled then
exit;

if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) and
Comment thread
Shikhverma marked this conversation as resolved.
(Rec.Quantity = xRec.Quantity)
then
if SalesHeader."Document Type" <> SalesHeader."Document Type"::Invoice then
exit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9467,7 +9467,9 @@ table 39 "Purchase Line"
var
OutstandingAmountExclTax: Decimal;
begin
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) and
(Rec.Quantity = xRec.Quantity)
then
if PurchHeader."Document Type" <> PurchHeader."Document Type"::Invoice then
exit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9494,7 +9494,9 @@ table 39 "Purchase Line"
var
OutstandingAmountExclTax: Decimal;
begin
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) and
(Rec.Quantity = xRec.Quantity)
then
if PurchHeader."Document Type" <> PurchHeader."Document Type"::Invoice then
exit;

Expand Down
4 changes: 3 additions & 1 deletion src/Layers/NO/BaseApp/Sales/Document/SalesLine.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -5751,7 +5751,9 @@ table 37 "Sales Line"
if IsHandled then
exit;

if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) and
(Rec.Quantity = xRec.Quantity)
then
if SalesHeader."Document Type" <> SalesHeader."Document Type"::Invoice then
exit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9717,7 +9717,9 @@ table 39 "Purchase Line"
var
OutstandingAmountExclTax: Decimal;
begin
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) and
(Rec.Quantity = xRec.Quantity)
then
if PurchHeader."Document Type" <> PurchHeader."Document Type"::Invoice then
exit;

Expand Down
4 changes: 3 additions & 1 deletion src/Layers/RU/BaseApp/Sales/Document/SalesLine.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -5866,7 +5866,9 @@ table 37 "Sales Line"
if IsHandled then
exit;

if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) and
(Rec.Quantity = xRec.Quantity)
then
if SalesHeader."Document Type" <> SalesHeader."Document Type"::Invoice then
exit;

Expand Down
25 changes: 25 additions & 0 deletions src/Layers/RU/Tests/Prepayment/ERMPrepayment.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -4369,6 +4369,31 @@
NotificationLifecycleMgt.RecallAllNotifications();
end;

[Test]
[Scope('OnPrem')]
procedure CannotReduceSalesOrderQuantityToInvoicedQuantityAfterPrepayment()
var
SalesHeader: Record "Sales Header";
SalesLine: Record "Sales Line";
begin
// [SCENARIO 646136] Reduce Sales Order quantity after prepayment and partial invoicing

// [GIVEN] Posted 50% Prepayment Invoice for Sales Order
InitSalesPrepaymentScenario(SalesHeader, SalesLine, false, 50, '');
LibrarySales.PostSalesPrepaymentInvoice(SalesHeader);

// [GIVEN] Order is partially shipped and invoiced
PostPartialSalesInvoice(SalesHeader, SalesLine);
LibrarySales.ReopenSalesDocument(SalesHeader);
SalesLine.Find();

// [WHEN] Reduce Quantity to the invoiced quantity
asserterror SalesLine.Validate(Quantity, SalesLine."Quantity Invoiced");

// [THEN] Error occurs because the posted prepayment exceeds the new line amount
Assert.ExpectedError(SalesLine.FieldCaption("Prepmt. Line Amount"));
end;

local procedure Initialize()
var
LibraryERMCountryData: Codeunit "Library - ERM Country Data";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9473,7 +9473,9 @@ table 39 "Purchase Line"
var
OutstandingAmountExclTax: Decimal;
begin
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) and
(Rec.Quantity = xRec.Quantity)
then
if PurchHeader."Document Type" <> PurchHeader."Document Type"::Invoice then
exit;

Expand Down
4 changes: 3 additions & 1 deletion src/Layers/SE/BaseApp/Sales/Document/SalesLine.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -5714,7 +5714,9 @@ table 37 "Sales Line"
if IsHandled then
exit;

if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) and
(Rec.Quantity = xRec.Quantity)
then
if SalesHeader."Document Type" <> SalesHeader."Document Type"::Invoice then
exit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9462,7 +9462,9 @@ table 39 "Purchase Line"
var
OutstandingAmountExclTax: Decimal;
begin
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Rcd. Not Invoiced" = 0) and
Comment thread
Shikhverma marked this conversation as resolved.
(Rec.Quantity = xRec.Quantity)
then
if PurchHeader."Document Type" <> PurchHeader."Document Type"::Invoice then
exit;

Expand Down
4 changes: 3 additions & 1 deletion src/Layers/W1/BaseApp/Sales/Document/SalesLine.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -5702,7 +5702,9 @@ table 37 "Sales Line"
if IsHandled then
exit;

if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) then
if (Rec.Quantity <> 0) and (Rec."Outstanding Quantity" = 0) and (Rec."Qty. Shipped Not Invoiced" = 0) and
Comment thread
Shikhverma marked this conversation as resolved.
(Rec.Quantity = xRec.Quantity)
then
if SalesHeader."Document Type" <> SalesHeader."Document Type"::Invoice then
exit;

Expand Down
49 changes: 49 additions & 0 deletions src/Layers/W1/Tests/Prepayment/ERMPrepayment.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -2619,6 +2619,30 @@
Assert.ExpectedTestFieldError(PurchaseLine.FieldCaption("Prepmt. Amt. Inv."), '');
end;

[Test]
[Scope('OnPrem')]
procedure CannotReducePurchaseOrderQuantityToInvoicedQuantityAfterPrepayment()
var
PurchaseHeader: Record "Purchase Header";
PurchaseLine: Record "Purchase Line";
begin
// [SCENARIO 646136] Reduce Purchase Order quantity after prepayment and partial invoicing
// [GIVEN] Posted 50% Prepayment Invoice for Purchase Order
InitPurchasePrepaymentScenario(PurchaseHeader, PurchaseLine, false, 50, '');
LibraryPurchase.PostPurchasePrepaymentInvoice(PurchaseHeader);

// [GIVEN] Order is partially received and invoiced
PostPartialPurchaseInvoice(PurchaseHeader, PurchaseLine);
LibraryPurchase.ReopenPurchaseDocument(PurchaseHeader);
PurchaseLine.Find();

// [WHEN] Reduce Quantity to the invoiced quantity
asserterror PurchaseLine.Validate(Quantity, PurchaseLine."Quantity Invoiced");

// [THEN] Error occurs because the posted prepayment exceeds the new line amount
Assert.ExpectedError(PurchaseLine.FieldCaption("Prepmt. Line Amount"));
end;

[Test]
[Scope('OnPrem')]
procedure DeletePurchaseOrderAfterPrepaymentCrMemo()
Expand Down Expand Up @@ -4162,6 +4186,31 @@
TearDownVATPostingSetup(SalesHeader."VAT Bus. Posting Group");
end;

[Test]
[Scope('OnPrem')]
procedure CannotReduceSalesOrderQuantityToInvoicedQuantityAfterPrepayment()
var
SalesHeader: Record "Sales Header";
SalesLine: Record "Sales Line";
begin
// [SCENARIO 646136] Reduce Sales Order quantity after prepayment and partial invoicing

// [GIVEN] Posted 50% Prepayment Invoice for Sales Order
InitSalesPrepaymentScenario(SalesHeader, SalesLine, false, 50, '');
LibrarySales.PostSalesPrepaymentInvoice(SalesHeader);

// [GIVEN] Order is partially shipped and invoiced
PostPartialSalesInvoice(SalesHeader, SalesLine);
LibrarySales.ReopenSalesDocument(SalesHeader);
SalesLine.Find();

// [WHEN] Reduce Quantity to the invoiced quantity
asserterror SalesLine.Validate(Quantity, SalesLine."Quantity Invoiced");

// [THEN] Error occurs because the posted prepayment exceeds the new line amount
Assert.ExpectedError(SalesLine.FieldCaption("Prepmt. Line Amount"));
end;

local procedure Initialize()
var
LibraryERMCountryData: Codeunit "Library - ERM Country Data";
Expand Down
Loading