コード例 #1
0
        public IActionResult Index()
        {
            ValidateSession();

            ViewBag.TaxToCall = Enum.GetValues(typeof(Enum_TaxToCall)).Cast <Enum_TaxToCall>();
            var configuration = _configurationLogic.GetSingleById(1);

            _unitTypeLogic    = new Lms_UnitTypeLogic(_cache, new EntityFrameworkGenericRepository <Lms_UnitTypePoco>(_dbContext));
            _weightScaleLogic = new Lms_WeightScaleLogic(_cache, new EntityFrameworkGenericRepository <Lms_WeightScalePoco>(_dbContext));

            ViewBag.UnitTypes    = _unitTypeLogic.GetList();
            ViewBag.WeightScales = _weightScaleLogic.GetList();
            return(View(configuration));
        }
コード例 #2
0
        private int CreateNewAccount(Lms_CustomerPoco customerPoco)
        {
            int newAccountId = 0;

            _configurationLogic  = new Lms_ConfigurationLogic(_cache, new EntityFrameworkGenericRepository <Lms_ConfigurationPoco>(_dbContext));
            _chartOfAccountLogic = new Lms_ChartOfAccountLogic(_cache, new EntityFrameworkGenericRepository <Lms_ChartOfAccountPoco>(_dbContext));

            var parentGLForCustomerAccount = _configurationLogic.GetSingleById(1).ParentGLForCustomerAccount;
            var accounts = _chartOfAccountLogic.GetList().Where(c => c.ParentGLCode == parentGLForCustomerAccount).ToList();

            newAccountId = accounts.Max(c => c.Id) + 1;

            Lms_ChartOfAccountPoco accountPoco = new Lms_ChartOfAccountPoco();

            accountPoco.Id             = newAccountId;
            accountPoco.ParentGLCode   = parentGLForCustomerAccount;
            accountPoco.AccountName    = customerPoco.CustomerName;
            accountPoco.BranchId       = sessionData.BranchId == null ? 1 : (int)sessionData.BranchId;
            accountPoco.CurrentBalance = 0;
            accountPoco.IsActive       = true;
            accountPoco.Remarks        = "Customer Account Receivable";
            accountPoco.CreateDate     = DateTime.Now;
            accountPoco.CreatedBy      = sessionData.UserId;

            var newAcc = _chartOfAccountLogic.Add(accountPoco);

            if (newAcc != null)
            {
                return(newAccountId);
            }
            else
            {
                return(0);
            }
        }
