コード例 #1
0
        public void Test_CreateGAFRecordsForDocumentGroup_When_Document_Is_In_Base_Cury_And_TaxTrans_By_Tax_Document()
        {
            //Arrange
            var taxDataItem = TaxDataBuilder.CreateTaxDataItems(new[]
            {
                TaxDataContext.VatDirect.TaxID,
            })
                              .Single();

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

            const decimal taxableAmt = 10;
            const decimal taxAmt     = 1m;

            var billAggr1 = new APInvoiceAggregateBuilder()
                            .CreateDocument(APDocType.Invoice,
                                            refNbr: DocumentDataContext.RefNbr,
                                            docDate: DocumentDataContext.DocDate,
                                            curyID: CompanyDataContext.Company.BaseCuryID)
                            .DocumentWith(vendorID: VendorDataContext.Vendor.BAccountID,
                                          vendorLocationID: LocationDataContext.VendorLocation.LocationID)
                            .AddTaxTran(taxDataItem.TaxID, taxDataItem.TranTaxType, taxableAmt, taxAmt, 20, 2)
                            .Build();

            var taxBill1 = new APInvoiceAggregateBuilder()
                           .CreateDocument(APDocType.Invoice)
                           .AddTaxTran(new TaxTran()
            {
                TaxID = taxDataItem.TaxID, OrigRefNbr = DocumentDataContext.RefNbr
            })
                           .Build();

            var billAggregs    = new[] { billAggr1 };
            var taxBillAggregs = new[] { taxBill1 };

            SetupRepositoryMethodsForDocumentsWithTaxDocumentTrans(billAggregs, billAggr1.Document.OrigModule, billAggr1.Document.DocType, taxAgencyID,
                                                                   taxPeriodID, taxBillAggregs);

            var documentGroup = new DocumentGroup <AP.APInvoice>()
            {
                Module            = billAggr1.Document.OrigModule,
                DocumentType      = billAggr1.Document.DocType,
                DocumentsByRefNbr = billAggregs.ToDictionary(aggr => aggr.Document.RefNbr, aggr => aggr.Document)
            };

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

            //Assert
            Assert.Equal(taxableAmt, purchaseRecord.Amount);
            Assert.Equal(taxAmt, purchaseRecord.GSTAmount);
            Assert.Equal(ForeignCurrencyCodeForDocumentInBaseCury, purchaseRecord.ForeignCurrencyCode);
            Assert.Equal(0, purchaseRecord.ForeignCurrencyAmount);
            Assert.Equal(0, purchaseRecord.ForeignCurrencyAmountGST);
        }
コード例 #2
0
        public void Test_CreateGAFRecordsForDocumentGroup_That_IDN_Has_Been_Taked_From_Determined_Document_When_Exist_Many_Tax_Documents_For_Same_Document_And_Tax(
            TaxDocumentDataItem[] taxDocumentDataItems,
            string expectedDocDesc)
        {
            //Arrange
            var taxDataItems = TaxDataBuilder.CreateTaxDataItems(new[]
            {
                TaxDataContext.VatDirect.TaxID,
                TaxDataContext.VatDirect2.TaxID,
            });

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

            var billAggr1 = _apInvoiceAggregateBuilderFactory.CreateInvoiceAggregateBuilder(APDocType.Invoice)
                            .AddTaxTran(taxDataItems[0].TaxID, taxDataItems[0].TranTaxType)
                            .AddTaxTran(taxDataItems[1].TaxID, taxDataItems[1].TranTaxType)
                            .Build();


            var docBuilder = new APInvoiceAggregateBuilder();

            var billAggregs    = new[] { billAggr1 };
            var taxBillAggregs = taxDocumentDataItems.Select(taxDocData =>
                                                             docBuilder.CreateDocument(taxDocData.DocType,
                                                                                       refNbr: taxDocData.RefNbr,
                                                                                       docDesc: taxDocData.DocDesc)
                                                             .AddTaxTran(new TaxTran()
            {
                TaxID = taxDataItems[0].TaxID, OrigRefNbr = DocumentDataContext.RefNbr
            })
                                                             .AddTaxTran(new TaxTran()
            {
                TaxID = taxDataItems[1].TaxID, OrigRefNbr = DocumentDataContext.RefNbr
            })
                                                             .Build())
                                 .ToArray();

            SetupRepositoryMethodsForDocumentsWithTaxDocumentTrans(billAggregs, billAggr1.Document.OrigModule,
                                                                   billAggr1.Document.DocType, taxAgencyID, taxPeriodID, taxBillAggregs);

            var documentGroup = new DocumentGroup <AP.APInvoice>()
            {
                Module            = billAggr1.Document.OrigModule,
                DocumentType      = billAggr1.Document.DocType,
                DocumentsByRefNbr = billAggregs.ToDictionary(aggr => aggr.Document.RefNbr, aggr => aggr.Document)
            };

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

            //Assert
            Assert.Equal(expectedDocDesc, purchaseRecords[0].ImportDeclarationNumber);
            Assert.Equal(expectedDocDesc, purchaseRecords[1].ImportDeclarationNumber);
        }
