public CashBankMutation VHasTargetCashBank(CashBankMutation cashBankMutation, ICashBankService _cashBankService)
        {
            CashBank targetCashBank = _cashBankService.GetObjectById(cashBankMutation.TargetCashBankId);

            if (targetCashBank == null)
            {
                cashBankMutation.Errors.Add("TargetCashBankId", "Tidak terasosiasi dengan target cashbank");
            }
            return(cashBankMutation);
        }
        public PaymentVoucher VHasCashBank(PaymentVoucher paymentVoucher, ICashBankService _cashBankService)
        {
            CashBank cashBank = _cashBankService.GetObjectById(paymentVoucher.CashBankId);

            if (cashBank == null)
            {
                paymentVoucher.Errors.Add("CashBankId", "Tidak boleh tidak ada");
            }
            return(paymentVoucher);
        }
        public RetailSalesInvoice VHasCashBank(RetailSalesInvoice retailSalesInvoice, ICashBankService _cashBankService)
        {
            CashBank cashBank = _cashBankService.GetObjectById((int)retailSalesInvoice.CashBankId.GetValueOrDefault());

            if (cashBank == null)
            {
                retailSalesInvoice.Errors.Add("CashBankId", "Tidak valid");
            }
            return(retailSalesInvoice);
        }
        public CashBankMutation VHasSourceCashBank(CashBankMutation cashBankMutation, ICashBankService _cashBankService)
        {
            CashBank sourceCashBank = _cashBankService.GetObjectById(cashBankMutation.SourceCashBankId);

            if (sourceCashBank == null)
            {
                cashBankMutation.Errors.Add("SourceCashBankId", "Tidak terasosiasi dengan source cashbank");
            }
            return(cashBankMutation);
        }
        public CashMutation VHasCashBank(CashMutation cashMutation, ICashBankService _cashBankService)
        {
            CashBank cashBank = _cashBankService.GetObjectById(cashMutation.CashBankId);

            if (cashBank == null)
            {
                cashMutation.Errors.Add("Generic", "Tidak terasosiasi dengan cashBank");
            }
            return(cashMutation);
        }
Exemple #6
0
 public CashBank CreateObject(CashBank cashBank)
 {
     cashBank.Errors = new Dictionary <string, string>();
     if (_validator.ValidCreateObject(cashBank, this))
     {
         // Create Leaf Cash Bank Account
         _repository.CreateObject(cashBank);
     }
     return(cashBank);
 }
Exemple #7
0
        public CashBank CreateObject(string name, string description)
        {
            CashBank cashBank = new CashBank
            {
                Name        = name,
                Description = description,
                Amount      = 0
            };

            return(this.CreateObject(cashBank));
        }
        public RetailPurchaseInvoice VIsCashBankTypeBank(RetailPurchaseInvoice retailPurchaseInvoice, ICashBankService _cashBankService)
        {
            CashBank cashBank = _cashBankService.GetObjectById((int)retailPurchaseInvoice.CashBankId.GetValueOrDefault());

            if (!cashBank.IsBank)
            {
                retailPurchaseInvoice.Errors.Add("Generic", "CashBank bukan tipe Bank");
                return(retailPurchaseInvoice);
            }
            return(retailPurchaseInvoice);
        }
Exemple #9
0
 public CashBank GetTargetCashBank(CashBankMutation cashBankMutation)
 {
     using (var db = GetContext())
     {
         CashBank targetCashBank =
             (from obj in db.CashBanks
              where obj.Id == cashBankMutation.TargetCashBankId && !obj.IsDeleted
              select obj).First();
         return(targetCashBank);
     }
 }
 public ReceiptVoucher VIfGBCHThenIsBank(ReceiptVoucher receiptVoucher, ICashBankService _cashBankService)
 {
     if (receiptVoucher.IsGBCH)
     {
         CashBank cashBank = _cashBankService.GetObjectById(receiptVoucher.CashBankId);
         if (!cashBank.IsBank)
         {
             receiptVoucher.Errors.Add("IsBank", "Jika GBCH Harus IsBank");
         }
     }
     return(receiptVoucher);
 }
