Zum Hauptinhalt springen

transactions

Module: billing

Billing and procurement transactions (quotes, orders, invoices).

Status codes

StatusActivityIDColorQuotes (0)Orders (1)Deliveries (2)Invoices (3)Credits (4)
DraftDRAFT0greenXXXXX
BookedOPEN1greenXXXXX
On HoldOPEN2orangeXXXXX
CancelledCANCELLED3redXXXXX
ClosedCLOSED4blackXXXXX
Partly OrderedOPEN5orangeX----
Partly Ordered / CancelledCANCELLED6redX----
Partly Ordered / ClosedCLOSED7blackX----
OrderedCLOSED8blackX----
Partly DeliveredOPEN9orange-X---
Partly Delivered / CancelledCANCELLED10red-X---
Partly Delivered / ClosedCLOSED11black-X---
DeliveredCLOSED12black-X---
Partly InvoicedOPEN13orange-XX--
Partly Invoiced / CancelledCANCELLED14red-XX--
Partly Invoiced / ClosedCLOSED15black-XX--
InvoicedCLOSED16black-XX--
Partly PaidOPEN17orange---XX
Partly Paid / CancelledCANCELLED18red---XX
Partly Paid / ClosedCLOSED19black---XX
PaidCLOSED20black---XX
OverpaidCLOSED21black---XX

Transaction Items

Read and Write ###

Every once in a while, you might want to take a closer look at the items involved in the transactions at hand. You can do so by retrieving them in a db:select and then decoding them from JSON into an associative array with decode:json like this:

XML
<db:select var_result="transaction" type="self">
<db:fields>
<db:field>items</db:field>
</db:fields>
<db:table>transactions</db:table>
<db:is field="transactionnum">L.1409.1234</db:is>
</db:select>

<decode:json var="transitems">$transaction.items</decode:json>

Conversely, when you create a transaction, you can initialize the items with transitems and encode them with encode:json before you write them into the database:

XML
<transitems var="transitems" />

<encode:json var="transitems" var_result="jsonItems" />

<db:insert table="transactions">
...
<db:data field="items">$jsonItems</db:data>
</db:insert>
Structure ###

Transaction items are stored as an array of objects (like a list of products). A product has the following basic properties:

PropertyDescription
type0 for line item, 1 for text
originalThe original (previous) transaction
subindexThe subindex of that transaction
referencesFurther references to other transactions (siblings and descendants)

Each of the references has two properties:

PropertyDescription
transactionThe referenced transaction
subindexThe subindex of the transaction

If the line is just text, its properties can be found here:

PropertyDescription
variantThe variant of the text entry (description, annotation, subtitle, title, header)
textThe subindex of the transaction

There are further properties that describe the product:

PropertyDescription
nameName of the product
manufacturerManufacturer
itemnumItem number
barcodeBar code / EAN
itemtypeItem type
unitUnit of measure
amountAmount
amounttakenAmount taken
sellingpriceSelling price
purchasepricePurchase price
rebateRebate
discountDiscount
discount2Second discount
taxrateTax rate
weightWeight
itemID of the item
reservationID of the reservation stock transaction (only for active orders)
transactionsTransactions array

The transactions array looks as follows:

PropertyDescription
transactionID of the stock transaction
storageID of the storage
amountAmount
chargenumCharge number
locationStock location
serialsSerial

The JSON of a full-blown items field looks somewhat like this:

JSON

