Ejemplo n.º 1
0
        public async Task SetAllProductToVatType(int vatTypeId)
        {
            var products = await productRepositoy.All().ToListAsync();

            foreach (var product in products)
            {
                product.VatTypeId = vatTypeId;
                productRepositoy.Update(product);
            }
            await productRepositoy.SaveChangesAsync();
        }
Ejemplo n.º 2
0
        public async Task Edit(EmployeeDto employeeDto, int companyId)
        {
            var employee = employeeRepository.All().Where(e => e.Id == employeeDto.Id).FirstOrDefault();

            if (employeeDto.Id != 0 && employee != null)
            {
                if (employeeDto.IsActive == true)
                {
                    SetAllNonActive(companyId);
                }

                employee.FullName = employeeDto.FullName;
                employee.IsActive = employeeDto.IsActive;

                employeeRepository.Update(employee);
                await employeeRepository.SaveChangesAsync();
            }
        }
Ejemplo n.º 3
0
        public async Task Edit(QuantityTypeDto quantityTypeDto)
        {
            var quantityType = quantityTypeRepository.All().Where(e => e.Id == quantityTypeDto.Id).FirstOrDefault();

            if (quantityTypeDto.Id != 0 && quantityType != null)
            {
                if (quantityTypeDto.IsActive == true)
                {
                    SetAllNonActive();
                }

                quantityType.Type        = quantityTypeDto.Type;
                quantityType.Description = quantityTypeDto.Description;
                quantityType.IsActive    = quantityTypeDto.IsActive;

                quantityTypeRepository.Update(quantityType);
                await quantityTypeRepository.SaveChangesAsync();
            }
        }
Ejemplo n.º 4
0
        public async Task Edit(VatTypeDto vatTypeDto)
        {
            var vatType = await vatTypeRepository.All().Where(vt => vt.Id == vatTypeDto.Id).FirstOrDefaultAsync();

            if (vatTypeDto.Id != 0 && vatType != null)
            {
                if (vatTypeDto.IsActive == true)
                {
                    SetAllNonActive();
                }

                vatType.Name        = vatTypeDto.Name;
                vatType.Description = vatTypeDto.Description;
                vatType.Percantage  = vatTypeDto.Percantage;
                vatType.IsActive    = vatTypeDto.IsActive;

                vatTypeRepository.Update(vatType);
                await vatTypeRepository.SaveChangesAsync();
            }
        }
Ejemplo n.º 5
0
        public async Task Edit(PaymentTypeDto paymentTypeDto)
        {
            var paymentType = paymentTypeRepository.All().Where(e => e.Id == paymentTypeDto.Id).FirstOrDefault();

            if (paymentTypeDto.Id != 0 && paymentType != null)
            {
                if (paymentTypeDto.IsActiv == true)
                {
                    SetAllNonActive();
                }

                paymentType.Name               = paymentTypeDto.Name;
                paymentType.Description        = paymentTypeDto.Description;
                paymentType.IsActiv            = paymentTypeDto.IsActiv;
                paymentType.RequireBankAccount = paymentTypeDto.RequiredBankAccount;

                paymentTypeRepository.Update(paymentType);
                await paymentTypeRepository.SaveChangesAsync();
            }
        }
Ejemplo n.º 6
0
        public async Task <NonVatDocumentDto> EditNonVatDocumentAsync(NonVatDocumentDto nonVatDocumentDto)
        {
            var document = await NonVatDocumentRepo.GetByIdAsync(nonVatDocumentDto.Id);

            if (document is null)
            {
                nonVatDocumentDto.ErrorMassages.Add($"Грешка, не съществува документ с №{nonVatDocumentDto.Id}!");
                return(nonVatDocumentDto);
            }
            if (nonVatDocumentDto.PartnerId == 0)
            {
                nonVatDocumentDto.ErrorMassages.Add($"Моля въведете контрагент!");
                return(nonVatDocumentDto);
            }

            var companyId = await NonVatDocumentRepo.Context.Companies.OrderBy(c => c.Id).Select(c => c.Id).LastAsync();

            document.CompanyObjectId = await NonVatDocumentRepo.Context.CompanyObjects
                                       .Where(o => o.GUID == userCompanyTemp.CompanyObjectGUID)
                                       .Select(o => o.Id)
                                       .FirstOrDefaultAsync();

            document.PartnerId        = nonVatDocumentDto.PartnerId;
            document.CompanyId        = companyId;
            document.WriterEmployeeId = await employeeService.GetOrSetEmployeeIdByNameAsync(nonVatDocumentDto.WriterEmployee);

            document.RecipientEmployeeId = await partnerEmployeeService.GetOrSetEmployeeIdByNameAsync(nonVatDocumentDto.RecipientEmployee, nonVatDocumentDto.PartnerId);

            document.CreatedDate   = SetDate(nonVatDocumentDto.CreatedDate, nonVatDocumentDto);
            document.VatReasonDate = SetDate(nonVatDocumentDto.VatReasonDate, nonVatDocumentDto);
            document.PaymentTypeId = nonVatDocumentDto.PaymentTypeId;
            document.BankAccountId = await GetBankAccountIdIfRequare(nonVatDocumentDto);

            document.Type        = (Data.CompanyData.Models.Enums.NonVatDocumentTypes)nonVatDocumentDto.Type;
            document.FreeText    = nonVatDocumentDto.FreeText;
            document.Description = nonVatDocumentDto.Description;

            await ProcessingEditSales(nonVatDocumentDto);

            document.SubTottal = nonVatDocumentDto.SubTottal;
            document.Vat       = nonVatDocumentDto.Vat;
            document.Tottal    = nonVatDocumentDto.Tottal;

            if (nonVatDocumentDto.HasErrors)
            {
                return(nonVatDocumentDto);
            }
            NonVatDocumentRepo.Update(document);
            await NonVatDocumentRepo.SaveChangesAsync();

            return(nonVatDocumentDto);
        }
Ejemplo n.º 7
0
        public async Task Edit(BankAccountDto bankAccountDto)
        {
            var bankAccount = bankAccountRepository.All().Where(bo => bo.Id == bankAccountDto.Id).FirstOrDefault();

            if (bankAccountDto.Id != 0 && bankAccount != null)
            {
                if (bankAccountDto.IsActive == true)
                {
                    await SetAllNonActive();
                }

                bankAccount.Name        = bankAccountDto.Name;
                bankAccount.BankName    = bankAccountDto.BankName;
                bankAccount.BIC         = bankAccount.BIC;
                bankAccount.IBAN        = bankAccountDto.IBAN;
                bankAccount.Description = bankAccountDto.Description;
                bankAccount.IsActive    = bankAccountDto.IsActive;

                bankAccountRepository.Update(bankAccount);
                await bankAccountRepository.SaveChangesAsync();
            }
        }
Ejemplo n.º 8
0
        public async Task Edit(PartnerDto partnerDto)
        {
            if (partnerDto.Id != 0)
            {
                var partner = await partnerRepository.GetByIdAsync(partnerDto.Id);

                partner.Name            = partnerDto.Name;
                partner.Country         = partnerDto.Country;
                partner.City            = partnerDto.City;
                partner.Address         = partnerDto.Address;
                partner.EIK             = partnerDto.EIK;
                partner.IsVatRegistered = partnerDto.IsVatRegistered;
                partner.VatId           = partnerDto.VatId;
                partner.Email           = partnerDto.Email;
                partner.IsActive        = partnerDto.IsActive;
                partner.MOL             = partnerDto.MOL;


                partnerRepository.Update(partner);
                await partnerRepository.SaveChangesAsync();
            }
        }