public async Task <bool> Process(int purchaseOrderId) { PurchaseOrder = await Tenant.PurchaseOrders .WhereId(purchaseOrderId) .IncludeStore() .IncludePurchasePayments() .IncludePurchasedProducts() .SingleOrDefaultAsync(); if (PurchaseOrder == null || PurchaseOrder.Confirmed || PurchaseOrderIsPending()) { return(false); } ProductReplenishment = new ProductReplenishment(Tenant, PurchaseOrder); if (!await ProductReplenishment.Confirm()) { return(false); } PurchaseCost = new PurchaseCost(Tenant, PurchaseOrder); PurchaseCost.Confirm(); PurchaseOrder.ConfirmationDate = DateTime.UtcNow; await Tenant.SaveChangesAsync(); return(true); }
public async Task <bool> Revert(int purchaseOrderId) { PurchaseOrder = await Tenant.PurchaseOrders .WhereId(purchaseOrderId) .IncludeStore() .IncludePurchasedProducts() .IncludePurchaseExpenses() .SingleOrDefaultAsync(); if (PurchaseOrder == null || !PurchaseOrder.Confirmed) { return(false); } ProductReplenishment = new ProductReplenishment(Tenant, PurchaseOrder); if (!await ProductReplenishment.Revert()) { return(false); } PurchaseCost = new PurchaseCost(Tenant, PurchaseOrder); PurchaseCost.Revert(); PurchaseOrder.ConfirmationDate = null; await Tenant.SaveChangesAsync(); return(true); }
public async Task <PaymentResult> MakePayment(StripeTokenViewModel model) { PurchaseCost pc = await _context.PurchaseCosts.Where(p => p.Id == model.purchaseType).SingleOrDefaultAsync(); if (pc == null) { return(new PaymentResult(false, "Purchase type not found.")); } try { await new StripeChargeService().CreateAsync(new StripeChargeCreateOptions() { Amount = (int)Math.Ceiling((pc.Price * 100)), Currency = "gbp", Description = await _practicesService.GetCurrentUserPracticeName() + " bought " + pc.Quantity * model.purchaseQty + " x " + pc.PurchaseType.ToString(), SourceTokenOrExistingSourceId = model.stripeToken }); } catch (StripeException StEx) { return(new PaymentResult(false, StEx.Message)); } return(new PaymentResult(true)); }
// default sorting method // ID -> Cage Number -> Purchase Cost public int CompareTo(IZoo other) { if (other == null) { return(1); // i.e. this is greater than other (null) } int compareValue = 0; // Next determine your logical sort variables for your application // For this application ID could be used as the first sort variable compareValue = ID.CompareTo(other.ID); if (compareValue == 0) { // Nest another sort comparison based on your application needs… // For this application you could use cage number or maybe cost. Choose based // on your needs for the application compareValue = CageNumber.CompareTo(other.CageNumber); if (compareValue == 0) { compareValue = PurchaseCost.CompareTo(other.PurchaseCost); if (compareValue == 0) { compareValue = Name.CompareTo(other.Name); } } } return(compareValue); }
public XElement GenerateAddRq(decimal?TotalValue = null, DateTime?InventoryDate = null) { XElement Add = new XElement(typeof(ItemInventory).Name + "Add"); Add.Add(Name?.ToQBXML(nameof(Name))); Add.Add(BarCode?.ToQBXML(nameof(BarCode))); Add.Add(IsActive.ToQBXML(nameof(IsActive))); Add.Add(ClassRef?.ToQBXML(nameof(ClassRef))); Add.Add(ParentRef?.ToQBXML(nameof(ParentRef))); Add.Add(ManufacturerPartNumber?.ToQBXML(nameof(ManufacturerPartNumber))); Add.Add(UnitOfMeasureSetRef?.ToQBXML(nameof(UnitOfMeasureSetRef))); Add.Add(SalesTaxCodeRef?.ToQBXML(nameof(SalesTaxCodeRef))); Add.Add(SalesDesc?.ToQBXML(nameof(SalesDesc))); Add.Add(SalesPrice?.ToQBXML(nameof(SalesPrice))); Add.Add(IncomeAccountRef?.ToQBXML(nameof(IncomeAccountRef))); Add.Add(PurchaseDesc?.ToQBXML(nameof(PurchaseDesc))); Add.Add(PurchaseCost?.ToQBXML(nameof(PurchaseCost))); Add.Add(COGSAccountRef?.ToQBXML(nameof(COGSAccountRef))); Add.Add(PrefVendorRef?.ToQBXML(nameof(PrefVendorRef))); Add.Add(AssetAccountRef?.ToQBXML(nameof(AssetAccountRef))); Add.Add(ReorderPoint?.ToQBXML(nameof(ReorderPoint))); Add.Add(Max?.ToQBXML(nameof(Max))); Add.Add(QuantityOnHand?.ToQBXML(nameof(QuantityOnHand))); Add.Add(TotalValue?.ToQBXML(nameof(TotalValue))); Add.Add(InventoryDate?.ToQBXML(nameof(InventoryDate))); Add.Add(ExternalGUID?.ToQBXML(nameof(ExternalGUID))); XElement AddRq = new XElement(typeof(ItemInventory).Name + "AddRq", Add); foreach (var value in IncludeRetElement) { AddRq.Add(value.ToQBXML(nameof(IncludeRetElement))); } return(AddRq); }
public async Task AddMessagePurchaseToPractice(int purchaseType, int qty) { var practice = await _context.Practices.Where(prac => prac.SubscriberPractices.Any(sp => sp.SubscriberUserId == _userProvider.GetUserId())).SingleOrDefaultAsync(); PurchaseCost pc = await _context.PurchaseCosts.Where(p => p.Id == purchaseType).SingleOrDefaultAsync(); if (pc != null) { if (practice.MessagePurchases == null) { practice.MessagePurchases = new List <MessagePurchase>(); } practice.MessagePurchases.Add(new MessagePurchase() { NumberPurchased = pc.Quantity * qty, PurchaseType = pc.PurchaseType, DoExpire = false, ExpiryDate = DateTime.Now }); await _context.SaveChangesAsync(); } }
public XElement GenerateModRq(bool?ForceUOMChange = null, bool?ApplyIncomeAccountRefToExistingTxns = null, bool?ApplyCOGSAccountRefToExistingTxns = null) { XElement Mod = new XElement(typeof(ItemInventory).Name + "Mod"); Mod.Add(ListID?.ToQBXML(nameof(ListID))); Mod.Add(EditSequence?.ToQBXML(nameof(EditSequence))); Mod.Add(Name?.ToQBXML(nameof(Name))); Mod.Add(BarCode?.ToQBXML(nameof(BarCode))); Mod.Add(IsActive.ToQBXML(nameof(IsActive))); Mod.Add(ClassRef?.ToQBXML(nameof(ClassRef))); Mod.Add(ParentRef?.ToQBXML(nameof(ParentRef))); Mod.Add(ManufacturerPartNumber?.ToQBXML(nameof(ManufacturerPartNumber))); Mod.Add(UnitOfMeasureSetRef?.ToQBXML(nameof(UnitOfMeasureSetRef))); Mod.Add(ForceUOMChange?.ToQBXML(nameof(ForceUOMChange))); Mod.Add(SalesTaxCodeRef?.ToQBXML(nameof(SalesTaxCodeRef))); Mod.Add(SalesDesc?.ToQBXML(nameof(SalesDesc))); Mod.Add(SalesPrice?.ToQBXML(nameof(SalesPrice))); Mod.Add(IncomeAccountRef?.ToQBXML(nameof(IncomeAccountRef))); Mod.Add(ApplyIncomeAccountRefToExistingTxns?.ToQBXML(nameof(ApplyIncomeAccountRefToExistingTxns))); Mod.Add(PurchaseDesc?.ToQBXML(nameof(PurchaseDesc))); Mod.Add(PurchaseCost?.ToQBXML(nameof(PurchaseCost))); Mod.Add(COGSAccountRef?.ToQBXML(nameof(COGSAccountRef))); Mod.Add(ApplyCOGSAccountRefToExistingTxns?.ToQBXML(nameof(ApplyCOGSAccountRefToExistingTxns))); Mod.Add(PrefVendorRef?.ToQBXML(nameof(PrefVendorRef))); Mod.Add(AssetAccountRef?.ToQBXML(nameof(AssetAccountRef))); Mod.Add(ReorderPoint?.ToQBXML(nameof(ReorderPoint))); Mod.Add(Max?.ToQBXML(nameof(Max))); XElement ModRq = new XElement(typeof(ItemInventory).Name + "ModRq", Mod); foreach (var value in IncludeRetElement) { ModRq.Add(value.ToQBXML(nameof(IncludeRetElement))); } return(ModRq); }
public async void EditProduct() { Value = true; var connection = await apiService.CheckConnection(); if (!connection.IsSuccess) { await Application.Current.MainPage.DisplayAlert( Languages.Warning, Languages.CheckConnection, Languages.Ok); return; } if (string.IsNullOrEmpty(Product.code) || string.IsNullOrEmpty(Product.description)) { Value = true; return; } if (Product.supplier == null || Product.customsDuty == null || Product.measureUnit == null) { Value = true; return; } if(SelectedStatus == null) { await Application.Current.MainPage.DisplayAlert("Warning", "Select Availability", "ok"); return; } var purchaseCost = new PurchaseCost { id = Product.purchaseCost.id, currency = Product.purchaseCost.currency, value = Product.purchaseCost.value }; var currencyStatic = new Currency { id = 2, entity = "ÅLAND ISLANDS", currency = "Euro", alphabeticCode = "EUR", numericCode = "978", minorUnit = "2", withdrawalDate = null, remark = null }; var packagingCost = new PackagingCost { id = Product.packagingCost.id, currency = currencyStatic, value = Product.packagingCost.value }; var product = new Product { id = Product.id, code = Product.code, availability = SelectedStatus.Key, description = Product.description, purchaseCost = purchaseCost, packagingCost = packagingCost, updateCostDate = Product.updateCostDate, costChange = Product.costChange, quantityPerPackage = 1, active = Product.active, fob = Product.fob, supplier = Product.supplier, packagingMethod = Product.packagingMethod, measureUnit = Product.measureUnit, composed = Product.composed, component = Product.component, importVolume = Product.importVolume, importQuantity = Product.importQuantity, customsDuty = Product.customsDuty, note = Product.note, width = Product.width, height = Product.height, length = Product.length, cartonVolume = 1, useCarton = Product.useCarton }; var eubasiccost = new PackagingCost { currency = currencyStatic, value = Product.purchaseCost.value }; var euddpcost = new PackagingCost { currency = currencyStatic, value = Product.purchaseCost.value }; var productJson = new ProductJson { // prices = [], product = product, username = "******", eubasicpcost = eubasiccost, euddpcost = euddpcost, //piecesPerContainer = 30 }; var response = await apiService.PutProduct<Product>( "https://app.smart-path.it", "/md-core", "/medial/product", productJson); /* if (!response.IsSuccess) { await Application.Current.MainPage.DisplayAlert("Error", response.Message, "ok"); return; }*/ Value = false; //ProductsViewModel.GetInstance().Update(productJson); MessagingCenter.Send((App)Application.Current, "OnSaved"); DependencyService.Get<INotification>().CreateNotification("Medial", "Product Updated"); await Navigation.PopAsync(); }