var Unibase; (function (Unibase) { let Forms; (function (Forms) { let Controls; (function (Controls) { class ItemDetails extends Unibase.Platform.Core.BaseComponent { constructor() { super(...arguments); this.rowIndex = 0; this.deletedItems = new Array(); this.itemIds = new Array(); this.SplitedInvoiceItemList = new Array(); this.deleted_invoiceItems = new Array(); this.container = ""; } init(formpropertyid, prop, callback) { var instance = ItemDetails.Instance(); instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId); instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId); Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/controls/itemdetails/item.mrp.js", function () { }); } loadControl(containerid, prop) { var html = '
Item Details
Item Name
Qty
Unit Price
Disc.
Total
Add Item
'; $("#" + containerid).html(html); $("#btnInvoiceItem").off().click(function () { ItemDetails.instance.AddRow(); }); ItemDetails.instance.container = containerid; Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("tenants/themes/default/components/details/details.js", function () { }); } loadControlSettings(controlsettingjson, formpropertyid) { return null; } loadPropertySettings(propertysettings, formpropertyid) { return null; } bindEditFormDetails(formpropertyid, propval, DocPropertyName) { return null; } AddRow() { var emptyRow = { orderItemId: 0, invoiceItemId: 0, itemName: "", itemId: 0, itemSKU: "", unitName: "", packSize: 0, packCount: 0, packs: 0, quantity: 0, availPacks: 0, availQty: 0, listPrice: 0, description: "", taxGroupName: "", taxGroupId: 0, isTaxInclusive: $("#hfIsTaxInclusive").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: false, TariffNo: "", exciseAmount: 0, discountName: "", discountId: 0, _description: "", refNo: "", DiscountGroupId: 0, DiscountGroupName: '', RefInvoiceItemId: 0, MrpId: 0, taxAdjustment: 0, assesableAdjustment: 0, inventoryTypeId: 0, dcItemId: 0, TotalRowAmount: 0, maxQty: 0, }; this.addDataRow(emptyRow); } addDataRow(row) { Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("tenants/themes/default/components/details/details.js", function () { }); this.rowIndex = $(".InvoiceItems").find(".item-addedrow").length + 1; var bg = ""; if (row.packSize == 0) row.packSize = 1; if (row.packCount == 0) row.packCount = 1; if (row.quantity == 0) row.quantity = row.packCount * row.packs * row.packSize; var price = row.unitPrice; if (row.unitPrice == 0) price = row.listPrice; var currenttaxgroupid = 0; if ($("#hfInv_Invoicetype").val() == "PurchaseReturn" || $("#hfInv_Invoicetype").val() == "SalesReturn") row.invoiceallocations = null; if ($('#hfInv_IsRetun').val() == 1) row.invoiceItemId = 0; var zeroBilled = ""; if (price == 0) zeroBilled = "bg-danger"; var zeroQtyText = ""; var zeroQtyDiv = "bg-light"; var recordId = Unibase.Themes.Providers.Detail_Settings.Instance().RecordId; if (recordId == 0 || recordId == undefined) { if ($('#hfInv_IsRetun').val() == 1 && row.itemId != 0 && ($('#hfInv_Invoicetype').val() == 'Sales' || $('#hfInv_Invoicetype').val() == 'PurchaseReturn')) { if (row.availQty == 0) { row.quantity = 0; zeroQtyText = "text-danger"; zeroQtyDiv = "bg-danger"; } else if (row.availQty < row.quantity) { row.quantity = row.availQty; } } } var readonlyQty = ""; if (($("#hfDcId").val() != "0" || $("#hfDcId").val() == "") && recordId == 0) { readonlyQty = "readonly"; } var ManageInvoice = 2; var AutoDc = false; var ManageInvoiceTax = 2; var readonlyPrice = ""; var readonlyDisc = ""; var readonlyTax = ""; if (ManageInvoice == 1 && AutoDc == false) { readonlyQty = "readonly"; readonlyPrice = "readonly"; readonlyDisc = "readonly"; readonlyTax = "disabled"; } if ($('#hfInv_Invoicetype').val() == "Sales" && ManageInvoiceTax == 1 && AutoDc == false) { readonlyTax = "readonly"; } if (row.inventoryTypeId == "2") { readonlyQty = ""; readonlyPrice = ""; } 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 itemNameClass = "floating-label-form-group"; if (row.invoiceItemId != 0) itemNameClass = ""; var mt = ""; if (row.invoiceItemId != 0) { mt = "mt-5"; } if (row.orderItemId != 0) { mt = "mt-10"; } if (row.inventoryTypeId != 5 && row.inventoryTypeId != 6 && row.inventoryTypeId != 7) { var IsBom = ""; if (row.IsBoMItem == true && row.IsBoMItem != undefined) { IsBom = "hidden"; } var html = '
' + '
' + '
' + '
' + 'Item Name' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + ''; if (row.IsFoc == true) { html += ''; } html += '
' + ' '; if (row.invoiceItemId != 0) { var itemName = row.itemSKU + ' - ' + row.itemName; if (row.ExchangeItem) itemName = '(Exchange) ' + row.itemSKU + ' - ' + row.itemName; html += '' + itemName + ''; } else { var itemName = ""; if (row.ExchangeItem) itemName = '(Exchange) ' + row.itemName; else if (itemName != "" && row.itemSKU != "") { itemName = row.itemSKU + '-' + row.itemName; html += '' + itemName + ''; } else if (itemName != "") { itemName = row.itemName; html += '' + itemName + ''; } else { html += ''; } } html += '
' + '
' + '
' + '' + '
' + '
' + 'Qty' + '' + '
' + '
' + '
' + '
' + '
Unit Price'; var readonly = ""; html += ''; html += '
' + '' + '
' + '
' + 'Disc.' + '' + '' + '' + '' + '
' + '' + '
' + '' + '
' + '
' + '
' + '
' + '
' + '' + '' + '' + ''; if ($("#hfInv_Invoicetype").val() == "Purchase" || $("#hfInv_Invoicetype").val() == "PurchaseReturn" || $("#hfInv_Invoicetype").val() == "DebitNote") { html += ''; html += ''; } else { html += '

Total:0.00

'; } html += '
' + '