public void InvoiceBuilderTest() { Staff saleRep = new Staff("QAD0001", "Shuayb", JobRole.Sale); Order order = Setup(); InvoiceBuilder iBuild = new InvoiceBuilder(); iBuild.Order = order; iBuild.Staff = saleRep; Sale sInvoice = iBuild.Prepare() as Sale; Assert.Fail(); }
/// <summary> /// Process the payment and produces a tax invoice /// </summary> public string CreatePayment(CreditCard card) { if (_customer == null || _sInvoice == null) { return("Need to declare payment parameters!"); } string lResult = ""; PaymentProcessor pProcessor = new PaymentProcessor(); lResult = pProcessor.SetPaymentDetail(card); if (lResult != "VALID") { return("Payment details are not vaild."); } string paymentId = pProcessor.Pay(_sInvoice.TotalCost); if (paymentId == "ERROR") { return("An error occoured with the payment system. Unknown!."); } InvoiceBuilder iBuild = new InvoiceBuilder(); iBuild.Invoice = InvoiceType.Tax; iBuild.SaleInvoice = _sInvoice; iBuild.Customer = _customer; iBuild.PaymentId = paymentId; _tInvoice = iBuild.Prepare() as Tax; UpdateVehicleInventoryState(); string msg = _manager["Invoice"].Update(_tInvoice); if (msg != "Successfully updated.") { return(msg); } return("Payment Success."); }
public string CreateSale(PriceRate discount) { if (_vehicle == null || _compatibleAddons == null || _selectedAddons == null) { return("Missing key sales details"); } OrderBuilder oBuild = new OrderBuilder(); oBuild.Add(_vehicle, VehicleType.New); oBuild.Add(_tradeIn, VehicleType.Trade); oBuild.SetDiscount(discount); oBuild.Add(_selectedAddons, _compatibleAddons); Order orders = oBuild.Prepare(); InvoiceBuilder iBuild = new InvoiceBuilder(); iBuild.Staff = _saleRep; iBuild.Order = orders; _sInvoice = iBuild.Prepare() as Sale; return(_manager["Invoice"].Add(_sInvoice)); }