private static void BuildPages() { ApplyLeave = new ApplyLeave(); C1MarginReport = new C1MarginReport(); CustomerBalanceAgeingAnalysis = new CustomerBalanceAgeingAnalysis(); ConvertPurchaseRequestToOrder = new ConvertPurchaseRequestToOrder(); CreateExpenseInvoice = new CreateExpenseInvoice(); CreateVoucher = new CreateVoucher(); CreatePurchaseRequest = new CreatePurchaseRequest(); EditExpenseInvoice = new EditExpenseInvoice(); EditPurchaseOrder = new EditPurchaseOrder(); EditPurchaseRequest = new EditPurchaseRequest(); EditVoucher = new EditVoucher(); ExpenseInvoiceTaxCalculationSummary = new ExpenseInvoiceTaxCalculationSummary(); Login = new Login(); ManageRequest = new ManageRequest(); PRAdditionalDetails = new PRAdditionalDetails(); SelectPurchaseOrder = new SelectPurchaseOrder(); SelfServiceHome = new SelfServiceHome(); SpecifyPOPRCoverage = new SpecifyPOPRCoverage(); SpecifyTermsAndCondition = new SpecifyTermsAndCondition(); SpecifyScheduleAndDistribution = new SpecifyScheduleAndDistribution(); TaxCalculationSummary = new TaxCalculationSummary(); ViewPurchaseOrder = new ViewPurchaseOrder(); ViewPurchaseRequest = new ViewPurchaseRequest(); }
protected async override Task OnInitializedAsync() { Vendors = await VendorService.GetAllVendorsAsync(); if (IsEdit) { Purchase = await PurchaseService.GetOnePurchaseAsync((Guid)Id); CreatePurchase = new CreatePurchaseRequest() { Id = Purchase.Id, VendorId = Purchase.VendorId, Date = Purchase.Date, ReferenceNumber = Purchase.ReferenceNumber }; } else { CreatePurchase = new CreatePurchaseRequest { Id = (Guid)Id, Date = DateTime.Today }; } }
public async Task <IActionResult> CreatePurchase([FromBody] CreatePurchaseRequest request) { var supplierFilter = Builders <Supplier> .Filter.Where(x => x.Id.Equals(request.SupplierId)); var validSupplier = await _mongoDbService.GetCollection <Supplier>(Collections.Suppliers) .Find(supplierFilter).AnyAsync(); if (!validSupplier) { throw new CustomException("Invalid supplier specified."); } var productFilter = Builders <Product> .Filter.In(x => x.Id, request.Details.Select(d => d.ProductId)); var products = await _mongoDbService.GetCollection <Product>(Collections.Products) .Find(productFilter).ToListAsync(); var validProducts = request.Details .All(d => products.Any(p => p.Id.Equals(d.ProductId))); if (!validProducts) { throw new CustomException("Invalid products specified."); } var session = await _mongoDbService.StartTransactionAsync(); var newPurchase = new Purchase() { SupplierId = request.SupplierId, ReceiptType = request.ReceiptType.Trim().ToLowerInvariant(), Tax = request.Tax, Total = Math.Round(request.Details.Sum(d => d.Quantity * d.UnitPrice) * (1 + (request.Tax / 100)), 2), Date = DateTime.Now, Approved = true, Details = request.Details.Select(d => new PurchaseDetail() { ProductId = d.ProductId, Quantity = d.Quantity, UnitPrice = d.UnitPrice }) .ToList() }; await _mongoDbService.GetCollection <Purchase>(Collections.Purchases).InsertOneAsync(session, newPurchase); await request.Details.ForEachAsync(async item => { var productFilter = Builders <Product> .Filter.Where(p => p.Id.Equals(item.ProductId)); var stockUpdateDefinition = new UpdateDefinitionBuilder <Product>() .Inc(x => x.Stock, item.Quantity); await _mongoDbService.GetCollection <Product>(Collections.Products) .UpdateOneAsync(session, productFilter, stockUpdateDefinition); }); await _mongoDbService.CommitTransactionAsync(); return(new SuccessResult()); }
public void correctPurchaseReturnTrue() { CreatePurchaseRequest purchase = new CreatePurchaseRequest() { name = "some name", cost = 1337, purchaseTime = new DateTime(2011, 11, 11, 11, 11, 11) }; var result = _pController.correctPurchase(purchase); Assert.True(result); }
public void correctPurchaseReturnFalseWhileCostIsNull() { CreatePurchaseRequest purchase = new CreatePurchaseRequest() { name = "some name", cost = 0, purchaseTime = new DateTime(2011, 11, 11, 11, 11, 11) }; var result = _pController.correctPurchase(purchase); Assert.False(result); }
public async Task UpdatePurchaseAsync(CreatePurchaseRequest CreatePurchase) { var UpdatePurchase = new UpdatePurchaseRequest { Id = CreatePurchase.Id, VendorId = CreatePurchase.VendorId, Date = CreatePurchase.Date, ReferenceNumber = CreatePurchase.ReferenceNumber }; await PurchaseService.UpdatePurchaseAsync(UpdatePurchase); await ModalInstance.CloseAsync(); }
public JsonResult addPurchase(int userId, [FromBody] CreatePurchaseRequest purchase) { if (!userExists(userId)) { Response.StatusCode = (int)HttpStatusCode.NotFound; return(Json(NotFound("User was not found"))); } if (!correctPurchase(purchase)) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(ValidationProblem())); } var newPurchase = new Purchase(userId, purchase.purchaseTime, purchase.name, purchase.cost); _purchaseDAO.addPurchase(newPurchase); Response.StatusCode = (int)HttpStatusCode.Created; return(Json(Created($"api/users/{userId}", newPurchase))); }
public bool correctPurchase(CreatePurchaseRequest purchase) { return(purchase.cost != 0 && purchase.name != null); }
public async Task AddNewPurchaseAsync(CreatePurchaseRequest Purchase) { var PurchaseJson = new StringContent(JsonSerializer.Serialize(Purchase), Encoding.UTF8, "application/json"); await HttpClient.PostAsync($"purchases", PurchaseJson); }
public async Task AddPurchaseAsync(CreatePurchaseRequest CreatePurchase) { await PurchaseService.AddNewPurchaseAsync(CreatePurchase); await ModalInstance.CloseAsync(); }
public CreatePurchaseResponse CreatePurchase(CreatePurchaseRequest request, IRequestOptions options = null) { return WebClient.Send(request, options); }
public CreatePurchaseResponse CreatePurchase(CreatePurchaseRequest request, IRequestOptions options = null) { return(WebClient.Send(request, options)); }