Exemple #11
0
 public PaymentVoucher VIfGBCHThenIsBank(PaymentVoucher paymentVoucher, ICashBankService _cashBankService)
 {
     if (paymentVoucher.IsGBCH)
     {
         CashBank cashBank = _cashBankService.GetObjectById(paymentVoucher.CashBankId);
         if (!cashBank.IsBank)
         {
             paymentVoucher.Errors.Add("Generic", "Jika GBCH Harus IsBank");
         }
     }
     return(paymentVoucher);
 }
Exemple #12
0
 public CashBank VName(CashBank cashBank, ICashBankService _cashBankService)
 {
     if (String.IsNullOrEmpty(cashBank.Name) || cashBank.Name.Trim() == "")
     {
         cashBank.Errors.Add("Name", "Tidak boleh kosong");
     }
     if (_cashBankService.IsNameDuplicated(cashBank))
     {
         cashBank.Errors.Add("Name", "Tidak boleh ada duplikasi");
     }
     return(cashBank);
 }
Exemple #13
0
        public string PrintError(CashBank obj)
        {
            string erroroutput = "";
            KeyValuePair <string, string> first = obj.Errors.ElementAt(0);

            erroroutput += first.Key + "," + first.Value;
            foreach (KeyValuePair <string, string> pair in obj.Errors.Skip(1))
            {
                erroroutput += Environment.NewLine;
                erroroutput += pair.Key + "," + pair.Value;
            }
            return(erroroutput);
        }
 public CashBankAdjustment ConfirmObject(CashBankAdjustment cashBankAdjustment, DateTime ConfirmationDate, ICashMutationService _cashMutationService, ICashBankService _cashBankService)
 {
     cashBankAdjustment.ConfirmationDate = ConfirmationDate;
     if (_validator.ValidConfirmObject(cashBankAdjustment, _cashBankService))
     {
         CashBank     cashBank     = _cashBankService.GetObjectById(cashBankAdjustment.CashBankId);
         CashMutation cashMutation = _cashMutationService.CreateCashMutationForCashBankAdjustment(cashBankAdjustment, cashBank);
         // cashBank.Amount += cashBankAdjustment.Amount;
         _cashMutationService.CashMutateObject(cashMutation, _cashBankService);
         _repository.ConfirmObject(cashBankAdjustment);
     }
     return(cashBankAdjustment);
 }
Exemple #15
0
 public CashBankMutation UnconfirmObject(CashBankMutation cashBankMutation, ICashMutationService _cashMutationService, ICashBankService _cashBankService)
 {
     if (_validator.ValidUnconfirmObject(cashBankMutation, _cashBankService))
     {
         CashBank             sourceCashBank = _cashBankService.GetObjectById(cashBankMutation.SourceCashBankId);
         CashBank             targetCashBank = _cashBankService.GetObjectById(cashBankMutation.TargetCashBankId);
         IList <CashMutation> cashMutations  = _cashMutationService.SoftDeleteCashMutationForCashBankMutation(cashBankMutation, sourceCashBank, targetCashBank);
         foreach (var cashMutation in cashMutations)
         {
             _cashMutationService.ReverseCashMutateObject(cashMutation, _cashBankService);
         }
         _repository.UnconfirmObject(cashBankMutation);
     }
     return(cashBankMutation);
 }
 public CashBankAdjustment UnconfirmObject(CashBankAdjustment cashBankAdjustment, ICashMutationService _cashMutationService, ICashBankService _cashBankService)
 {
     if (_validator.ValidUnconfirmObject(cashBankAdjustment, _cashBankService))
     {
         CashBank             cashBank      = _cashBankService.GetObjectById(cashBankAdjustment.CashBankId);
         IList <CashMutation> cashMutations = _cashMutationService.SoftDeleteCashMutationForCashBankAdjustment(cashBankAdjustment, cashBank);
         // cashBank.Amount -= cashBankAdjustment.Amount;
         foreach (var cashMutation in cashMutations)
         {
             _cashMutationService.ReverseCashMutateObject(cashMutation, _cashBankService);
         }
         _repository.UnconfirmObject(cashBankAdjustment);
     }
     return(cashBankAdjustment);
 }