コード例 #3
0
        public void Test_CreateGAFRecordsForDocumentGroup_For_Documents_With_Two_Taxes_And_Custom_LineNumbers(string module)
        {
            //Arrange
            var taxDataItems = TaxDataBuilder.CreateTaxDataItems(new[]
            {
                TaxDataContext.VatTax.TaxID,
                TaxDataContext.VatTax2.TaxID
            });

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

            var billAggr1 = new APInvoiceAggregateBuilder()
                            .CreateDocument(
                APDocType.Invoice,
                refNbr: "DOC001",
                docDate: new DateTime(2015, 3, 1),
                curyID: "EUR",
                module: module)
                            .DocumentWith(vendorID: VendorDataContext.Vendor.BAccountID,
                                          vendorLocationID: LocationDataContext.VendorLocation.LocationID)
                            .AddTran(100, 200, "tyre purchase 1", lineNbr: 3, taxDataItems: taxDataItems)
                            .AddTran(300, 600, "oil purchase 1", lineNbr: 7, taxDataItems: taxDataItems)
                            .Build();

            var billAggr2 = new APInvoiceAggregateBuilder()
                            .CreateDocument(APDocType.Invoice,
                                            refNbr: "DOC002",
                                            docDate: new DateTime(2015, 3, 5),
                                            curyID: "GBP",
                                            module: module)
                            .DocumentWith(vendorID: VendorDataContext.Vendor2.BAccountID,
                                          vendorLocationID: LocationDataContext.Vendor2Location.LocationID)
                            .AddTran(200, 400, "tyre purchase 2", lineNbr: 4, taxDataItems: taxDataItems)
                            .AddTran(500, 700, "oil purchase 2", lineNbr: 9, taxDataItems: taxDataItems)
                            .Build();

            var billAggregs = new[] { billAggr1, billAggr2 };

            SetupRepositoryMethods(billAggregs, billAggr1.Document.OrigModule, billAggr1.Document.DocType, taxAgencyID, taxPeriodID);

            var documentGroup = new DocumentGroup <AP.APInvoice>()
            {
                Module            = billAggr1.Document.OrigModule,
                DocumentType      = billAggr1.Document.DocType,
                DocumentsByRefNbr = billAggregs.ToDictionary(aggr => aggr.Document.RefNbr, aggr => aggr.Document)
            };

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

            //Assert
            Approvals.VerifyAll(purchaseRecords, "purchaseRecords", record => record.Dump());
        }
コード例 #4
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 billAggr = new APInvoiceAggregateBuilder()
                           .CreateDocument(APDocType.Invoice,
                                           DocumentDataContext.RefNbr,
                                           DocumentDataContext.DocDate,
                                           CompanyDataContext.Company.BaseCuryID)
                           .DocumentWith(vendorID: VendorDataContext.Vendor.BAccountID,
                                         vendorLocationID: LocationDataContext.VendorLocation.LocationID)
                           .AddTran(InvoiceTranDataContext.TranAmt, InvoiceTranDataContext.CuryTranAmt, taxDataItems: taxDataItems)
                           .Build();

            var billAggregs = billAggr.SingleToArray();

            SetupRepositoryMethods(billAggregs, billAggr.Document.OrigModule, billAggr.Document.DocType, taxAgencyID, taxPeriodID);

            var documentGroup = new DocumentGroup <AP.APInvoice>()
            {
                Module            = billAggr.Document.OrigModule,
                DocumentType      = billAggr.Document.DocType,
                DocumentsByRefNbr = billAggregs.ToDictionary(aggr => aggr.Document.RefNbr, aggr => aggr.Document)
            };

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

            //Assert
            Assert.Equal(InvoiceTranDataContext.TranAmt, purchaseRecord.Amount);
            Assert.Equal(InvoiceTranDataContext.VatTaxTaxAmt, purchaseRecord.GSTAmount);
            Assert.Equal(ForeignCurrencyCodeForDocumentInBaseCury, purchaseRecord.ForeignCurrencyCode);
            Assert.Equal(0, purchaseRecord.ForeignCurrencyAmount);
            Assert.Equal(0, purchaseRecord.ForeignCurrencyAmountGST);
        }
