Esempio n. 1
0
 public StockBookingCommand(IInventoryDatabaseService database,
                            ILogger <StockBookingCommand> logger,
                            ISalesOrderQuery saleOrderQuery,
                            IStockBookingQuery query)
 {
     _database           = database;
     _customerOrderQuery = saleOrderQuery;
     _logger             = logger;
     _stockQuery         = query;
 }
Esempio n. 2
0
 public InvoicesController(IInvoicesCommand command,
                           IInvoicesQuery query,
                           IInvoiceFactory factory,
                           ISalesOrderQuery customerOrderQuery,
                           ILogger <InvoicesController> logger)
 {
     _command            = command;
     _query              = query;
     _factory            = factory;
     _customerOrderQuery = customerOrderQuery;
     _logger             = logger;
 }
Esempio n. 3
0
 public SalesOrderController(ISalesOrderFactory factory,
                             ISalesOrderQuery query,
                             ISalesOrderCommand command,
                             ILogger <SalesOrderController> logger,
                             ICustomersQuery customerQuery,
                             IEmployeesQuery employeeQuery,
                             ISalesOrderReportQuery salesReportQuery)
 {
     _factory          = factory;
     _command          = command;
     _query            = query;
     _customerQuery    = customerQuery;
     _employeeQuery    = employeeQuery;
     _salesReportQuery = salesReportQuery;
 }
 public CustomerOrderBookingController(IStockBookingQuery bookingQuery,
                                       ILogger <CustomerOrderBookingController> logger,
                                       IWorkOrder workOrderController,
                                       IStockBookingCommand command,
                                       ISalesOrderQuery saleOrderQuery,
                                       IWorkOrdersFactory workOrderFactory,
                                       IStockBookingFactory factory)
 {
     _logger              = logger;
     _bookingQuery        = bookingQuery;
     _salesOrderQuery     = saleOrderQuery;
     _bookingCommand      = command;
     _bookingFactory      = factory;
     _workOrderController = workOrderController;
     _workOrderFactory    = workOrderFactory;
 }
        public WorkOrdersController(IWorkOrdersCommand commands,
                                    IWorkOrdersFactory factory,
                                    IWorkOrdersQuery query,
                                    IResponseFormatFactory resposeFactory,
                                    IEmployeesQuery employeeQuery,
                                    ILogger <WorkOrdersController> logger,
                                    ISalesOrderQuery salesQuery)
        {
            _command    = commands;
            _query      = query;
            _factory    = factory;
            _response   = resposeFactory;
            _salesQuery = salesQuery;
            _logger     = logger;

            _employeeQuery = employeeQuery;
        }
        public SalesOrder Populate(string salesOrderNumber)
        {
            IMsgSetRequest requestMsgSet = _MySessionManager.CreateMsgSetRequest("US", 13, 0);

            ISalesOrderQuery soQuery = requestMsgSet.AppendSalesOrderQueryRq();

            soQuery.ORTxnNoAccountQuery.RefNumberList.Add(salesOrderNumber);

            soQuery.IncludeLineItems.SetValue(true);

            IMsgSetResponse responseMsgSet = _MySessionManager.DoRequests(requestMsgSet);

            IResponseList rsList = responseMsgSet.ResponseList;

            IResponse response = rsList.GetAt(0);

            ISalesOrderRetList SalesOrderList = (ISalesOrderRetList)response.Detail;

            if (SalesOrderList == null)
            {
                throw new Exception("Sales order not found.");
            }

            try
            {
                ISalesOrderRet QBSalesOrder = SalesOrderList.GetAt(0);

                _salesOrder          = new SalesOrder();
                _salesOrder.Number   = QBSalesOrder.RefNumber.GetValue();
                _salesOrder.Date     = QBSalesOrder.TxnDate.GetValue();
                _salesOrder.ShipDate = QBSalesOrder.ShipDate.GetValue();
                _salesOrder.Total    = QBSalesOrder.TotalAmount.GetAsString();

                _salesOrder.CustomerFullName = QBSalesOrder.CustomerRef.FullName.GetValue();

                Address address = new Address();
                _salesOrder.BillingAddress  = address.getAddress(QBSalesOrder.BillAddress);
                _salesOrder.ShippingAddress = address.getAddress(QBSalesOrder.ShipAddress);

                IORSalesOrderLineRetList SalesOrderItems = QBSalesOrder.ORSalesOrderLineRetList;

                if (SalesOrderItems != null)
                {
                    for (int i = 0; i <= SalesOrderItems.Count - 1; i++)
                    {
                        IORSalesOrderLineRet SalesOrderItem = SalesOrderItems.GetAt(i);

                        if (SalesOrderItem.ortype == ENORSalesOrderLineRet.orsolrSalesOrderLineRet)
                        {
                            InventoryItem inventoryItem = new InventoryItem();

                            inventoryItem.ItemCode = SalesOrderItem.SalesOrderLineRet.ItemRef.FullName.GetValue();

                            inventoryItem.Description = SalesOrderItem.SalesOrderLineRet.Desc.GetValue();

                            if (SalesOrderItem.SalesOrderLineRet.Quantity != null)
                            {
                                _salesOrder.TotalQty  += SalesOrderItem.SalesOrderLineRet.Quantity.GetValue();
                                inventoryItem.Quantity = SalesOrderItem.SalesOrderLineRet.Quantity.GetAsString();
                            }
                            else
                            {
                                inventoryItem.Quantity = "";
                            }

                            inventoryItem.Price  = SalesOrderItem.SalesOrderLineRet.ORRate.Rate.GetValue();
                            inventoryItem.Amount = SalesOrderItem.SalesOrderLineRet.Amount.GetAsString();
                            _salesOrder.InventoryItems.Add(inventoryItem);
                        }
                    }

                    //Update the items UPC and List in the sales order from itemsWithUPC list
                    //The reason is that the salesOrder items don't have these properties
                    //So we make another request to QB to get items with all properties
                    InventoryHelper inventoryHelper = new InventoryHelper(_MySessionManager);
                    _salesOrder.InventoryItems = inventoryHelper.UpdateItemUPCAndListID(_salesOrder.InventoryItems);
                }

                return(_salesOrder);
            }
            catch (Exception)
            {
                throw new Exception("Failed to read Sales Order from QuickBooks.");
            }
        }
 public StockBookingController(IStockBookingQuery bookingQuery,
                               ISalesOrderQuery customerOrderQuery)
 {
     _bookingQuery       = bookingQuery;
     _customerOrderQuery = customerOrderQuery;
 }