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

[Event Request] codeunit 18147 "e-Invoice Json Handler" OnBeforeWriteItem #27911

Open
BadaboomDev opened this issue Jan 9, 2025 · 0 comments

Comments

@BadaboomDev
Copy link

Describe the request

    local procedure WriteItem(
        SlNo: Text[10];
        ProductName: Text;
        HSNCode: Text[10];
        GstRate: Decimal;
        Quantity: Decimal;
        Unit: Text[3];
        UnitPrice: Decimal;
        TotAmount: Decimal;
        Discount: Decimal;
        OtherCharges: Decimal;
        AssessableAmount: Decimal;
        CGSTRate: Decimal;
        SGSTRate: Decimal;
        IGSTRate: Decimal;
        CESSRate: Decimal;
        CessNonAdvanceAmount: Decimal;
        TotalItemValue: Decimal;
        IsServc: Text[1])
    var
        JItem: JsonObject;
        UoMLoc: record "Unit of Measure";
    begin
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        OnBeforeWriteItem(Unit);
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        JItem.Add('SlNo', SlNo);
        JItem.Add('PrdDesc', ProductName);
        JItem.Add('IsServc', IsServc);
        JItem.Add('HsnCd', HSNCode);
        JItem.Add('Qty', Quantity);
    [IntegrationEvent(false, false)]
    local procedure OnBeforeWriteItem(var Unit: Text[3])
    begin
    end;
    local procedure ReadEwbDtls()
    var
        SalesInvHeader: Record "Sales Invoice Header";
        ShippingAgent: Record "Shipping Agent";
        TransID: Text[15];
        TransName: Text[100];
        TransMode: Text[20];
        Distance: Integer;
        TransDocNo: Text[15];
        TransDocDt: Text[10];
        TransportDocDt: Text[10];
        VehNo: Text[20];
        VehType: Text[1];
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        IsHandled: Boolean;
    begin
        IsHandled := false;
        OnBeforeReadEwbDtls(IsHandled);
        if IsHandled then
            exit;
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        [IntegrationEvent(false, false)]
    local procedure OnBeforeReadEwbDtls(var IsHandled: Boolean)
    begin
    end;
    local procedure ReadDocumentItemList()
    var
        SalesInvoiceLine: Record "Sales Invoice Line";
        SalesCrMemoLine: Record "Sales Cr.Memo Line";
        AssessableAmount: Decimal;
        GstRate: Decimal;
        CGSTRate: Decimal;
        SGSTRate: Decimal;
        IGSTRate: Decimal;
        CessRate: Decimal;
        CesNonAdval: Decimal;
        StateCess: Decimal;
        CGSTValue: Decimal;
        SGSTValue: Decimal;
        IGSTValue: Decimal;
        IsServc: Text[1];
        Count: Integer;
    begin
        Count := 1;
        Clear(JsonArrayData);
        if IsInvoice then begin
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
            OnReadDocumentItemListSetSalesInvoiceLineFilter(salesinvoiceline);
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            SalesInvoiceLine.SetRange("Document No.", DocumentNo);

        [IntegrationEvent(false, false)]
    local procedure OnReadDocumentItemListSetSalesInvoiceLineFilter(var SalesInvoiceLine: Record "Sales Invoice Line")
    begin
    end;

    local procedure ReadDocumentItemList()
    var
        SalesInvoiceLine: Record "Sales Invoice Line";
        SalesCrMemoLine: Record "Sales Cr.Memo Line";
        AssessableAmount: Decimal;
        GstRate: Decimal;
        CGSTRate: Decimal;
        SGSTRate: Decimal;
        IGSTRate: Decimal;
        CessRate: Decimal;
        CesNonAdval: Decimal;
        StateCess: Decimal;
        CGSTValue: Decimal;
        SGSTValue: Decimal;
        IGSTValue: Decimal;
        IsServc: Text[1];
        Count: Integer;
    begin
        Count := 1;
        Clear(JsonArrayData);
...
        end else begin
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
            OnReadDocumentItemListSetSalesCrMemoLineFilter(SalesCrMemoLine);
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            SalesCrMemoLine.SetRange("Document No.", DocumentNo);
            SalesCrMemoLine.SetFilter(Type, '<>%1', SalesCrMemoLine.Type::" ");
            SalesCrMemoLine.SetFilter(Quantity, '<>%1', 0);
            if SalesCrMemoLine.FindSet() then begin
                if SalesCrMemoLine.Count > 100 then
                    Error(SalesLinesMaxCountLimitErr, SalesCrMemoLine.Count);
            [IntegrationEvent(false, false)]
    local procedure OnReadDocumentItemListSetSalesCrMemoLineFilter(var SalesCrMemoLine: Record "Sales Cr.Memo Line")
    begin
    end;

Additional context

We are not using the Standard Unit Of Measure Codes from India (UQC) Codes and therefore want to change the Unit of Measure Code before creating the json file

We don't want to create the Transportation Details --> Ishandled

And we want to add additional filters to create not every item within the e-invoice file

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

No branches or pull requests

1 participant