Ejemplo n.º 1
0
        public void UpdateTotalRemittanceAmount(Guid txID, long remittanceId)
        {
            FnRemittanceDataset fnRemittanceDS = (FnRemittanceDataset)TransactionService.GetDS(txID);

            if (fnRemittanceDS != null)
            {
                double totalRemittanceAmount     = 0;
                double totalRemittanceMainAmount = 0;
                FnRemittanceDataset.FnRemittanceItemRow[] items           = (FnRemittanceDataset.FnRemittanceItemRow[])fnRemittanceDS.FnRemittanceItem.Select();
                FnRemittanceDataset.FnRemittanceRow       fnremittanceRow = fnRemittanceDS.FnRemittance.FindByRemittanceID(remittanceId);
                if (items.Length > 0)
                {
                    totalRemittanceAmount = items.Sum(x => x.AmountTHB);
                    if ((!fnremittanceRow.IsIsRepOfficeNull() && fnremittanceRow.IsRepOffice))
                    {
                        totalRemittanceMainAmount = items.Sum(x => x.MainCurrencyAmount);
                    }
                }

                fnremittanceRow.BeginEdit();
                fnremittanceRow.TotalAmount        = (double)Math.Round((decimal)totalRemittanceAmount, 2, MidpointRounding.AwayFromZero);
                fnremittanceRow.MainCurrencyAmount = (double)Math.Round((decimal)totalRemittanceMainAmount, 2, MidpointRounding.AwayFromZero);
                //fnremittanceRow.IsRepOffice = isRepOffice;
                fnremittanceRow.EndEdit();
            }
        }
Ejemplo n.º 2
0
        public void UpdateRemittanceDocumentTransaction(Guid txtID, FnRemittance fnRemittance, bool IsHeaderAndFooter)
        {
            this.ValidateRemittance(fnRemittance, IsHeaderAndFooter); // function to validateion of remittance.
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            FnRemittanceDataset fnRemittanceDS = (FnRemittanceDataset)TransactionService.GetDS(txtID);

            #region FnRemittanceDocument
            FnRemittanceDataset.FnRemittanceRow fnremittanceRow = fnRemittanceDS.FnRemittance.FindByRemittanceID(fnRemittance.RemittanceID);

            if (!IsHeaderAndFooter && fnremittanceRow.TotalAmount == 0)
            {
                errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("CannotSaveRemittance_TotalRemittanceAmountMustMoreThanZero"));
            }

            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }


            fnremittanceRow.BeginEdit();
            if (fnRemittance.Document != null)
            {
                fnremittanceRow.DocumentID = fnRemittance.Document.DocumentID;
            }
            if (fnRemittance.TADocumentID > 0)
            {
                fnremittanceRow.TADocumentID = fnRemittance.TADocumentID;
            }
            if (fnRemittance.PB != null)
            {
                fnremittanceRow.PBID = fnRemittance.PB.Pbid;
            }
            if (fnRemittance.MainCurrencyID != null)
            {
                fnremittanceRow.MainCurrencyID = fnRemittance.MainCurrencyID;
            }
            //fnremittanceRow.TotalAmount = (double)Math.Round((decimal)fnRemittance.TotalAmount, 2, MidpointRounding.AwayFromZero);
            fnremittanceRow.isFullClearing = fnRemittance.IsFullClearing;
            fnremittanceRow.IsRepOffice    = Convert.ToBoolean(fnRemittance.IsRepOffice);
            fnremittanceRow.Active         = fnRemittance.Active;
            fnremittanceRow.CreBy          = UserAccount.UserID;
            fnremittanceRow.CreDate        = DateTime.Now;
            fnremittanceRow.UpdBy          = UserAccount.UserID;
            fnremittanceRow.UpdDate        = DateTime.Now;;
            fnremittanceRow.UpdPgm         = UserAccount.CurrentProgramCode;

            fnremittanceRow.EndEdit();
            #endregion
        }