Exemple #17
0
 public CashBankMutation ConfirmObject(CashBankMutation cashBankMutation, DateTime ConfirmationDate, ICashMutationService _cashMutationService, ICashBankService _cashBankService)
 {
     cashBankMutation.ConfirmationDate = ConfirmationDate;
     if (_validator.ValidConfirmObject(cashBankMutation, _cashBankService))
     {
         CashBank             sourceCashBank = _cashBankService.GetObjectById(cashBankMutation.SourceCashBankId);
         CashBank             targetCashBank = _cashBankService.GetObjectById(cashBankMutation.TargetCashBankId);
         IList <CashMutation> cashMutations  = _cashMutationService.CreateCashMutationForCashBankMutation(cashBankMutation, sourceCashBank, targetCashBank);
         foreach (var cashMutation in cashMutations)
         {
             _cashMutationService.CashMutateObject(cashMutation, _cashBankService);
         }
         _repository.ConfirmObject(cashBankMutation);
     }
     return(cashBankMutation);
 }
Exemple #18
0
 public CashBankAdjustment UnconfirmObject(CashBankAdjustment cashBankAdjustment, ICashMutationService _cashMutationService, ICashBankService _cashBankService,
                                           IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService, IClosingService _closingService)
 {
     if (_validator.ValidUnconfirmObject(cashBankAdjustment, _cashBankService, _closingService))
     {
         CashBank             cashBank      = _cashBankService.GetObjectById(cashBankAdjustment.CashBankId);
         IList <CashMutation> cashMutations = _cashMutationService.SoftDeleteCashMutationForCashBankAdjustment(cashBankAdjustment, cashBank);
         // cashBank.Amount -= cashBankAdjustment.Amount;
         foreach (var cashMutation in cashMutations)
         {
             _cashMutationService.ReverseCashMutateObject(cashMutation, _cashBankService);
         }
         _generalLedgerJournalService.CreateUnconfirmationJournalForCashBankAdjustment(cashBankAdjustment, cashBank, _accountService);
         _repository.UnconfirmObject(cashBankAdjustment);
     }
     return(cashBankAdjustment);
 }
Exemple #19
0
 public CashBankMutation UnconfirmObject(CashBankMutation cashBankMutation, ICashMutationService _cashMutationService, ICashBankService _cashBankService,
                                         IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService, IClosingService _closingService)
 {
     if (_validator.ValidUnconfirmObject(cashBankMutation, _cashBankService, _closingService))
     {
         CashBank             sourceCashBank = _cashBankService.GetObjectById(cashBankMutation.SourceCashBankId);
         CashBank             targetCashBank = _cashBankService.GetObjectById(cashBankMutation.TargetCashBankId);
         IList <CashMutation> cashMutations  = _cashMutationService.SoftDeleteCashMutationForCashBankMutation(cashBankMutation, sourceCashBank, targetCashBank);
         foreach (var cashMutation in cashMutations)
         {
             _cashMutationService.ReverseCashMutateObject(cashMutation, _cashBankService);
         }
         _generalLedgerJournalService.CreateUnconfirmationJournalForCashBankMutation(cashBankMutation, sourceCashBank, targetCashBank, _accountService);
         _repository.UnconfirmObject(cashBankMutation);
     }
     return(cashBankMutation);
 }
        public dynamic Insert(CashBank model)
        {
            try
            {
                model = _cashBankService.CreateObject(model);
            }
            catch (Exception ex)
            {
                LOG.Error("Insert Failed", ex);
                model.Errors.Add("Insert Failed", "Error : " + ex);
            }

            return(Json(new
            {
                model.Errors
            }));
        }
        public dynamic Delete(CashBank model)
        {
            try
            {
                var data = _cashBankService.GetObjectById(model.Id);
                model = _cashBankService.SoftDeleteObject(data, _cashMutationService);
            }
            catch (Exception ex)
            {
                LOG.Error("Delete Failed", ex);
                model.Errors.Add("Delete Failed", "Error : " + ex);
            }

            return(Json(new
            {
                model.Errors
            }));
        }
        public ReceiptVoucher VCashBankHasMoreAmountReceiptVoucherDetails(ReceiptVoucher receiptVoucher, IReceiptVoucherDetailService _receiptVoucherDetailService, ICashBankService _cashBankService)
        {
            decimal totalamount = 0;
            IList <ReceiptVoucherDetail> details = _receiptVoucherDetailService.GetObjectsByReceiptVoucherId(receiptVoucher.Id);

            foreach (var detail in details)
            {
                totalamount += detail.Amount;
            }

            CashBank cashBank = _cashBankService.GetObjectById(receiptVoucher.CashBankId);

            if (cashBank.Amount < totalamount)
            {
                receiptVoucher.Errors.Add("Generic", "Cash bank tidak boleh kurang dari total amount");
            }
            return(receiptVoucher);
        }
