private async void SavePurchaseItem() { IRestDataMapper mapper = containerExtension.Resolve <IRestDataMapper>(); CurrentPurchaseItem.recordState = ConstValues.RCS_FINE; CurrentPurchaseItem.purchaseType = GetPurchaseType(); decimal rq = (CurrentPurchaseItem.reorderLevel * SelectedUom.baseRatioToPurchase * SelectedUom.purchaseQuantifyValue); PurchaseItem pi = PurchaseItems.Where(i => i.item.id == SelectedItem.id).FirstOrDefault(); if (pi != null) { SelectedStore.reorderLevel += rq; CurrentPurchaseItem.reorderLevel = rq; CurrentPurchaseItem = CurrentPurchaseItem.Merge(pi); _ = await PurchaseRestService.UpdatePurchaseItemAsync(mapper, CurrentPurchaseItem); _ = await ItemRestService.UpdateStoreInforAsync(mapper, SelectedStore); PurchaseItem np = CurrentPurchaseItem.CloneObject(); PurchaseItems.Remove(pi); PurchaseItems.Add(np); SelectedStore = null; SelectedUom = null; SelectedItem = null; SelectedItmCt = null; CurrentPurchaseItem = null; } else { CurrentPurchaseItem.reorderLevel = rq; SelectedStore.reorderLevel = rq; CurrentPurchaseItem = await PurchaseRestService.CreatePurchaseItemAsync(mapper, CurrentPurchaseItem); if (CurrentPurchaseItem.id > 0) { _ = await ItemRestService.UpdateStoreInforAsync(mapper, SelectedStore); PurchaseItems.Add(CurrentPurchaseItem.CloneObject()); SelectedStore = null; SelectedUom = null; SelectedItem = null; SelectedItmCt = null; CurrentPurchaseItem = null; } else { _ = ShowMessageDialg("Saving Purchase Item", "Can't Savae Purchase Item, found Some problems.", MsgDialogType.error); } } CurrenPurchase.CalaculatePurchase(PurchaseItems); _ = await PurchaseRestService.UpdatePurchaseAsync(mapper, CurrenPurchase); }
private async void EndPurchase() { IRestDataMapper mapper = containerExtension.Resolve <IRestDataMapper>(); CurrenPurchase.recordState = ConstValues.RCS_FINE; _ = await PurchaseRestService.UpdatePurchaseAsync(mapper, CurrenPurchase); if (CurrenPurchase.creditAmount > 0.00m) { CurrenPurchase.invoiceType = ConstValues.INVT_CREDIT; CreditInvoice = CreditInvoice.CreateNewCreditInvoice(branch, loggedUser.LoggedUser, CurrenPurchase); SelectedSupplier.supplierCreditAccount.totalCredit += CurrenPurchase.creditAmount; _ = await SupplierCreditRestService.updateSupplierCreditAccountAsync(mapper, SelectedSupplier.supplierCreditAccount); _ = await SupplierCreditRestService.CreateSupplierCreditInvoiceAsync(mapper, CreditInvoice); } if (CurrenPurchase.payAmount > 0.00m) { CurrenCashBook = CurrenCashBook.CreateNewCashBook(branch, loggedUser.LoggedUser, CurrenPurchase); CurrenCashBook.branchAccount = SelectedBac; _ = await FinancialRestService.CreateCashBookAsync(mapper, CurrenCashBook); } if (CurrenPurchase.chqAmount > 0.00m) { CurrenChqueBook = CurrenChqueBook.CreateNewChequeBook(branch, loggedUser.LoggedUser, CurrenPurchase); CurrenChqueBook.branchAccount = SelectedBac; _ = await FinancialRestService.CreateChequeBookAsync(mapper, CurrenChqueBook); } SelectedStore = null; SelectedUom = null; SelectedItem = null; SelectedItmCt = null; CurrentPurchaseItem = null; CurrenPurchase = null; SelectedSupCt = null; SelectedSupplier = null; CreditInvoice = null; CurrenCashBook = null; CurrenChqueBook = null; PurchaseItems.Clear(); Initialize(); }