[{
"type" : 1,
"original" : null,
"subindex" : 0,
"references" : [],
"variant" : 4,
"text" : "Header-Test"
}, {
"type" : 1,
"original" : null,
"subindex" : 0,
"references" : [],
"variant" : 3,
"text" : "Title Test"
}, {
"type" : 1,
"original" : null,
"subindex" : 0,
"references" : [],
"variant" : 2,
"text" : "Subtitle Test"
}, {
"type" : 0,
"original" : null,
"subindex" : 0,
"references" : [],
"name" : "Testartikel",
"manufacturer" : "Ich",
"itemnum" : "18929537",
"barcode" : "2541235256262626233",
"itemtype" : 1,
"unit" : "C62",
"amount" : 23,
"amounttaken" : 0,
"sellingprice" : 50,
"purchaseprice" : 40,
"rebate" : 0,
"discount" : 0,
"discount2" : 0,
"taxrate" : 19,
"weight" : 2,
"item" : 1,
"reservation" : null,
"transactions" : []
}, {
"type" : 1,
"original" : null,
"subindex" : 0,
"references" : [],
"variant" : 0,
"text" : "Description Test"
}, {
"type" : 1,
"original" : null,
"subindex" : 0,
"references" : [],
"variant" : 2,
"text" : "Subtitle Test 2"
}, {
"type" : 0,
"original" : null,
"subindex" : 0,
"references" : [],
"name" : "Serienartikel",
"manufacturer" : "FACTORY INC.",
"itemnum" : "ARTNUM12345",
"barcode" : "165749875341",
"itemtype" : 1,
"unit" : "C62",
"amount" : 2,
"amounttaken" : 0,
"sellingprice" : 0,
"purchaseprice" : 0,
"rebate" : 0,
"discount" : 0,
"discount2" : 0,
"taxrate" : 0,
"weight" : 0,
"item" : 4,
"reservation" : null,
"transactions" : []
}, {
"type" : 0,
"original" : null,
"subindex" : 0,
"references" : [],
"name" : "Testartikel",
"manufacturer" : "Ich",
"itemnum" : "18929537",
"barcode" : "2541235256262626233",
"itemtype" : 1,
"unit" : "C62",
"amount" : 12,
"amounttaken" : 0,
"sellingprice" : 50,
"purchaseprice" : 40,
"rebate" : 0,
"discount" : 0,
"discount2" : 0,
"taxrate" : 19,
"weight" : 2,
"item" : 1,
"reservation" : null,
"transactions" : []
}, {
"type" : 1,
"original" : null,
"subindex" : 0,
"references" : [],
"variant" : 0,
"text" : "Description Test 2"
}, {
"type" : 0,
"original" : 46,
"subindex" : 0,
"references" : [],
"name" : "Testartikel",
"manufacturer" : "Ich",
"itemnum" : "18929537",
"barcode" : "2541235256262626233",
"itemtype" : 0,
"unit" : "C62",
"amount" : 5,
"amounttaken" : 0,
"sellingprice" : 50,
"purchaseprice" : 40,
"rebate" : 0,
"discount" : 0,
"discount2" : 0,
"taxrate" : 19,
"weight" : 2,
"item" : 1,
"reservation" : null,
"transactions" : [{
"transaction" : 47,
"storage" : 1,
"amount" : 12,
"chargenum" : "",
"serials" : []
}
]
}, {
"type" : 0,
"original" : 46,
"subindex" : 0,
"references" : [],
"name" : "Testartikel",
"manufacturer" : "Ich",
"itemnum" : "18929537",
"barcode" : "2541235256262626233",
"itemtype" : 0,
"unit" : "C62",
"amount" : 12,
"amounttaken" : 0,
"sellingprice" : 50,
"purchaseprice" : 40,
"rebate" : 0,
"discount" : 0,
"discount2" : 0,
"taxrate" : 19,
"weight" : 2,
"item" : 1,
"reservation" : null,
"transactions" : [{
"transaction" : 47,
"storage" : 1,
"amount" : 12,
"chargenum" : "",
"serials" : []
}
]
}, {
"type" : 0,
"original" : 57,
"subindex" : 0,
"references" : [],
"name" : "Serienartikel",
"manufacturer" : "FACTORY INC.",
"itemnum" : "ARTNUM12345",
"barcode" : "165749875341",
"itemtype" : 1,
"unit" : "C62",
"amount" : 1,
"amounttaken" : 0,
"sellingprice" : 0,
"purchaseprice" : 0,
"rebate" : 0,
"discount" : 0,
"discount2" : 0,
"taxrate" : 0,
"weight" : 0,
"item" : 4,
"reservation" : null,
"transactions" : [{
"transaction" : 59,
"storage" : 1,
"amount" : 1,
"chargenum" : "",
"serials" : ["98144-98144-98144-98144"]
}
]
}
]