コード例 #5
0
        public void Test_CreateGAFRecordsForDocumentGroup_For_Documents_With_Two_Tax_And_TaxTrans_By_Tax_Document(string module)
        {
            //Arrange
            var taxDataItems = TaxDataBuilder.CreateTaxDataItems(new[]
            {
                TaxDataContext.VatDirect.TaxID,
                TaxDataContext.VatDirect2.TaxID,
                TaxDataContext.VatTax.TaxID,                //invalid - not direct tax, should not be exported
            });

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

            var billRefNbr1 = "DOC001";

            var billAggr1 = new APInvoiceAggregateBuilder()
                            .CreateDocument(APDocType.Invoice,
                                            refNbr: billRefNbr1,
                                            docDate: new DateTime(2015, 3, 1),
                                            curyID: "EUR",
                                            docDesc: "bill desc 1",
                                            module: module)
                            .DocumentWith(vendorID: VendorDataContext.Vendor.BAccountID,
                                          vendorLocationID: LocationDataContext.VendorLocation.LocationID)
                            .AddTaxTran(taxDataItems[0].TaxID, taxDataItems[0].TranTaxType, 10, 1, 20, 3)
                            .AddTaxTran(taxDataItems[1].TaxID, taxDataItems[1].TranTaxType, 15, 2, 25, 5)
                            .AddTaxTran(taxDataItems[2].TaxID, taxDataItems[2].TranTaxType)                                            //should not be exported
                            .Build();

            var taxBill1 = new APInvoiceAggregateBuilder()
                           .CreateDocument(APDocType.Invoice,
                                           docDesc: "tax bill desc 1")
                           .AddTaxTran(new TaxTran()
            {
                TaxID = taxDataItems[0].TaxID, OrigRefNbr = billRefNbr1
            })
                           .AddTaxTran(new TaxTran()
            {
                TaxID = taxDataItems[1].TaxID, OrigRefNbr = billRefNbr1
            })
                           .Build();


            var billRefNbr2 = "DOC002";

            var billAggr2 = new APInvoiceAggregateBuilder()
                            .CreateDocument(APDocType.Invoice,
                                            refNbr: billRefNbr2,
                                            docDate: new DateTime(2015, 3, 5),
                                            curyID: "GBP",
                                            docDesc: "bill desc 2",
                                            module: module)
                            .DocumentWith(vendorID: VendorDataContext.Vendor2.BAccountID,
                                          vendorLocationID: LocationDataContext.Vendor2Location.LocationID)
                            .AddTaxTran(taxDataItems[0].TaxID, taxDataItems[0].TranTaxType, 14, 3, 23, 6)
                            .AddTaxTran(taxDataItems[1].TaxID, taxDataItems[1].TranTaxType, 16, 4, 27, 8)
                            .AddTaxTran(taxDataItems[2].TaxID, taxDataItems[2].TranTaxType)                                            //should not be exported
                            .Build();

            var taxBill2 = new APInvoiceAggregateBuilder()
                           .CreateDocument(APDocType.Invoice,
                                           docDesc: "tax bill desc 2")
                           .AddTaxTran(new TaxTran()
            {
                TaxID = taxDataItems[0].TaxID, OrigRefNbr = billRefNbr2
            })
                           .AddTaxTran(new TaxTran()
            {
                TaxID = taxDataItems[1].TaxID, OrigRefNbr = billRefNbr2
            })
                           .Build();

            var billAggregs    = new[] { billAggr1, billAggr2 };
            var taxBillAggregs = new[] { taxBill1, taxBill2 };

            SetupRepositoryMethodsForDocumentsWithTaxDocumentTrans(billAggregs, billAggr1.Document.OrigModule, billAggr1.Document.DocType, taxAgencyID,
                                                                   taxPeriodID, taxBillAggregs);

            var documentGroup = new DocumentGroup <AP.APInvoice>()
            {
                Module            = billAggr1.Document.OrigModule,
                DocumentType      = billAggr1.Document.DocType,
                DocumentsByRefNbr = billAggregs.ToDictionary(aggr => aggr.Document.RefNbr, aggr => aggr.Document)
            };

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

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