Exemple #23
0
        public void UpdateInvalidCashBank()
        {
            CashBank cashBankToUpdate = new CashBank()
            {
                CashBankId = 7, CashBankName = "Cash Bank Greece", Description = "axcd"
            };
            CrudViewModel <CashBank> crudView = new CrudViewModel <CashBank>()
            {
                action      = "update",
                antiForgery = "",
                key         = 7,
                value       = cashBankToUpdate
            };

            var exception = Assert.Throws <DbUpdateConcurrencyException>(() => controller.Update(crudView));

            Assert.IsType <DbUpdateConcurrencyException>(exception);
        }
Exemple #24
0
        public PaymentVoucher VCashBankHasMoreAmountPaymentVoucherDetails(PaymentVoucher paymentVoucher, IPaymentVoucherDetailService _paymentVoucherDetailService, ICashBankService _cashBankService)
        {
            decimal totalamount = 0;
            IList <PaymentVoucherDetail> details = _paymentVoucherDetailService.GetObjectsByPaymentVoucherId(paymentVoucher.Id);

            foreach (var detail in details)
            {
                totalamount += detail.Amount;
            }

            CashBank cashBank = _cashBankService.GetObjectById(paymentVoucher.CashBankId);

            if (cashBank.Amount < totalamount)
            {
                paymentVoucher.Errors.Add("Generic", "Cash bank tidak boleh kurang dari total amount");
            }
            return(paymentVoucher);
        }
Exemple #25
0
        public HttpResponseMessage Post(FormDataCollection form)
        {
            var model  = new CashBank();
            var values = JsonConvert.DeserializeObject <IDictionary>(form.Get("values"));

            PopulateModel(model, values);

            Validate(model);
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, GetFullErrorMessage(ModelState)));
            }

            var result = _context.CashBanks.Add(model);

            _context.SaveChanges();

            return(Request.CreateResponse(HttpStatusCode.Created, result.CashBankId));
        }
        public dynamic GetInfo(int Id)
        {
            CashBank model = new CashBank();

            try
            {
                model = _cashBankService.GetObjectById(Id);
            }
            catch (Exception ex)
            {
                LOG.Error("GetInfo", ex);
                model.Errors.Add("Generic", "Error" + ex);
            }

            return(Json(new
            {
                model
            }, JsonRequestBehavior.AllowGet));
        }
        public dynamic Update(CashBank model)
        {
            try
            {
                var data = _cashBankService.GetObjectById(model.Id);
                data.Name        = model.Name;
                data.Description = model.Description;
                model            = _cashBankService.UpdateObject(data);
            }
            catch (Exception ex)
            {
                LOG.Error("Update Failed", ex);
                model.Errors.Add("Update Failed", "Error : " + ex);
            }

            return(Json(new
            {
                model.Errors
            }));
        }
        public CashBankAdjustment VNonNegativeNorZeroCashBankAmount(CashBankAdjustment cashBankAdjustment, ICashBankService _cashBankService, bool CaseConfirm)
        {
            CashBank cashBank = _cashBankService.GetObjectById(cashBankAdjustment.CashBankId);

            if (CaseConfirm && cashBankAdjustment.Amount < 0)
            {
                if (cashBank.Amount + cashBankAdjustment.Amount < 0)
                {
                    cashBankAdjustment.Errors.Add("Generic", "Final CashBank Amount tidak boleh kurang dari 0");
                }
            }
            else if (!CaseConfirm && cashBankAdjustment.Amount > 0)
            {
                if (cashBank.Amount - cashBankAdjustment.Amount < 0)
                {
                    cashBankAdjustment.Errors.Add("Generic", "Adjustment Amount tidak boleh lebih besar dari CashBank Amount");
                }
            }
            return(cashBankAdjustment);
        }