コード例 #3
0
        public IActionResult Add([FromBody] dynamic employeeData)
        {
            ValidateSession();
            var result = "";

            try
            {
                if (employeeData != null)
                {
                    Lms_EmployeePoco employeePoco = JsonConvert.DeserializeObject <Lms_EmployeePoco>(JsonConvert.SerializeObject(employeeData[0]));

                    if (employeePoco.Id < 1 && employeePoco.FirstName.Trim() != string.Empty)
                    {
                        _configurationLogic  = new Lms_ConfigurationLogic(_cache, new EntityFrameworkGenericRepository <Lms_ConfigurationPoco>(_dbContext));
                        _chartOfAccountLogic = new Lms_ChartOfAccountLogic(_cache, new EntityFrameworkGenericRepository <Lms_ChartOfAccountPoco>(_dbContext));

                        var parentGLForEmployeeAccount = _configurationLogic.GetSingleById(1).ParentGLForEmployeeAccount;
                        var accounts      = _chartOfAccountLogic.GetList().Where(c => c.ParentGLCode == parentGLForEmployeeAccount).ToList();
                        var newAccountId  = accounts.Max(c => c.Id) + 1;
                        var newEmployeeId = _employeeLogic.GetMaxId() + 1;

                        using (var scope = new TransactionScope())
                        {
                            Lms_ChartOfAccountPoco accountPoco = new Lms_ChartOfAccountPoco();
                            accountPoco.Id             = newAccountId;
                            accountPoco.ParentGLCode   = parentGLForEmployeeAccount;
                            accountPoco.AccountName    = employeePoco.FirstName + employeePoco.LastName;
                            accountPoco.BranchId       = sessionData.BranchId == null ? 1 : (int)sessionData.BranchId;
                            accountPoco.CurrentBalance = 0;
                            accountPoco.IsActive       = true;
                            accountPoco.Remarks        = "Employee Account Payable";
                            accountPoco.CreateDate     = DateTime.Now;
                            accountPoco.CreatedBy      = sessionData.UserId;

                            var addedAcc = _chartOfAccountLogic.Add(accountPoco);
                            if (addedAcc.Id > 0)
                            {
                                employeePoco.Id         = newEmployeeId;
                                employeePoco.AccountId  = addedAcc.Id;
                                employeePoco.CreateDate = DateTime.Now;
                                employeePoco.CreatedBy  = sessionData.UserId;
                                var employeeId = _employeeLogic.Add(employeePoco).Id;

                                if (employeeId > 0)
                                {
                                    scope.Complete();
                                    result = employeeId.ToString();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(Json(result));
        }
コード例 #4
0
        public IActionResult Add([FromBody] dynamic employeeLoanData)
        {
            ValidateSession();
            var result = "";

            try
            {
                if (employeeLoanData != null)
                {
                    Lms_EmployeeLoanPoco employeeLoanPoco = JsonConvert.DeserializeObject <Lms_EmployeeLoanPoco>(JsonConvert.SerializeObject(employeeLoanData[0]));

                    if (employeeLoanPoco.LoanAmount > 0)
                    {
                        using (var scope = new TransactionScope()) {
                            var _transactionController = new TransactionController(_cache, _dbContext);
                            var _configLogic           = new Lms_ConfigurationLogic(_cache, new EntityFrameworkGenericRepository <Lms_ConfigurationPoco>(_dbContext));
                            var configInfo             = _configLogic.GetSingleById(1);
                            var employeeInfo           = _employeeLogic.GetSingleById(employeeLoanPoco.EmployeeId);

                            List <TransactionModel> debitTransactionModelList = new List <TransactionModel>();
                            TransactionModel        debitTransactionModel     = new TransactionModel();
                            debitTransactionModel.AccountId = employeeInfo.AccountId;
                            debitTransactionModel.TxnAmount = employeeLoanPoco.LoanAmount;
                            debitTransactionModelList.Add(debitTransactionModel);

                            List <TransactionModel> creditTransactionModelList = new List <TransactionModel>();
                            TransactionModel        creditTransactionModel     = new TransactionModel();
                            creditTransactionModel.AccountId = (int)configInfo.LoanIncomeAccount;
                            creditTransactionModel.TxnAmount = employeeLoanPoco.LoanAmount;
                            creditTransactionModelList.Add(creditTransactionModel);

                            var txnId = _transactionController.MakeTransaction(debitTransactionModelList, creditTransactionModelList, employeeLoanPoco.LoanAmount, DateTime.Now, DateTime.Now, employeeLoanPoco.Remarks);

                            employeeLoanPoco.TransactionId = txnId;
                            employeeLoanPoco.CreatedBy     = sessionData.UserId;
                            var loanId = _employeeLoanLogic.Add(employeeLoanPoco);
                            if (!string.IsNullOrEmpty(loanId.ToString()))
                            {
                                result = loanId.ToString();
                                scope.Complete();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(Json(result));
        }
コード例 #5
0
        public IActionResult Index()
        {
            ValidateSession();
            _configurationLogic          = new Lms_ConfigurationLogic(_cache, new EntityFrameworkGenericRepository <Lms_ConfigurationPoco>(_dbContext));
            ViewBag.DefaultFuelSurcharge = _configurationLogic.GetSingleById(1).DefaultFuelSurcharge;

            _cityLogic        = new App_CityLogic(_cache, new EntityFrameworkGenericRepository <App_CityPoco>(_dbContext));
            ViewBag.Cities    = _cityLogic.GetList();
            _provinceLogic    = new App_ProvinceLogic(_cache, new EntityFrameworkGenericRepository <App_ProvincePoco>(_dbContext));
            ViewBag.Provinces = _provinceLogic.GetList();
            _countryLogic     = new App_CountryLogic(_cache, new EntityFrameworkGenericRepository <App_CountryPoco>(_dbContext));
            ViewBag.Countries = _countryLogic.GetList();

            return(View(GetCustomerData(0)));
        }
コード例 #6
0
        public JsonResult GetCustomerById(string id)
        {
            if (!string.IsNullOrEmpty(id))
            {
                var customer = _customerLogic.GetSingleById(Convert.ToInt32(id));

                if (customer != null)
                {
                    if (customer.FuelSurChargePercentage == null || customer.FuelSurChargePercentage <= 0)
                    {
                        _configurationLogic = new Lms_ConfigurationLogic(_cache, new EntityFrameworkGenericRepository <Lms_ConfigurationPoco>(_dbContext));
                        var defaultFuelSurcharge = _configurationLogic.GetSingleById(1).DefaultFuelSurcharge;
                        customer.FuelSurChargePercentage = defaultFuelSurcharge;
                    }
                    return(Json(JsonConvert.SerializeObject(customer)));
                }
            }
            return(Json(string.Empty));
        }
コード例 #7
0
        public IActionResult Add([FromBody] dynamic orderData)
        {
            ValidateSession();
            var result = "";

            try
            {
                if (orderData != null)
                {
                    using (var scope = new TransactionScope())
                    {
                        Lms_OrderPoco orderPoco = JsonConvert.DeserializeObject <Lms_OrderPoco>(JsonConvert.SerializeObject(orderData[0]));
                        _addressLogic = new Lms_AddressLogic(_cache, new EntityFrameworkGenericRepository <Lms_AddressPoco>(_dbContext));
                        var addressList = _addressLogic.GetList();

                        Lms_AddressPoco newAddress = new Lms_AddressPoco();

                        var orderAddressData    = (JObject)orderData[0];
                        var customerId          = orderAddressData.SelectToken("customerId").ToString();
                        var waybillNumber       = orderAddressData.SelectToken("wayBillNumber").ToString();
                        var customerAddressId   = orderAddressData.SelectToken("customerAddressId").ToString();
                        var customerAddressline = orderAddressData.SelectToken("customerAddressline").ToString();
                        var customerUnitNo      = orderAddressData.SelectToken("customerUnitNo").ToString();
                        var customerCityId      = orderAddressData.SelectToken("customerCityId").ToString();
                        var customerProvinceId  = orderAddressData.SelectToken("customerProvinceId").ToString();
                        var customerPostcode    = orderAddressData.SelectToken("customerPostcode").ToString();
                        var orderDate           = orderAddressData.SelectToken("orderDate").ToString();
                        orderPoco.ShipperAddressId  = customerAddressId == "" ? 0 : Convert.ToInt32(customerAddressId);
                        orderPoco.ShipperCustomerId = customerId == "" ? 0 : Convert.ToInt32(customerId);
                        orderPoco.IsInvoiced        = false;
                        orderPoco.CreateDate        = orderDate == "" ? DateTime.Today : Convert.ToDateTime(orderDate);
                        orderPoco.CreatedBy         = sessionData.UserId;
                        orderPoco.OrderTypeId       = 3; //3 for misc. order
                        var newWbNumber = _orderLogic.GetList().OrderByDescending(c => c.WayBillNumber).Take(1).FirstOrDefault().WayBillNumber;
                        if (!(newWbNumber.Length > 0))
                        {
                            newWbNumber = _configurationLogic.GetSingleById(1).DeliveryWBNoStartFrom;
                        }
                        else
                        {
                            newWbNumber = (Convert.ToInt16(newWbNumber) + 1).ToString();
                        }

                        orderPoco.WayBillNumber = newWbNumber;

                        var customerAddressInfo = addressList.Where(c => c.Id == orderPoco.ShipperAddressId).FirstOrDefault();
                        if (customerAddressInfo != null)
                        {
                            customerAddressInfo.UnitNumber = !string.IsNullOrEmpty(customerAddressInfo.UnitNumber) ? Convert.ToString(customerAddressInfo.UnitNumber).Trim().ToUpper() : "";
                            if (customerAddressline.Trim().ToUpper() == customerAddressInfo.AddressLine.Trim().ToUpper() && customerUnitNo.Trim().ToUpper() == customerAddressInfo.UnitNumber && Convert.ToInt16(customerCityId) == customerAddressInfo.CityId)
                            {
                                if (Convert.ToInt16(customerProvinceId) != customerAddressInfo.ProvinceId || customerPostcode != customerAddressInfo.PostCode)
                                {
                                    customerAddressInfo.ProvinceId = Convert.ToInt16(customerProvinceId);
                                    customerAddressInfo.PostCode   = customerPostcode;
                                    _addressLogic.Update(customerAddressInfo);
                                }
                            }
                            else
                            {
                                newAddress                 = new Lms_AddressPoco();
                                newAddress.AddressLine     = customerAddressline;
                                newAddress.UnitNumber      = customerUnitNo;
                                newAddress.CityId          = Convert.ToInt16(customerCityId);
                                newAddress.ProvinceId      = Convert.ToInt16(customerProvinceId);
                                newAddress.CountryId       = 41; // default Canada
                                newAddress.PostCode        = customerPostcode;
                                newAddress.CreatedBy       = sessionData.UserId;
                                orderPoco.ShipperAddressId = _addressLogic.Add(newAddress).Id;
                            }
                        }

                        List <Lms_OrderAdditionalServicePoco> orderAdditionalServices = JsonConvert.DeserializeObject <List <Lms_OrderAdditionalServicePoco> >(JsonConvert.SerializeObject(orderData[1]));
                        _orderAdditionalServiceLogic = new Lms_OrderAdditionalServiceLogic(_cache, new EntityFrameworkGenericRepository <Lms_OrderAdditionalServicePoco>(_dbContext));
                        if (orderPoco.Id < 1 && orderPoco.BillToCustomerId > 0)
                        {
                            var addedOrder = _orderLogic.Add(orderPoco);
                            foreach (var item in orderAdditionalServices)
                            {
                                item.OrderId = addedOrder.Id;
                                var existingRecord = _orderAdditionalServiceLogic.GetList().Where(c => c.OrderId == addedOrder.Id && c.AdditionalServiceId == item.AdditionalServiceId).FirstOrDefault();
                                if (existingRecord == null)
                                {
                                    _orderAdditionalServiceLogic.Add(item);
                                }
                                else
                                {
                                    _orderAdditionalServiceLogic.Remove(existingRecord);
                                    _orderAdditionalServiceLogic.Add(item);
                                }
                            }

                            result = addedOrder.WayBillNumber;
                        }

                        if (result != "")
                        {
                            scope.Complete();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(Json(result));
        }
コード例 #8
0
        public IActionResult Add([FromBody] dynamic customerData)
        {
            ValidateSession();
            var result = "";

            try
            {
                if (customerData != null)
                {
                    Lms_CustomerPoco customerPoco = JsonConvert.DeserializeObject <Lms_CustomerPoco>(JsonConvert.SerializeObject(customerData[0]));

                    CustomerAddressMapping customerAddress = JsonConvert.DeserializeObject <CustomerAddressMapping>(JsonConvert.SerializeObject(customerData[1]));

                    _configurationLogic  = new Lms_ConfigurationLogic(_cache, new EntityFrameworkGenericRepository <Lms_ConfigurationPoco>(_dbContext));
                    _chartOfAccountLogic = new Lms_ChartOfAccountLogic(_cache, new EntityFrameworkGenericRepository <Lms_ChartOfAccountPoco>(_dbContext));

                    var parentGLForCustomerAccount = _configurationLogic.GetSingleById(1).ParentGLForCustomerAccount;
                    var accounts      = _chartOfAccountLogic.GetList().Where(c => c.ParentGLCode == parentGLForCustomerAccount).ToList();
                    var newAccountId  = accounts.Max(c => c.Id) + 1;
                    var newCustomerId = _customerLogic.GetMaxId() + 1;

                    using (var scope = new TransactionScope())
                    {
                        Lms_ChartOfAccountPoco accountPoco = new Lms_ChartOfAccountPoco();
                        accountPoco.Id             = newAccountId;
                        accountPoco.ParentGLCode   = parentGLForCustomerAccount;
                        accountPoco.AccountName    = customerPoco.CustomerName;
                        accountPoco.BranchId       = sessionData.BranchId == null ? 1 : (int)sessionData.BranchId;
                        accountPoco.CurrentBalance = 0;
                        accountPoco.IsActive       = true;
                        accountPoco.Remarks        = "Customer Account Receivable";
                        accountPoco.CreateDate     = DateTime.Now;
                        accountPoco.CreatedBy      = sessionData.UserId;

                        var addedAcc = _chartOfAccountLogic.Add(accountPoco);
                        if (addedAcc.Id > 0)
                        {
                            customerPoco.Id         = newCustomerId;
                            customerPoco.AccountId  = addedAcc.Id;
                            customerPoco.CreateDate = DateTime.Now;
                            customerPoco.CreatedBy  = sessionData.UserId;
                            var customerId = _customerLogic.Add(customerPoco).Id;

                            result = customerId.ToString();
                        }

                        if (customerAddress != null && !string.IsNullOrEmpty(customerAddress.AddressLine))
                        {
                            customerAddress.CustomerId = newCustomerId;
                            customerAddress.IsDefault  = true;
                            _addressLogic = new Lms_AddressLogic(_cache, new EntityFrameworkGenericRepository <Lms_AddressPoco>(_dbContext));
                            var addressList = _addressLogic.GetList();

                            _customerAddressMappingLogic = new Lms_CustomerAddressMappingLogic(_cache, new EntityFrameworkGenericRepository <Lms_CustomerAddressMappingPoco>(_dbContext));
                            var customerAddressList = _customerAddressMappingLogic.GetList().Where(c => c.CustomerId == customerAddress.CustomerId);

                            int addressId       = 0;
                            var existingAddress = addressList.Where(c => c.UnitNumber == customerAddress.UnitNumber && c.AddressLine == customerAddress.AddressLine && c.CityId == customerAddress.CityId).FirstOrDefault();
                            if (existingAddress != null)
                            {
                                existingAddress.ProvinceId         = customerAddress.ProvinceId;
                                existingAddress.CountryId          = customerAddress.CountryId;
                                existingAddress.PostCode           = customerAddress.PostCode;
                                existingAddress.PrimaryPhoneNumber = customerAddress.PrimaryPhoneNumber;
                                existingAddress.Fax               = customerAddress.Fax;
                                existingAddress.EmailAddress1     = customerAddress.EmailAddress1;
                                existingAddress.EmailAddress2     = customerAddress.EmailAddress1;
                                existingAddress.ContactPersonName = customerAddress.ContactPersonName;

                                addressId = _addressLogic.Update(existingAddress).Id;
                            }
                            else
                            {
                                Lms_AddressPoco addressPoco = new Lms_AddressPoco();
                                addressPoco.UnitNumber         = customerAddress.UnitNumber;
                                addressPoco.AddressLine        = customerAddress.AddressLine;
                                addressPoco.CityId             = customerAddress.CityId;
                                addressPoco.ProvinceId         = customerAddress.ProvinceId;
                                addressPoco.CountryId          = customerAddress.CountryId;
                                addressPoco.PostCode           = customerAddress.PostCode;
                                addressPoco.PrimaryPhoneNumber = customerAddress.PrimaryPhoneNumber;
                                addressPoco.Fax               = customerAddress.Fax;
                                addressPoco.EmailAddress1     = customerAddress.EmailAddress1;
                                addressPoco.EmailAddress2     = customerAddress.EmailAddress1;
                                addressPoco.ContactPersonName = customerAddress.ContactPersonName;

                                addressId = _addressLogic.Add(addressPoco).Id;
                            }

                            if (customerAddress.AddressTypeId == 0)
                            {
                                Lms_CustomerAddressMappingPoco customerAddressMappingPoco = new Lms_CustomerAddressMappingPoco();
                                customerAddressMappingPoco.CustomerId    = customerAddress.CustomerId;
                                customerAddressMappingPoco.AddressId     = addressId;
                                customerAddressMappingPoco.AddressTypeId = (byte)Enum_AddressType.Billing;
                                customerAddressMappingPoco.IsDefault     = customerAddress.IsDefault;
                                _customerAddressMappingLogic.Add(customerAddressMappingPoco);

                                customerAddressMappingPoco               = new Lms_CustomerAddressMappingPoco();
                                customerAddressMappingPoco.CustomerId    = customerAddress.CustomerId;
                                customerAddressMappingPoco.AddressId     = addressId;
                                customerAddressMappingPoco.AddressTypeId = (byte)Enum_AddressType.Shipping;
                                customerAddressMappingPoco.IsDefault     = customerAddress.IsDefault;
                                _customerAddressMappingLogic.Add(customerAddressMappingPoco);
                            }
                            else
                            {
                                Lms_CustomerAddressMappingPoco customerAddressMappingPoco = new Lms_CustomerAddressMappingPoco();
                                customerAddressMappingPoco.CustomerId    = customerAddress.CustomerId;
                                customerAddressMappingPoco.AddressId     = addressId;
                                customerAddressMappingPoco.AddressTypeId = customerAddress.AddressTypeId;
                                customerAddressMappingPoco.IsDefault     = customerAddress.IsDefault;
                                _customerAddressMappingLogic.Add(customerAddressMappingPoco);
                            }
                        }

                        scope.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(Json(result));
        }