예제 #1
0
 private Account(Guid wholeSalerId, Guid oMCId, Guid retailerId, string name,
                 AccountNumber accountNumber, AccountBearerType accountBearerType,
                 Guid chartOfAccountId, Money accountTransactionLimit, int signatories)
 {
     if (accountBearerType != AccountBearerType.Office && wholeSalerId == Guid.Empty &&
         oMCId == Guid.Empty && retailerId == Guid.Empty)
     {
         throw new Exception("A non-office account must have a bearer");
     }
     if (signatories <= 0)
     {
         throw new ArgumentOutOfRangeException(nameof(signatories));
     }
     if (string.IsNullOrWhiteSpace(name))
     {
         throw new ArgumentNullException(nameof(name));
     }
     GenerateNewIdentity();
     Name                    = name;
     WholeSalerId            = wholeSalerId;
     OMCId                   = oMCId;
     RetailerId              = retailerId;
     AccountNumber           = accountNumber ?? throw new ArgumentNullException(nameof(accountNumber));
     AccountBearerType       = accountBearerType;
     CreatedOn               = DateTimeRangeExtensions.GetDate();
     ChartOfAccountId        = chartOfAccountId;
     AccountTransactionLimit = accountTransactionLimit ?? throw new ArgumentNullException(nameof(accountTransactionLimit));
     Signatories             = signatories;
 }
예제 #2
0
 private Wallet(Guid accountId, Money credit, Money debit,
                Guid txnRefrence, Guid externalReference, string narration, Guid transactingUser)
 {
     if (credit.Amount == debit.Amount)
     {
         throw new Exception("Invalid Entry Debit Equal Credit");
     }
     if (string.IsNullOrWhiteSpace(narration))
     {
         throw new ArgumentNullException(nameof(narration));
     }
     if (txnRefrence == Guid.Empty)
     {
         throw new ArgumentNullException(nameof(txnRefrence));
     }
     if (transactingUser == Guid.Empty)
     {
         throw new ArgumentNullException(nameof(transactingUser));
     }
     GenerateNewIdentity();
     AccountId         = accountId;
     TxnTime           = DateTimeRangeExtensions.GetDate();
     Credit            = credit ?? throw new ArgumentNullException(nameof(credit));
     Debit             = debit ?? throw new ArgumentNullException(nameof(debit));
     TxnRefrence       = txnRefrence;
     ExternalReference = externalReference;
     Narration         = narration;
     TransactingUser   = transactingUser;
 }
예제 #3
0
 internal PurchaseProcess(Guid purchaseId, PurchaseStage purchaseStage, Guid maker, string comments)
 {
     PurchaseId    = purchaseId;
     PurchaseStage = purchaseStage;
     Maker         = maker;
     DateTime      = DateTimeRangeExtensions.GetDate();
     Comments      = comments ?? throw new ArgumentNullException(nameof(comments));
 }
예제 #4
0
 private Supplier(string name, string email, string phone, Guid branchId, string accountNumber)
 {
     Name          = name ?? throw new ArgumentNullException(nameof(name));
     Email         = email ?? throw new ArgumentNullException(nameof(email));
     Phone         = phone ?? throw new ArgumentNullException(nameof(phone));
     BranchId      = branchId;
     AccountNumber = accountNumber ?? throw new ArgumentNullException(nameof(accountNumber));
     AddedOn       = DateTimeRangeExtensions.GetDate();
 }
예제 #5
0
 private Purchase(Guid initiator, Guid supplierId)
 {
     UserId        = initiator;
     SupplierId    = supplierId;
     CreatedOn     = DateTimeRangeExtensions.GetDate();
     PurchaseStage = PurchaseStage.New;
     Processes     = new List <PurchaseProcess>();
     Items         = new List <Item>();
     Documents     = new List <Document>();
 }
예제 #6
0
 private Inventory(Guid purchaseId, Guid userId, string comments)
 {
     if (string.IsNullOrWhiteSpace(comments))
     {
         throw new ArgumentNullException(nameof(comments));
     }
     PurchaseId = purchaseId;
     UserId     = userId;
     AddedOn    = DateTimeRangeExtensions.GetDate();
     Comments   = comments;
     Items      = new List <Item>();
 }
예제 #7
0
 public int Age() => DateTimeRangeExtensions.GetDate().Year - DOB.Year;
예제 #8
0
        private Employee(string jobNumber, Guid jobTypeId, Guid jobTitleId, Guid suffixId, Name name, long phone, string email,
                         Guid genderId, Guid maritalStatusId, DateTime dOB, Guid idTypeId, string idNumber,
                         Guid nationalityId, Guid countyId, PaymentMode paymentMode, Guid branchId, string accountNumber,
                         Money basicSalary, string kraPin, long nHIF, long nSSF, DateTime?hireDate = null,
                         string secondaryPhone = null, Guid reportTo = default, bool isSystemUser = false)
        {
            if (string.IsNullOrWhiteSpace(jobNumber))
            {
                throw new ArgumentNullException(nameof(jobNumber));
            }
            if (jobTypeId == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(jobTypeId));
            }
            if (jobTitleId == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(jobTitleId));
            }
            if (suffixId == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(suffixId));
            }
            Name = name ?? throw new ArgumentNullException(nameof(name));
            if (phone.ToString().Length < 7)
            {
                throw new ArgumentOutOfRangeException(nameof(phone));
            }
            if (string.IsNullOrWhiteSpace(email))
            {
                throw new ArgumentNullException(nameof(email));
            }
            if (genderId == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(genderId));
            }
            if (maritalStatusId == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(maritalStatusId));
            }
            DOB = dOB;
            if (Age() < 18)
            {
                throw new ArgumentOutOfRangeException(nameof(dOB), "Cannot be a Minor; Legally");
            }
            if (idTypeId == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(idTypeId));
            }
            if (string.IsNullOrWhiteSpace(idNumber))
            {
                throw new ArgumentNullException(nameof(idNumber));
            }
            if (nationalityId == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(nationalityId));
            }
            if (countyId == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(countyId));
            }
            if (branchId == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(branchId));
            }
            if (string.IsNullOrWhiteSpace(accountNumber))
            {
                throw new ArgumentNullException(nameof(accountNumber));
            }
            GenerateNewIdentity();
            JobNumber       = jobNumber;
            JobTypeId       = jobTypeId;
            JobTitleId      = jobTitleId;
            SuffixId        = suffixId;
            Phone           = phone;
            Email           = email;
            GenderId        = genderId;
            MaritalStatusId = maritalStatusId;
            IdTypeId        = idTypeId;
            IdNumber        = idNumber;
            NationalityId   = nationalityId;
            CountyId        = countyId;
            SecondaryPhone  = secondaryPhone;
            PaymentMode     = paymentMode;
            BranchId        = branchId;
            AccountNumber   = accountNumber;
            BasicSalary     = basicSalary ?? throw new ArgumentNullException(nameof(basicSalary));
            HireDate        = hireDate == null?DateTimeRangeExtensions.GetDate() : hireDate.Value;

            KraPin       = kraPin ?? throw new ArgumentNullException(nameof(kraPin));
            NHIF         = nHIF;
            NSSF         = nSSF;
            ReportTo     = reportTo;
            IsSystemUser = isSystemUser;
        }
예제 #9
0
        //This is a full Value object now
        public static Money Create(string currency, decimal amount, DateTime?time = null)
        {
            DateTime t = time != null ? time.Value : DateTimeRangeExtensions.GetDate();

            return(new Money(currency, amount, t));
        }