public APPaymentGAFRecordsCreatorTests() { _vendorDataContext = GetService <VendorDataContext>(); _taxPeriodDataContext = GetService <TaxPeriodDataContext>(); _locationDataContext = GetService <LocationDataContext>(); var purchaseRecordBuilder = new PurchaseRecordBuilderByTaxTranOfAPPayment(GAFRepository, new PurchaseRecordBuilderByVendorData(GAFRepository), new GafRecordBuilderByRegister(GAFRepository)); ApPaymentGAFRecordsCreator = new APPaymentGAFRecordsCreator(GAFRepository, purchaseRecordBuilder); }
public GAFDataCreator(IGAFRepository gafRepository, GAFValidator gafValidator, GLGAFLedgerRecordsCreator glgafLedgerRecordsCreator, APInvoiceGAFRecordsCreator apInvoiceGAFRecordsCreator, ARInvoiceGAFRecordsCreator arInvoiceGAFRecordsCreator, ARInvoiceFromSOGAFRecordsCreator arInvoiceFromSOGafRecordsCreator, APPaymentGAFRecordsCreator apPaymentGAFRecordsCreator, CADocumentPurchaseGAFRecordsCreator caDocumentPurchaseGAFRecordsCreator, CADocumentSupplyGAFRecordsCreator caDocumentSupplyGAFRecordsCreator, TaxAdjustmentGAFRecordsCreator taxAdjustmentGAFRecordsCreator, GLDocumentGAFRecordsCreator glDocumentGAFRecordsCreator, GafRecordWriter gafRecordWriter) { if (gafRepository == null) { throw new ArgumentNullException(nameof(gafRepository)); } if (gafValidator == null) { throw new ArgumentNullException(nameof(gafValidator)); } if (glgafLedgerRecordsCreator == null) { throw new ArgumentNullException(nameof(glgafLedgerRecordsCreator)); } if (apInvoiceGAFRecordsCreator == null) { throw new ArgumentNullException(nameof(apInvoiceGAFRecordsCreator)); } if (arInvoiceGAFRecordsCreator == null) { throw new ArgumentNullException(nameof(arInvoiceGAFRecordsCreator)); } if (arInvoiceFromSOGafRecordsCreator == null) { throw new ArgumentNullException(nameof(arInvoiceFromSOGafRecordsCreator)); } if (apPaymentGAFRecordsCreator == null) { throw new ArgumentNullException(nameof(apPaymentGAFRecordsCreator)); } if (caDocumentPurchaseGAFRecordsCreator == null) { throw new ArgumentNullException(nameof(caDocumentPurchaseGAFRecordsCreator)); } if (caDocumentSupplyGAFRecordsCreator == null) { throw new ArgumentNullException(nameof(caDocumentSupplyGAFRecordsCreator)); } if (taxAdjustmentGAFRecordsCreator == null) { throw new ArgumentNullException(nameof(taxAdjustmentGAFRecordsCreator)); } if (gafRecordWriter == null) { throw new ArgumentNullException(nameof(gafRecordWriter)); } _gafRepository = gafRepository; _gafValidator = gafValidator; _glgafLedgerRecordsCreator = glgafLedgerRecordsCreator; _apInvoiceGAFRecordsCreator = apInvoiceGAFRecordsCreator; _arInvoiceGAFRecordsCreator = arInvoiceGAFRecordsCreator; _arInvoiceFromSOGafRecordsCreator = arInvoiceFromSOGafRecordsCreator; _apPaymentGAFRecordsCreator = apPaymentGAFRecordsCreator; _caDocumentPurchaseGAFRecordsCreator = caDocumentPurchaseGAFRecordsCreator; _caDocumentSupplyGAFRecordsCreator = caDocumentSupplyGAFRecordsCreator; _taxAdjustmentGAFRecordsCreator = taxAdjustmentGAFRecordsCreator; _glDocumentGAFRecordsCreator = glDocumentGAFRecordsCreator; _gafRecordWriter = gafRecordWriter; }
private static void GenerateProc(GAFPeriod gafPeriod) { var gafGenerationProcess = PXGraph.CreateInstance <GAFGenerationProcess>(); IGAFRepository gafRepository = new GAFRepository(gafGenerationProcess); var recordBuilderByVendorData = new PurchaseRecordBuilderByVendorData(gafRepository); var recordBuilderByCustomerData = new SupplyRecordBuilderByCustomerData(gafRepository); var recordBuilderByRegister = new GafRecordBuilderByRegister(gafRepository); var recordCountryBuilderForSO = new SupplyRecordCountryBuilderForSOInvoice(gafRepository); var recordCountryBuilderForAR = new SupplyRecordCountryBuilderForARInvoice(gafRepository); var apInvoiceGAFRecordsCreator = new APInvoiceGAFRecordsCreator(gafRepository, new PurchaseRecordBuilderByInvoiceTran(gafRepository, recordBuilderByVendorData, recordBuilderByRegister), new PurchaseRecordBuilderByTaxTranFromTaxDocument(gafRepository, recordBuilderByVendorData, recordBuilderByRegister), new PurchaseRecordBuilderByAPInvoiceTaxTranForTaxCalcedOnDocumentAmt(gafRepository, recordBuilderByRegister, recordBuilderByVendorData)); var arInvoiceGAFRecordsCreator = new ARInvoiceGAFRecordsCreator(gafRepository, new SupplyRecordBuilderByARInvoice(gafRepository, recordBuilderByRegister, recordBuilderByCustomerData, recordCountryBuilderForAR), new SupplyRecordBuilderByARInvoiceTaxTranForTaxCalcedOnDocumentAmt(gafRepository, recordBuilderByRegister, recordBuilderByCustomerData, recordCountryBuilderForAR)); var arInvoiceFromSOGAFRecordsCreator = new ARInvoiceFromSOGAFRecordsCreator(gafRepository, new SupplyRecordBuilderBySOInvoice(gafRepository, recordBuilderByRegister, recordBuilderByCustomerData, recordCountryBuilderForSO), new SupplyRecordBuilderBySOInvoiceTaxTranForTaxCalcedOnDocumentAmt(gafRepository, recordBuilderByRegister, recordBuilderByCustomerData, recordCountryBuilderForSO)); var apPaymentGAFRecordsCreator = new APPaymentGAFRecordsCreator(gafRepository, new PurchaseRecordBuilderByTaxTranOfAPPayment(gafRepository, recordBuilderByVendorData, recordBuilderByRegister)); var caDocumentPurchaseGAFRecordsCreator = new CADocumentPurchaseGAFRecordsCreator(gafRepository, new PurchaseRecordBuilderByCADocument(gafRepository, recordBuilderByRegister), new PurchaseRecordBuilderByCADocumentTaxTranForTaxCalcedOnDocumentAmt(gafRepository, recordBuilderByRegister)); var caDocumentSupplyGAFRecordsCreator = new CADocumentSupplyGAFRecordsCreator(gafRepository, new SupplyRecordBuilderByCADocument(gafRepository, recordBuilderByRegister), new SupplyRecordBuilderByCADocumentTaxTranForTaxCalcedOnDocumentAmt(gafRepository, recordBuilderByRegister)); var taxAdjustmentGafRecordsCreator = new TaxAdjustmentGAFRecordsCreator(gafRepository, new GafRecordBuilderByTaxAdjustmentTaxTran(gafRepository)); var glDocumentGAFRecordsCreator = new GLDocumentGAFRecordsCreator(gafRepository, new GafRecordBuilderByGLTranAndTaxTran(gafRepository)); var gafCreationHelper = new GAFValidator(gafRepository); var gafDataCreator = new GAFDataCreator(gafRepository, gafCreationHelper, new GLGAFLedgerRecordsCreator(gafRepository), apInvoiceGAFRecordsCreator, arInvoiceGAFRecordsCreator, arInvoiceFromSOGAFRecordsCreator, apPaymentGAFRecordsCreator, caDocumentPurchaseGAFRecordsCreator, caDocumentSupplyGAFRecordsCreator, taxAdjustmentGafRecordsCreator, glDocumentGAFRecordsCreator, new GafRecordWriter(gafRepository)); var gafPeriodFromDB = gafRepository.FindGAFPeriodByKey(gafPeriod.BranchID, gafPeriod.TaxAgencyID, gafPeriod.TaxPeriodID); gafPeriod = gafPeriodFromDB ?? gafGenerationProcess.GAFPeriodView.Insert(gafPeriod); var gstAuditFile = gafDataCreator.Create(gafPeriod, gafGenerationProcess.Accessinfo.BusinessDate.Value); if (gstAuditFile == null) { return; } gafPeriod.GAFMajorVersion = gstAuditFile.MajorVersion; gafPeriod.GAFMinorLastVersion = gstAuditFile.MinorVersion; gafGenerationProcess.GAFPeriodView.Update(gafPeriod); using (var ts = new PXTransactionScope()) { PX.Objects.Common.Tools.UploadFileHelper.AttachDataAsFile(gstAuditFile.FileName, gstAuditFile.Data, gafPeriod, gafGenerationProcess); gafGenerationProcess.Actions.PressSave(); ts.Complete(); } }