123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663 |
- var Unibase;
- (function (Unibase) {
- let Forms;
- (function (Forms) {
- let Controls;
- (function (Controls) {
- class MRPDetails extends Unibase.Platform.Core.BaseComponent {
- constructor() {
- super(...arguments);
- this.Type = "";
- this.PendingQty = 0;
- this.SplitedInvoiceItemList = new Array();
- this.rowIndex = 0;
- this.container = "";
- this.DcItemIds = new Array();
- }
- jsFiles() {
- return ["platform/controls/itemdetails/item.mrp.js"];
- }
- cssFiles() {
- return [];
- }
- load(containerid) {
- var instance = this;
- $("#btn_InvoiceItem_Close").click(function () {
- instance.navigationHelper.closePopUp();
- });
- }
- loadForm(FormId, Pk_Value, AppConfigurationId, Callback, ElementId) {
- }
- html() {
- var html = '<div class="frm_Bizgazetransact_Invoice_createInvoiceItem card"><div class="card-header"><div class="row col-sm-12 ml-5"><strong class="titlename InvoiceItemName col-8"></strong><div class="col-4 pull-right"><span class="pull-right mr-10">Amount: <strong class="hf_nettotal">0.00</strong></span></div></div></div><div style="overflow-x:hidden;" class="d modal-body bg-light"><div class="bg-white mb-10"><span class="ml-10"> Pending: <span class="hf_pendingQty ml-5" > 0 </span><span>/Total Avail: </span><span class="hf_AvailQty ml-5">0</span > </span></div > <div class="card" > <div class="card-body"><div class="col-sm-12 d-none d-md-block"><div class="row " style="overflow-x:hidden;"><input type="hidden" id="hf_ItemId" ><div class="col-sm-4 min-padding"><strong class="EnabledType ml-20">MRP</strong> </div><div class="col-sm-2 text-center min-padding"><strong class="ml-15">Qty</strong></div><div class="col-sm-2 text-center min-padding"><strong>Unit Price</strong></div><div class="col-sm-2 text-center min-padding"><strong>Disc.</strong></div><div class="col-sm-2 text-right min-padding"><strong class="mr-15">Total</strong></div></div></div><div><div class="Mrp-row added-row hidden"></div><div class="Batch-row added-row hidden"></div><div class="Serial-row added-row hidden"></div></div><div class="row"><a href="javascript:;" class="default pull-left" title="Add" data-original-title="Add"><span class="pull-right btn" id="btnInvoice_Batch">Add</span></a></div></div></div></div><footer class="bg-white modal-footer"><a id="btn_InvoiceItem_Close" class="btn btn-light btn-sm mr-auto"> Close</a><a href="javascript:;" id="btn_InvoiceItem_Save_mobile" class="btn btn-primary btn-sm">Save</a></footer>';
- return html;
- }
- init(element, ItemName, type) {
- $(".InvoiceItemName").text(ItemName);
- $(".EnabledType").text(type);
- this.Type = type;
- this.SplitedInvoiceItemList.push({
- orderItemId: 0,
- invoiceItemId: 0,
- itemName: "test",
- itemId: 0,
- itemSKU: 0,
- unitName: 0,
- packSize: 0,
- packCount: 0,
- packs: 0,
- quantity: 0,
- availPacks: 0,
- availQty: 0,
- listPrice: 0,
- description: "",
- taxGroupName: "",
- taxGroupId: 0,
- isTaxInclusive: $("#hfId_IsTaxInclusive").val(),
- addlDiscountPercent: 0,
- addlDiscountValue: 0,
- creditNote: 0,
- priceListId: 0,
- batchId: 0,
- unitPrice: 0,
- invoiceallocations: null,
- exciseInvoiceItem: null,
- accountId: 0,
- accountName: "",
- walletId: 0,
- Adjustment: 0,
- IsFoc: 0,
- TariffNo: "",
- exciseAmount: 0,
- discountName: "",
- discountId: 0,
- refNo: "",
- DiscountGroupId: 0,
- DiscountGroupName: "",
- ExchangeItem: 0,
- maxQty: 0,
- RefInvoiceItemId: 0,
- MrpId: 0,
- taxAdjustment: 0,
- assesableAdjustment: 0,
- inventoryTypeId: 0,
- IsBoMItem: 0,
- dcItemId: 0,
- TotalRowAmount: 0,
- TotalDiscount: 0,
- BatchId: 0,
- });
- var ItemExist = false;
- for (var i = 0; i < this.SplitedInvoiceItemList.length; i++) {
- if (this.SplitedInvoiceItemList[i].itemId == $("#hf_ItemId").val()) {
- ItemExist = true;
- MRPDetails.Instance().addMrpRowWithData(this.SplitedInvoiceItemList[i]);
- }
- }
- $("#hf_ItemId").val(element.find(".selectedItemId").val());
- $(".hf_AvailQty").text(element.find(".prodAvail").text());
- if ($("#hf_" + $("#hfLayout_InstalledPageId").val() + "_OrderId").val() != "0" && $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_OrderId").val() != undefined) {
- $(".hf_pendingQty").text(element.find(".maxQty").val());
- this.PendingQty = element.find(".maxQty").val();
- }
- $("#btnInvoice_Batch").click(function () {
- MRPDetails.Instance().addMrpRow(element);
- });
- $("#btn_InvoiceItem_Save").click(function () {
- });
- $(document).click(function (e) {
- var container = $(".div_Item_MoreDetails");
- });
- if (ItemExist == false)
- var orderid = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_OrderId").val();
- var dcid = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_DcId").val();
- var InvoiceId = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_InvoiceId").val();
- var OrdersettingId = 2;
- if (OrdersettingId == 1 || ((orderid == "0" || orderid == undefined) && (dcid != "0" && dcid != undefined) && (InvoiceId == "0" || InvoiceId == "null")))
- $("#btnInvoice_Batch").addClass('hidden');
- }
- addMrpRow(element) {
- var array = {
- orderItemId: element.find('.orderItemId').val(),
- invoiceItemId: 0,
- itemId: element.find('.selectedItemId').val(),
- packSize: 0,
- packCount: 0,
- packs: 0,
- quantity: 0,
- availPacks: 0,
- availQty: 0,
- Description: "",
- isTaxInclusive: $("#hfIsTaxInclusive").val(),
- addlDiscountPercent: 0,
- addlDiscountValue: 0,
- creditNote: 0,
- priceListId: element.find('.hf_PriceList').val(),
- invoiceallocations: null,
- exciseInvoiceItem: null,
- walletId: 0,
- Adjustment: 0,
- IsFoc: 0,
- TariffNo: "",
- exciseAmount: 0,
- discountName: "",
- discountId: 0,
- description: "",
- RefNo: "",
- DiscountGroupId: 0,
- DiscountGroupName: '',
- RefInvoiceItemId: 0,
- taxAdjustment: element.find('.hfItemTaxAdjsutmentVal').val(),
- assesableAdjustment: element.find('.hfItemAssesableAdjustmentVal').val(),
- inventoryTypeId: 0,
- dcItemId: 0,
- ExchangeItem: element.find('.IsExchangeItem').val(),
- unitPrice: element.find('.prodPrice').val(),
- taxGroupId: $("#hf_TaxGroupId").val(),
- BatchId: 0,
- MrpId: 0,
- SerialId: 0,
- Name: '',
- maxQty: 0
- };
- MRPDetails.Instance().addMrpRowWithData(array);
- }
- addMrpRowWithData(row) {
- this.rowIndex = $(".SplInvoiceItemRow").length + 1;
- var activeDiscVal = "";
- var activeDiscPercent = "";
- var activeDiscMul = "";
- var activeDiscText = "";
- var discValue = 0;
- if (row.addlDiscountPercent > 0) {
- discValue = row.addlDiscountPercent;
- activeDiscPercent = "active";
- activeDiscText = "%";
- }
- else if (row.addlDiscountValue > 0 && row.DiscountGroupId > 0) {
- discValue = row.addlDiscountValue;
- activeDiscMul = "active";
- activeDiscText = "Mul";
- }
- else {
- discValue = row.addlDiscountValue;
- activeDiscVal = "active";
- activeDiscText = "Val";
- }
- var Class = "";
- if (Type == "MRP") {
- Class = "Mrp-row Mrp-addedrow";
- }
- else if (Type == "BatchNo") {
- Class = "Batch-row Batch-addedrow";
- }
- else if (Type == "SerialNo") {
- Class = "Serial-row Serial-addedrow";
- }
- var readonlyPrice = "";
- var readonlyDisc = "";
- var readonlyTax = "";
- var readonlyQty = "";
- var ManageInvoice = 1;
- var ManageInvoiceTax = 1;
- if (ManageInvoice == 1 && AutoDc == false) {
- readonlyQty = "readonly";
- readonlyPrice = "readonly";
- readonlyDisc = "readonly";
- readonlyTax = "readonly";
- }
- if ($('#hfInv_Invoicetype').val() == "Sales" && ManageInvoiceTax == 1 && AutoDc == false) {
- readonlyTax = "readonly";
- }
- var html = '<div class="row ' + Class + ' form-group mt-20 SplInvoiceItemRow">' +
- '<div class="row col-sm-12 ml-5">' +
- '<input type="hidden" class="txt_rowIndex" value="' + this.rowIndex + '"/>' +
- '<input type="hidden" class="hf_orderItemId" value="' + row.orderItemId + '"/>' +
- '<input type="hidden" class="hf_dcItemId" value="' + row.dcItemId + '"/>' +
- '<input type="hidden" class="hf_selectedInvoiceItemId" value="' + row.invoiceItemId + '"/>' +
- '<input type="hidden" class="hf_refInvoiceItemId" value="' + row.RefInvoiceItemId + '"/>' +
- '<input type="hidden" class="hf_selectedItemId" value="' + row.itemId + '"/>' +
- '<input type="hidden" class="hf_offerapplied" value="0"/>' +
- '<input type="hidden" class="hf_refNo" value="' + row.RefNo + '"/>' +
- '<input type="hidden" class="hf_description" value="' + row.description + '"/>' +
- '<input type="hidden" class="hf_IsExchangeItem" value="' + row.ExchangeItem + '"/>' +
- '<input type="hidden" class="hf_ItemTaxAdjsutmentVal" value="' + row.taxAdjustment + '"/>' +
- '<input type="hidden" class="hf_ItemAssesableAdjustmentVal" value="' + row.assesableAdjustment + '"/>' +
- '<input type="hidden" class="hf_maxQty" value="' + row.maxQty + '" />' +
- '<input type="hidden" class="exciseAmount" value="0"/>' +
- '<input type="hidden" class="hf_UnitPrice" value="' + row.unitPrice + '"/>' +
- '<input type="hidden" class="hf_' + Type + '_Name" value=""/>' +
- '<div class="col-sm-4">' +
- '<div class=" min-padding">' +
- '<a class="no-border bg-white delete-row" href = "javascript:;" title = "Remove row" style = ""> <i class="fa fa-trash-o fa-lg mt-15 mr-2" style="margin-left:-25px;color:red"></i></a>' +
- '<select type="text" class=" required form-control ui-autocomplete select_' + Type + '" id="select_itemMrp_' + this.rowIndex + '" data-required="true" value="" placeholder=" Select ' + Type + '" style="width:100%;" ></select>' +
- '<input type="hidden" id="hf_itemMrp_' + this.rowIndex + '" class="hf_' + Type + '_Id"/>' +
- '</div></div>' +
- '<div class="col-sm-2">' +
- '<div class="floating-label-form-group min-padding">' +
- '<input type="text" class="Quantity text-center form-control" placeholder="0.00" value="' + row.quantity + '" ' + readonlyQty + '>' +
- '</div></div>' +
- '<div class="col-sm-2">' +
- '<div class="floating-label-form-group min-padding">' +
- '<input type="text" class="Price text-center form-control" placeholder="0.00" value="' + row.unitPrice + '" ' + readonlyPrice + '/>' +
- '</div></div>' +
- '<div class="col-sm-2">' +
- '<div class="floating-label-form-group">' +
- '<input type="hidden" id="hf_ItemDiscountGroupId" value="' + row.DiscountGroupId + '" />' +
- '<input type="hidden" id="hf_ItemDiscountGroupName" value="' + row.DiscountGroupName + '" />' +
- '<input type="hidden" id="hf_ItemDiscountList" value=""/>' +
- '<input type="hidden" id="hf_ItemDiscountApplyTypes" value=""/>' +
- '<div class="input-group">' +
- '<input type="text" id="txt_discount" placeholder="0.00" class="form-control txt_addldiscount text-center d-none d-md-block" value="' + discValue + '" readonlyDisc>' +
- '<input type="text" id="txt_discount" placeholder="0.00" class="form-control txt_addldiscount text-center ml-40 d-md-none" value="' + discValue + '" readonlyDisc>' +
- '<div class="input-group-btn">' +
- '<div class="input-group-btn">' +
- '<select class="btn_item_DiscType mt-10 border-blue"><option value="Val">Val</option><option value="%">%</option></select>' +
- '</div>' +
- '</div></div></div></div>' +
- '<div class="col-sm-2">' +
- '<input type="hidden" class="hf_DiscountedAmount" value="0" />' +
- '<input type="hidden" class="hf_RowTotalAdjustment" value="' + row.Adjustment + '" />' +
- '<input type="hidden" class="hf_AssesableAdjustment" value="" />' +
- '<input type="hidden" class="hf_TaxAdjustment" value="" />';
- if ($("#hfInv_Invoicetype").val() == "Purchase" || $("#hfInv_Invoicetype").val() == "PurchaseReturn" || $("#hfInv_Invoicetype").val() == "DebitNote") {
- html += '<a href="javascript:;" class="AjustmentRow"><input type="text" style="color:#5ba8fb;text-decoration:underline;cursor:pointer" class="hf_RowTotalwithAdjustment form-control txt_RowTotalwithAdjustment text-right" value="0" /></a>';
- html += '<a href="javascript:;" class="hidden" onclick="javascript:_bizgazetransact_invoice_edit.editInvItemTaxAllocs(' + row.invoiceItemId + ',' + row.TaxGroupId + ',' + row.itemId + ',' + row.orderItemId + ')"><input type="text" style="color:#5ba8fb;text-decoration:underline;cursor:pointer" class="hf_RowTotal form-control txt_RowTotal text-right" value="0" /></a>';
- }
- else {
- html += '<p class="pull-right mt-10 mr-10"><strong><input type="hidden" class="hf_RowTotal" value="0" /><span class="TotalPrice">0.00</span></strong></p>';
- }
- html += '</div></div >';
- html += '<div class="row col-sm-12 div_Item_MoreDetails clear hidden">' +
- '<div class="row col-sm-12 bg-light ml-10 mt-5">' +
- '<div class="col-sm-6">' +
- '<div class="floating-label-form-group form-group floating-label focus">' +
- '<label for="lbl_Description" id="lbl_Description">Description</label>' +
- '<input type="text" id="txt_Item_Description" data-isdynamic="false" class="form-control floating-label-control " data-placeholder="Enter Description" placeholder="Description" data-label="Description"/>' +
- '</div></div>';
- if (Type != "MRP") {
- html += '<div class="col-sm-2 mt-30">' +
- '<label for="lbl_Mrp" id="lbl_Mrp"><b>Mrp:  <span></span></b></label>' +
- '<span class="spn_Mrp">0</span>' +
- '<input type="hidden" class="hf_MrpId"/>' +
- '</div>';
- }
- html += '<div class="col-sm-3 mt-30">' +
- '<label for="lbl_Avalilability" id="lbl_Avalilability"><b>Availability:  <span></span></b></label>' +
- '<span class="spn_Avail">0</span>' +
- '<input type="hidden" class="hf_PriceList" value="' + row.priceListId + '"/>' +
- '</div>' +
- '</div></div></div>';
- var element = "";
- var Type = "MRP";
- if (Type == "MRP") {
- $(".Mrp-row:last").after(html);
- element = $(".Mrp-addedrow:last");
- }
- else if (Type == "BatchNo") {
- $(".Batch-row:last").after(html);
- element = $(".Batch-addedrow:last");
- }
- else if (Type == "SerialNo") {
- $(".Serial-row:last").after(html);
- element = $(".Serial-addedrow:last");
- }
- element.find(".btn_item_DiscType option[value='" + activeDiscText + "']").prop("selected", true);
- if (row.description != null && row.description != '' && row.description != 'null')
- element.find('#txt_Item_Description').val(row.description);
- if ((row.orderItemId != 0 && row.dcItemId != 0 && OrdersettingId == 1) || (row.orderItemId == 0 && row.dcItemId != 0 && AutoDc == false)) {
- element.find('.select_' + Type + '').prop('disabled', true);
- }
- $('.txt_addldiscount').keypress(function (event) {
- if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
- }
- else {
- event.preventDefault();
- }
- }).on('paste', function (event) {
- event.preventDefault();
- });
- $('.Quantity').keypress(function (event) {
- if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
- }
- else {
- event.preventDefault();
- }
- }).on('paste', function (event) {
- event.preventDefault();
- });
- $('.Price').keypress(function (event) {
- if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
- }
- else {
- event.preventDefault();
- }
- }).on('paste', function (event) {
- event.preventDefault();
- });
- this.Load(element);
- var OrdersettingId = 2;
- var AutoDc = false;
- if (row.dcItemId != 0 && OrdersettingId != 2 && AutoDc == false)
- element.find(".Quantity").prop('disabled', true);
- if (row.invoiceItemId != 0 || row.dcItemId != 0 || row.orderItemId != 0) {
- if (Type == "MRP") {
- row.Name = element.find('.hf_' + Type + '_Name').val();
- }
- else if (Type == "BatchNo") {
- row.Name = element.find('.hf_' + Type + '_Name').val();
- }
- else if (Type == "SerialNo") {
- row.Name = element.find('.hf_' + Type + '_Name').val();
- }
- }
- if (row.Name != '') {
- if (Type == "MRP") {
- if (row.MrpId != 0) {
- element.find(".select_" + Type + "").empty();
- element.find(".select_" + Type + "").append(new Option(row.Name, row.MrpId, true));
- element.find('.hf_' + Type + '_Id').val(row.MrpId);
- }
- }
- else if (Type == "BatchNo") {
- if (row.BatchId != 0) {
- element.find(".select_" + Type + "").empty();
- element.find(".select_" + Type + "").append(new Option(row.Name, row.BatchId, true));
- element.find('.hf_' + Type + '_Id').val(row.BatchId);
- }
- }
- else if (Type == "SerialNo") {
- if (row.SerialId != 0) {
- element.find(".select_" + Type + "").empty();
- element.find(".select_" + Type + "").append(new Option(row.Name, row.SerialId, true));
- element.find('.hf_' + Type + '_Id').val(row.SerialId);
- }
- }
- }
- element.find(".Price,.Quantity,.txt_addldiscount ").focusin(function () {
- $(".div_Item_MoreDetails").addClass("hidden");
- element.find(".div_Item_MoreDetails").removeClass("hidden");
- });
- element.find(".prodName").focusin(function () {
- $(".div_Item_MoreDetails").addClass("hidden");
- });
- element.find(".txt_addldiscount").change(function () {
- if (element.find(".btn_item_DiscType").val() == "%") {
- if (Number(element.find(".txt_addldiscount").val()) > 100)
- element.find(".txt_addldiscount").val("100");
- }
- });
- element.find('.AjustmentRow').click(function () {
- });
- var url = _appsettings.server_url() + '/apis/v4/unibase/transact/items/getitems/itemids/' + ',' + '/lobid/' + 100284890000001;
- AutoCompleteHelper.getHelper().Create("#select_itemMrp_" + this.rowIndex, "#hf_itemMrp_" + this.rowIndex, url, function (response) {
- var data = response;
- });
- MRPDetails.Instance().RemoveRow(element);
- element.find('.btn_item_DiscType').change(function () {
- if (element.find(".btn_item_DiscType").val() == "%") {
- if (Number(element.find(".txt_addldiscount").val()) > 100)
- element.find(".txt_addldiscount").val("100");
- }
- if (element.find(".btn_item_DiscType option:selected").text().trim() == 'Val') {
- element.find('#hf_ItemDiscountGroupId').val(0);
- element.find('#hf_ItemDiscountGroupName').val('');
- element.find('.txt_addldiscount').prop('disabled', false);
- }
- else if (element.find(".btn_item_DiscType option:selected").text().trim() == '%') {
- element.find('#hf_ItemDiscountGroupId').val(0);
- element.find('#hf_ItemDiscountGroupName').val('');
- element.find('.txt_addldiscount').prop('disabled', false);
- }
- });
- }
- RemoveRow(element) {
- element.find(".delete-row").on('click', function () {
- var _this = $(this);
- _this.parents('.SplInvoiceItemRow');
- var invoiceitemid = _this.parents('.SplInvoiceItemRow').find(".hf_selectedInvoiceItemId").val();
- if (invoiceitemid != 0) {
- if (confirm("You are about to Delete the invoice item. Are you sure?")) {
- var x = [];
- for (var i = 0; i < this.SplitedInvoiceItemList.length; i++) {
- if (this.SplitedInvoiceItemList[i].invoiceItemId == _this.parents('.SplInvoiceItemRow').find('.hf_selectedInvoiceItemId').val()) {
- x.push(i);
- }
- }
- for (var i = x.length - 1; i >= 0; i--) {
- this.SplitedInvoiceItemList.splice(x[i], 1);
- }
- _this.parents('.SplInvoiceItemRow').remove();
- }
- }
- else {
- if (confirm("You are about to Delete the invoice item. Are you sure?")) {
- _this.parents('.SplInvoiceItemRow').remove();
- }
- }
- });
- element.find('.btn_item_DiscType').change(function () {
- if (element.find(".btn_item_DiscType").val() == "%") {
- if (Number(element.find(".txt_addldiscount").val()) > 100)
- element.find(".txt_addldiscount").val("100");
- }
- if (element.find(".btn_item_DiscType option:selected").text().trim() == 'Val') {
- element.find('#hf_ItemDiscountGroupId').val(0);
- element.find('#hf_ItemDiscountGroupName').val('');
- element.find('.txt_addldiscount').prop('disabled', false);
- }
- else if (element.find(".btn_item_DiscType option:selected").text().trim() == '%') {
- element.find('#hf_ItemDiscountGroupId').val(0);
- element.find('#hf_ItemDiscountGroupName').val('');
- element.find('.txt_addldiscount').prop('disabled', false);
- }
- });
- }
- Load(element) {
- var Type = "";
- var Ids = [];
- var AutoText = element.find(".select_" + Type + "");
- var hdnAutoId = element.find(".hf_" + Type + "_Id");
- Ids = [0];
- $(".hf_" + Type + "_Id").each(function () {
- Ids.push($(this).val());
- });
- var InvoiceType = 'Purchase';
- var BranchId = $("#ddl_ShipToAddressId").val();
- if ($('#hfInv_Invoicetype').val() == 'Sales' || $('#hfInv_Invoicetype').val() == 'PurchaseReturn' || $('#hfInv_Invoicetype').val() == 'CreditNote') {
- InvoiceType = 'Sales';
- BranchId = $("#ddl_ShipFromAddressId").val();
- }
- var url;
- if (Type == "MRP") {
- if ($("#hf_FormAppTitle").val() == "Sales Return" || $("#hf_FormAppTitle").val() == "Purchase Return") {
- }
- else { }
- }
- else if (Type == "BatchNo") {
- }
- else if (Type == "SerialNo") {
- }
- var AutoText = element.find(".select_" + Type + "");
- var hdnAutoId = element.find(".hf_" + Type + "_Id");
- }
- SaveItem(elements) {
- var qty = false;
- var avlqty = false;
- var UnitPrice = false;
- var CreateBatch_Validation = 'frm_Bizgazetransact_Invoice_createInvoiceItem';
- if (!CreateBatch_Validation) {
- MessageHelper.Instance().showError(" Mandatory fields are missing ", "bizgaze_CreateBatchErrorMessages");
- return false;
- }
- $(".SplInvoiceItemRow").each(function () {
- if ($(this).find(".Quantity").val() == 0) {
- qty = true;
- }
- });
- $(".SplInvoiceItemRow").each(function () {
- if ($(this).find(".Price ").val() == 0) {
- UnitPrice = true;
- }
- });
- var OrdersettingId = 1;
- var AutoDc = false;
- var qty = true;
- var UnitPrice = true;
- var avlqty = true;
- if ($('#hfInv_Invoicetype').val() == 'Sales' || $('#hfInv_Invoicetype').val() == 'PurchaseReturn') {
- $(".SplInvoiceItemRow").each(function () {
- if (OrdersettingId == 1 || AutoDc == true) {
- if (Number($(this).find(".Quantity").val()) > Number($(this).find('.spn_Avail').text())) {
- avlqty = true;
- }
- }
- });
- }
- if (qty == true) {
- MessageHelper.Instance().showError("Item quantity should not be zero.", "bizgaze_CreateBatchErrorMessages");
- return false;
- }
- if (UnitPrice == true) {
- MessageHelper.Instance().showError("Unit Price should not be zero.", "bizgaze_CreateBatchErrorMessages");
- return false;
- }
- if (avlqty == true) {
- MessageHelper.Instance().showError("Available Quantity is less for an item", 'bizgaze_CreateBatchErrorMessages');
- return false;
- }
- var x = [];
- for (var i = 0; i < this.SplitedInvoiceItemList.length; i++) {
- if (this.SplitedInvoiceItemList[i].itemId == $("#hf_ItemId").val()) {
- x.push(i);
- var index = this.DcItemIds.indexOf(this.SplitedInvoiceItemList[i].dcItemId);
- if (index > -1)
- this.DcItemIds.splice(index, 1);
- }
- }
- for (var i = x.length - 1; i >= 0; i--) {
- this.SplitedInvoiceItemList.splice(x[i], 1);
- }
- var TotalQuantity = 0;
- var TotalAmount = 0;
- var TotalDisc = 0;
- var RowExist = false;
- var TaxGroupId = elements.find('.hfProdTax').val();
- var Taxgroupname = elements.find('.txtProdTax').val();
- var AccountId = elements.find('.hf_Account').val();
- var AccountName = elements.find('.txt_AccountName').val();
- var instance = this;
- $(".SplInvoiceItemRow").each(function () {
- var element = $(this);
- var BatchId = 0;
- var SerialNoId = 0;
- var MrpId = 0;
- var Name = '';
- var Type = "MRP";
- if (Type == "MRP") {
- MrpId = Number(element.find('.hf_MRP_Id').val());
- Name = element.find('.select_' + Type + ' option[value=' + MrpId + ']').text();
- }
- else if (Type == "BatchNo") {
- BatchId = Number(element.find('.select_' + Type + '').val());
- MrpId = Number(element.find(".hf_MrpId").val());
- Name = element.find('.select_' + Type + ' option[value =' + BatchId + ']').text();
- }
- else if (Type == "SerialNo") {
- SerialNoId = Number(element.find('.select_' + Type + '').val());
- MrpId = Number(element.find(".hf_MrpId").val());
- Name = element.find('.select_' + Type + ' option[value=' + SerialNoId + ']').text();
- }
- if (element.find("#hf_" + Type + "_Id").val() != '' && element.find("#hf_" + Type + "_Id").val() != 0) {
- RowExist = true;
- var discountAmount = 0;
- var discountPercent = 0;
- if ((element.find(".btn_item_DiscType option:selected").text().trim() == 'Val' || element.find(".btnOrder_DiscType option:selected").text().trim() == 'Mul') && element.find('.txt_addldiscount').val() != '' && element.find('.txt_addldiscount').val() != undefined) {
- discountAmount = Number(element.find('.txt_addldiscount').val());
- }
- else if (element.find(".btn_item_DiscType option:selected").text().trim() == '%' && element.find('.txt_addldiscount').val() != '' && element.find('.txt_addldiscount').val() != undefined) {
- discountPercent = Number(element.find('.txt_addldiscount').val());
- }
- var DiscType = element.find(".btnOrder_DiscType option:selected").text().trim();
- instance.SplitedInvoiceItemList.push({
- invoiceItemId: element.find(".hf_selectedInvoiceItemId").val(),
- orderItemId: element.find(".hf_orderItemId").val(),
- itemId: element.find(".hf_selectedItemId").val(),
- taxGroupId: TaxGroupId,
- taxGroupName: Taxgroupname,
- description: element.find("#txt_Item_Description").val(),
- priceListId: element.find(".hf_PriceList").val(),
- unitPrice: element.find(".Price").val(),
- addlDiscountValue: discountAmount,
- addlDiscountPercent: discountPercent,
- IsTaxInclusive: $('#hfId_IsTaxInclusive').val(),
- accountId: AccountId,
- accountName: AccountName,
- Adjustment: element.find(".hf_RowTotalAdjustment").val(),
- TotalAmount: element.find(".hf_RowTotal").val(),
- quantity: element.find(".Quantity").val(),
- exciseAmount: element.find(".exciseAmount").val(),
- refNo: element.find(".hf_refNo").val(),
- DiscountGroupId: element.find("#hf_ItemDiscountGroupId").val(),
- RefInvoiceItemId: element.find(".hf_refInvoiceItemId").val(),
- MrpId: MrpId,
- dcItemId: element.find(".hf_dcItemId").val(),
- BatchId: BatchId,
- SerialId: SerialNoId,
- ExchangeItem: element.find('.hf_IsExchangeItem').val(),
- taxAdjustment: element.find('.hf_ItemTaxAdjsutmentVal').val(),
- assesableAdjustment: element.find('.hf_ItemAssesableAdjustmentVal').val(),
- DiscountGroupName: element.find('.hf_ItemDiscountGroupName').val(),
- DiscountedAmount: element.find(".hf_DiscountedAmount").val(),
- TaxPercent: elements.find(".hfProdTaxPercent").val(),
- Name: Name,
- DiscType: DiscType,
- maxQty: element.find('.hf_maxQty').val()
- });
- TotalQuantity += Number(element.find(".Quantity").val());
- var discount = 0;
- var qyt = Number(element.find(".Quantity").val());
- var price = Number(element.find(".Price").val());
- var excamt = Number(element.find(".exciseAmount").val());
- var assesableAdjustment = Number(element.find('.hf_ItemAssesableAdjustmentVal').val());
- var ItemAdjustment = Number(element.find(".hf_RowTotalAdjustment").val());
- discount = (((qyt * price) + assesableAdjustment + ItemAdjustment - excamt) * Number(discountPercent) / 100) + (Number(qyt) * Number(discountAmount));
- discount = Number(discount);
- TotalDisc += discount;
- if ($("#hfInv_Invoicetype").val() == "Purchase" || $("#hfInv_Invoicetype").val() == "PurchaseReturn" || $("#hfInv_Invoicetype").val() == "DebitNote") {
- TotalAmount += Number(element.find(".txt_RowTotalwithAdjustment").val());
- }
- else {
- TotalAmount += Number(element.find(".TotalPrice").text());
- }
- instance.DcItemIds.push(Number(element.find(".hf_dcItemId").val()));
- }
- });
- var Type = "MRP";
- if (RowExist = true)
- elements.find('.spn_InvoiceItem').text("View " + Type);
- else
- elements.find('.spn_InvoiceItem').text("Select " + Type);
- elements.find('.prodQuantity').val();
- elements.find('.prodQuantity').val(TotalQuantity);
- elements.find('#inv_txtdiscount').val();
- elements.find('#inv_txtdiscount').val(TotalDisc);
- if ($("#hfInv_Invoicetype").val() == "Purchase" || $("#hfInv_Invoicetype").val() == "PurchaseReturn" || $("#hfInv_Invoicetype").val() == "DebitNote") {
- elements.find(".txtRowTotalwithAdjustment").val();
- elements.find(".txtRowTotalwithAdjustment").val(TotalAmount);
- }
- else {
- elements.find('.prodTotalPrice').text('');
- elements.find('.prodTotalPrice').text(TotalAmount);
- }
- this.navigationHelper.closePopUp();
- }
- static Instance() {
- return new MRPDetails();
- }
- }
- MRPDetails.element = "";
- Controls.MRPDetails = MRPDetails;
- })(Controls = Forms.Controls || (Forms.Controls = {}));
- })(Forms = Unibase.Forms || (Unibase.Forms = {}));
- })(Unibase || (Unibase = {}));
|