Esempio n. 1
0
        public async Task <HttpResponseMessage> LoadInvoiceTransObj([FromBody] int id)
        {
            try
            {
                var organId = Convert.ToInt32(SecurityManager.CurrentUserContext.OrganizationId);

                var invoice = await Rule.FindAsync(id);

                InvoiceTransObj invoiceTransObj = new InvoiceTransObj();

                invoiceTransObj.invoice      = Mapper.Map <InvoiceVM>(invoice);
                invoiceTransObj.invoiceItems = invoiceTransObj.invoice.InvoiceItems;
                //invoiceTransObj.payments =  await transactionRule.GetAllByInvoiceIdAsync(id,true,false);
                PayRecevieRule payRecevieRule = new PayRecevieRule();
                invoiceTransObj.tempPayments = await payRecevieRule.GetTempPaymentsByInvoiceIdAsync(id);

                for (int i = 0; i < invoiceTransObj.invoiceItems.Count; i++)
                {
                    ItemRule itemRule = new ItemRule();
                    invoiceTransObj.invoiceItems[i].Item = Mapper.Map <ItemVM>(await itemRule.FindAsync(invoiceTransObj.invoiceItems[i].ItemId));
                }

                ContactRule contactRule = new ContactRule();
                invoiceTransObj.invoice.Contact = Mapper.Map <ContactVM>(await contactRule.FindAsync(invoice.ContactId));
                CashRule cashRule = new CashRule();
                var      cashes   = await cashRule.GetAllByOrganIdAsync(Convert.ToInt32(organId));

                invoiceTransObj.cashes = Mapper.Map <List <CashVM> >(cashes);

                BankRule bankRule = new BankRule();
                var      banks    = await bankRule.GetAllByOrganIdAsync(Convert.ToInt32(organId));

                invoiceTransObj.banks = Mapper.Map <List <BankVM> >(banks);


                return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = ZhivarEnums.ResultCode.Successful, data = invoiceTransObj }));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 2
0
        public async Task <HttpResponseMessage> LoadCostTransObj([FromBody] int id)
        {
            try
            {
                var organId = Convert.ToInt32(SecurityManager.CurrentUserContext.OrganizationId);

                var cost = await Rule.FindAsync(id);

                CostTransObj costTransObj = new CostTransObj();

                costTransObj.cost      = Mapper.Map <CostVM>(cost);
                costTransObj.costItems = costTransObj.cost.CostItems;
                TransactionRule transactionRule = new TransactionRule();
                costTransObj.payments = await transactionRule.GetAllByCostIdAsync(id);

                for (int i = 0; i < costTransObj.costItems.Count; i++)
                {
                    costTransObj.costItems[i].Item = await this.BusinessRule.UnitOfWork.RepositoryAsync <DomainClasses.Accounting.Account>().FindAsync(costTransObj.costItems[i].ItemId);
                }

                ContactRule contactRule = new ContactRule();
                costTransObj.cost.Contact = Mapper.Map <ContactVM>(await contactRule.FindAsync(cost.ContactId));
                CashRule cashRule = new CashRule();
                var      cashes   = await cashRule.GetAllByOrganIdAsync(Convert.ToInt32(organId));

                costTransObj.cashes = Mapper.Map <List <CashVM> >(cashes);

                BankRule bankRule = new BankRule();
                var      banks    = await bankRule.GetAllByOrganIdAsync(Convert.ToInt32(organId));

                costTransObj.banks = Mapper.Map <List <BankVM> >(banks);


                return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = ZhivarEnums.ResultCode.Successful, data = costTransObj }));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 3
