コード例 #1
0
        public void Test_CreateGAFRecordsForDocumentGroup_When_Document_Is_In_Base_Cury()
        {
            //Arrange
            var taxAgencyID = VendorDataContext.TaxAgency.BAccountID;
            var taxPeriodID = TaxPeriodDataContext.TaxPeriod.TaxPeriodID;

            var taxDataItems = TaxDataBuilder.CreateTaxDataItems(new[]
            {
                TaxDataContext.VatTax.TaxID,
            });

            var invoiceAggr = new ARInvoiceAggregateBuilder()
                              .CreateDocument(APDocType.Invoice,
                                              DocumentDataContext.RefNbr,
                                              DocumentDataContext.DocDate,
                                              CompanyDataContext.Company.BaseCuryID)
                              .DocumentWith(customerID: CustomerDataContext.Customer.BAccountID,
                                            customerLocationID: LocationDataContext.CustomerLocation.LocationID,
                                            billingAddressID: ArAddressDataContext.CustomerAddress.AddressID)
                              .AddTran(InvoiceTranDataContext.TranAmt, InvoiceTranDataContext.CuryTranAmt, taxDataItems: taxDataItems)
                              .Build();

            var invoiceAggregs = invoiceAggr.SingleToArray();

            SetupRepositoryMethods(invoiceAggregs, invoiceAggr.Document.OrigModule, invoiceAggr.Document.DocType, taxAgencyID, taxPeriodID);

            var documentGroup = new DocumentGroup <AR.ARInvoice>()
            {
                Module            = invoiceAggr.Document.OrigModule,
                DocumentType      = invoiceAggr.Document.DocType,
                DocumentsByRefNbr = invoiceAggregs.ToDictionary(aggr => aggr.Document.RefNbr, aggr => aggr.Document)
            };

            //Action
            var supplyRecord = InvoiceGafRecordsCreator.CreateGAFRecordsForDocumentGroup(documentGroup, taxAgencyID, taxPeriodID)
                               .Single();

            //Assert
            Assert.Equal(InvoiceTranDataContext.TranAmt, supplyRecord.Amount);
            Assert.Equal(InvoiceTranDataContext.VatTaxTaxAmt, supplyRecord.GSTAmount);
            Assert.Equal(ForeignCurrencyCodeForDocumentInBaseCury, supplyRecord.ForeignCurrencyCode);
            Assert.Equal(0, supplyRecord.ForeignCurrencyAmount);
            Assert.Equal(0, supplyRecord.ForeignCurrencyAmountGST);
        }
コード例 #2
0
        public void Test_CreateGAFRecordsForDocumentGroup_For_Documents_With_Two_Tax_And_Custom_LineNumbers(string module, Action additionalSetup = null)
        {
            //Arrange
            var taxDataItems = TaxDataBuilder.CreateTaxDataItems(new[]
            {
                TaxDataContext.VatTax.TaxID,
                TaxDataContext.VatTax2.TaxID
            });

            var taxAgencyID = VendorDataContext.TaxAgency.BAccountID;
            var taxPeriodID = TaxPeriodDataContext.TaxPeriod.TaxPeriodID;

            var invoiceAggr1 = new ARInvoiceAggregateBuilder()
                               .CreateDocument(ARDocType.Invoice,
                                               refNbr: DocumentDataContext.RefNbr,
                                               docDate: DocumentDataContext.DocDate,
                                               curyID: DocumentDataContext.CuryIDEUR,
                                               module: module)
                               .DocumentWith(customerID: CustomerDataContext.Customer.BAccountID,
                                             customerLocationID: LocationDataContext.CustomerLocation.LocationID,
                                             billingAddressID: ArAddressDataContext.CustomerAddress.AddressID)
                               .AddTran(100, 200, "tyre sale 1", lineNbr: 3, taxDataItems: taxDataItems)
                               .AddTran(300, 600, "oil sale 1", lineNbr: 7, taxDataItems: taxDataItems)
                               .Build();

            var invoiceAggr2 = new ARInvoiceAggregateBuilder()
                               .CreateDocument(ARDocType.Invoice,
                                               refNbr: DocumentDataContext.RefNbr2,
                                               docDate: DocumentDataContext.DocDate2,
                                               curyID: DocumentDataContext.CuryIDGBP,
                                               module: module)
                               .DocumentWith(customerID: CustomerDataContext.Customer2.BAccountID,
                                             customerLocationID: LocationDataContext.Customer2Location.LocationID,
                                             billingAddressID: ArAddressDataContext.Customer2Address.AddressID)
                               .AddTran(200, 400, "tyre sale 2", lineNbr: 4, taxDataItems: taxDataItems)
                               .AddTran(500, 700, "oil sale 2", lineNbr: 9, taxDataItems: taxDataItems)
                               .Build();

            var invoiceAggregs = new[] { invoiceAggr1, invoiceAggr2 };

            SetupRepositoryMethods(invoiceAggregs, invoiceAggr1.Document.OrigModule, invoiceAggr1.Document.DocType, taxAgencyID, taxPeriodID);

            if (additionalSetup != null)
            {
                additionalSetup();
            }

            var documentGroup = new DocumentGroup <AR.ARInvoice>()
            {
                Module            = invoiceAggr1.Document.OrigModule,
                DocumentType      = invoiceAggr1.Document.DocType,
                DocumentsByRefNbr = invoiceAggregs.ToDictionary(aggr => aggr.Document.RefNbr, aggr => aggr.Document)
            };

            //Action
            var supplyRecords = InvoiceGafRecordsCreator.CreateGAFRecordsForDocumentGroup(documentGroup, taxAgencyID,
                                                                                          taxPeriodID);

            //Assert
            Approvals.VerifyAll(supplyRecords, "supplyRecords", record => record.Dump());
        }