Exemple #29
0
        private void PopulateModel(CashBank model, IDictionary values)
        {
            string CASH_BANK_ID   = nameof(CashBank.CashBankId);
            string CASH_BANK_NAME = nameof(CashBank.CashBankName);
            string DESCRIPTION    = nameof(CashBank.Description);

            if (values.Contains(CASH_BANK_ID))
            {
                model.CashBankId = Convert.ToInt32(values[CASH_BANK_ID]);
            }

            if (values.Contains(CASH_BANK_NAME))
            {
                model.CashBankName = Convert.ToString(values[CASH_BANK_NAME]);
            }

            if (values.Contains(DESCRIPTION))
            {
                model.Description = Convert.ToString(values[DESCRIPTION]);
            }
        }
Exemple #30
0
        public CustomPurchaseInvoice PaidObject(CustomPurchaseInvoice customPurchaseInvoice, decimal AmountPaid, ICashBankService _cashBankService, IPayableService _payableService,
                                                IPaymentVoucherService _paymentVoucherService, IPaymentVoucherDetailService _paymentVoucherDetailService, IContactService _contactService,
                                                ICashMutationService _cashMutationService, IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService,
                                                IClosingService _closingService)
        {
            customPurchaseInvoice.AmountPaid = AmountPaid;
            if (_validator.ValidPaidObject(customPurchaseInvoice, _cashBankService, _paymentVoucherService, _closingService))
            {
                CashBank cashBank = _cashBankService.GetObjectById((int)customPurchaseInvoice.CashBankId.GetValueOrDefault());
                customPurchaseInvoice.IsBank = cashBank.IsBank;

                if (!customPurchaseInvoice.IsGBCH)
                {
                    customPurchaseInvoice.GBCH_No     = null;
                    customPurchaseInvoice.Description = null;
                }
                if (customPurchaseInvoice.AmountPaid == customPurchaseInvoice.Total)
                {
                    customPurchaseInvoice.IsFullPayment = true;
                }
                Payable payable = _payableService.GetObjectBySource(Core.Constants.Constant.PayableSource.CustomPurchaseInvoice, customPurchaseInvoice.Id);
                payable.AllowanceAmount = customPurchaseInvoice.Allowance;
                payable.RemainingAmount = payable.Amount - customPurchaseInvoice.Allowance;
                _payableService.UpdateObject(payable);
                PaymentVoucher paymentVoucher = _paymentVoucherService.CreateObject((int)customPurchaseInvoice.CashBankId.GetValueOrDefault(), customPurchaseInvoice.ContactId, DateTime.Now, customPurchaseInvoice.AmountPaid.GetValueOrDefault() /*payable.RemainingAmount*/,
                                                                                    customPurchaseInvoice.IsGBCH, (DateTime)customPurchaseInvoice.DueDate.GetValueOrDefault(), customPurchaseInvoice.IsBank, _paymentVoucherDetailService,
                                                                                    _payableService, _contactService, _cashBankService);
                PaymentVoucherDetail paymentVoucherDetail = _paymentVoucherDetailService.CreateObject(paymentVoucher.Id, payable.Id, customPurchaseInvoice.AmountPaid.GetValueOrDefault(),
                                                                                                      "Automatic Payment", _paymentVoucherService, _cashBankService, _payableService);

                customPurchaseInvoice = _repository.PaidObject(customPurchaseInvoice);
                _generalLedgerJournalService.CreatePaidJournalForCustomPurchaseInvoice(customPurchaseInvoice, _accountService);
                _paymentVoucherService.ConfirmObject(paymentVoucher, (DateTime)customPurchaseInvoice.ConfirmationDate.GetValueOrDefault(), _paymentVoucherDetailService,
                                                     _cashBankService, _payableService, _cashMutationService, _generalLedgerJournalService, _accountService, _closingService);
            }

            return(customPurchaseInvoice);
        }