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);
        }
        public async Task <bool> ProcessDelivery(int rentContractId)
        {
            RentContract = await Tenant.RentContracts
                           .WhereId(rentContractId)
                           .IncludeStore()
                           .IncludeRentedProducts()
                           .IncludePaymentMethodsAndFees()
                           .SingleOrDefaultAsync();

            if (RentContract == null || RentContract.Confirmed || RentContractIsPending())
            {
                return(false);
            }

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

            Billing = new RentBilling(Tenant, RentContract);
            Billing.Confirm();

            RentContract.ConfirmationDate = DateTime.UtcNow;

            await Tenant.SaveChangesAsync();

            return(true);
        }
Exemple #3
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);
        }
        public async Task <bool> Revert(int rentContractId)
        {
            RentContract = await Tenant.RentContracts
                           .WhereId(rentContractId)
                           .IncludeStore()
                           .IncludeRentedProducts()
                           .IncludeRentIncomes()
                           .SingleOrDefaultAsync();

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

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

            ProductReplenishment = new ProductReplenishment(Tenant, RentContract);
            if (!await ProductReplenishment.Revert())
            {
                return(false);
            }

            Billing = new RentBilling(Tenant, RentContract);
            Billing.Revert();

            RentContract.ConfirmationDate = null;
            RentContract.DateOfReturn     = null;

            await Tenant.SaveChangesAsync();

            return(true);
        }