The 5D4C is 5-1965, D-April, 4-4th Day and C-Afternoon Shift.
The B040788 is the serial number B for built in Basildon.
The other number should be for Chassis, Fuel, Pto and Transmission in that order but the number D138 is not a good number for my book codes.
Here is some examples:
3=Live 540 rpm pto
C= 8 speed transmission