Beispiel #1
0
        public long MakeSupplyPayment(MultipleSupplies model, AccountTransactionActivity accountActivity, string userId)
        {
            long accountActivityId = 0;
            //long defaultBranchId = 2;
            string supplierId = "";

            if (model.Supplies.Any())
            {
                foreach (var supply in model.Supplies)
                {
                    supplierId = supply.SupplierId;
                    var supplyObject = new SupplyDTO()
                    {
                        SupplyId   = supply.SupplyId,
                        SupplierId = supply.SupplierId,
                        //SupplyNumber = supply.SupplyNumber,
                        Price            = supply.Price,
                        Amount           = supply.Amount,
                        AmountToPay      = supply.AmountToPay,
                        StoreId          = supply.StoreId,
                        BranchId         = supply.BranchId,
                        SupplyDate       = supply.SupplyDate,
                        TruckNumber      = supply.TruckNumber,
                        WeightNoteNumber = supply.WeightNoteNumber,
                        Used             = supply.Used,
                        IsPaid           = true,
                        StatusId         = supply.StatusId,
                        Deleted          = supply.Deleted,
                        MoistureContent  = supply.MoistureContent,
                        BagsOfStones     = supply.BagsOfStones,
                        NormalBags       = supply.NormalBags,
                        Quantity         = supply.Quantity,
                        Offloading       = supply.Offloading,
                    };
                    _dataService.SaveSupply(supplyObject, userId);
                }


                UpdateCreditorRecords(supplierId, accountActivity.Amount, userId);


                var accountActivityObject = new AccountTransactionActivity()
                {
                    AspNetUserId   = accountActivity.AspNetUserId,
                    CasualWorkerId = accountActivity.CasualWorkerId,
                    Amount         = accountActivity.Amount,
                    Notes          = accountActivity.Notes,
                    AccountTransactionActivityId = accountActivity.AccountTransactionActivityId,
                    Action               = accountActivity.Action,
                    BranchId             = accountActivity.BranchId,
                    TransactionSubTypeId = accountActivity.TransactionSubTypeId,
                    SectorId             = accountActivity.SectorId,
                    Deleted              = accountActivity.Deleted,
                    CreatedBy            = accountActivity.CreatedBy,
                    CreatedOn            = accountActivity.CreatedOn
                };
                accountActivityId = _accountTransactionActivityService.SaveAccountTransactionActivity(accountActivityObject, userId);

                if (accountActivity.PaymentModeId == 2)
                {
                    if (accountActivity.BranchId == 0 || accountActivity.BranchId == null)
                    {
                        Cash cash = new Cash()
                        {
                            Amount               = accountActivity.Amount,
                            Notes                = accountActivity.Notes,
                            Action               = accountActivity.Action,
                            BranchId             = Convert.ToInt64(accountActivity.BranchId),
                            TransactionSubTypeId = accountActivity.TransactionSubTypeId,
                            SectorId             = accountActivity.SectorId,
                        };
                        _cashService.SaveApplicationCash(cash, userId);
                    }
                    else
                    {
                        Cash cash = new Cash()
                        {
                            Amount               = accountActivity.Amount,
                            Notes                = accountActivity.Notes,
                            Action               = accountActivity.Action,
                            BranchId             = Convert.ToInt64(accountActivity.BranchId),
                            TransactionSubTypeId = accountActivity.TransactionSubTypeId,
                            SectorId             = accountActivity.SectorId,
                        };
                        _cashService.SaveCash(cash, userId);
                    }
                }
            }
            return(accountActivityId);
        }
        public long PayMultipleSupplies(MultipleSupplies model)
        {
            var Id = _SupplyService.MakeSupplyPayment(model, model.AccountActivity, userId);

            return(Id);
        }