Service - CommerceAccounting Purchase: Difference between revisions

From Izara Wiki
Jump to navigation Jump to search
No edit summary
 
(29 intermediate revisions by 2 users not shown)
Line 15: Line 15:
{
{
objectType: "comAccPurchaseLink",
objectType: "comAccPurchaseLink",
    generatedBy: "userGenerated",
canDelete: false,
canDelete: false,
belongTo: {
belongTo: {
serviceTag: "ComAccLink",
serviceTag: "CommerceAccountingLink",
objectType: "comAccLinkByBusiness"
objectType: "comAccLinkByBusiness"
},
},
addOnDataStructure: [],
addOnDataStructure: [],
storageResources: {
storageResources: {
        "myGraph":{
          "storageType": "graph",
          "graphServerTag": "GraphHandler"
        },
"dynamo": {
"dynamo": {
"storageType": "dynamoDB",
"storageType": "dynamoDB",
Line 28: Line 33:
     },
     },
     fieldNames: {
     fieldNames: {
// businessId,
businessId:{
// accountLinkTag // type of link: inputVAT|..
fromObjType:{
// accountId
  serviceTag: "CommerceAccountingLink",
  objectType: "comAccLinkByBusiness"
},
        },
organizationId: {
fromObjType:{
  serviceTag: "CommerceAccountingLink",
  objectType: "comAccLinkByOrganization"
},
},
        accountLinkTag:{  // type of link: inputVAT|salesTax|vatTax..
            type: "string",
requriedOnCreate: true,
storageResourceTags: ['myGraph','dynamo']
        }
        accountId:{
            type: "string",
requriedOnCreate: true,
storageResourceTags: ['myGraph','dynamo']
        }
     },
     },
     identifiers: [
     identifiers: [
{
{
type: "partitionKey",
type: "partitionKey",
fieldName: "businessId",
fieldNames: ["businessId", "organizationId"],
name: "comAccLinkId",
},
},
{
{
Line 52: Line 77:
{
{
objectType: "comAccPurchase",
objectType: "comAccPurchase",
    generatedBy: "systemGenerated",
canDelete: false,
canDelete: false,
belongTo: {
    addOnDataStructure: [],
serviceTag: "ComAccLink",
objectType: "comAccLinkByBusiness"
},
addOnDataStructure: [],
storageResources: {
storageResources: {
"dynamo": {
"dynamo": {
Line 66: Line 88:
     fieldNames: {
     fieldNames: {
// businessId,
// businessId,
// organizationId,
// purchaseId,
// purchaseId,
inputVatJournalId: {
 
// record lock eg: prefix: "updatePurchase"
// updatePurchase_status: {requiredOnCreate: true}, // open|lock,
// updatePurchase_uniqueRequestId: {requiredOnCreate: true},
// updatePurchase_timestamp: {requiredOnCreate: true},
 
journalId: {
type: "string",
type: "string",
optionalOnCreate: true,
optionalOnCreate: true,
Line 73: Line 102:
storageResourceTags: ["dynamo"],
storageResourceTags: ["dynamo"],
},
},
     },
     },
     identifiers: [
     identifiers: [
{
{
type: "partitionKey",
type: "partitionKey",
fieldName: "businessId",
fieldNames: ["businessId", "organizationId"],
name: "comAccLinkId",
},
},
{
{
Line 93: Line 122:
{
{
objectType: "comAccPurchaseLineItem",
objectType: "comAccPurchaseLineItem",
canDelete: false,
generatedBy: "systemGenerated",
belongTo: {
    canDelete: false,
serviceTag: "ComAccLink",
objectType: "comAccLinkByBusiness"
},
addOnDataStructure: [],
addOnDataStructure: [],
storageResources: {
storageResources: {
Line 106: Line 132:
     },
     },
     fieldNames: {
     fieldNames: {
// businessId
// organizationId
// purchaseId,
// purchaseId,
// purchaseLineItemId,
// purchaseLineItemId,
// journalId
// accountId
// lineItemQuantity
// lineItemUnitPricelineItemUnitPrice
// entryId // not sure want to record because multiple lineItems might be in the same entryId
     },
     },
     identifiers: [
     identifiers: [
{
{
type: "partitionKey",
type: "partitionKey",
fieldName: "purchaseId"
fieldNames: ["businessId", "organizationId", "purchaseId"],
name: "comAccLinkPurchaseId
},
},
{
{
Line 122: Line 154:
}
}
</syntaxhighlight>
</syntaxhighlight>
* This table might not be needed because 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 144: Line 179:
purchaseId: "",
purchaseId: "",
vendorId: "",
vendorId: "",
    timestamp: 1111111,
purchaseCurrencyId: "",
purchaseCurrencyId: "",
inventoryLocationId: "", // required if have any inventory/?assets
purchaseLineItems: {
purchaseLineItems: {
{purchaseLineItemId}: {
{purchaseLineItemId}: {
Type: "", // inventory|expense|services|freight|salesTax|vatTax|other
 
SubType: "", // inventory: goods|intangibleGoods|rawMaterial|asset|intangibleAsset, expense: pointInTime|overTime, services: pointInTime|overTime, freight: standard, order: standard
            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,
lineItemQuantity: 1,
lineItemUnitPrice: "2.00"
lineItemUnitPrice: "2.00"
Line 157: Line 210:
</syntaxhighlight>
</syntaxhighlight>


== purchaseChange ==
== updatePurchase ==


* make adjustment to journal entries when purchaseLineItemId changes
* make adjustment to journal entries when purchaseLineItemId changes
* handle 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 13:51, 9 August 2026

Overview

Handle links between purchases and Accounting records.

Repository

...

Object Schemas

Additional Information
Per Service Schemas

comAccPurchaseLink

{
	objectType: "comAccPurchaseLink",
    generatedBy: "userGenerated",
	canDelete: false,
	belongTo: {
		serviceTag: "CommerceAccountingLink",
		objectType: "comAccLinkByBusiness"
	},
	addOnDataStructure: [],
	storageResources: {
        "myGraph":{
          "storageType": "graph",
          "graphServerTag": "GraphHandler"
        },
		"dynamo": {
			"storageType": "dynamoDB",
			"tableName": "comAccPurchaseLink",
		}
    },
    fieldNames: {
		businessId:{
			fromObjType:{
			  serviceTag: "CommerceAccountingLink",
			  objectType: "comAccLinkByBusiness" 
			},
        },
		organizationId: {
			fromObjType:{
			  serviceTag: "CommerceAccountingLink",
			  objectType: "comAccLinkByOrganization" 
			},
		},
        accountLinkTag:{   // type of link: inputVAT|salesTax|vatTax..
            type: "string",
			requriedOnCreate: true,
			storageResourceTags: ['myGraph','dynamo']
        }		
        accountId:{
            type: "string",
			requriedOnCreate: true,
			storageResourceTags: ['myGraph','dynamo']
        }
    },
    identifiers: [
		{
			type: "partitionKey",
			fieldNames: ["businessId", "organizationId"],
			name: "comAccLinkId",
		},
		{
			type: "sortKey",
			fieldName: "accountLinkTag"
		},
    ]
}
  • sets which Accounting accountId journal entries are added to

comAccPurchase

{
	objectType: "comAccPurchase",
    generatedBy: "systemGenerated",
	canDelete: false,
    addOnDataStructure: [],
	storageResources: {
		"dynamo": {
			"storageType": "dynamoDB",
			"tableName": "comAccPurchase",
		}
    },
    fieldNames: {
		// businessId,
		// organizationId,
		// purchaseId,

		// record lock eg: prefix: "updatePurchase"
		// updatePurchase_status: {requiredOnCreate: true}, // open|lock, 
		// updatePurchase_uniqueRequestId: {requiredOnCreate: true},
		// updatePurchase_timestamp: {requiredOnCreate: true},

		journalId: {
			type: "string",
			optionalOnCreate: true,
			canUpdate: true,
			storageResourceTags: ["dynamo"],
		},
    },
    identifiers: [
		{
			type: "partitionKey",
			fieldNames: ["businessId", "organizationId"],
			name: "comAccLinkId",
		},
		{
			type: "sortKey",
			fieldName: "purchaseId"
		},
    ]
}

comAccPurchaseLineItem

{
	objectType: "comAccPurchaseLineItem",
	generatedBy: "systemGenerated",
    canDelete: false,
	addOnDataStructure: [],
	storageResources: {
		"dynamo": {
			"storageType": "dynamoDB",
			"tableName": "comAccPurchaseLineItem",
		}
    },
    fieldNames: {
		// businessId
		// organizationId
		// purchaseId,
		// purchaseLineItemId,
		// accountId
		// lineItemQuantity
		// lineItemUnitPricelineItemUnitPrice
		// entryId // not sure want to record because multiple lineItems might be in the same entryId
    },
    identifiers: [
		{
			type: "partitionKey",
			fieldNames: ["businessId", "organizationId", "purchaseId"],
			name: "comAccLinkPurchaseId
		},
		{
			type: "sortKey",
			fieldName: "purchaseLineItemId"
		},
    ]
}
  • This table might not be needed because 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