﻿/*@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400&display=swap');*/

:root {
    --primary-color: #6a5acd;
    --secondary-color: #4b0082;
    --gradient-primary: linear-gradient(135deg, #6a5acd 0%, #4b0082 100%);
    --gradient-secondary: linear-gradient(135deg, #8a2be2 0%, #4b0082 100%);
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
}

* {
    box-sizing: border-box;
    transition: all 0.3s ease;
}

body {
    font-family: 'Poppins', Arial, sans-serif;
    background-color: #f4f6fa;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    font-weight: 300;
    margin: 0;
    padding: 0;
    text-rendering: optimizeLegibility;
}

.vendorbooks-page-navbar-custom {
    background: linear-gradient(135deg, #3f37c9, #4cd964) !important;
    padding: 0.1rem 0.5rem;
    color: #fff;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    margin: 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
}

.vendorbooks-page-brand-custom {
    background: linear-gradient(135deg, #fdfdfd, #eaf7fd); /* Match button-container */
    color: #1e293b !important; /* Dark neutral for contrast */
    font-weight: 600;
    font-size: 1.3rem;
    letter-spacing: -0.5px;
    padding: 0.5rem 1rem;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

    .vendorbooks-page-brand-custom i {
        color: #338aff; /* Match button blue */
        margin-right: 8px;
    }


/*
.vendorbooks-page-brand-custom {
    color: white !important;
    font-weight: 600;
    font-size: 1.3rem;
    letter-spacing: -0.5px;
}

    .vendorbooks-page-brand-custom i {
        color: rgba(255, 255, 255, 0.9);
        margin-right: 12px;
    }*/

.vendorbooks-button-btn-custom {
    position: relative;
    z-index: 1;
    overflow: hidden;
    background: linear-gradient(-45deg, #ffa63d, #87cefa, #338aff, #3cf0c5);
    background-size: 600%;
    animation: anime 16s linear infinite;
    color: rgba(255, 255, 255, 0.95) !important;
    border: none;
    border-radius: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
    font-size: 0.9rem;
    padding: 0.6rem 1rem;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
}

    .vendorbooks-button-btn-custom::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 15px;
        background: linear-gradient(-45deg, #ffa63d, #87cefa, #338aff, #3cf0c5);
        background-size: 600%;
        animation: anime 16s linear infinite;
        filter: blur(30px);
        opacity: 0.8;
        z-index: -1;
    }

    .vendorbooks-button-btn-custom:hover {
        transform: translateY(-3px);
        box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
        color: aqua;
    }

@media (max-width: 768px) {
    .vendorbooks-page-navbar-custom {
        padding: 0.6rem 1rem;
    }
}

@keyframes anime {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.vendorbooks-login-bg-custom {
    position: relative;
    z-index: 1;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.2);
    color: #ffffff;
    animation: floaty-glow 10s ease infinite;
    transition: all 0.4s ease;
    max-width: 400px;
    margin: auto;
}

    .vendorbooks-login-bg-custom::before {
        content: '';
        position: absolute;
        top: -50%;
        left: -50%;
        width: 200%;
        height: 200%;
        background: conic-gradient(from 0deg, #ffa63d, #87cefa, #338aff, #3cf0c5, #ffa63d);
        animation: rotate-gradient 10s linear infinite;
        z-index: -2;
        opacity: 0.7;
        filter: blur(50px);
    }

    .vendorbooks-login-bg-custom:hover {
        transform: translateY(-5px);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    }

@keyframes rotate-gradient {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes floaty-glow {
    0%, 100% {
        box-shadow: 0 0 30px rgba(255, 255, 255, 0.1);
    }

    50% {
        box-shadow: 0 0 50px rgba(255, 255, 255, 0.2);
    }
}

.vend-pos-tender {
    background: linear-gradient(135deg, #1c1c1e, #0c81ff, #4ade80);
    background-size: 300% 300%;
    animation: gradientFlow 14s ease infinite;
    color: white;
    padding: 1rem;
    border-radius: 10px;
}

@keyframes gradientFlow {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.vend-pos-navbar {
    background: linear-gradient(135deg, #1c1c1e, #0c81ff, #4ade80);
    background-size: 400% 400%;
    animation: gradientFlow 20s ease infinite;
    color: white;
    padding: 1rem 2rem;
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transform: translateZ(0);
    will-change: background-position;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.gradient-button-container {
    background: linear-gradient(135deg, #b4ccd1, #cee8ce);
    border: 1px solid #c3f0cc;
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.gradient-button-container-dark {
    background: linear-gradient(135deg, #1e293b, #3b4252, #e7f9ff20);
    border: 1px solid #4b5563;
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    color: #f1f5f9;
}

.gradient-button-container-soft {
    background: linear-gradient(135deg, #e7f9ff, #ccf3e0, #d0f2f9);
    border: 1px solid #b6e6e6;
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.button-container {
    background: linear-gradient(135deg, #fdfdfd, #eaf7fd); /* Soft cool white-blue */
    padding: 0.75rem;
    border-radius: 1.25rem;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    display: flex;
    color: #1e293b; /* Dark neutral text */
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    border: 1px solid #d6eaf8;
    margin: 0;
}

.top-navbar-container {
    background: linear-gradient(135deg, #fdfdfd, #eaf7fd); /* Same gradient as button-container */
    padding: 0.75rem 1.5rem;
    border-radius: 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06); /* Slightly lighter shadow for softer tone */
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #d6eaf8; /* Matches button-container border */
    position: sticky;
    top: 0;
    width: 100%;
    z-index: 1000;
    color: #1e293b; /* Dark text for contrast */
}



.nav-link {
    font-weight: 500;
    padding: 12px 16px;
    margin: 4px 0;
    color: #333;
    display: flex;
    align-items: center;
    border-radius: 6px;
    transition: background 0.3s, color 0.3s;
}

    .nav-link:hover {
        background-color: #eaf4fb;@model VendorbookMVPlus.Models.DiscountModel

<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="~/FrontEnd/plugins/fontawesome-free/css/all.min.css">
    <!-- DataTables -->
    <link rel="stylesheet" href="~/FrontEnd/plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
    <link rel="stylesheet" href="~/FrontEnd/plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
    <link rel="stylesheet" href="~/FrontEnd/plugins/datatables-buttons/css/buttons.bootstrap4.min.css">
    <link rel="stylesheet" href="~/FrontEnd/dist/css/adminlte.min.css">
    <link href="~/FrontEnd/plugins/jquery-ui/jquery-ui.min.css" rel="stylesheet" />
    <script src="~/FrontEnd/plugins/jquery-ui/jquery-ui.min.js"></script>
    <script src="~/FrontEnd/plugins/datatables/jquery.dataTables.min.js"></script>
    <script src="~/FrontEnd/plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
    <script src="~/FrontEnd/plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
    <script src="~/FrontEnd/plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
    <script src="~/FrontEnd/plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
    <script src="~/FrontEnd/plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
    <script src="~/FrontEnd/plugins/jszip/jszip.min.js"></script>
    <script src="~/FrontEnd/plugins/pdfmake/pdfmake.min.js"></script>
    <script src="~/FrontEnd/plugins/pdfmake/vfs_fonts.js"></script>
    <script src="~/FrontEnd/plugins/datatables-buttons/js/buttons.html5.min.js"></script>
    <script src="~/FrontEnd/plugins/datatables-buttons/js/buttons.print.min.js"></script>
    <script src="~/FrontEnd/plugins/datatables-buttons/js/buttons.colVis.min.js"></script>
    <script src="~/Scripts/Scripts.js"></script>
    <script src="~/Formscripts/appscripts.js"></script>
    <script src="~/Formscripts/applicationFormScripts.js"></script>
    <script src="~/Scripts/notify.min.js"></script>
    <link href="~/Content/chosen/chosen.min.css" rel="stylesheet" />
    <link href="~/Content/chosen/chosencustomcss.css" rel="stylesheet" />
    @Scripts.Render("~/bundles/jqueryval")
    <style>
        /* Add this CSS code to your stylesheet */
        .custom-confirm-button {
            background-color: #d9534f !important; /* Change the color to your desired red shade */
            color: #fff !important;
        }
    </style>

</head>

<body>


    <div class="row" style="width:100%;margin:1px">
        <div class="col-lg-12 col-md-12 bg-gradient-white" style="width:100%;margin:1px">
            @using (Html.BeginForm("CreateDiscount", "Payment", FormMethod.Post, new { onsubmit = "return SubmitDiscount(this)" }))
            {
                @*@Html.AntiForgeryToken()*@

                <div class="form-horizontal">
                    @Html.ValidationSummary(true, "", new { @class = "text-danger" })

                    <div class="card card-default p-0">
                        <div class="card-header card-lightblue">
                            <h3 class="card-title"><strong>DISCOUNT DETAILS</strong></h3>
                        </div>
                        <div id="dvcoa" class="card-body p-1">
                            <div class="row p-0">
                                <div class="col-lg-6 col-md-6 col-sm-12">
                                    <div class="form-group">
                                        @Html.LabelFor(model => model.TransactionDate, htmlAttributes: new { @class = "control-label" })
                                        <div>

                                            @Html.TextBoxFor(x => x.TransactionDate, "{0:yyyy-MM-dd}", new { @class = "form-control form-control-sm", @type = "date", @id = "txtdate" })
                                            @Html.ValidationMessageFor(model => model.TransactionDate, "", new { @class = "text-danger" })
                                        </div>
                                    </div>
                                </div>

                                <div class="col-lg-6 col-md-6 col-sm-12">
                                    <div class="form-group">
                                        @Html.LabelFor(model => model.MaxDiscountRate, htmlAttributes: new { @class = "control-label" })
                                        <div>
                                            @Html.EditorFor(model => model.MaxDiscountRate, new { htmlAttributes = new { @class = "form-control form-control-sm", @id = "txtmaxdiscountrate", @readonly = "readonly" } })
                                            @Html.ValidationMessageFor(model => model.MaxDiscountRate, "", new { @class = "text-danger" })
                                        </div>
                                    </div>
                                </div>

                            </div>



                            <div class="row p-0">
                                <div class="col-lg-4 col-md-4 col-sm-12">
                                    <div class="form-group">
                                        @Html.LabelFor(model => model.Amount, htmlAttributes: new { @class = "control-label" })
                                        <div>
                                            @Html.EditorFor(model => model.Amount, new { htmlAttributes = new { @class = "form-control form-control-sm", @id = "txtamount", @readonly = "readonly" } })
                                            @Html.ValidationMessageFor(model => model.Amount, "", new { @class = "text-danger" })
                                        </div>
                                    </div>
                                </div>

                                <div class="col-lg-4 col-md-4 col-sm-12">
                                    <div class="form-group">
                                        @Html.LabelFor(model => model.DiscountRate, htmlAttributes: new { @class = "control-label" })
                                        <div>
                                            @Html.EditorFor(model => model.DiscountRate, new { htmlAttributes = new { @class = "form-control form-control-sm", @id = "txtdiscountrate" } })
                                            @Html.ValidationMessageFor(model => model.DiscountRate, "", new { @class = "text-danger" })
                                        </div>
                                    </div>
                                </div>

                                <div class="col-lg-4 col-md-4 col-sm-12">
                                    <div class="form-group">
                                        @Html.LabelFor(model => model.Discount, htmlAttributes: new { @class = "control-label" })
                                        <div>
                                            @Html.EditorFor(model => model.Discount, new { htmlAttributes = new { @class = "form-control form-control-sm", @id = "txtdiscount" } })
                                            @Html.ValidationMessageFor(model => model.Discount, "", new { @class = "text-danger" })
                                        </div>
                                    </div>
                                </div>

                            </div>




                        </div>
                    </div>

                    <div class="card card-default p-0">
                        <div class="card-header card-lightblue">
                            <h3 class="card-title"><strong>ACCOUNT TO CREDIT</strong></h3>
                        </div>
                        <div id="dvcoa" class="card-body">
                            <div class="row p-0">
                                <div class="col-lg-4 col-md-4 col-sm-12">
                                    <div class="form-group">
                                        @Html.LabelFor(model => model.AccountNo, htmlAttributes: new { @class = "control-label" })
                                        <div>
                                            @Html.EditorFor(model => model.AccountNo, new { htmlAttributes = new { @class = "form-control form-control-sm", @id = "txtactno", @readonly = "readonly" } })
                                            @Html.ValidationMessageFor(model => model.AccountNo, "", new { @class = "text-danger" })
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-4 col-md-4 col-sm-12">
                                    <div class="form-group">
                                        @Html.LabelFor(model => model.CustomerID, htmlAttributes: new { @class = "control-label" })
                                        <div>
                                            @Html.EditorFor(model => model.CustomerID, new { htmlAttributes = new { @class = "form-control form-control-sm", @id = "txtcustomerid", @readonly = "readonly" } })
                                            @Html.ValidationMessageFor(model => model.CustomerID, "", new { @class = "text-danger" })
                                        </div>
                                    </div>
                                </div>

                                <div class="col-lg-4 col-md-4 col-sm-12">
                                    <div class="form-group">
                                        @Html.LabelFor(model => model.ReferenceNo, htmlAttributes: new { @class = "control-label" })
                                        <div>
                                            @Html.EditorFor(model => model.ReferenceNo, new { htmlAttributes = new { @class = "form-control form-control-sm", @id = "txtreferenceno", @readonly = "readonly" } })
                                            @Html.ValidationMessageFor(model => model.ReferenceNo, "", new { @class = "text-danger" })
                                        </div>
                                    </div>
                                </div>

                            </div>

                            <div class="row p-0">
                                <div class="col-lg-12 col-md-12 col-sm-12">
                                    <div class="form-group">
                                        @Html.LabelFor(model => model.AccountName, htmlAttributes: new { @class = "control-label" })
                                        <div>
                                            @Html.EditorFor(model => model.AccountName, new { htmlAttributes = new { @class = "form-control form-control-sm", @id = "txtaccountname", @readonly = "readonly" } })
                                            @Html.ValidationMessageFor(model => model.AccountName, "", new { @class = "text-danger" })
                                        </div>
                                    </div>
                                </div>
                            </div>

                        </div>
                    </div>


                    <div class="card card-lightblue p-0">
                        <div class="card-header bg-yellow">
                            <h3 class="card-title"><strong>DISCOUNT INFO</strong></h3>
                        </div>
                        <div id="dvcoa" class="card-body bg-gradient-warning">
                            <div class="row p-1">
                                <div class="col-lg-4 col-md-4 col-sm-12">
                                    <div class="form-group">
                                        @Html.LabelFor(model => model.MinDiscount, htmlAttributes: new { @class = "control-label" })
                                        <div>
                                            @Html.EditorFor(model => model.MinDiscount, new { htmlAttributes = new { @class = "form-control form-control-sm", @id = "txtmindiscount", @readonly = "readonly" } })
                                            @Html.ValidationMessageFor(model => model.MinDiscount, "", new { @class = "text-danger" })
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-4 col-md-12 col-sm-12">
                                    <div class="form-group">
                                        @Html.LabelFor(model => model.MaxDiscount, htmlAttributes: new { @class = "control-label" })
                                        <div>
                                            @Html.EditorFor(model => model.MaxDiscount, new { htmlAttributes = new { @class = "form-control form-control-sm", @id = "txtmaxdiscount", @readonly = "readonly" } })
                                            @Html.ValidationMessageFor(model => model.MaxDiscount, "", new { @class = "text-danger" })
                                        </div>
                                    </div>
                                </div>

                                <div class="col-lg-4 col-md-12 col-sm-12">
                                    <div class="form-group">
                                        @Html.LabelFor(model => model.AppliedDiscount, htmlAttributes: new { @class = "control-label" })
                                        <div>
                                            @Html.EditorFor(model => model.AppliedDiscount, new { htmlAttributes = new { @class = "form-control form-control-sm", @id = "txtapplieddiscount", @readonly = "readonly" } })
                                            @Html.ValidationMessageFor(model => model.AppliedDiscount, "", new { @class = "text-danger" })
                                        </div>
                                    </div>
                                </div>

                            </div>

                        </div>
                    </div>


                    <div class="form-group">
                        <div class="col-md-offset-2 col-md-12">
                            <input type="submit" value="Save" id="btnsavediscount" class="btn btn-outline-primary btn-block" />
                        </div>
                    </div>

                </div>
            }
        </div>
    </div>


    <div id="discountdiv">
        <div class="row p-0">
            <div class="col-lg-6 col-md-6 col-sm-12">
                <div class="form-group">
                    @Html.LabelFor(model => model.DiscountAccountNo, htmlAttributes: new { @class = "control-label" })
                    <div>
                        @Html.EditorFor(model => model.DiscountAccountNo, new { htmlAttributes = new { @class = "form-control form-control-sm", @id = "txtdiscaccountno", @readonly = "readonly" } })
                        @Html.ValidationMessageFor(model => model.DiscountAccountNo, "", new { @class = "text-danger" })
                    </div>
                </div>
            </div>
            <div class="col-lg-6 col-md-6 col-sm-12">
                <div class="form-group">
                    @Html.LabelFor(model => model.CustomerID, htmlAttributes: new { @class = "control-label" })
                    <div>
                        @Html.EditorFor(model => model.CustomerID, new { htmlAttributes = new { @class = "form-control form-control-sm", @id = "txtcustomerid", @readonly = "readonly" } })
                        @Html.ValidationMessageFor(model => model.CustomerID, "", new { @class = "text-danger" })
                    </div>
                </div>
            </div>

        </div>

        <div class="row p-0">
            <div class="col-lg-6 col-md-6 col-sm-12">
                <div class="form-group">
                    @Html.LabelFor(model => model.DiscountAccountName, htmlAttributes: new { @class = "control-label" })
                    <div>
                        @Html.EditorFor(model => model.DiscountAccountName, new { htmlAttributes = new { @class = "form-control form-control-sm", @id = "txtdiscaccountname", @readonly = "readonly" } })
                        @Html.ValidationMessageFor(model => model.DiscountAccountName, "", new { @class = "text-danger" })
                    </div>
                </div>
            </div>
            <div class="col-lg-6 col-md-6 col-sm-12">
                <div class="form-group">
                    @Html.LabelFor(model => model.ReferenceNo, htmlAttributes: new { @class = "control-label" })
                    <div>
                        @Html.EditorFor(model => model.ReferenceNo, new { htmlAttributes = new { @class = "form-control form-control-sm", @id = "txtreferenceno", @readonly = "readonly" } })
                        @Html.ValidationMessageFor(model => model.ReferenceNo, "", new { @class = "text-danger" })
                    </div>
                </div>
            </div>

        </div>


    </div>


    <link href="~/FrontEnd/plugins/jquery-ui/jquery-ui.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@11.1.7/dist/sweetalert2.min.css">
    <script src="~/Content/chosen/chosen.jquery.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#txtdiscountrate").val('');
            $("#txtdiscount").val('');
            $("#txtdiscount").focus();
            $("#btndiscountClose").on("click", function (e) {
                $('#DiscountpartialModal').modal('hide');
            });



            $("#txtdiscountrate").keyup(function () {

                var minValue = parseFloat($("#txtmindiscount").val());
                var discountValue = parseFloat($("#txtdiscount").val());
                var discountRate = parseFloat($("#txtdiscountrate").val());
                var TotalInvoice = parseFloat($("#txtamount").val());
                var maxdsicrate = parseFloat($("#txtmaxdiscount").val());

                if (discountValue > minValue) {
                    Swal.fire({
                        title: 'Invalid Rate Entered',
                        text: 'The discount rate exceeds the discount rate allowed',
                        icon: 'error',
                    });



                    $("#txtdiscount, #txtdiscountrate").val("");
                    return;
                }
                if (discountRate > maxdsicrate) {
                    Swal.fire({
                        title: 'Invalid Rate Entered',
                        text: 'The discount rate exceeds the discount rate allowed',
                        icon: 'error',
                    });

                    $("#txtdiscount, #txtdiscountrate").val("");
                    return;
                }
                calculateDiscountValue(TotalInvoice, discountRate);
                debugger;
            });

            $("#txtdiscount").on("keyup", function () {

                var discountValue = parseFloat($("#txtdiscount").val());
                var minValue = parseFloat($("#txtmindiscount").val());
                var TotalInvoice = parseFloat($("#txtamount").val());
                var maxdsicrate = parseFloat($("#txtmaxdiscount").val());
                if (discountValue > minValue) {
                    Swal.fire({
                        title: 'Invalid Rate Entered',
                        text: 'The discount rate exceeds the discount rate allowed',
                        icon: 'error',
                    });

                    $("#txtdiscount, #txtdiscountrate").val("");
                    return;
                }
                calculateDiscountRateValue(discountValue, TotalInvoice)

            });

            function calculateDiscountValue(kTotal, kRate, addisc) {
                // Calculate the discount value
                var disc = Math.round((kRate / 100) * kTotal * 100) / 100;

                // Set the value to the input field based on the addisc condition
                if (addisc > 0) {
                    $("#txtdiscount").val(addisc);
                } else {
                    $("#txtdiscount").val(disc.toFixed(3));
                }
            }

            function calculateDiscountRateValue(kdiscount, total) {
                // Ensure the total includes the discount for the correct base calculation
                var baseTotal = total + kdiscount;
                // Calculate the discount rate and round to three decimal places
                var disc = Math.round((kdiscount / baseTotal) * 100 * 1000) / 1000;
                //alert('Discount: ' + kdiscount + ' Total: ' + total + ' Discount Rate: ' + disc.toFixed(3) + '%');
                if (disc > 0) {
                    $("#txtdiscountrate").val(disc.toFixed(3));
                } else {
                    $("#txtdiscountrate").val('');
                }
            }


        });
    </script>

</body>
</html>































        color: #41A4CD;
    }

.nav-item.active > .nav-link {
    background-color: #d4eef9;
    color: #0c5a7d;
    font-weight: 600;
}

.nav-icon {
    margin-right: 8px;
    color: inherit;
}
