Service - CommerceAccounting Sale

From Izara Wiki
Revision as of 12:21, 11 January 2026 by Sven the Barbarian (talk | contribs) (Created page with "= Overview = Handle sales in one service, and some Accounting entries include the full amount, some break up according to saleLineItems. = Repository = ... = Object Schemas = ; Additional Information: Per Service Schemas <syntaxhighlight lang="JavaScript"> { objectType: "comAccSaleLink", canDelete: false, belongTo: { serviceTag: "User", objectType: "user" }, addOnDataStructure: [], storageResources: { "dynamo": { "storageType": "dynamoDB", "tab...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Overview

Handle sales in one service, and some Accounting entries include the full amount, some break up according to saleLineItems.

Repository

...

Object Schemas

Additional Information
Per Service Schemas
{
	objectType: "comAccSaleLink",
	canDelete: false,
	belongTo: {
		serviceTag: "User",
		objectType: "user"
	},
	addOnDataStructure: [],
	storageResources: {
		"dynamo": {
			"storageType": "dynamoDB",
			"tableName": "comAccSaleLink",
		}
    },
    fieldNames: {
		// probably have two dynamo tables, one identified by saleId, one by journalId
		
    },
    identifiers: [
		{
			// see above note
		}
    ]
}
  • one saleId may link to multiple journalIds, sale value and inventory adjustment entries
  • maintains a link between saleId and journalIds, so can adjust if changes made to purchases

Relationships

...

flowSchemas

saleCreated

  • when creating a sale, iterate saleLineItems to decide which journal entries are created

Sale Value

  • the total sale value has journal entry for all the below:
    1. (debit)accountsReceivable(Asset)
  • The other side (credit) is broken up depending on goods or assets
  • For goods value an entry is entered into the below
    1. (credit)sales(Revenue)
  • Assets have:
    1. (credit)inventoryAsset(Asset)
    2. (debit)accumulatedDepreciation(Asset)
    3. (debit or credit)creditGainOnSale(Renenue)/debitLossOnSale(Expense)
  • both goods and assets may have:
    1. (credit)salesTaxPayable(Liability)

Goods Sold

  • the total saleLineItem value for Inventory Goods has a journal entry for:
    1. (debit)cogsGoods(Expense)
    2. (credit)inventoryGoods(Asset)

Raw Material Sold

  • the total saleLineItem value for Inventory Raw Materials has a journal entry for:
    1. (debit)cogsRawMaterial(Expense)
    2. (credit)inventoryRawMaterial(Asset)

Assets Sold

  • might not have accumulatedDepreciation applied yet
  • if sold for same amount as original value then not have creditGainOnSale/debitLossOnSale
  • will need to query Accounting Assets service for depreciation amount
  • may need to query ComAcc Inventory service to find link between Commerce Asset and Accounting Asset, so can find depreciation

inventoryGoodsPurchaseChange

  • make adjustment to journal entries when saleLineItemId changes
  • perhaps handling removal of sale/journal entries, or creation of new entries
  • basically re-calculate all entries and check against existing

Working documents

CommerceAccounting Sale