public void Test_CreateGAFRecordsForDocumentGroup_That_Country_Field_Is_Null_When_Sale_Country_Is_Malaysia(string module, Action additionalSetup = null) { //Arrange var taxAgencyID = VendorDataContext.TaxAgency.BAccountID; var taxPeriodID = TaxPeriodDataContext.TaxPeriod.TaxPeriodID; var invoiceAggr = ArInvoiceAggregateBuilderFactory.CreateInvoiceAggregateBuilder(ARDocType.Invoice, withTax: true, module: module) .Build(); var invoiceAggregs = invoiceAggr.SingleToArray(); SetupRepositoryMethods(invoiceAggregs, invoiceAggr.Document.OrigModule, invoiceAggr.Document.DocType, taxAgencyID, taxPeriodID); if (additionalSetup != null) { additionalSetup(); } 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.Null(supplyRecord.Country); }
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); }
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); }
public void Test_CreateGAFRecordsForDocumentGroup_When_Tax_Calced_On_Document_Amount() { //Arrange var taxAgencyID = VendorDataContext.TaxAgency.BAccountID; var taxPeriodID = TaxPeriodDataContext.TaxPeriod.TaxPeriodID; var taxDataItems = TaxDataBuilder.CreateTaxDataItems(new[] { TaxDataContext.VatTax.TaxID, }); var taxDataItemOfTaxCalcedOnDocAmt = TaxDataBuilder.CreateTaxDataItems(new[] { TaxDataContext.VatTaxCalcedOnDocAmtAmt.TaxID }) .Single(); const decimal taxableAmt = 50; const decimal taxAmt = 3.5m; const decimal curyTaxableAmt = 101; const decimal curyTaxAmt = 7.1m; var documentAggr = _apInvoiceAggregateBuilderFactory.CreateInvoiceAggregateBuilder(APDocType.Invoice, lineCount: 1, taxDataItems: taxDataItems) .AddTaxTran(taxDataItemOfTaxCalcedOnDocAmt.TaxID, taxDataItemOfTaxCalcedOnDocAmt.TranTaxType, taxableAmt, taxAmt, curyTaxableAmt, curyTaxAmt) .Build(); var documentAggregs = documentAggr.SingleToArray(); SetupRepositoryMethods(documentAggregs, documentAggr.Document.OrigModule, documentAggr.Document.DocType, taxAgencyID, taxPeriodID); var documentGroup = new DocumentGroup <AP.APInvoice>() { Module = documentAggr.Document.OrigModule, DocumentType = documentAggr.Document.DocType, DocumentsByRefNbr = documentAggregs.ToDictionary(aggr => aggr.Document.RefNbr, aggr => aggr.Document) }; //Action var gafRecords = InvoiceGafRecordsCreator.CreateGAFRecordsForDocumentGroup(documentGroup, taxAgencyID, taxPeriodID) .Last(); //Assert Assert.Equal(taxDataItemOfTaxCalcedOnDocAmt.TaxID, gafRecords.TaxCode); Assert.Equal(DocumentDataContext.DocDesc, gafRecords.ProductDescription); Assert.Equal(DocumentDataContext.RefNbr, gafRecords.InvoiceNumber); Assert.Equal(DocumentDataContext.CuryIDEUR, gafRecords.ForeignCurrencyCode); Assert.Equal(ContactDataContext.VendorLocationContact.FullName, gafRecords.SupplierName); Assert.Equal(VendorDataContext.Vendor.AcctReferenceNbr, gafRecords.SupplierBRN); Assert.Equal(null, gafRecords.ImportDeclarationNumber); Assert.Equal(2, gafRecords.LineNumber); Assert.Equal(taxableAmt, gafRecords.Amount); Assert.Equal(taxAmt, gafRecords.GSTAmount); Assert.Equal(curyTaxableAmt, gafRecords.ForeignCurrencyAmount); Assert.Equal(curyTaxAmt, gafRecords.ForeignCurrencyAmountGST); }
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()); }
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); }
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()); }
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()); }