0
        private async Task CreateShareHolderAccounts(int organId, int contactId)
        {
            ContactRule contactRule = new ContactRule();
            var         contact     = await contactRule.FindAsync(contactId);

            AccountRule accountRule = new AccountRule();
            var         accounts    = await accountRule.GetAllByOrganIdAsync(organId);

            var accountShareholder = accounts.Where(x => x.ComplteCoding == "3101").SingleOrDefault();

            DomainClasses.Accounting.Account tempAccountShareholder = new DomainClasses.Accounting.Account();

            tempAccountShareholder = accounts.Where(x => x.ComplteCoding == "3101" + contact.Code).SingleOrDefault();

            if (tempAccountShareholder == null)
            {
                tempAccountShareholder = new DomainClasses.Accounting.Account();

                tempAccountShareholder.Coding        = contact.Code;
                tempAccountShareholder.ComplteCoding = "3101" + contact.Code;
                tempAccountShareholder.Level         = ZhivarEnums.AccountType.Tafzeli;
                tempAccountShareholder.Name          = contact.Name;
                tempAccountShareholder.OrganId       = organId;
                tempAccountShareholder.ParentId      = accountShareholder.ID;

                accountRule.Insert(tempAccountShareholder);
            }

            accountShareholder     = accounts.Where(x => x.ComplteCoding == "3102").SingleOrDefault();
            tempAccountShareholder = new DomainClasses.Accounting.Account();

            tempAccountShareholder = accounts.Where(x => x.ComplteCoding == "3102" + contact.Code).SingleOrDefault();

            if (tempAccountShareholder == null)
            {
                tempAccountShareholder = new DomainClasses.Accounting.Account();

                tempAccountShareholder.Coding        = contact.Code;
                tempAccountShareholder.ComplteCoding = "3102" + contact.Code;
                tempAccountShareholder.Level         = ZhivarEnums.AccountType.Tafzeli;
                tempAccountShareholder.Name          = contact.Name;
                tempAccountShareholder.OrganId       = organId;
                tempAccountShareholder.ParentId      = accountShareholder.ID;

                accountRule.Insert(tempAccountShareholder);
            }

            accountShareholder     = accounts.Where(x => x.ComplteCoding == "3103").SingleOrDefault();
            tempAccountShareholder = new DomainClasses.Accounting.Account();

            tempAccountShareholder = accounts.Where(x => x.ComplteCoding == "3103" + contact.Code).SingleOrDefault();

            if (tempAccountShareholder == null)
            {
                tempAccountShareholder = new DomainClasses.Accounting.Account();

                tempAccountShareholder.Coding        = contact.Code;
                tempAccountShareholder.ComplteCoding = "3103" + contact.Code;
                tempAccountShareholder.Level         = ZhivarEnums.AccountType.Tafzeli;
                tempAccountShareholder.Name          = contact.Name;
                tempAccountShareholder.OrganId       = organId;
                tempAccountShareholder.ParentId      = accountShareholder.ID;

                accountRule.Insert(tempAccountShareholder);
            }

            accountShareholder     = accounts.Where(x => x.ComplteCoding == "3104").SingleOrDefault();
            tempAccountShareholder = new DomainClasses.Accounting.Account();

            tempAccountShareholder = accounts.Where(x => x.ComplteCoding == "3104" + contact.Code).SingleOrDefault();

            if (tempAccountShareholder == null)
            {
                tempAccountShareholder = new DomainClasses.Accounting.Account();

                tempAccountShareholder.Coding        = contact.Code;
                tempAccountShareholder.ComplteCoding = "3104" + contact.Code;
                tempAccountShareholder.Level         = ZhivarEnums.AccountType.Tafzeli;
                tempAccountShareholder.Name          = contact.Name;
                tempAccountShareholder.OrganId       = organId;
                tempAccountShareholder.ParentId      = accountShareholder.ID;

                accountRule.Insert(tempAccountShareholder);
            }

            accountShareholder     = accounts.Where(x => x.ComplteCoding == "3105").SingleOrDefault();
            tempAccountShareholder = new DomainClasses.Accounting.Account();

            tempAccountShareholder = accounts.Where(x => x.ComplteCoding == "3105" + contact.Code).SingleOrDefault();

            if (tempAccountShareholder == null)
            {
                tempAccountShareholder = new DomainClasses.Accounting.Account();

                tempAccountShareholder.Coding        = contact.Code;
                tempAccountShareholder.ComplteCoding = "3105" + contact.Code;
                tempAccountShareholder.Level         = ZhivarEnums.AccountType.Tafzeli;
                tempAccountShareholder.Name          = contact.Name;
                tempAccountShareholder.OrganId       = organId;
                tempAccountShareholder.ParentId      = accountShareholder.ID;

                accountRule.Insert(tempAccountShareholder);
            }
        }