NameTypeNullableDefault ValueNotes
PKID
integerTransaction ID
fork
forks.ID
integerFork ID (`null` for base module)
ownergroup
groups.ID
integerOwner group ID (`null`=PUBLIC)
creator
integerCreator user ID (defaults to authenticated user on creation)
assigneduser
users.ID
integerAssigned user ID
creationdate
bigintdate_part('epoch', now())Creation date and time as a Unix timestamp (defaults to current date and time on creation)
lastmodified
bigintdate_part('epoch', now())Last modification date and time as a Unix timestamp (auto-reset on modification)
account
accounts.ID
integerAccount ID
item
items.ID
integerItem ID; must be `null` for BILLING and PROCUREMENT
contract
contracts.ID
integerContract ID
transactionnum
textTransaction number
type
smallint0Transaction type (`0`=BILLING_QUOTE, `1`=BILLING_ORDER, `2`=BILLING_DELIVERY, `3`=BILLING_INVOICE, `4`=BILLING_CREDIT, `5`=PROCUREMENT_REQUEST, `6`=PROCUREMENT_ORDER, `7`=PROCUREMENT_DELIVERY, `8`=PROCUREMENT_INVOICE, `9`=PROCUREMENT_CREDIT, `10`=PRODUCTION_FABRICATION, `11`=PRODUCTION_DISASSEMBLY)
date
bigintdate_part('epoch', now())Designated date and time as a Unix timestamp (defaults to current date and time on creation)
duedate
bigintDue date as a Unix timestamp
status
smallint0Status (`0`=DRAFT, `1`=BOOKED, `2`=HOLD, `3`=CANCELLED, `4`=CLOSED, `5`=PARTLYORDERED, `6`=PARTLYORDERED_CANCELLED, `7`=PARTLYORDERED_CLOSED, `8`=ORDERED, `9`=PARTLYDELIVERED, `10`=PARTLYDELIVERED_CANCELLED, `11`=PARTLYDELIVERED_CLOSED, `12`=DELIVERED, `13`=PARTLYINVOICED, `14`=PARTLYINVOICED_CANCELLED, `15`=PARTLYINVOICED_CLOSED, `16`=INVOICED, `17`=PARTLYPAID, `18`=PARTLYPAID_CANCELLED, `19`=PARTLYPAID_CLOSED, `20`=PAID, `21`=OVERPAID, `22`=PROCESSED, `23`=PROCESSED_CANCELLED)
calculation
smallint0Calculation method (`0`=NET, `1`=GROSS, `2`=EXACT, `3`=LEGACY, `4`=EXTERNAL)
productionfactor
integerProduction factor; is required for PRODUCTION, otherwise must be `null`
currency
character varying(3)Currency code (ISO 4217)
exchangerate
double precision1Exchange rate as a multiple of one monetary unit of the fixed system currency
taxid
text''Buyer Tax ID (e.g. VATIN or SSN)
shippingrecipient
text''Shipping recipient
shippingaddress
text''Shipping address (street and building/suite number)
shippingpostalcode
text''Shipping postal or ZIP code
shippingcity
text''Shipping city or locality
shippingregion
text''Shipping region or state
shippingcountry
character varying(2)''Shipping country code (ISO 3166-1 alpha-2)
billingrecipient
text''Billing recipient
billingaddress
text''Billing address (street and building/suite number)
billingpostalcode
text''Billing postal or ZIP code
billingcity
text''Billing city or locality
billingregion
text''Billing region or state
billingcountry
character varying(2)''Billing country code (ISO 3166-1 alpha-2)
sellertaxid
text''Seller Tax ID (e.g. VATIN or SSN)
sellername
text''Seller Name
selleraddress
text''Seller address (street and building/suite number)
sellerpostalcode
text''Seller postal or ZIP code
sellercity
text''Seller city or locality
sellerregion
text''Seller region or state
sellercountry
character varying(2)''Seller country code (ISO 3166-1 alpha-2)
discount
double precision0Total absolute discount
netamount
double precision0Total net amount
tax
double precision0Total tax amount
margin
double precision0Total absolute margin
weight
double precision0Total shipping weight in kilograms (only positive line items)
items
jsonJSON-encoded items (array)
NameUniqueNulls DistinctPrimaryPartialMethodKeys
fk_transactions_accountbtreeaccount
fk_transactions_assigneduserginassigneduser
fk_transactions_contractbtreecontract
fk_transactions_forkginfork
fk_transactions_itembtreeitem
fk_transactions_ownergroupginownergroup
i_transactions_billing_datebtreedate
i_transactions_collection_datebtreedate
i_transactions_noforkginfork
i_transactions_noownerginownergroup
i_transactions_procurement_datebtreedate
i_transactions_production_datebtreedate
i_transactions_transactionnumbtreetransactionnum
pk_transactionsbtreeID
s_transactions_transactionnumgintransactionnum
u_transactions_transactionnum_typebtreetransactionnum, type
NameType
c_transactions_typecheck
dc_transactions_billingaddresscheck
dc_transactions_billingcitycheck
dc_transactions_billingcountrycheck
dc_transactions_billingpostalcodecheck
dc_transactions_billingrecipientcheck
dc_transactions_billingregioncheck
dc_transactions_calculationcheck
dc_transactions_currencycheck
dc_transactions_exchangeratecheck
dc_transactions_itemscheck
dc_transactions_selleraddresscheck
dc_transactions_sellercitycheck
dc_transactions_sellercountrycheck
dc_transactions_sellernamecheck
dc_transactions_sellerpostalcodecheck
dc_transactions_sellerregioncheck
dc_transactions_sellertaxidcheck
dc_transactions_shippingaddresscheck
dc_transactions_shippingcitycheck
dc_transactions_shippingcountrycheck
dc_transactions_shippingpostalcodecheck
dc_transactions_shippingrecipientcheck
dc_transactions_shippingregioncheck
dc_transactions_statuscheck
dc_transactions_taxidcheck
dc_transactions_transactionnumcheck
dc_transactions_typecheck
dc_transactions_weightcheck
fk_transactions_accountforeign_key
fk_transactions_assigneduserforeign_key
fk_transactions_contractforeign_key
fk_transactions_forkforeign_key
fk_transactions_itemforeign_key
fk_transactions_ownergroupforeign_key
pk_transactionsprimary_key
NameTypeEventsFunctionDefinition
td_transactions_dunningafterdeleteftud_transactions_dunning
ti_transactions_itembeforeinsertftiu_transactions_item
ti_transactions_statusbeforeinsertftiu_transactions_status
tu_transactions_dunningafterupdateftud_transactions_dunning
tu_transactions_itembeforeupdateftiu_transactions_item
tu_transactions_statusbeforeupdateftiu_transactions_status
tu_transactions_typebeforeupdateft_integrity
Loading...