/// <summary>
        /// Subscribe supplier with a company
        /// </summary>
        /// <param name="supplierId">Supplier Identifier</param>
        /// <param name="companyId">Company Identifier</param>
        public virtual void Subscribe(int supplierId, int companyId)
        {
            // if relationship already exists, activate it and exit
            var supplierSubscription = GetSupplierSubscription(supplierId, companyId);

            if (supplierSubscription != null)
            {
                if (supplierSubscription.IsActive)
                {
                    throw new ArgumentException("Subscription already exists.");
                }
                supplierSubscription.IsActive = true;
                _repository.Save();
                return;
            }

            var company = _repository.GetById <Company>(companyId, c => c.ChartOfAccounts);

            if (company == null)
            {
                throw new ArgumentException("Company does not exist.");
            }

            var supplier = _repository.GetById <Supplier>(supplierId);

            if (supplier == null)
            {
                throw new ArgumentException("Supplier does not exist.");
            }

            var ledgerAccount = new LedgerAccount
            {
                AccountNumber     = _ledgerAccountService.GenerateNewAccountNumber(LedgerAccountGroup.AccountsPayable),
                Name              = $"{company.Name} - {supplier.Name} Accounts Payable",
                Description       = $"Amounts owed to {supplier.Name}",
                ChartOfAccountsId = company.ChartOfAccounts.Id,
                IsHidden          = true,
                IsDefault         = true,
                Type              = LedgerAccountType.Liability,
                Group             = LedgerAccountGroup.AccountsPayable
            };

            supplierSubscription = new SupplierSubscription
            {
                CompanyId     = companyId,
                SupplierId    = supplierId,
                LedgerAccount = ledgerAccount
            };

            _repository.Create(supplierSubscription);
            _repository.Save();
        }
        public void Can_create_supplierSubscription()
        {
            var supplierSubscription = new SupplierSubscription
            {
                Id              = 1,
                CompanyId       = 1,
                SupplierId      = 1,
                LedgerAccountId = 1
            };

            Assert.Equal(1, supplierSubscription.CompanyId);
            Assert.Equal(1, supplierSubscription.SupplierId);
            Assert.Equal(1, supplierSubscription.LedgerAccountId);
            Assert.True(supplierSubscription.IsActive);
        }