Exemplo n.º 1
0
        public long SaveRemittanceDocument(Guid txID, long remittanceID)
        {
            FnRemittanceDataset remittanceDS = (FnRemittanceDataset)TransactionService.GetDS(txID);

            FnRemittanceDataset.FnRemittanceRow remittanceRow = remittanceDS.FnRemittance.FindByRemittanceID(remittanceID);
            long documentID = remittanceRow.DocumentID;

            documentID = SCGDocumentService.SaveSCGDocument(txID, documentID);

            remittanceID = ScgeAccountingDaoProvider.FnRemittanceDao.Persist(remittanceDS.FnRemittance);

            ScgeAccountingDaoProvider.FnRemittanceDao.DeleteAllRemittanceItemAndRemittanceAdvance(remittanceRow.RemittanceID);

            FnRemittanceItemService.SaveRemittanceItem(txID, remittanceID);

            FnRemittanceAdvanceService.SaveRemittanceAdvance(txID, remittanceID);

            // Add code for update clearing advance by Anuwat S on 19/04/2009

            AvAdvanceDocumentService.UpdateRemittanceAdvance(remittanceID, double.Parse("0" + remittanceDS.FnRemittance.Rows[0]["TotalAmount"].ToString()), false);

            if (!remittanceRow.IsIsRepOfficeNull() && remittanceRow.IsRepOffice)
            {
                AvAdvanceDocumentService.UpdateRemittanceAdvanceForRepOffice(remittanceID, double.Parse("0" + remittanceDS.FnRemittance.Rows[0]["MainCurrencyAmount"].ToString()), false);
            }
            return(remittanceID);
        }
Exemplo n.º 2
0
        public FnRemittanceDataset PrepareDataToDataset(long documentID, bool isCopy)
        {
            FnRemittanceDataset remittanceDS = new FnRemittanceDataset();
            FnRemittance        remittance   = ScgeAccountingQueryProvider.FnRemittanceQuery.GetFnRemittanceByDocumentID(documentID);

            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();
            if (remittance == null)
            {
                errors.AddError("Remittance.Error", new Spring.Validation.ErrorMessage("NoRemittanceFound"));
            }
            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }


            // Prepare Data to Document datatable.
            if (!isCopy)
            {
                SCGDocumentService.PrepareDataToDataset(remittanceDS, documentID);
            }
            else
            {
                SCGDocumentService.PrepareDataInternalToDataset(remittanceDS, documentID, isCopy);
            }
            // Set data to Remittance Document row in FnremittanceDS.
            FnRemittanceDataset.FnRemittanceRow remittanceRow = remittanceDS.FnRemittance.NewFnRemittanceRow();
            remittanceRow.RemittanceID = remittance.RemittanceID;
            //remittanceRow.SAPIONo = remittance.SAPIONo;
            if (!isCopy)
            {
                if (remittance.Document != null)
                {
                    remittanceRow.DocumentID = remittance.Document.DocumentID;
                }
                //remittanceRow.PBID = remittance.PB.Pbid;
                remittanceRow.TotalAmount    = remittance.TotalAmount;
                remittanceRow.isFullClearing = remittance.IsFullClearing;
                remittanceRow.TADocumentID   = remittance.TADocumentID;
            }
            else
            {
                if (remittanceDS.Document.Rows.Count > 0)
                {
                    FnRemittanceDataset.DocumentRow docRow = (FnRemittanceDataset.DocumentRow)remittanceDS.Document.Rows[0];
                    remittanceRow.DocumentID = docRow.DocumentID;
                }
            }
            remittanceRow.PBID = remittance.PB.Pbid;
            remittanceRow.MainCurrencyAmount = remittance.MainCurrencyAmount;
            remittanceRow.IsRepOffice        = Convert.ToBoolean(remittance.IsRepOffice);
            remittanceRow.Active             = remittance.Active;
            remittanceRow.CreBy   = remittance.CreBy;
            remittanceRow.CreDate = remittance.CreDate;
            remittanceRow.UpdBy   = remittance.UpdBy;
            remittanceRow.UpdDate = remittance.UpdDate;
            remittanceRow.UpdPgm  = remittance.UpdPgm;
            // Add Remittance document row to FnremittanceDS.
            remittanceDS.FnRemittance.AddFnRemittanceRow(remittanceRow);

            // Prepare Data to RemittanceItem Datatable.
            FnRemittanceItemService.PrepareDataToDataset(remittanceDS, remittance.RemittanceID);

            // Prepare Data to RemittacneAdvance Datatable.
            FnRemittanceAdvanceService.PrepareDataToDataset(remittanceDS, remittance.RemittanceID);

            return(remittanceDS);
        }