Service - CommerceAccounting Purchase: Difference between revisions

From Izara Wiki
Jump to navigation Jump to search
Created page with "= Overview = Handle purchases in one service, becuase some Accounting entries include the full amount, some break up according to purchaseLineItems. = Repository = ... = Object Schemas = ; Additional Information: Per Service Schemas <syntaxhighlight lang="JavaScript"> { objectType: "comAccPurchaseLink", canDelete: false, belongTo: { serviceTag: "User", objectType: "user" }, addOnDataStructure: [], storageResources: { "dynamo": { "storageType": "dy..."
 
Mint (talk | contribs)
No edit summary
 
(19 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= Overview =
= Overview =


Handle purchases in one service, becuase some Accounting entries include the full amount, some break up according to purchaseLineItems.
Handle links between purchases and Accounting records.


= Repository =
= Repository =
Line 9: Line 9:
= Object Schemas =
= Object Schemas =
; Additional Information: [[Per Service Schemas]]
; Additional Information: [[Per Service Schemas]]
== comAccPurchaseLink ==


<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
Line 14: Line 16:
objectType: "comAccPurchaseLink",
objectType: "comAccPurchaseLink",
canDelete: false,
canDelete: false,
belongTo: {
serviceTag: "User",
objectType: "user"
},
addOnDataStructure: [],
addOnDataStructure: [],
storageResources: {
storageResources: {
Line 26: Line 24:
     },
     },
     fieldNames: {
     fieldNames: {
// probably have two dynamo tables, one identified by purchaseId, one by journalId
// businessId,
// accountLinkTag // type of link: inputVAT|salesTax|vatTax..
// accountId
     },
     },
     identifiers: [
     identifiers: [
{
{
// see above note
type: "partitionKey",
fieldName: "businessId",
},
{
type: "sortKey",
fieldName: "accountLinkTag"
},
    ]
}
</syntaxhighlight>
 
* sets which Accounting accountId journal entries are added to
 
== comAccPurchase ==
 
<syntaxhighlight lang="JavaScript">
{
objectType: "comAccPurchase",
canDelete: false,
    addOnDataStructure: [],
storageResources: {
"dynamo": {
"storageType": "dynamoDB",
"tableName": "comAccPurchase",
}
}
    },
    fieldNames: {
// businessId,
// purchaseId,
journalId: {
type: "string",
optionalOnCreate: true,
canUpdate: true,
storageResourceTags: ["dynamo"],
},
    },
    identifiers: [
{
type: "partitionKey",
fieldName: "businessId",
},
{
type: "sortKey",
fieldName: "purchaseId"
},
     ]
     ]
}
}
</syntaxhighlight>
</syntaxhighlight>


* one purchaseId may link to multiple journalIds, purchase value and inventory adjustment entries
== comAccPurchaseLineItem ==
* maintains a link between purchaseId and journalIds, so can adjust if changes made to purchase
 
<syntaxhighlight lang="JavaScript">
{
objectType: "comAccPurchaseLineItem",
canDelete: false,
addOnDataStructure: [],
storageResources: {
"dynamo": {
"storageType": "dynamoDB",
"tableName": "comAccPurchaseLineItem",
}
    },
    fieldNames: {
// purchaseId,
// purchaseLineItemId,
// accountId
// lineItemQuantity
// lineItemUnitPricelineItemUnitPrice
// entryId // not sure want to record because multiple lineItems might be in the same entryId
    },
    identifiers: [
{
type: "partitionKey",
fieldName: "purchaseId"
},
{
type: "sortKey",
fieldName: "purchaseLineItemId"
},
    ]
}
</syntaxhighlight>
 
* This table might not be needed becasue we do not create a journal entry per line item, we make a compound journal entry per purchase
* Keep it for now so we can reconcile Commerce data matches ComAcc data


== Relationships ==
== Relationships ==
Line 46: Line 123:
= flowSchemas =
= flowSchemas =


== purchaseCreated ==
== createPurchase ==


* when creating a purchase, iterate purchaseLineItems to decide which journal entries are created
* when creating a purchase, iterate purchaseLineItems to decide which journal entries are created
* accountsPayable accountId will need to come from [[Service - CommerceAccounting Vendor]]
* accountsPayable accountId comes from [[Service - CommerceAccounting Vendor]]
* each purchaseLineItem checks it's type then finds accountId from coresponding comAcc service


=== Purchase Value ===
=== Example request param from Commerce ===


* the total purchase value has journal entry for all the below:
<syntaxhighlight lang="JavaScript">
*# (credit)accountsPayable(Liability)
{
belongToIdentifiers: {
  businessId: "xxx"
},
purchaseId: "",
vendorId: "",
    timestamp: 1111111,
purchaseCurrencyId: "",
inventoryLocationId: "", // required if have any inventory/?assets
purchaseLineItems: {
{purchaseLineItemId}: {


* The other side (debit) is broken up depending on lineItem type
            inventoryId: "",
            inventoryTemplateId: "",
            // or
            expenseId: "",
            // or
            servicesId: "",
            servicesTemplateId: "",
            // or
            freightInId: "",
            // or


* For expenses value an entry is entered into the below
            otherPurchaseItemId: "",
* Maybe classify expenses and have different accounts depending on classification
           
*# (debit)expense(Expense)


* Goods:
type: "", // inventory|expense|services|freight|salesTax|vatTax|other
*# (debit)inventory(Asset)
subType: "", // inventory: goods|intangibleGoods|rawMaterial|asset|intangibleAsset, expense: pointInTime|overTime, services: pointInTime|overTime, freight: standard, other: standard


* Intangible Goods:
lineItemQuantity: 1,
*# (debit)expense(Expense)
lineItemUnitPrice: "2.00"
 
},
* Services:
//...
*# (debit)expense(Expense)
}
 
}
* Assets:
</syntaxhighlight>
*# (debit)inventoryAsset(Asset)
 
