Have you ever read a book about how to raise a dog?
If you have a puppy, you take it out quite often and praise it exaggeratedly when it pissed/shat outside. If it pisses into the flat, YOU are to blame, because YOU didn't pay attention. Anyways, that might happen, so tell your dog a loud and clear "NO", take it (preferably during the "act") and go outside. Again, if it pisses/shits, praise it.
At night, put it into a box. If it starts moving around, take it and go outside. Same procedure: Praise after pissing/shitting.
I have never beaten my dog and she pissed into our flat just twice when we just had her. Praise and/or a treat always works much better than violence. Sad to see how many apparent retards don't know how to treat a dog...