123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011 |
- var Bizgaze;
- (function (Bizgaze) {
- let Apps;
- (function (Apps) {
- let Transact;
- (function (Transact) {
- let Controls;
- (function (Controls) {
- let Invoices;
- (function (Invoices) {
- class SplitItem 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();
- this.Delete_InvoiceItems = new Array();
- }
- jsFiles() {
- return ["apps/transact/controls/pricelist/mrp.js", "/platform/forms/managers/interfaces/iformmanager.js", "/platform/forms/managers/formmanager.js", "platform/forms/components/formviewer/formviewer.js", 'libs/parsley/parsley.min.js', 'apps/transact/controls/pricelist/managers/pricelistmanager.js', "apps/transact/controls/inventory/batch.js"];
- }
- cssFiles() {
- return [];
- }
- load(item) {
- var instance = this;
- SplitItem.Instance().DcItemIds = [0];
- $("#btn_InvoiceItem_Close").click(function () {
- instance.navigationHelper.closePopUp();
- });
- let element = item[0].element;
- let type = item[0].type;
- this.Type = item[0].type;
- $(".InvoiceItemName").text(element.find(".selectedItemName").text());
- $(".EnabledType").text(type);
- $("#hf_ItemId").val(element.find(".selectedItemId").val());
- $(".hf_AvailQty").text(element.find(".prodAvail").text());
- let orderid = Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().orderid;
- if (orderid != undefined && orderid != null && orderid != 0) {
- $(".hf_pendingQty").text(element.find(".maxQty").val());
- this.PendingQty = element.find(".maxQty").val();
- }
- this.Type = type;
- $("#btnInvoice_Batch").click(function () {
- Invoices.SplitItem.Instance().addMrpRow(element);
- });
- $(".btn_InvoiceItem_Save").click(function () {
- Invoices.SplitItem.Instance().SaveItem(element);
- });
- $(document).click(function (e) {
- var container = $(".div_Item_MoreDetails");
- if ($(e.target).closest("[class^='div_Item_MoreDetails']").length <= 0 && $(e.target).closest("[class^='Quantity']").length <= 0 && $(e.target).closest("[class^='Price']").length <= 0) {
- $("[class^='div_Item_MoreDetails']").addClass('hidden');
- }
- });
- let dcid = Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().dcid;
- let InvoiceId = $(".hdn_invoiceid").val();
- let ItemExist = false;
- for (var i = 0; i < Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
- if (Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId == $("#hf_ItemId").val()) {
- if (Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().AutoDc == false && (Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().OrderSettingId == 1 || (Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().orderid == 0 && Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().dcid != 0)) && (InvoiceId == "0")) {
- if (SplitItem.Instance().Type == "MRP") {
- SplitItem.Instance().DcItemIds.push(Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList[i].MrpId);
- }
- else if (SplitItem.Instance().Type == "BatchNo") {
- SplitItem.Instance().DcItemIds.push(Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList[i].BatchId);
- }
- }
- ItemExist = true;
- Invoices.SplitItem.Instance().addMrpRowWithData(Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList[i]);
- var accid = Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList[i].accountId;
- var taxgrpid = Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList[i].taxGroupId;
- var taxgrptext = Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList[i].taxGroupName;
- var acctext = Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList[i].accountName;
- element.find(".hf_Account").val(Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList[i].accountId);
- element.find(".hfProdTax").val(Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList[i].taxGroupId);
- element.find(".txtProdTax").val(Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList[i].taxGroupName);
- element.find(".txt_AccountName").val(Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList[i].accountName);
- if (accid != 0) {
- $("#hf_AccountId").val(accid);
- $("#ddl_AccountId").append(new Option(acctext, accid, true));
- }
- if (taxgrpid != 0) {
- $("#hf_TaxGroupId").val(taxgrpid);
- $("#ddl_TaxGroupId").append(new Option(taxgrptext, taxgrpid, true));
- Invoices.SplitItem.Instance().update_TaxPercentage(taxgrpid);
- }
- }
- }
- Invoices.SplitItem.Instance().loadTaxGroupAutoComplete(element);
- if (ItemExist == false)
- this.addMrpRow(element);
- }
- loadTaxGroupAutoComplete(element) {
- var hfProdTax = element.find(".hfProdTax");
- var accid = element.find(".hf_Account").val();
- var taxgrpid = element.find(".hfProdTax").val();
- var taxgrptext = element.find(".txtProdTax").val();
- var acctext = element.find(".txt_AccountName").val();
- AutoCompleteHelper.getHelper().Create("#ddl_TaxGroupId", "#hf_TaxGroupId", _appsettings.server_url() + "/apis/v4/bizgaze/transact/tax/taxgroupautocomplete", function (result) {
- Invoices.SplitItem.Instance().update_TaxPercentage($("#hf_TaxGroupId").val());
- });
- var url = _appsettings.server_url() + '/apis/v4/bizgaze/transact/ledgers/ledgerautocomplete';
- AutoCompleteHelper.getHelper().Create("#ddl_AccountId", "#hf_AccountId", url, function (response) {
- });
- if (taxgrpid != 0) {
- $("#hf_TaxGroupId").val(taxgrpid);
- if ($("#ddl_TaxGroupId option[value='" + taxgrpid + "']").attr("selected", "selected").length == 0) {
- $("#ddl_TaxGroupId").append(new Option(taxgrptext, taxgrpid, true));
- }
- else {
- $("#ddl_TaxGroupId option[value='" + taxgrpid + "']").attr("selected", "selected");
- }
- Invoices.SplitItem.Instance().update_TaxPercentage($("#hf_TaxGroupId").val());
- }
- if (accid != 0) {
- $("#hf_AccountId").val(accid);
- if ($("#ddl_AccountId option[value='" + accid + "']").attr("selected", "selected").length == 0) {
- $("#ddl_AccountId").append(new Option(acctext, accid, true));
- }
- else {
- $("#ddl_AccountId option[value='" + accid + "']").attr("selected", "selected");
- }
- }
- }
- update_TaxPercentage(taxGroupId) {
- var hfTaxPercent = $(".hf_ProdTaxPercent");
- var percentage = 0;
- if (taxGroupId == "0" || taxGroupId == "" || taxGroupId == undefined)
- return percentage;
- var isExcise = false;
- if ($('#hfInv_InvoiceMode').val() == 'Excise')
- isExcise = true;
- let branchid = Unibase.Platform.Membership.Infos.Identity.getSetting("branchid");
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().gettaxpercentages(taxGroupId, branchid).then(function (response) {
- var percentstring = "";
- if (response.result.length > 0) {
- var percentages = response.result;
- for (var i = 0; i < percentages.length; i++) {
- percentstring += percentages[i].LedgerId + ":" + percentages[i].Percentage + ",";
- }
- hfTaxPercent.val(percentstring);
- }
- });
- }
- html() {
- var html = '<form id="frm_Bizgazetransact_Invoice_createInvoiceItem" data-validate="parsley"><div class="b-b bg-white modal-header bg-white b-b modal-header pa-10"><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 style="height: 840px; overflow:hidden auto;" class="simple-scroll-bar modal-body bg-cyan-light-5"><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 id="bizgaze_CreateBatchErrorMessages" class="clear"></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;border-bottom: 2px solid grey;"><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" style="text-decoration:underline;color:deepskyblue">Add</span></a></div><div class="row div_TaxDetails mt-5"><div class="col-sm-4"><div class="floating-label-form-group-with-value"> <label id="lbl_TaxGroupId" for= "lbl_TaxGroupId" >Tax Group Name<span class="text-red ml-1" >*</span></label><select id="ddl_TaxGroupId" class="form-control required ui-autocomplete" style = "width:100%;" data - placeholder="TaxGroup Name" data-label="TaxGroup Name" placeholder = "TaxGroup Name" ></select><input type ="hidden" class="hf_ProdTaxPercent" value="0" /><input type="hidden" id = "hf_TaxGroupId"></div></div><div class="col-sm-4"><div class="floating-label-form-group-with-value"> <label id="lbl_AccountId" for= "lbl_AccountId"> Account Name <span class= "text-red ml-1" >* </span></label ><select id= "ddl_AccountId" class="form-control required ui-autocomplete" style = "width:100%;" data - placeholder="Account Name" data-label="Account Name" placeholder ="Account Name"></select> <input type = "hidden" id = "hf_AccountId" ></div></div></div></div></div></div><div class="b-t bg-white modal-footer pa-10"><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 btn_InvoiceItem_Save">Save</a></div></form>';
- return html;
- }
- addMrpRow(element) {
- let item = false;
- $(".Mrp-addedrow").each(function () {
- if ($(this).find('.select_' + Invoices.SplitItem.Instance().Type + '').val() == undefined || $(this).find('.select_' + Invoices.SplitItem.Instance().Type + '').val() == null) {
- item = true;
- }
- });
- if (item) {
- MessageHelper.Instance().showError("Please Select " + Invoices.SplitItem.Instance().Type, "bizgaze_CreateBatchErrorMessages");
- return false;
- }
- 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,
- AccountId: element.find('.txt_Account').val(),
- AccountName: element.find('.txt_Account').text()
- };
- Invoices.SplitItem.Instance().addMrpRowWithData(array);
- }
- addMrpRowWithData(row) {
- this.rowIndex += 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 (SplitItem.Instance().Type == "MRP") {
- Class = "Mrp-row Mrp-addedrow";
- }
- else if (SplitItem.Instance().Type == "BatchNo") {
- Class = "Batch-row Batch-addedrow";
- }
- else if (SplitItem.Instance().Type == "SerialNo") {
- Class = "Serial-row Serial-addedrow";
- }
- var readonlyPrice = "";
- var readonlyDisc = "";
- var readonlyTax = "";
- var readonlyQty = "";
- var ManageInvoice = 2;
- var ManageInvoiceTax = 1;
- if (ManageInvoice == 1 && AutoDc == false) {
- readonlyQty = "readonly";
- readonlyPrice = "readonly";
- readonlyDisc = "readonly";
- readonlyTax = "readonly";
- }
- if ($('.hdn_invoicetypeid').val() == "1" && ManageInvoiceTax == 1 && AutoDc == false) {
- readonlyTax = "readonly";
- }
- if (($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && $('#hfInv_IsRetun').val() == "1") {
- row.invoiceallocations = null;
- row.invoiceItemId = 0;
- }
- var html = '<div class="row ' + Class + ' form-group mt-20 SplInvoiceItemRow "' + this.rowIndex + '"" >' +
- '<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_' + SplitItem.Instance().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 class=" required select_' + SplitItem.Instance().Type + '" id="select_itemMrp_' + this.rowIndex + '" placeholder=" Select ' + SplitItem.Instance().Type + '" style="width:100%;" ></select>' +
- '<input type="hidden" id="hf_itemMrp_' + this.rowIndex + '" class="hf_' + SplitItem.Instance().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 ($(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "7") {
- 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 desc">' +
- '<label for="lbl_Description" id="lbl_Description">Description</label>' +
- '<input type="text" id="txt_Item_Description" data-isdynamic="false" class="type-control form-control type-control value-control floating-label-control" data-placeholder="Enter Description" placeholder="Description" data-label="Description"/>' +
- '</div></div>';
- if (SplitItem.Instance().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 = "";
- if (SplitItem.Instance().Type == "MRP") {
- $(".Mrp-row:last").after(html);
- element = $(".Mrp-addedrow:last");
- }
- else if (SplitItem.Instance().Type == "BatchNo") {
- $(".Batch-row:last").after(html);
- element = $(".Batch-addedrow:last");
- }
- else if (SplitItem.Instance().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);
- element.find('#txt_Item_Description').parent(".desc").addClass("floating-label-form-group-with-value");
- }
- if ((row.orderItemId != 0 && row.dcItemId != 0 && Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().OrderSettingId == 1) || (row.orderItemId == 0 && row.dcItemId != 0 && AutoDc == false)) {
- element.find('.select_' + SplitItem.Instance().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();
- });
- var AutoDc = Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().AutoDc;
- if (row.dcItemId != 0 || row.MrpId != 0 || row.BatchId != 0) {
- if (SplitItem.Instance().Type == "MRP") {
- if ((row.MrpId != 0 && row.MrpId != undefined) || row.dcItemId != 0) {
- element.find('.hf_' + SplitItem.Instance().Type + '_Id').val(row.MrpId);
- Invoices.SplitItem.Instance().GetMrpandBatchQty(row.MrpId, element, "", 0, row);
- }
- else {
- Invoices.SplitItem.Instance().Load(element);
- }
- }
- else if (SplitItem.Instance().Type == "BatchNo") {
- if ((row.BatchId != 0 && row.BatchId != undefined)) {
- element.find('.hf_' + SplitItem.Instance().Type + '_Id').val(row.BatchId);
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/controls/pricelist/managers/pricelistmanager.js", function () {
- Bizgaze.Apps.Transact.Managers.PriceListManager.Instance().getbatch(row.BatchId).then(function (result) {
- Invoices.SplitItem.Instance().GetMrpandBatchQty(result.result.MrpId, element, result.result.BatchNo, row.BatchId, row);
- });
- });
- }
- else {
- Invoices.SplitItem.Instance().Load(element);
- }
- }
- else if (SplitItem.Instance().Type == "SerialNo") {
- if (row.SerialId != 0 || row.dcItemId != 0) {
- Invoices.SplitItem.Instance().GetMrpandBatchQty(row.SerialNoId, element, "", 0, null);
- row.Name = element.find('.hf_' + SplitItem.Instance().Type + '_Name').val();
- element.find('.hf_' + SplitItem.Instance().Type + '_Id').val(row.SerialId);
- }
- }
- }
- else {
- Invoices.SplitItem.Instance().Load(element);
- }
- 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(".select_" + SplitItem.Instance().Type).change(function () {
- let obj = [];
- obj.push({
- ItemId: $("#hf_ItemId").val(),
- element: element,
- });
- if ($(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3") {
- if (element.find(".select_" + SplitItem.Instance().Type + " option:selected").text() == "Create MRP") {
- var itemobj = Bizgaze.Apps.Transact.Controls.MRP.Instance();
- Unibase.Platform.Helpers.NavigationHelper.Instance().popup(obj, "", itemobj, null, Unibase.Platform.Helpers.Size.DockLeft);
- }
- else if (element.find(".select_" + SplitItem.Instance().Type + " option:selected").text() == "Create Batch") {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/controls/inventory/batch.js", function () {
- var item = Bizgaze.Apps.Transact.Controls.Batch.Instance();
- Unibase.Platform.Helpers.NavigationHelper.Instance().popup(Number($("#hf_ItemId").val()), "", item, null, Unibase.Platform.Helpers.Size.DockLeft);
- });
- }
- }
- });
- Invoices.SplitItem.Instance().update_row_total(element);
- if ($(".hdn_invoicetypeid").val() == "2") {
- element.find('.AjustmentRow').click(function () {
- Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().editInvItemTaxAllocs(row.invoiceItemId, row.taxGroupId, row.itemId, row.orderItemId, element);
- });
- }
- Invoices.SplitItem.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);
- }
- });
- }
- GetMrpandBatchQty(id, element, BatchNo, batchid, row) {
- var mrpid;
- var name = "";
- var url = '';
- let Mrpid = id;
- if (Mrpid == -1)
- Mrpid = 0;
- if ($(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "7") {
- url = 'apis/v4/bizgaze/transact/items/getitemmrpavailability/itemid/' + $("#hf_ItemId").val() + '/branchid/' + $(".txtAutoComplete_shiptoaddressid").val() + '/mrpid/' + Mrpid;
- }
- else {
- url = 'apis/v4/bizgaze/transact/items/getitemmrpavailability/itemid/' + $("#hf_ItemId").val() + '/branchid/' + $(".txtAutoComplete_shipfromaddressid").val() + '/mrpid/' + Mrpid;
- }
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().GetMrpandBatchQty(url).then(function (response) {
- let AvailItemQuntity = 0;
- if (response.result != null && response.result != '') {
- AvailItemQuntity = response.result.Quantity;
- element.find(".spn_Avail").text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number(AvailItemQuntity), 2));
- if (Invoices.SplitItem.Instance().Type == "MRP") {
- element.find('.hf_' + Invoices.SplitItem.Instance().Type + '_Name').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number(response.result.Mrp), 2) + ' (' + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number(AvailItemQuntity), 2) + ')');
- name = element.find('.hf_' + SplitItem.Instance().Type + '_Name').val();
- element.find(".select_" + SplitItem.Instance().Type + "").empty();
- element.find(".select_" + SplitItem.Instance().Type + "").append(new Option(name, id));
- element.find(".select_" + SplitItem.Instance().Type + "").val(id).trigger("change");
- element.find(".select_" + SplitItem.Instance().Type + "").val(id);
- element.find(".spn_Mrp").text(response.result.Mrp);
- element.find(".hf_MrpId").val(id);
- Invoices.SplitItem.Instance().Load(element);
- if (row != null) {
- if (row.addlDiscountPercent > 0)
- element.find("#txt_discount").val(row.addlDiscountPercent);
- else
- element.find("#txt_discount").val(row.addlDiscountValue);
- element.find(".Quantity").val(row.quantity);
- Invoices.SplitItem.Instance().update_row_total(element);
- }
- }
- else if (Invoices.SplitItem.Instance().Type == "BatchNo") {
- element.find('.hf_' + Invoices.SplitItem.Instance().Type + '_Name').val('Batch No: ' + BatchNo + ' (' + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number(AvailItemQuntity), 3) + ')');
- element.find(".hf_MrpId").val(id);
- element.find(".spn_Mrp").text(response.result.Mrp);
- name = element.find('.hf_' + SplitItem.Instance().Type + '_Name').val();
- element.find(".select_" + SplitItem.Instance().Type + "").empty();
- element.find(".select_" + SplitItem.Instance().Type + "").append(new Option(name, batchid, true));
- Invoices.SplitItem.Instance().Load(element);
- if (row != null) {
- ``;
- if (row.addlDiscountPercent > 0)
- element.find("#txt_discount").val(row.addlDiscountPercent);
- else
- element.find("#txt_discount").val(row.addlDiscountValue);
- element.find(".Quantity").val(row.quantity);
- Invoices.SplitItem.Instance().update_row_total(element);
- }
- }
- }
- });
- }
- 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 < Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
- if (Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList[i].invoiceItemId == _this.parents('.SplInvoiceItemRow').find('.hf_selectedInvoiceItemId').val()) {
- x.push(i);
- SplitItem.Instance().Delete_InvoiceItems.push(invoiceitemid);
- }
- }
- for (var i = x.length - 1; i >= 0; i--) {
- Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList.splice(x[i], 1);
- }
- SplitItem.Instance().updateQuantity();
- }
- }
- else if (Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().AutoDc == false && (Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().OrderSettingId == 1 || (Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().orderid == 0 && Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().dcid != 0)) && ($(".hdn_invoiceid").val() == "0") && element.find('.hf_' + Invoices.SplitItem.Instance().Type + '_Id').val() != "0") {
- var x = [];
- for (var i = 0; i < SplitItem.Instance().DcItemIds.length; i++) {
- if (Number(SplitItem.Instance().DcItemIds[i]) == Number(element.find('.hf_' + Invoices.SplitItem.Instance().Type + '_Id').val())) {
- x.push(i);
- }
- }
- for (var i = x.length - 1; i >= 0; i--) {
- SplitItem.Instance().DcItemIds.splice(x[i], 1);
- }
- _this.parents('.SplInvoiceItemRow').remove();
- SplitItem.Instance().updateQuantity();
- }
- else {
- _this.parents('.SplInvoiceItemRow').remove();
- SplitItem.Instance().updateQuantity();
- }
- });
- 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);
- }
- });
- element.find(".Price,.exciseAmount,.txt_addldiscount").blur(function () {
- Invoices.SplitItem.Instance().update_price(element);
- });
- element.find(".btn_item_DiscType").change(function () {
- Invoices.SplitItem.Instance().update_price(element);
- });
- element.find(".Quantity").blur(function () {
- Invoices.SplitItem.Instance().CheckAvailableQuantity(element);
- });
- }
- CheckAvailableQuantity(elements) {
- var quantity = elements.find('.Quantity').val();
- var element = elements;
- if (element.find('.hf_' + Invoices.SplitItem.Instance().Type + '_Id').val() == "0") {
- MessageHelper.Instance().showError("Please Select " + Invoices.SplitItem.Instance().Type, 'bizgaze_CreateBatchErrorMessages');
- }
- if (($('.hdn_invoicetypeid').val() == '1' || $('.hdn_invoicetypeid').val() == '4' || $('.hdn_invoicetypeid').val() == '6') && Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().OrderSettingId != 1) {
- if (element.find('.hf_' + Invoices.SplitItem.Instance().Type + '_Id').val() != '0') {
- if (Number(quantity) > Number(element.find('.spn_Avail').text())) {
- MessageHelper.Instance().showError("Check available quantity", 'bizgaze_CreateBatchErrorMessages');
- if (Number(element.find('.spn_Avail').text()) > 0)
- elements.find('.Quantity').val(element.find('.spn_Avail').text());
- else {
- elements.find('.Quantity').val();
- }
- }
- }
- }
- if ((Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().OrderSettingId == 1 && element.find('.hf_dcItemId').val() != "0") || (element.find('.hf_orderItemId').val() == "0" && element.find('.hf_dcItemId').val() != "0" && Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().AutoDc == false)) {
- if (Number(quantity) > Number(element.find('.hf_maxQty').val())) {
- elements.find('.Quantity').val(Number(element.find('.hf_maxQty').val()));
- }
- }
- if (element.find('.hf_orderItemId').val() != 0) {
- var totalqty = 0;
- $('.SplInvoiceItemRow').each(function () {
- totalqty += Number($(this).find('.Quantity').val());
- });
- if (Number(Invoices.SplitItem.Instance().PendingQty) < totalqty) {
- var d = totalqty - Number(Invoices.SplitItem.Instance().PendingQty);
- elements.find('.Quantity').val(Number(quantity) - d);
- }
- }
- Invoices.SplitItem.Instance().update_row_total(element);
- }
- update_price(element) {
- Invoices.SplitItem.Instance().update_row_total(element);
- }
- update_row_total(element) {
- var row = element;
- var rowTotal = row.find('.Price').val() * (Number(row.find('.Quantity').val()));
- var rowTotalwithAdjustment = row.find('.Price').val() * (Number(row.find('.Quantity').val()));
- rowTotal += Number(row.find('.hf_RowTotalAdjustment').val());
- Number($(this).find('.txt_RowTotalwithAdjustment').val());
- rowTotalwithAdjustment += Number(row.find('.hf_RowTotalAdjustment').val());
- var exciseAmount = element.find(".exciseAmount").val();
- if (exciseAmount != undefined) {
- rowTotal += Number(exciseAmount);
- rowTotalwithAdjustment += Number(exciseAmount);
- }
- var asbAdjAmt = 0;
- asbAdjAmt = row.find('.hf_ItemAssesableAdjustmentVal').val();
- if (!isNaN(asbAdjAmt))
- rowTotalwithAdjustment += Number(asbAdjAmt);
- rowTotal = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(rowTotal, 2);
- let assesableAdjustment = Number(element.find('.hf_ItemAssesableAdjustmentVal').val());
- if (!isNaN(assesableAdjustment)) {
- assesableAdjustment = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(assesableAdjustment, 2);
- }
- else {
- assesableAdjustment = 0;
- }
- rowTotalwithAdjustment += Number(assesableAdjustment);
- rowTotalwithAdjustment = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(rowTotalwithAdjustment, 2);
- if (isNaN(rowTotal)) {
- element.find('.TotalPrice').html("N/A");
- element.find('.hf_RowTotal').val("0");
- element.find('.hf_RowTotalwithAdjustment').val("0");
- }
- else {
- element.find('.hf_RowTotal').val(rowTotal);
- element.find('.hf_RowTotalwithAdjustment').val(rowTotalwithAdjustment);
- element.find('.TotalPrice').html(rowTotal);
- }
- Invoices.SplitItem.Instance().update_Discount(element);
- Invoices.SplitItem.Instance().updateQuantity();
- }
- updateQuantity() {
- var TotalAmt = 0;
- var totalqty = 0;
- $(".SplInvoiceItemRow").each(function () {
- if ($(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "7")
- TotalAmt += Number($(this).find('.txt_RowTotalwithAdjustment').val());
- else
- TotalAmt += Number($(this).find('.TotalPrice').text());
- if ($("#hf_" + $("#hfLayout_InstalledPageId").val() + "_OrderId").val() != "0" && $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_OrderId").val() != undefined) {
- totalqty += Number($(this).find('.Quantity').val());
- }
- });
- $('.hf_nettotal').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(TotalAmt, 2));
- $(".hf_pendingQty").text(Number(Invoices.SplitItem.Instance().PendingQty) - totalqty);
- Controls.InvoiceItem.Instance().GetDiscounts();
- }
- update_Discount(element) {
- let totalLineAmount = element.find('.hf_RowTotal').val();
- if (!isNaN(totalLineAmount))
- var discountPercent = 0;
- var discountValue = 0;
- var quantity = Number(element.find(".Quantity").val());
- var unitPrice = Number(element.find(".Price").val());
- totalLineAmount = element.find('.Price').val().replace("$", "") * quantity;
- var exciseAmount = Number(element.find(".exciseAmount").val());
- if (isNaN(exciseAmount))
- exciseAmount = 0;
- var nonexciseAmount = totalLineAmount - exciseAmount;
- if (element.find(".btn_item_DiscType option:selected").text().trim() == 'Val' && element.find('.txt_addldiscount').val() != '' && element.find('.txt_addldiscount').val() != undefined) {
- discountValue = 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 discountAmount = 0;
- discountAmount = (Number(nonexciseAmount) * Number(discountPercent) / 100)
- + (Number(quantity) * Number(discountValue));
- discountAmount = Number(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(discountAmount, 2));
- let discountedAmount = Number(totalLineAmount) - Number(discountAmount);
- element.find(".hf_DiscountedAmount").val(discountAmount);
- if ($(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "7") {
- var assesableAdjustment = Number(element.find('.hf_ItemAssesableAdjustmentVal').val());
- element.find(".txt_RowTotalwithAdjustment").val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totalLineAmount - discountAmount + assesableAdjustment, 2));
- }
- else {
- element.find(".TotalPrice").html(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totalLineAmount - discountAmount, 2));
- element.find(".hf_RowTotal").val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totalLineAmount - discountAmount, 2));
- }
- }
- Load(element) {
- var Ids = [];
- var AutoText = element.find(".select_" + SplitItem.Instance().Type + "");
- var hdnAutoId = element.find(".hf_" + SplitItem.Instance().Type + "_Id");
- Ids = [0];
- $(".hf_" + SplitItem.Instance().Type + "_Id").each(function (index) {
- if ($(this).val() == element.find(".hf_" + SplitItem.Instance().Type + "_Id").val()) { }
- else
- Ids.push($(this).val());
- });
- var InvoiceType = 'Purchase';
- var dctypeid = 1;
- var BranchId = $(".txtAutoComplete_shiptoaddressid").val();
- if ($('.hdn_invoicetypeid').val() == '1' || $('.hdn_invoicetypeid').val() == '4' || $('.hdn_invoicetypeid').val() == '6') {
- InvoiceType = 'Sales';
- BranchId = $(".txtAutoComplete_shipfromaddressid").val();
- dctypeid = 2;
- }
- let url;
- if (SplitItem.Instance().Type == "MRP") {
- url = _appsettings.server_url() + '/apis/v4/bizgaze/transact/pricelists/MrpsAutoComplete/itemid/' + $("#hf_ItemId").val() + '/mrpids/' + Ids.toString() + '/invoicetype/' + InvoiceType + '/dctype/' + dctypeid + '/branchid/' + BranchId + '/isinvoice/true';
- }
- else if (SplitItem.Instance().Type == "BatchNo") {
- url = _appsettings.server_url() + '/apis/v4/bizgaze/transact/pricelists/BatchAutoComplete/itemid/' + $("#hf_ItemId").val() + '/ids/' + Ids.toString() + '/invoicetype/' + InvoiceType + '/dctype/' + dctypeid + '/branchid/' + BranchId + '/isinvoice/true';
- }
- else if (SplitItem.Instance().Type == "SerialNo") {
- url = _appsettings.server_url() + "/api/v3/MRPs/Item/" + $("#hf_ItemId").val() + "/SerialNos/" + Ids.toString() + "/InvoiceType/" + InvoiceType + "/DCtype/0/";
- }
- var AutoText = element.find(".select_" + SplitItem.Instance().Type);
- var hdnAutoId = element.find(".hf_" + SplitItem.Instance().Type + "_Id");
- AutoCompleteHelper.getHelper().Create(AutoText, hdnAutoId, url, function (result) {
- var ids = $(hdnAutoId).val();
- if (ids != '0' && result.id != 0 && result.addlData != undefined) {
- element.find(".Quantity").val("0");
- element.find("Price").val(element.find('.hf_UnitPrice').val());
- element.find("#txt_discount").val("0");
- Invoices.SplitItem.Instance().update_row_total(element);
- if (Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().AutoDc == false && (Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().OrderSettingId == 1 || (Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().orderid == 0 && Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().dcid != 0) && result.addlData != undefined) && ($(".hdn_invoiceid").val() == "0")) {
- SplitItem.Instance().DcItemIds.push(result.id);
- element.find(".hf_dcItemId").val(result.addlData.split(':')[1]);
- element.find(".hf_orderItemId").val(result.addlData.split(':')[2]);
- element.find(".Quantity").val(result.addlData.split(':')[3]);
- element.find(".spn_Avail").text(result.addlData.split(':')[0]);
- }
- else {
- element.find(".spn_Avail").text(result.addlData);
- }
- if (SplitItem.Instance().Type == "MRP") {
- if (result.id.search(":") != -1)
- element.find(".hf_MrpId").val(result.id);
- else
- element.find(".hf_MrpId").val(result.id);
- }
- else if (SplitItem.Instance().Type == 'BatchNo') {
- Bizgaze.Apps.Transact.Managers.PriceListManager.Instance().getbatch(result.id).then(function (result) {
- element.find(".hf_MrpId").val(result.result.MrpId);
- element.find(".spn_Mrp").text(result.result.Mrp);
- });
- }
- Ids = [0];
- $(".hf_" + SplitItem.Instance().Type + "_Id").each(function () {
- Ids.push($(this).val());
- });
- }
- });
- }
- SaveItem(elements) {
- this.fileCacheHelper.loadJsFile("libs/parsley/parsley.min.js", null);
- var qty = false;
- var avlqty = false;
- var UnitPrice = false;
- let appcontrolid = "frm_Bizgazetransact_Invoice_createInvoiceItem";
- let itemcount = 0;
- var MRPandBatch = false;
- $(".SplInvoiceItemRow").each(function () {
- itemcount += 1;
- if ($(this).find(".Quantity").val() == 0) {
- qty = true;
- }
- if ($(this).find(".Price ").val() == 0) {
- UnitPrice = true;
- }
- if (($(this).find(".select_" + Invoices.SplitItem.Instance().Type).text()) == "") {
- MRPandBatch = true;
- }
- });
- if (itemcount == 0) {
- MessageHelper.Instance().showError("Please Select " + Invoices.SplitItem.Instance().Type, "bizgaze_CreateBatchErrorMessages");
- return false;
- }
- if (MRPandBatch) {
- MessageHelper.Instance().showError("Please Select " + Invoices.SplitItem.Instance().Type, "bizgaze_CreateBatchErrorMessages");
- return false;
- }
- let result = Unibase.Platform.Forms.Components.FormViewer.Instance().requiredFieldValidation(appcontrolid);
- if (result == false) {
- MessageHelper.Instance().showError("Mandatory fields are missing", "bizgaze_CreateBatchErrorMessages");
- return false;
- }
- if ($('#hf_InventoryTypeId').val() == '1' || $('#hf_InventoryTypeId').val() == '4' || $('#hf_InventoryTypeId').val() == '5') {
- $(".SplInvoiceItemRow").each(function () {
- if (Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().OrderSettingId != 1) {
- if (Number($(this).find(".Quantity").val()) > Number($(this).find('.spn_Avail').text())) {
- avlqty = true;
- }
- }
- });
- }
- if (qty) {
- MessageHelper.Instance().showError("Item quantity should not be zero.", "bizgaze_CreateBatchErrorMessages");
- return false;
- }
- if (UnitPrice) {
- MessageHelper.Instance().showError("Unit Price should not be zero.", "bizgaze_CreateBatchErrorMessages");
- return false;
- }
- if (avlqty) {
- MessageHelper.Instance().showError("Check available quantity", 'bizgaze_CreateBatchErrorMessages');
- return false;
- }
- var x = [];
- for (var i = 0; i < Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
- if (Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId == $("#hf_ItemId").val()) {
- x.push(i);
- }
- }
- for (var i = 0; i < SplitItem.Instance().Delete_InvoiceItems.length; i++) {
- Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().deleted_invoiceItems.push(i);
- }
- for (var i = x.length - 1; i >= 0; i--) {
- Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList.splice(x[i], 1);
- }
- var TotalQuantity = 0;
- var TotalAmount = 0;
- var TotalDisc = 0;
- var RowExist = false;
- $(".SplInvoiceItemRow").each(function () {
- var element = $(this);
- var BatchId = 0;
- var SerialNoId = 0;
- var MrpId = 0;
- var Name = '';
- if (Invoices.SplitItem.Instance().Type == "MRP") {
- MrpId = Number(element.find('.hf_MRP_Id').val());
- Name = element.find('.select_' + Invoices.SplitItem.Instance().Type + ' option[value=' + MrpId + ']').text();
- }
- else if (Invoices.SplitItem.Instance().Type == "BatchNo") {
- BatchId = Number(element.find('.select_' + Invoices.SplitItem.Instance().Type + '').val());
- MrpId = Number(element.find(".hf_MrpId").val());
- Name = element.find('.select_' + Invoices.SplitItem.Instance().Type + ' option[value =' + BatchId + ']').text();
- }
- else if (Invoices.SplitItem.Instance().Type == "SerialNo") {
- SerialNoId = Number(element.find('.select_' + Invoices.SplitItem.Instance().Type + '').val());
- MrpId = Number(element.find(".hf_MrpId").val());
- Name = element.find('.select_' + Invoices.SplitItem.Instance().Type + ' option[value=' + SerialNoId + ']').text();
- }
- if (element.find("#hf_" + Invoices.SplitItem.Instance().Type + "_Id").val() != '' && element.find("#hf_" + Invoices.SplitItem.Instance().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(".btn_item_DiscType option:selected").text().trim();
- var AccountId = elements.find(".hf_Account").val();
- var TaxGroupId = elements.find(".hfProdTax").val();
- Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList.push({
- invoiceItemId: element.find(".hf_selectedInvoiceItemId").val(),
- orderItemId: element.find(".hf_orderItemId").val(),
- itemId: element.find(".hf_selectedItemId").val(),
- taxGroupId: $("#ddl_TaxGroupId").val(),
- taxGroupName: $("#ddl_TaxGroupId option:selected").text(),
- 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: $("#ddl_AccountId").val(),
- accountName: $("#ddl_AccountId option:selected").text(),
- 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: $(".hf_ProdTaxPercent").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(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(discount, 3));
- TotalDisc += discount;
- if ($(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "7") {
- TotalAmount += Number(element.find(".txt_RowTotalwithAdjustment").val());
- }
- else {
- TotalAmount += Number(element.find(".TotalPrice").text());
- }
- }
- });
- if (RowExist = true)
- elements.find('.spn_InvoiceItem').text("View " + Invoices.SplitItem.Instance().Type);
- else
- elements.find('.spn_InvoiceItem').text("Select " + Invoices.SplitItem.Instance().Type);
- elements.find('.prodQuantity').val();
- elements.find('.prodQuantity').val(TotalQuantity);
- elements.find('#inv_txtdiscount').val();
- elements.find('#inv_txtdiscount').val(TotalDisc);
- if (($(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6") && $(".hdn_invoiceid").val() != "0") {
- elements.find(".txtRowTotalwithAdjustment").val();
- elements.find(".txtRowTotalwithAdjustment").val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(TotalAmount, 2));
- }
- else {
- elements.find('.prodTotalPrice').text('');
- elements.find('.prodTotalPrice').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(TotalAmount, 2));
- }
- Invoices.SplitItem.Instance().navigationHelper.closePopUp();
- if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.length > 0) {
- let OrderId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_orderid") == undefined ? 0 : Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_orderid").Value);
- if (OrderId == 0) {
- Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().GetPlanItems(elements.find(".selectedItemId").val(), TotalQuantity, elements);
- }
- }
- Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().update_total();
- Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().TotalAdjustment();
- Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().update_discount_total();
- }
- bindDetails(response, element) {
- var data = JSON.parse(response.result);
- if (SplitItem.instance.Type == "MRP") {
- element.find(".select_" + SplitItem.Instance().Type).empty();
- element.find(".select_" + SplitItem.Instance().Type).append(new Option(data.Mrp + '(0)', data.MrpId, true));
- element.find(".hf_" + SplitItem.Instance().Type + "_Id").val(data.MrpId);
- Invoices.SplitItem.Instance().GetMrpandBatchQty(data.MrpId, element, "", 0, null);
- }
- else if (SplitItem.instance.Type == "Batch") {
- element.find(".select_" + SplitItem.Instance().Type).empty();
- element.find(".select_" + SplitItem.Instance().Type).append(new Option(data.BatchNo + '(0)', data.BatchId, true));
- element.find(".hf_" + SplitItem.Instance().Type + "_Id").val(data.BatchId);
- }
- }
- refreshInvoiceTypes() {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/invoicemanager.js", function () {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().refreshInvoiceTypes().then(function (response) {
- MessageHelper.Instance().showSuccess(response.message, '');
- });
- });
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new Invoices.SplitItem();
- }
- return this.instance;
- }
- }
- SplitItem.element = "";
- Invoices.SplitItem = SplitItem;
- })(Invoices = Controls.Invoices || (Controls.Invoices = {}));
- })(Controls = Transact.Controls || (Transact.Controls = {}));
- })(Transact = Apps.Transact || (Apps.Transact = {}));
- })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
- })(Bizgaze || (Bizgaze = {}));
|