Built files from Bizgaze WebServer
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

item.mrp.js 41KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. var Unibase;
  2. (function (Unibase) {
  3. let Forms;
  4. (function (Forms) {
  5. let Controls;
  6. (function (Controls) {
  7. class MRPDetails extends Unibase.Platform.Core.BaseComponent {
  8. constructor() {
  9. super(...arguments);
  10. this.Type = "";
  11. this.PendingQty = 0;
  12. this.SplitedInvoiceItemList = new Array();
  13. this.rowIndex = 0;
  14. this.container = "";
  15. this.DcItemIds = new Array();
  16. }
  17. jsFiles() {
  18. return ["platform/controls/itemdetails/item.mrp.js"];
  19. }
  20. cssFiles() {
  21. return [];
  22. }
  23. load(containerid) {
  24. var instance = this;
  25. $("#btn_InvoiceItem_Close").click(function () {
  26. instance.navigationHelper.closePopUp();
  27. });
  28. }
  29. loadForm(FormId, Pk_Value, AppConfigurationId, Callback, ElementId) {
  30. }
  31. html() {
  32. 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>';
  33. return html;
  34. }
  35. init(element, ItemName, type) {
  36. $(".InvoiceItemName").text(ItemName);
  37. $(".EnabledType").text(type);
  38. this.Type = type;
  39. this.SplitedInvoiceItemList.push({
  40. orderItemId: 0,
  41. invoiceItemId: 0,
  42. itemName: "test",
  43. itemId: 0,
  44. itemSKU: 0,
  45. unitName: 0,
  46. packSize: 0,
  47. packCount: 0,
  48. packs: 0,
  49. quantity: 0,
  50. availPacks: 0,
  51. availQty: 0,
  52. listPrice: 0,
  53. description: "",
  54. taxGroupName: "",
  55. taxGroupId: 0,
  56. isTaxInclusive: $("#hfId_IsTaxInclusive").val(),
  57. addlDiscountPercent: 0,
  58. addlDiscountValue: 0,
  59. creditNote: 0,
  60. priceListId: 0,
  61. batchId: 0,
  62. unitPrice: 0,
  63. invoiceallocations: null,
  64. exciseInvoiceItem: null,
  65. accountId: 0,
  66. accountName: "",
  67. walletId: 0,
  68. Adjustment: 0,
  69. IsFoc: 0,
  70. TariffNo: "",
  71. exciseAmount: 0,
  72. discountName: "",
  73. discountId: 0,
  74. refNo: "",
  75. DiscountGroupId: 0,
  76. DiscountGroupName: "",
  77. ExchangeItem: 0,
  78. maxQty: 0,
  79. RefInvoiceItemId: 0,
  80. MrpId: 0,
  81. taxAdjustment: 0,
  82. assesableAdjustment: 0,
  83. inventoryTypeId: 0,
  84. IsBoMItem: 0,
  85. dcItemId: 0,
  86. TotalRowAmount: 0,
  87. TotalDiscount: 0,
  88. BatchId: 0,
  89. });
  90. var ItemExist = false;
  91. for (var i = 0; i < this.SplitedInvoiceItemList.length; i++) {
  92. if (this.SplitedInvoiceItemList[i].itemId == $("#hf_ItemId").val()) {
  93. ItemExist = true;
  94. MRPDetails.Instance().addMrpRowWithData(this.SplitedInvoiceItemList[i]);
  95. }
  96. }
  97. $("#hf_ItemId").val(element.find(".selectedItemId").val());
  98. $(".hf_AvailQty").text(element.find(".prodAvail").text());
  99. if ($("#hf_" + $("#hfLayout_InstalledPageId").val() + "_OrderId").val() != "0" && $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_OrderId").val() != undefined) {
  100. $(".hf_pendingQty").text(element.find(".maxQty").val());
  101. this.PendingQty = element.find(".maxQty").val();
  102. }
  103. $("#btnInvoice_Batch").click(function () {
  104. MRPDetails.Instance().addMrpRow(element);
  105. });
  106. $("#btn_InvoiceItem_Save").click(function () {
  107. });
  108. $(document).click(function (e) {
  109. var container = $(".div_Item_MoreDetails");
  110. });
  111. if (ItemExist == false)
  112. var orderid = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_OrderId").val();
  113. var dcid = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_DcId").val();
  114. var InvoiceId = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_InvoiceId").val();
  115. var OrdersettingId = 2;
  116. if (OrdersettingId == 1 || ((orderid == "0" || orderid == undefined) && (dcid != "0" && dcid != undefined) && (InvoiceId == "0" || InvoiceId == "null")))
  117. $("#btnInvoice_Batch").addClass('hidden');
  118. }
  119. addMrpRow(element) {
  120. var array = {
  121. orderItemId: element.find('.orderItemId').val(),
  122. invoiceItemId: 0,
  123. itemId: element.find('.selectedItemId').val(),
  124. packSize: 0,
  125. packCount: 0,
  126. packs: 0,
  127. quantity: 0,
  128. availPacks: 0,
  129. availQty: 0,
  130. Description: "",
  131. isTaxInclusive: $("#hfIsTaxInclusive").val(),
  132. addlDiscountPercent: 0,
  133. addlDiscountValue: 0,
  134. creditNote: 0,
  135. priceListId: element.find('.hf_PriceList').val(),
  136. invoiceallocations: null,
  137. exciseInvoiceItem: null,
  138. walletId: 0,
  139. Adjustment: 0,
  140. IsFoc: 0,
  141. TariffNo: "",
  142. exciseAmount: 0,
  143. discountName: "",
  144. discountId: 0,
  145. description: "",
  146. RefNo: "",
  147. DiscountGroupId: 0,
  148. DiscountGroupName: '',
  149. RefInvoiceItemId: 0,
  150. taxAdjustment: element.find('.hfItemTaxAdjsutmentVal').val(),
  151. assesableAdjustment: element.find('.hfItemAssesableAdjustmentVal').val(),
  152. inventoryTypeId: 0,
  153. dcItemId: 0,
  154. ExchangeItem: element.find('.IsExchangeItem').val(),
  155. unitPrice: element.find('.prodPrice').val(),
  156. taxGroupId: $("#hf_TaxGroupId").val(),
  157. BatchId: 0,
  158. MrpId: 0,
  159. SerialId: 0,
  160. Name: '',
  161. maxQty: 0
  162. };
  163. MRPDetails.Instance().addMrpRowWithData(array);
  164. }
  165. addMrpRowWithData(row) {
  166. this.rowIndex = $(".SplInvoiceItemRow").length + 1;
  167. var activeDiscVal = "";
  168. var activeDiscPercent = "";
  169. var activeDiscMul = "";
  170. var activeDiscText = "";
  171. var discValue = 0;
  172. if (row.addlDiscountPercent > 0) {
  173. discValue = row.addlDiscountPercent;
  174. activeDiscPercent = "active";
  175. activeDiscText = "%";
  176. }
  177. else if (row.addlDiscountValue > 0 && row.DiscountGroupId > 0) {
  178. discValue = row.addlDiscountValue;
  179. activeDiscMul = "active";
  180. activeDiscText = "Mul";
  181. }
  182. else {
  183. discValue = row.addlDiscountValue;
  184. activeDiscVal = "active";
  185. activeDiscText = "Val";
  186. }
  187. var Class = "";
  188. if (Type == "MRP") {
  189. Class = "Mrp-row Mrp-addedrow";
  190. }
  191. else if (Type == "BatchNo") {
  192. Class = "Batch-row Batch-addedrow";
  193. }
  194. else if (Type == "SerialNo") {
  195. Class = "Serial-row Serial-addedrow";
  196. }
  197. var readonlyPrice = "";
  198. var readonlyDisc = "";
  199. var readonlyTax = "";
  200. var readonlyQty = "";
  201. var ManageInvoice = 1;
  202. var ManageInvoiceTax = 1;
  203. if (ManageInvoice == 1 && AutoDc == false) {
  204. readonlyQty = "readonly";
  205. readonlyPrice = "readonly";
  206. readonlyDisc = "readonly";
  207. readonlyTax = "readonly";
  208. }
  209. if ($('#hfInv_Invoicetype').val() == "Sales" && ManageInvoiceTax == 1 && AutoDc == false) {
  210. readonlyTax = "readonly";
  211. }
  212. var html = '<div class="row ' + Class + ' form-group mt-20 SplInvoiceItemRow">' +
  213. '<div class="row col-sm-12 ml-5">' +
  214. '<input type="hidden" class="txt_rowIndex" value="' + this.rowIndex + '"/>' +
  215. '<input type="hidden" class="hf_orderItemId" value="' + row.orderItemId + '"/>' +
  216. '<input type="hidden" class="hf_dcItemId" value="' + row.dcItemId + '"/>' +
  217. '<input type="hidden" class="hf_selectedInvoiceItemId" value="' + row.invoiceItemId + '"/>' +
  218. '<input type="hidden" class="hf_refInvoiceItemId" value="' + row.RefInvoiceItemId + '"/>' +
  219. '<input type="hidden" class="hf_selectedItemId" value="' + row.itemId + '"/>' +
  220. '<input type="hidden" class="hf_offerapplied" value="0"/>' +
  221. '<input type="hidden" class="hf_refNo" value="' + row.RefNo + '"/>' +
  222. '<input type="hidden" class="hf_description" value="' + row.description + '"/>' +
  223. '<input type="hidden" class="hf_IsExchangeItem" value="' + row.ExchangeItem + '"/>' +
  224. '<input type="hidden" class="hf_ItemTaxAdjsutmentVal" value="' + row.taxAdjustment + '"/>' +
  225. '<input type="hidden" class="hf_ItemAssesableAdjustmentVal" value="' + row.assesableAdjustment + '"/>' +
  226. '<input type="hidden" class="hf_maxQty" value="' + row.maxQty + '" />' +
  227. '<input type="hidden" class="exciseAmount" value="0"/>' +
  228. '<input type="hidden" class="hf_UnitPrice" value="' + row.unitPrice + '"/>' +
  229. '<input type="hidden" class="hf_' + Type + '_Name" value=""/>' +
  230. '<div class="col-sm-4">' +
  231. '<div class=" min-padding">' +
  232. '<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>' +
  233. '<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>' +
  234. '<input type="hidden" id="hf_itemMrp_' + this.rowIndex + '" class="hf_' + Type + '_Id"/>' +
  235. '</div></div>' +
  236. '<div class="col-sm-2">' +
  237. '<div class="floating-label-form-group min-padding">' +
  238. '<input type="text" class="Quantity text-center form-control" placeholder="0.00" value="' + row.quantity + '" ' + readonlyQty + '>' +
  239. '</div></div>' +
  240. '<div class="col-sm-2">' +
  241. '<div class="floating-label-form-group min-padding">' +
  242. '<input type="text" class="Price text-center form-control" placeholder="0.00" value="' + row.unitPrice + '" ' + readonlyPrice + '/>' +
  243. '</div></div>' +
  244. '<div class="col-sm-2">' +
  245. '<div class="floating-label-form-group">' +
  246. '<input type="hidden" id="hf_ItemDiscountGroupId" value="' + row.DiscountGroupId + '" />' +
  247. '<input type="hidden" id="hf_ItemDiscountGroupName" value="' + row.DiscountGroupName + '" />' +
  248. '<input type="hidden" id="hf_ItemDiscountList" value=""/>' +
  249. '<input type="hidden" id="hf_ItemDiscountApplyTypes" value=""/>' +
  250. '<div class="input-group">' +
  251. '<input type="text" id="txt_discount" placeholder="0.00" class="form-control txt_addldiscount text-center d-none d-md-block" value="' + discValue + '" readonlyDisc>' +
  252. '<input type="text" id="txt_discount" placeholder="0.00" class="form-control txt_addldiscount text-center ml-40 d-md-none" value="' + discValue + '" readonlyDisc>' +
  253. '<div class="input-group-btn">' +
  254. '<div class="input-group-btn">' +
  255. '<select class="btn_item_DiscType mt-10 border-blue"><option value="Val">Val</option><option value="%">%</option></select>' +
  256. '</div>' +
  257. '</div></div></div></div>' +
  258. '<div class="col-sm-2">' +
  259. '<input type="hidden" class="hf_DiscountedAmount" value="0" />' +
  260. '<input type="hidden" class="hf_RowTotalAdjustment" value="' + row.Adjustment + '" />' +
  261. '<input type="hidden" class="hf_AssesableAdjustment" value="" />' +
  262. '<input type="hidden" class="hf_TaxAdjustment" value="" />';
  263. if ($("#hfInv_Invoicetype").val() == "Purchase" || $("#hfInv_Invoicetype").val() == "PurchaseReturn" || $("#hfInv_Invoicetype").val() == "DebitNote") {
  264. 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>';
  265. 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>';
  266. }
  267. else {
  268. 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>';
  269. }
  270. html += '</div></div >';
  271. html += '<div class="row col-sm-12 div_Item_MoreDetails clear hidden">' +
  272. '<div class="row col-sm-12 bg-light ml-10 mt-5">' +
  273. '<div class="col-sm-6">' +
  274. '<div class="floating-label-form-group form-group floating-label focus">' +
  275. '<label for="lbl_Description" id="lbl_Description">Description</label>' +
  276. '<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"/>' +
  277. '</div></div>';
  278. if (Type != "MRP") {
  279. html += '<div class="col-sm-2 mt-30">' +
  280. '<label for="lbl_Mrp" id="lbl_Mrp"><b>Mrp: &ensp;<span></span></b></label>' +
  281. '<span class="spn_Mrp">0</span>' +
  282. '<input type="hidden" class="hf_MrpId"/>' +
  283. '</div>';
  284. }
  285. html += '<div class="col-sm-3 mt-30">' +
  286. '<label for="lbl_Avalilability" id="lbl_Avalilability"><b>Availability: &ensp;<span></span></b></label>' +
  287. '<span class="spn_Avail">0</span>' +
  288. '<input type="hidden" class="hf_PriceList" value="' + row.priceListId + '"/>' +
  289. '</div>' +
  290. '</div></div></div>';
  291. var element = "";
  292. var Type = "MRP";
  293. if (Type == "MRP") {
  294. $(".Mrp-row:last").after(html);
  295. element = $(".Mrp-addedrow:last");
  296. }
  297. else if (Type == "BatchNo") {
  298. $(".Batch-row:last").after(html);
  299. element = $(".Batch-addedrow:last");
  300. }
  301. else if (Type == "SerialNo") {
  302. $(".Serial-row:last").after(html);
  303. element = $(".Serial-addedrow:last");
  304. }
  305. element.find(".btn_item_DiscType option[value='" + activeDiscText + "']").prop("selected", true);
  306. if (row.description != null && row.description != '' && row.description != 'null')
  307. element.find('#txt_Item_Description').val(row.description);
  308. if ((row.orderItemId != 0 && row.dcItemId != 0 && OrdersettingId == 1) || (row.orderItemId == 0 && row.dcItemId != 0 && AutoDc == false)) {
  309. element.find('.select_' + Type + '').prop('disabled', true);
  310. }
  311. $('.txt_addldiscount').keypress(function (event) {
  312. if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
  313. }
  314. else {
  315. event.preventDefault();
  316. }
  317. }).on('paste', function (event) {
  318. event.preventDefault();
  319. });
  320. $('.Quantity').keypress(function (event) {
  321. if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
  322. }
  323. else {
  324. event.preventDefault();
  325. }
  326. }).on('paste', function (event) {
  327. event.preventDefault();
  328. });
  329. $('.Price').keypress(function (event) {
  330. if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
  331. }
  332. else {
  333. event.preventDefault();
  334. }
  335. }).on('paste', function (event) {
  336. event.preventDefault();
  337. });
  338. this.Load(element);
  339. var OrdersettingId = 2;
  340. var AutoDc = false;
  341. if (row.dcItemId != 0 && OrdersettingId != 2 && AutoDc == false)
  342. element.find(".Quantity").prop('disabled', true);
  343. if (row.invoiceItemId != 0 || row.dcItemId != 0 || row.orderItemId != 0) {
  344. if (Type == "MRP") {
  345. row.Name = element.find('.hf_' + Type + '_Name').val();
  346. }
  347. else if (Type == "BatchNo") {
  348. row.Name = element.find('.hf_' + Type + '_Name').val();
  349. }
  350. else if (Type == "SerialNo") {
  351. row.Name = element.find('.hf_' + Type + '_Name').val();
  352. }
  353. }
  354. if (row.Name != '') {
  355. if (Type == "MRP") {
  356. if (row.MrpId != 0) {
  357. element.find(".select_" + Type + "").empty();
  358. element.find(".select_" + Type + "").append(new Option(row.Name, row.MrpId, true));
  359. element.find('.hf_' + Type + '_Id').val(row.MrpId);
  360. }
  361. }
  362. else if (Type == "BatchNo") {
  363. if (row.BatchId != 0) {
  364. element.find(".select_" + Type + "").empty();
  365. element.find(".select_" + Type + "").append(new Option(row.Name, row.BatchId, true));
  366. element.find('.hf_' + Type + '_Id').val(row.BatchId);
  367. }
  368. }
  369. else if (Type == "SerialNo") {
  370. if (row.SerialId != 0) {
  371. element.find(".select_" + Type + "").empty();
  372. element.find(".select_" + Type + "").append(new Option(row.Name, row.SerialId, true));
  373. element.find('.hf_' + Type + '_Id').val(row.SerialId);
  374. }
  375. }
  376. }
  377. element.find(".Price,.Quantity,.txt_addldiscount ").focusin(function () {
  378. $(".div_Item_MoreDetails").addClass("hidden");
  379. element.find(".div_Item_MoreDetails").removeClass("hidden");
  380. });
  381. element.find(".prodName").focusin(function () {
  382. $(".div_Item_MoreDetails").addClass("hidden");
  383. });
  384. element.find(".txt_addldiscount").change(function () {
  385. if (element.find(".btn_item_DiscType").val() == "%") {
  386. if (Number(element.find(".txt_addldiscount").val()) > 100)
  387. element.find(".txt_addldiscount").val("100");
  388. }
  389. });
  390. element.find('.AjustmentRow').click(function () {
  391. });
  392. var url = _appsettings.server_url() + '/apis/v4/unibase/transact/items/getitems/itemids/' + ',' + '/lobid/' + 100284890000001;
  393. AutoCompleteHelper.getHelper().Create("#select_itemMrp_" + this.rowIndex, "#hf_itemMrp_" + this.rowIndex, url, function (response) {
  394. var data = response;
  395. });
  396. MRPDetails.Instance().RemoveRow(element);
  397. element.find('.btn_item_DiscType').change(function () {
  398. if (element.find(".btn_item_DiscType").val() == "%") {
  399. if (Number(element.find(".txt_addldiscount").val()) > 100)
  400. element.find(".txt_addldiscount").val("100");
  401. }
  402. if (element.find(".btn_item_DiscType option:selected").text().trim() == 'Val') {
  403. element.find('#hf_ItemDiscountGroupId').val(0);
  404. element.find('#hf_ItemDiscountGroupName').val('');
  405. element.find('.txt_addldiscount').prop('disabled', false);
  406. }
  407. else if (element.find(".btn_item_DiscType option:selected").text().trim() == '%') {
  408. element.find('#hf_ItemDiscountGroupId').val(0);
  409. element.find('#hf_ItemDiscountGroupName').val('');
  410. element.find('.txt_addldiscount').prop('disabled', false);
  411. }
  412. });
  413. }
  414. RemoveRow(element) {
  415. element.find(".delete-row").on('click', function () {
  416. var _this = $(this);
  417. _this.parents('.SplInvoiceItemRow');
  418. var invoiceitemid = _this.parents('.SplInvoiceItemRow').find(".hf_selectedInvoiceItemId").val();
  419. if (invoiceitemid != 0) {
  420. if (confirm("You are about to Delete the invoice item. Are you sure?")) {
  421. var x = [];
  422. for (var i = 0; i < this.SplitedInvoiceItemList.length; i++) {
  423. if (this.SplitedInvoiceItemList[i].invoiceItemId == _this.parents('.SplInvoiceItemRow').find('.hf_selectedInvoiceItemId').val()) {
  424. x.push(i);
  425. }
  426. }
  427. for (var i = x.length - 1; i >= 0; i--) {
  428. this.SplitedInvoiceItemList.splice(x[i], 1);
  429. }
  430. _this.parents('.SplInvoiceItemRow').remove();
  431. }
  432. }
  433. else {
  434. if (confirm("You are about to Delete the invoice item. Are you sure?")) {
  435. _this.parents('.SplInvoiceItemRow').remove();
  436. }
  437. }
  438. });
  439. element.find('.btn_item_DiscType').change(function () {
  440. if (element.find(".btn_item_DiscType").val() == "%") {
  441. if (Number(element.find(".txt_addldiscount").val()) > 100)
  442. element.find(".txt_addldiscount").val("100");
  443. }
  444. if (element.find(".btn_item_DiscType option:selected").text().trim() == 'Val') {
  445. element.find('#hf_ItemDiscountGroupId').val(0);
  446. element.find('#hf_ItemDiscountGroupName').val('');
  447. element.find('.txt_addldiscount').prop('disabled', false);
  448. }
  449. else if (element.find(".btn_item_DiscType option:selected").text().trim() == '%') {
  450. element.find('#hf_ItemDiscountGroupId').val(0);
  451. element.find('#hf_ItemDiscountGroupName').val('');
  452. element.find('.txt_addldiscount').prop('disabled', false);
  453. }
  454. });
  455. }
  456. Load(element) {
  457. var Type = "";
  458. var Ids = [];
  459. var AutoText = element.find(".select_" + Type + "");
  460. var hdnAutoId = element.find(".hf_" + Type + "_Id");
  461. Ids = [0];
  462. $(".hf_" + Type + "_Id").each(function () {
  463. Ids.push($(this).val());
  464. });
  465. var InvoiceType = 'Purchase';
  466. var BranchId = $("#ddl_ShipToAddressId").val();
  467. if ($('#hfInv_Invoicetype').val() == 'Sales' || $('#hfInv_Invoicetype').val() == 'PurchaseReturn' || $('#hfInv_Invoicetype').val() == 'CreditNote') {
  468. InvoiceType = 'Sales';
  469. BranchId = $("#ddl_ShipFromAddressId").val();
  470. }
  471. var url;
  472. if (Type == "MRP") {
  473. if ($("#hf_FormAppTitle").val() == "Sales Return" || $("#hf_FormAppTitle").val() == "Purchase Return") {
  474. }
  475. else { }
  476. }
  477. else if (Type == "BatchNo") {
  478. }
  479. else if (Type == "SerialNo") {
  480. }
  481. var AutoText = element.find(".select_" + Type + "");
  482. var hdnAutoId = element.find(".hf_" + Type + "_Id");
  483. }
  484. SaveItem(elements) {
  485. var qty = false;
  486. var avlqty = false;
  487. var UnitPrice = false;
  488. var CreateBatch_Validation = 'frm_Bizgazetransact_Invoice_createInvoiceItem';
  489. if (!CreateBatch_Validation) {
  490. MessageHelper.Instance().showError(" Mandatory fields are missing ", "bizgaze_CreateBatchErrorMessages");
  491. return false;
  492. }
  493. $(".SplInvoiceItemRow").each(function () {
  494. if ($(this).find(".Quantity").val() == 0) {
  495. qty = true;
  496. }
  497. });
  498. $(".SplInvoiceItemRow").each(function () {
  499. if ($(this).find(".Price ").val() == 0) {
  500. UnitPrice = true;
  501. }
  502. });
  503. var OrdersettingId = 1;
  504. var AutoDc = false;
  505. var qty = true;
  506. var UnitPrice = true;
  507. var avlqty = true;
  508. if ($('#hfInv_Invoicetype').val() == 'Sales' || $('#hfInv_Invoicetype').val() == 'PurchaseReturn') {
  509. $(".SplInvoiceItemRow").each(function () {
  510. if (OrdersettingId == 1 || AutoDc == true) {
  511. if (Number($(this).find(".Quantity").val()) > Number($(this).find('.spn_Avail').text())) {
  512. avlqty = true;
  513. }
  514. }
  515. });
  516. }
  517. if (qty == true) {
  518. MessageHelper.Instance().showError("Item quantity should not be zero.", "bizgaze_CreateBatchErrorMessages");
  519. return false;
  520. }
  521. if (UnitPrice == true) {
  522. MessageHelper.Instance().showError("Unit Price should not be zero.", "bizgaze_CreateBatchErrorMessages");
  523. return false;
  524. }
  525. if (avlqty == true) {
  526. MessageHelper.Instance().showError("Available Quantity is less for an item", 'bizgaze_CreateBatchErrorMessages');
  527. return false;
  528. }
  529. var x = [];
  530. for (var i = 0; i < this.SplitedInvoiceItemList.length; i++) {
  531. if (this.SplitedInvoiceItemList[i].itemId == $("#hf_ItemId").val()) {
  532. x.push(i);
  533. var index = this.DcItemIds.indexOf(this.SplitedInvoiceItemList[i].dcItemId);
  534. if (index > -1)
  535. this.DcItemIds.splice(index, 1);
  536. }
  537. }
  538. for (var i = x.length - 1; i >= 0; i--) {
  539. this.SplitedInvoiceItemList.splice(x[i], 1);
  540. }
  541. var TotalQuantity = 0;
  542. var TotalAmount = 0;
  543. var TotalDisc = 0;
  544. var RowExist = false;
  545. var TaxGroupId = elements.find('.hfProdTax').val();
  546. var Taxgroupname = elements.find('.txtProdTax').val();
  547. var AccountId = elements.find('.hf_Account').val();
  548. var AccountName = elements.find('.txt_AccountName').val();
  549. var instance = this;
  550. $(".SplInvoiceItemRow").each(function () {
  551. var element = $(this);
  552. var BatchId = 0;
  553. var SerialNoId = 0;
  554. var MrpId = 0;
  555. var Name = '';
  556. var Type = "MRP";
  557. if (Type == "MRP") {
  558. MrpId = Number(element.find('.hf_MRP_Id').val());
  559. Name = element.find('.select_' + Type + ' option[value=' + MrpId + ']').text();
  560. }
  561. else if (Type == "BatchNo") {
  562. BatchId = Number(element.find('.select_' + Type + '').val());
  563. MrpId = Number(element.find(".hf_MrpId").val());
  564. Name = element.find('.select_' + Type + ' option[value =' + BatchId + ']').text();
  565. }
  566. else if (Type == "SerialNo") {
  567. SerialNoId = Number(element.find('.select_' + Type + '').val());
  568. MrpId = Number(element.find(".hf_MrpId").val());
  569. Name = element.find('.select_' + Type + ' option[value=' + SerialNoId + ']').text();
  570. }
  571. if (element.find("#hf_" + Type + "_Id").val() != '' && element.find("#hf_" + Type + "_Id").val() != 0) {
  572. RowExist = true;
  573. var discountAmount = 0;
  574. var discountPercent = 0;
  575. 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) {
  576. discountAmount = Number(element.find('.txt_addldiscount').val());
  577. }
  578. else if (element.find(".btn_item_DiscType option:selected").text().trim() == '%' && element.find('.txt_addldiscount').val() != '' && element.find('.txt_addldiscount').val() != undefined) {
  579. discountPercent = Number(element.find('.txt_addldiscount').val());
  580. }
  581. var DiscType = element.find(".btnOrder_DiscType option:selected").text().trim();
  582. instance.SplitedInvoiceItemList.push({
  583. invoiceItemId: element.find(".hf_selectedInvoiceItemId").val(),
  584. orderItemId: element.find(".hf_orderItemId").val(),
  585. itemId: element.find(".hf_selectedItemId").val(),
  586. taxGroupId: TaxGroupId,
  587. taxGroupName: Taxgroupname,
  588. description: element.find("#txt_Item_Description").val(),
  589. priceListId: element.find(".hf_PriceList").val(),
  590. unitPrice: element.find(".Price").val(),
  591. addlDiscountValue: discountAmount,
  592. addlDiscountPercent: discountPercent,
  593. IsTaxInclusive: $('#hfId_IsTaxInclusive').val(),
  594. accountId: AccountId,
  595. accountName: AccountName,
  596. Adjustment: element.find(".hf_RowTotalAdjustment").val(),
  597. TotalAmount: element.find(".hf_RowTotal").val(),
  598. quantity: element.find(".Quantity").val(),
  599. exciseAmount: element.find(".exciseAmount").val(),
  600. refNo: element.find(".hf_refNo").val(),
  601. DiscountGroupId: element.find("#hf_ItemDiscountGroupId").val(),
  602. RefInvoiceItemId: element.find(".hf_refInvoiceItemId").val(),
  603. MrpId: MrpId,
  604. dcItemId: element.find(".hf_dcItemId").val(),
  605. BatchId: BatchId,
  606. SerialId: SerialNoId,
  607. ExchangeItem: element.find('.hf_IsExchangeItem').val(),
  608. taxAdjustment: element.find('.hf_ItemTaxAdjsutmentVal').val(),
  609. assesableAdjustment: element.find('.hf_ItemAssesableAdjustmentVal').val(),
  610. DiscountGroupName: element.find('.hf_ItemDiscountGroupName').val(),
  611. DiscountedAmount: element.find(".hf_DiscountedAmount").val(),
  612. TaxPercent: elements.find(".hfProdTaxPercent").val(),
  613. Name: Name,
  614. DiscType: DiscType,
  615. maxQty: element.find('.hf_maxQty').val()
  616. });
  617. TotalQuantity += Number(element.find(".Quantity").val());
  618. var discount = 0;
  619. var qyt = Number(element.find(".Quantity").val());
  620. var price = Number(element.find(".Price").val());
  621. var excamt = Number(element.find(".exciseAmount").val());
  622. var assesableAdjustment = Number(element.find('.hf_ItemAssesableAdjustmentVal').val());
  623. var ItemAdjustment = Number(element.find(".hf_RowTotalAdjustment").val());
  624. discount = (((qyt * price) + assesableAdjustment + ItemAdjustment - excamt) * Number(discountPercent) / 100) + (Number(qyt) * Number(discountAmount));
  625. discount = Number(discount);
  626. TotalDisc += discount;
  627. if ($("#hfInv_Invoicetype").val() == "Purchase" || $("#hfInv_Invoicetype").val() == "PurchaseReturn" || $("#hfInv_Invoicetype").val() == "DebitNote") {
  628. TotalAmount += Number(element.find(".txt_RowTotalwithAdjustment").val());
  629. }
  630. else {
  631. TotalAmount += Number(element.find(".TotalPrice").text());
  632. }
  633. instance.DcItemIds.push(Number(element.find(".hf_dcItemId").val()));
  634. }
  635. });
  636. var Type = "MRP";
  637. if (RowExist = true)
  638. elements.find('.spn_InvoiceItem').text("View " + Type);
  639. else
  640. elements.find('.spn_InvoiceItem').text("Select " + Type);
  641. elements.find('.prodQuantity').val();
  642. elements.find('.prodQuantity').val(TotalQuantity);
  643. elements.find('#inv_txtdiscount').val();
  644. elements.find('#inv_txtdiscount').val(TotalDisc);
  645. if ($("#hfInv_Invoicetype").val() == "Purchase" || $("#hfInv_Invoicetype").val() == "PurchaseReturn" || $("#hfInv_Invoicetype").val() == "DebitNote") {
  646. elements.find(".txtRowTotalwithAdjustment").val();
  647. elements.find(".txtRowTotalwithAdjustment").val(TotalAmount);
  648. }
  649. else {
  650. elements.find('.prodTotalPrice').text('');
  651. elements.find('.prodTotalPrice').text(TotalAmount);
  652. }
  653. this.navigationHelper.closePopUp();
  654. }
  655. static Instance() {
  656. return new MRPDetails();
  657. }
  658. }
  659. MRPDetails.element = "";
  660. Controls.MRPDetails = MRPDetails;
  661. })(Controls = Forms.Controls || (Forms.Controls = {}));
  662. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  663. })(Unibase || (Unibase = {}));