Exemple #1
0
        public async Task <bool> Revert(int saleOrderId)
        {
            SaleOrder = await Tenant.SaleOrders
                        .WhereId(saleOrderId)
                        .IncludeStore()
                        .IncludeSaleProducts()
                        .IncludeSaleIncomes()
                        .SingleOrDefaultAsync();

            if (SaleOrder == null || !SaleOrder.Confirmed)
            {
                return(false);
            }

            ProductConsumption = new ProductConsumption(Tenant, SaleOrder);
            await ProductConsumption.Revert();

            Billing = new SaleBilling(Tenant, SaleOrder);
            Billing.Revert();

            SaleOrder.ConfirmationDate = null;

            await Tenant.SaveChangesAsync();

            return(true);
        }
Exemple #2
0
        public async Task <bool> Process(int saleOrderId)
        {
            SaleOrder = await Tenant.SaleOrders
                        .WhereId(saleOrderId)
                        .IncludeStore()
                        .IncludeSaleProducts()
                        .IncludePaymentMethodsAndFees()
                        .SingleOrDefaultAsync();

            if (SaleOrder == null || SaleOrder.Confirmed || SaleOrderIsPending())
            {
                return(false);
            }

            ProductConsumption = new ProductConsumption(Tenant, SaleOrder);
            if (!await ProductConsumption.Confirm())
            {
                return(false);
            }

            Billing = new SaleBilling(Tenant, SaleOrder);
            Billing.Confirm();

            SaleOrder.ConfirmationDate = DateTime.UtcNow;

            await Tenant.SaveChangesAsync();

            return(true);
        }