Trying to make an inventory management system using barcode scanning upon transactions
The scanner may send the barcode directly as-is. The RS232 message may contain some header information or additional checksums. To find that exactly you need the scanner's datasheet or user manual.

Some barcodes contain checksum information. If the scanner hasn't already verified it, you'll have to do it.

You'll need some kind of small database. When scanning a barcode, check if it is already in the database. If yes, modify the number of boxes accordingly (increment or decrement). If not, then add the scanned barcode to the database.