* Intangible Assets have:
*# (debit)inventoryIntangibleAsset(Asset)
 
* all debit side may have:
*# (debit)vatReceivable(Asset)


== purchaseChange ==
== updatePurchase ==


* make adjustment to journal entries when purchaseLineItemId changes
* make adjustment to journal entries when purchaseLineItemId changes
* perhaps handling removal of purchase/journal entries, or creation of new entries
* handle removal of purchase/journal entries, or creation of new entries
* basically re-calculate all entries and check against existing
* basically re-calculate all entries and check against existing
* each journalId must check Accounting that it's period/s are not locked, if locked return error, cannot make update


= Working documents =
= Working documents =

Latest revision as of 08:37, 10 June 2026

Overview

Handle links between purchases and Accounting records.

Repository

...

Object Schemas

Additional Information
Per Service Schemas

comAccPurchaseLink

{
	objectType: "comAccPurchaseLink",
	canDelete: false,
	addOnDataStructure: [],
	storageResources: {
		"dynamo": {
			"storageType": "dynamoDB",
			"tableName": "comAccPurchaseLink",
		}
    },
    fieldNames: {
		// businessId,
		// accountLinkTag // type of link: inputVAT|salesTax|vatTax..
		// accountId
    },
    identifiers: [
		{
			type: "partitionKey",
			fieldName: "businessId",
		},
		{
			type: "sortKey",
			fieldName: "accountLinkTag"
		},
    ]
}
  • sets which Accounting accountId journal entries are added to

comAccPurchase

{
	objectType: "comAccPurchase",
	canDelete: false,	
    addOnDataStructure: [],
	storageResources: {
		"dynamo": {
			"storageType": "dynamoDB",
			"tableName": "comAccPurchase",
		}
    },
    fieldNames: {
		// businessId,
		// purchaseId,
		journalId: {
			type: "string",
			optionalOnCreate: true,
			canUpdate: true,
			storageResourceTags: ["dynamo"],
		},

    },
    identifiers: [
		{
			type: "partitionKey",
			fieldName: "businessId",
		},
		{
			type: "sortKey",
			fieldName: "purchaseId"
		},
    ]
}

comAccPurchaseLineItem

{
	objectType: "comAccPurchaseLineItem",
	canDelete: false,
	addOnDataStructure: [],
	storageResources: {
		"dynamo": {
			"storageType": "dynamoDB",
			"tableName": "comAccPurchaseLineItem",
		}
    },
    fieldNames: {
		// purchaseId,
		// purchaseLineItemId,
		// accountId
		// lineItemQuantity
		// lineItemUnitPricelineItemUnitPrice
		// entryId // not sure want to record because multiple lineItems might be in the same entryId
    },
    identifiers: [
		{
			type: "partitionKey",
			fieldName: "purchaseId"
		},
		{
			type: "sortKey",
			fieldName: "purchaseLineItemId"
		},
    ]
}
  • This table might not be needed becasue we do not create a journal entry per line item, we make a compound journal entry per purchase
  • Keep it for now so we can reconcile Commerce data matches ComAcc data

Relationships

...

flowSchemas

createPurchase

  • when creating a purchase, iterate purchaseLineItems to decide which journal entries are created
  • accountsPayable accountId comes from Service - CommerceAccounting Vendor
  • each purchaseLineItem checks it's type then finds accountId from coresponding comAcc service

Example request param from Commerce

{
	belongToIdentifiers: {
	  businessId: "xxx"
	},
	purchaseId: "",
	vendorId: "",
    timestamp: 1111111,
	purchaseCurrencyId: "",
	inventoryLocationId: "", // required if have any inventory/?assets
	purchaseLineItems: {
		{purchaseLineItemId}: {

            inventoryId: "",
            inventoryTemplateId: "",
            // or
            expenseId: "",
            // or
            servicesId: "",
            servicesTemplateId: "",
            // or
            freightInId: "",
            // or

            otherPurchaseItemId: "",
            

			type: "", // inventory|expense|services|freight|salesTax|vatTax|other
			subType: "", // inventory: goods|intangibleGoods|rawMaterial|asset|intangibleAsset, expense: pointInTime|overTime, services: pointInTime|overTime, freight: standard, other: standard

			lineItemQuantity: 1,
			lineItemUnitPrice: "2.00"
		},
		//...
	}
}

updatePurchase

  • make adjustment to journal entries when purchaseLineItemId changes
  • handle removal of purchase/journal entries, or creation of new entries
  • basically re-calculate all entries and check against existing
  • each journalId must check Accounting that it's period/s are not locked, if locked return error, cannot make update

Working documents

CommerceAccounting Purchase